Skip to content

Commit 7b2c338

Browse files
committed
Merge branch 'jk/filter-process-fix'
Test portability improvements and cleanups for t0021. * jk/filter-process-fix: t0021: fix filehandle usage on older perl t0021: use $PERL_PATH for rot13-filter.pl t0021: put $TEST_ROOT in $PATH t0021: use write_script to create rot13 shell script
2 parents 81cf0b6 + 4821494 commit 7b2c338

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

t/t0021-conversion.sh

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@ test_description='blob conversion via gitattributes'
55
. ./test-lib.sh
66

77
TEST_ROOT="$(pwd)"
8+
PATH=$TEST_ROOT:$PATH
89

9-
cat <<EOF >"$TEST_ROOT/rot13.sh"
10-
#!$SHELL_PATH
10+
write_script <<\EOF "$TEST_ROOT/rot13.sh"
1111
tr \
1212
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' \
1313
'nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM'
1414
EOF
15-
chmod +x "$TEST_ROOT/rot13.sh"
15+
16+
write_script rot13-filter.pl "$PERL_PATH" \
17+
<"$TEST_DIRECTORY"/t0021/rot13-filter.pl
1618

1719
generate_random_characters () {
1820
LEN=$1
@@ -65,7 +67,7 @@ test_cmp_exclude_clean () {
6567
# is equal to the committed content.
6668
test_cmp_committed_rot13 () {
6769
test_cmp "$1" "$2" &&
68-
"$TEST_ROOT/rot13.sh" <"$1" >expected &&
70+
rot13.sh <"$1" >expected &&
6971
git cat-file blob :"$2" >actual &&
7072
test_cmp expected actual
7173
}
@@ -341,7 +343,7 @@ test_expect_success 'diff does not reuse worktree files that need cleaning' '
341343
'
342344

343345
test_expect_success PERL 'required process filter should filter data' '
344-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
346+
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
345347
test_config_global filter.protocol.required true &&
346348
rm -rf repo &&
347349
mkdir repo &&
@@ -434,7 +436,7 @@ test_expect_success PERL 'required process filter should filter data' '
434436

435437
test_expect_success PERL 'required process filter takes precedence' '
436438
test_config_global filter.protocol.clean false &&
437-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean" &&
439+
test_config_global filter.protocol.process "rot13-filter.pl clean" &&
438440
test_config_global filter.protocol.required true &&
439441
rm -rf repo &&
440442
mkdir repo &&
@@ -459,7 +461,7 @@ test_expect_success PERL 'required process filter takes precedence' '
459461
'
460462

461463
test_expect_success PERL 'required process filter should be used only for "clean" operation only' '
462-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean" &&
464+
test_config_global filter.protocol.process "rot13-filter.pl clean" &&
463465
rm -rf repo &&
464466
mkdir repo &&
465467
(
@@ -494,7 +496,7 @@ test_expect_success PERL 'required process filter should be used only for "clean
494496
'
495497

496498
test_expect_success PERL 'required process filter should process multiple packets' '
497-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
499+
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
498500
test_config_global filter.protocol.required true &&
499501
500502
rm -rf repo &&
@@ -514,7 +516,7 @@ test_expect_success PERL 'required process filter should process multiple packet
514516
for FILE in "$TEST_ROOT"/*.file
515517
do
516518
cp "$FILE" . &&
517-
"$TEST_ROOT/rot13.sh" <"$FILE" >"$FILE.rot13"
519+
rot13.sh <"$FILE" >"$FILE.rot13"
518520
done &&
519521
520522
echo "*.file filter=protocol" >.gitattributes &&
@@ -554,7 +556,7 @@ test_expect_success PERL 'required process filter should process multiple packet
554556
'
555557

556558
test_expect_success PERL 'required process filter with clean error should fail' '
557-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
559+
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
558560
test_config_global filter.protocol.required true &&
559561
rm -rf repo &&
560562
mkdir repo &&
@@ -573,7 +575,7 @@ test_expect_success PERL 'required process filter with clean error should fail'
573575
'
574576

575577
test_expect_success PERL 'process filter should restart after unexpected write failure' '
576-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
578+
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
577579
rm -rf repo &&
578580
mkdir repo &&
579581
(
@@ -617,14 +619,14 @@ test_expect_success PERL 'process filter should restart after unexpected write f
617619
618620
# Smudge failed
619621
! test_cmp smudge-write-fail.o smudge-write-fail.r &&
620-
"$TEST_ROOT/rot13.sh" <smudge-write-fail.o >expected &&
622+
rot13.sh <smudge-write-fail.o >expected &&
621623
git cat-file blob :smudge-write-fail.r >actual &&
622624
test_cmp expected actual
623625
)
624626
'
625627

626628
test_expect_success PERL 'process filter should not be restarted if it signals an error' '
627-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
629+
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
628630
rm -rf repo &&
629631
mkdir repo &&
630632
(
@@ -663,7 +665,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
663665
'
664666

665667
test_expect_success PERL 'process filter abort stops processing of all further files' '
666-
test_config_global filter.protocol.process "$TEST_DIRECTORY/t0021/rot13-filter.pl clean smudge" &&
668+
test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
667669
rm -rf repo &&
668670
mkdir repo &&
669671
(

t/t0021/rot13-filter.pl

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/perl
21
#
32
# Example implementation for the Git filter protocol version 2
43
# See Documentation/gitattributes.txt, section "Filter Protocol"
@@ -22,6 +21,7 @@
2221

2322
use strict;
2423
use warnings;
24+
use IO::File;
2525

2626
my $MAX_PACKET_CONTENT_SIZE = 65516;
2727
my @capabilities = @ARGV;

0 commit comments

Comments
 (0)