Skip to content

Commit bf80b8a

Browse files
committed
Merge branch 'jc/test-lazy-prereq' (early part)
* 'jc/test-lazy-prereq' (early part): t3419: drop unnecessary NOT_EXPENSIVE pseudo-prerequisite t3302: drop unnecessary NOT_EXPENSIVE pseudo-prerequisite t3302: do not chdir around in the primary test process t3302: coding style updates test: turn USR_BIN_TIME into a lazy prerequisite test: turn EXPENSIVE into a lazy prerequisite
2 parents a668853 + b687cd6 commit bf80b8a

File tree

5 files changed

+85
-78
lines changed

5 files changed

+85
-78
lines changed

t/t0021-conversion.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ test_expect_success 'required filter clean failure' '
190190
test_must_fail git add test.fc
191191
'
192192

193-
test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
194-
195193
test_expect_success EXPENSIVE 'filter large file' '
196194
git config filter.largefile.smudge cat &&
197195
git config filter.largefile.clean cat &&

t/t3302-notes-index-expensive.sh

Lines changed: 69 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,53 +7,51 @@ test_description='Test commit notes index (expensive!)'
77

88
. ./test-lib.sh
99

10-
test_set_prereq NOT_EXPENSIVE
1110
test -n "$GIT_NOTES_TIMING_TESTS" && test_set_prereq EXPENSIVE
12-
test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
1311

1412
create_repo () {
1513
number_of_commits=$1
1614
nr=0
1715
test -d .git || {
1816
git init &&
1917
(
20-
while [ $nr -lt $number_of_commits ]; do
18+
while test $nr -lt $number_of_commits
19+
do
2120
nr=$(($nr+1))
2221
mark=$(($nr+$nr))
2322
notemark=$(($mark+1))
2423
test_tick &&
25-
cat <<INPUT_END &&
26-
commit refs/heads/master
27-
mark :$mark
28-
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
29-
data <<COMMIT
30-
commit #$nr
31-
COMMIT
32-
33-
M 644 inline file
34-
data <<EOF
35-
file in commit #$nr
36-
EOF
37-
38-
blob
39-
mark :$notemark
40-
data <<EOF
41-
note for commit #$nr
42-
EOF
43-
44-
INPUT_END
45-
46-
echo "N :$notemark :$mark" >> note_commit
24+
cat <<-INPUT_END &&
25+
commit refs/heads/master
26+
mark :$mark
27+
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
28+
data <<COMMIT
29+
commit #$nr
30+
COMMIT
31+
32+
M 644 inline file
33+
data <<EOF
34+
file in commit #$nr
35+
EOF
36+
37+
blob
38+
mark :$notemark
39+
data <<EOF
40+
note for commit #$nr
41+
EOF
42+
43+
INPUT_END
44+
echo "N :$notemark :$mark" >>note_commit
4745
done &&
4846
test_tick &&
49-
cat <<INPUT_END &&
50-
commit refs/notes/commits
51-
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
52-
data <<COMMIT
53-
notes
54-
COMMIT
47+
cat <<-INPUT_END &&
48+
commit refs/notes/commits
49+
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
50+
data <<COMMIT
51+
notes
52+
COMMIT
5553
56-
INPUT_END
54+
INPUT_END
5755

5856
cat note_commit
5957
) |
@@ -65,62 +63,74 @@ INPUT_END
6563
test_notes () {
6664
count=$1 &&
6765
git config core.notesRef refs/notes/commits &&
68-
git log | grep "^ " > output &&
66+
git log | grep "^ " >output &&
6967
i=$count &&
70-
while [ $i -gt 0 ]; do
68+
while test $i -gt 0
69+
do
7170
echo " commit #$i" &&
7271
echo " note for commit #$i" &&
73-
i=$(($i-1));
74-
done > expect &&
72+
i=$(($i-1))
73+
done >expect &&
7574
test_cmp expect output
7675
}
7776

78-
cat > time_notes << \EOF
77+
write_script time_notes <<\EOF
7978
mode=$1
8079
i=1
81-
while [ $i -lt $2 ]; do
80+
while test $i -lt $2
81+
do
8282
case $1 in
8383
no-notes)
84-
GIT_NOTES_REF=non-existing; export GIT_NOTES_REF
85-
;;
84+
GIT_NOTES_REF=non-existing
85+
export GIT_NOTES_REF
86+
;;
8687
notes)
8788
unset GIT_NOTES_REF
88-
;;
89+
;;
8990
esac
90-
git log >/dev/null
91+
git log
9192
i=$(($i+1))
92-
done
93+
done >/dev/null
9394
EOF
9495

