Skip to content

Commit f2061f6

Browse files
committed
Merge branch 'js/test-file-size'
Test clean-up. * js/test-file-size: tests: consolidate the `file_size` function into `test-lib-functions.sh`
2 parents 719b92e + 53b67a8 commit f2061f6

File tree

5 files changed

+24
-42
lines changed

5 files changed

+24
-42
lines changed

t/t0021-conversion.sh

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ generate_random_characters () {
2323
perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME"
2424
}
2525

26-
file_size () {
27-
test-tool path-utils file-size "$1"
28-
}
29-
3026
filter_git () {
3127
rm -f *.log &&
3228
git "$@"
@@ -361,9 +357,9 @@ test_expect_success PERL 'required process filter should filter data' '
361357
cp "$TEST_ROOT/test3 '\''sq'\'',\$x=.o" "testsubdir/test3 '\''sq'\'',\$x=.r" &&
362358
>test4-empty.r &&
363359
364-
S=$(file_size test.r) &&
365-
S2=$(file_size test2.r) &&
366-
S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
360+
S=$(test_file_size test.r) &&
361+
S2=$(test_file_size test2.r) &&
362+
S3=$(test_file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
367363
M=$(git hash-object test.r) &&
368364
M2=$(git hash-object test2.r) &&
369365
M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
@@ -432,9 +428,9 @@ test_expect_success PERL 'required process filter should filter data for various
432428
(
433429
cd repo &&
434430
435-
S=$(file_size test.r) &&
436-
S2=$(file_size test2.r) &&
437-
S3=$(file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
431+
S=$(test_file_size test.r) &&
432+
S2=$(test_file_size test2.r) &&
433+
S3=$(test_file_size "testsubdir/test3 '\''sq'\'',\$x=.r") &&
438434
M=$(git hash-object test.r) &&
439435
M2=$(git hash-object test2.r) &&
440436
M3=$(git hash-object "testsubdir/test3 '\''sq'\'',\$x=.r") &&
@@ -549,7 +545,7 @@ test_expect_success PERL 'required process filter takes precedence' '
549545
550546
echo "*.r filter=protocol" >.gitattributes &&
551547
cp "$TEST_ROOT/test.o" test.r &&
552-
S=$(file_size test.r) &&
548+
S=$(test_file_size test.r) &&
553549
554550
# Check that the process filter is invoked here
555551
filter_git add . &&
@@ -573,7 +569,7 @@ test_expect_success PERL 'required process filter should be used only for "clean
573569
574570
echo "*.r filter=protocol" >.gitattributes &&
575571
cp "$TEST_ROOT/test.o" test.r &&
576-
S=$(file_size test.r) &&
572+
S=$(test_file_size test.r) &&
577573
578574
filter_git add . &&
579575
cat >expected.log <<-EOF &&
@@ -697,9 +693,9 @@ test_expect_success PERL 'process filter should restart after unexpected write f
697693
echo "this is going to fail" >smudge-write-fail.o &&
698694
cp smudge-write-fail.o smudge-write-fail.r &&
699695
700-
S=$(file_size test.r) &&
701-
S2=$(file_size test2.r) &&
702-
SF=$(file_size smudge-write-fail.r) &&
696+
S=$(test_file_size test.r) &&
697+
S2=$(test_file_size test2.r) &&
698+
SF=$(test_file_size smudge-write-fail.r) &&
703699
M=$(git hash-object test.r) &&
704700
M2=$(git hash-object test2.r) &&
705701
MF=$(git hash-object smudge-write-fail.r) &&
@@ -752,9 +748,9 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
752748
echo "this will cause an error" >error.o &&
753749
cp error.o error.r &&
754750
755-
S=$(file_size test.r) &&
756-
S2=$(file_size test2.r) &&
757-
SE=$(file_size error.r) &&
751+
S=$(test_file_size test.r) &&
752+
S2=$(test_file_size test2.r) &&
753+
SE=$(test_file_size error.r) &&
758754
M=$(git hash-object test.r) &&
759755
M2=$(git hash-object test2.r) &&
760756
ME=$(git hash-object error.r) &&
@@ -797,7 +793,7 @@ test_expect_success PERL 'process filter abort stops processing of all further f
797793
798794
M="blob=$(git hash-object abort.r)" &&
799795
rm -f debug.log &&
800-
SA=$(file_size abort.r) &&
796+
SA=$(test_file_size abort.r) &&
801797
802798
git add . &&
803799
rm -f *.r &&
@@ -859,7 +855,7 @@ test_expect_success PERL 'delayed checkout in process filter' '
859855
git commit -m "test commit"
860856
) &&
861857
862-
S=$(file_size "$TEST_ROOT/test.o") &&
858+
S=$(test_file_size "$TEST_ROOT/test.o") &&
863859
PM="ref=refs/heads/master treeish=$(git -C repo rev-parse --verify master) " &&
864860
M="${PM}blob=$(git -C repo rev-parse --verify master:test.a)" &&
865861
cat >a.exp <<-EOF &&

t/t1050-large.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ test_description='adding and checking out large blobs'
55

66
. ./test-lib.sh
77

8-
# This should be moved to test-lib.sh together with the
9-
# copy in t0021 after both topics have graduated to 'master'.
10-
file_size () {
11-
test-tool path-utils file-size "$1"
12-
}
13-
148
test_expect_success setup '
159
# clone does not allow us to pass core.bigfilethreshold to
1610
# new repos, so set core.bigfilethreshold globally
@@ -29,7 +23,7 @@ do
2923
test_expect_success "add with $config" '
3024
test_when_finished "rm -f .git/objects/pack/pack-*.* .git/index" &&
3125
git $config add large1 &&
32-
sz=$(file_size .git/objects/pack/pack-*.pack) &&
26+
sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
3327
case "$expect" in
3428
small) test "$sz" -le 100000 ;;
3529
large) test "$sz" -ge 100000 ;;

t/t5315-pack-objects-compression.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@ test_description='pack-object compression configuration'
44

55
. ./test-lib.sh
66

7-
# This should be moved to test-lib.sh together with the
8-
# copy in t0021 after both topics have graduated to 'master'.
9-
file_size () {
10-
test-tool path-utils file-size "$1"
11-
}
12-
137
test_expect_success setup '
148
printf "%2000000s" X |
159
git hash-object -w --stdin >object-name &&
@@ -24,7 +18,7 @@ do
2418
test_expect_success "pack-objects with $config" '
2519
test_when_finished "rm -f pack-*.*" &&
2620
git $config pack-objects pack <object-name &&
27-
sz=$(file_size pack-*.pack) &&
21+
sz=$(test_file_size pack-*.pack) &&
2822
case "$expect" in
2923
small) test "$sz" -le 100000 ;;
3024
large) test "$sz" -ge 100000 ;;