9596
time_notes () {
9697
for mode in no-notes notes
9798
do
9899
echo $mode
99-
/usr/bin/time "$SHELL_PATH" ../time_notes $mode $1
100+
/usr/bin/time ../time_notes $mode $1
100101
done
101102
}
102103

103104
do_tests () {
104-
pr=$1
105-
count=$2
106-
107-
test_expect_success $pr 'setup / mkdir' '
108-
mkdir $count &&
109-
cd $count
105+
count=$1 pr=${2-}
106+
107+
test_expect_success $pr "setup $count" '
108+
mkdir "$count" &&
109+
(
110+
cd "$count" &&
111+
create_repo "$count"
112+
)
110113
'
111114

112-
test_expect_success $pr "setup $count" "create_repo $count"
113-
114-
test_expect_success $pr 'notes work' "test_notes $count"
115-
116-
test_expect_success USR_BIN_TIME,$pr 'notes timing with /usr/bin/time' "time_notes 100"
115+
test_expect_success $pr 'notes work' '
116+
(
117+
cd "$count" &&
118+
test_notes "$count"
119+
)
120+
'
117121

118-
test_expect_success $pr 'teardown / cd ..' 'cd ..'
122+
test_expect_success "USR_BIN_TIME${pr:+,$pr}" 'notes timing with /usr/bin/time' '
123+
(
124+
cd "$count" &&
125+
time_notes 100
126+
)
127+
'
119128
}
120129

121-
do_tests NOT_EXPENSIVE 10
122-
for count in 100 1000 10000; do
123-
do_tests EXPENSIVE $count
130+
do_tests 10
131+
for count in 100 1000 10000
132+
do
133+
do_tests "$count" EXPENSIVE
124134
done
125135

126136
test_done

t/t3419-rebase-patch-id.sh

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ test_description='git rebase - test patch id computation'
44

55
. ./test-lib.sh
66

7-
test_set_prereq NOT_EXPENSIVE
87
test -n "$GIT_PATCHID_TIMING_TESTS" && test_set_prereq EXPENSIVE
9-
test -x /usr/bin/time && test_set_prereq USR_BIN_TIME
108

11-
count()
12-
{
9+
count () {
1310
i=0
1411
while test $i -lt $1
1512
do
@@ -18,8 +15,7 @@ count()
1815
done
1916
}
2017

21-
scramble()
22-
{
18+
scramble () {
2319
i=0
2420
while read x
2521
do
@@ -28,12 +24,11 @@ scramble()
2824
echo "$x"
2925
fi
3026
i=$((($i+1) % 10))
31-
done < "$1" > "$1.new"
27+
done <"$1" >"$1.new"
3228
mv -f "$1.new" "$1"
3329
}
3430

35-
run()
36-
{
31+
run () {
3732
echo \$ "$@"
3833
/usr/bin/time "$@" >/dev/null
3934
}
@@ -43,10 +38,8 @@ test_expect_success 'setup' '
4338
git tag root
4439
'
4540

46-
do_tests()
47-
{
48-
pr=$1
49-
nlines=$2
41+
do_tests () {
42+
nlines=$1 pr=${2-}
5043

5144
test_expect_success $pr "setup: $nlines lines" "
5245
rm -f .gitattributes &&
@@ -103,7 +96,7 @@ do_tests()
10396
"
10497
}
10598

106-
do_tests NOT_EXPENSIVE 500
107-
do_tests EXPENSIVE 50000
99+
do_tests 500
100+
do_tests 50000 EXPENSIVE
108101

109102
test_done

t/t5551-http-fetch-smart.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,6 @@ test_expect_success 'cookies stored in http.cookiefile when http.savecookies set
213213
test_cmp expect_cookies.txt cookies_tail.txt
214214
'
215215

216-
test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
217-
218216
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
219217
(
220218
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&

t/test-lib.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,14 @@ test_lazy_prereq AUTOIDENT '
976976
git var GIT_AUTHOR_IDENT
977977
'
978978

979+
test_lazy_prereq EXPENSIVE '
980+
test -n "$GIT_TEST_LONG"
981+
'
982+
983+
test_lazy_prereq USR_BIN_TIME '
984+
test -x /usr/bin/time
985+
'
986+
979987
# When the tests are run as root, permission tests will report that
980988
# things are writable when they shouldn't be.
981989
test -w / || test_set_prereq SANITY

0 commit comments

Comments
 (0)