t/t9303-fast-import-compression.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@
33
test_description='compression setting of fast-import utility'
44
. ./test-lib.sh
55

6-
# This should be moved to test-lib.sh together with the
7-
# copy in t0021 after both topics have graduated to 'master'.
8-
file_size () {
9-
test-tool path-utils file-size "$1"
10-
}
11-
126
import_large () {
137
(
148
echo blob
@@ -24,7 +18,7 @@ do
2418
test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
2519
test_when_finished "rm -rf .git/objects/??" &&
2620
import_large -c fastimport.unpacklimit=0 $config &&
27-
sz=$(file_size .git/objects/pack/pack-*.pack) &&
21+
sz=$(test_file_size .git/objects/pack/pack-*.pack) &&
2822
case "$expect" in
2923
small) test "$sz" -le 100000 ;;
3024
large) test "$sz" -ge 100000 ;;
@@ -47,7 +41,7 @@ do
4741
test_when_finished "rm -f .git/objects/pack/pack-*.*" &&
4842
test_when_finished "rm -rf .git/objects/??" &&
4943
import_large -c fastimport.unpacklimit=9 $config &&
50-
sz=$(file_size .git/objects/??/????*) &&
44+
sz=$(test_file_size .git/objects/??/????*) &&
5145
case "$expect" in
5246
small) test "$sz" -le 100000 ;;
5347
large) test "$sz" -ge 100000 ;;

t/test-lib-functions.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,10 @@ test_line_count () {
783783
fi
784784
}
785785

786+
test_file_size () {
787+
test-tool path-utils file-size "$1"
788+
}
789+
786790
# Returns success if a comma separated string of keywords ($1) contains a
787791
# given keyword ($2).
788792
# Examples:

0 commit comments

Comments
 (0)