t0021: make debug log file name configurable
The "rot13-filter.pl" helper wrote its debug logs always to "rot13-filter.log". Make this configurable by defining the log file as first parameter of "rot13-filter.pl". This is useful if "rot13-filter.pl" is configured multiple times similar to the subsequent patch 'convert: add "status=delayed" to filter process protocol'. Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Lars Schneider committed
Jun 1, 2017 at 10:22 UTC
e1ec4721d61d0cad59f36620b2cb15853eb5ef67
2 files changed
+27
-25
t/t0021-conversion.sh
+22
-22
@@ -28,7 +28,7 @@ file_size () {
28
}
29
30
filter_git () {
31
- rm -f rot13-filter.log &&
31
+ rm -f *.log &&
32
git "$@"
33
}
34
@@ -342,7 +342,7 @@ test_expect_success 'diff does not reuse worktree files that need cleaning' '
342
'
343
344
test_expect_success PERL 'required process filter should filter data' '
345
- test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
345
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
346
test_config_global filter.protocol.required true &&
347
rm -rf repo &&
348
mkdir repo &&
@@ -375,7 +375,7 @@ test_expect_success PERL 'required process filter should filter data' '
375
IN: clean testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
376
STOP
377
EOF
378
- test_cmp_count expected.log rot13-filter.log &&
378
+ test_cmp_count expected.log debug.log &&
379
380
git commit -m "test commit 2" &&
381
rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
@@ -388,7 +388,7 @@ test_expect_success PERL 'required process filter should filter data' '
388
IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
389
STOP
390
EOF
391
- test_cmp_exclude_clean expected.log rot13-filter.log &&
391
+ test_cmp_exclude_clean expected.log debug.log &&
392
393
filter_git checkout --quiet --no-progress empty-branch &&
394
cat >expected.log <<-EOF &&
@@ -397,7 +397,7 @@ test_expect_success PERL 'required process filter should filter data' '
397
IN: clean test.r $S [OK] -- OUT: $S . [OK]
398
STOP
399
EOF
400
- test_cmp_exclude_clean expected.log rot13-filter.log &&
400
+ test_cmp_exclude_clean expected.log debug.log &&
401
402
filter_git checkout --quiet --no-progress master &&
403
cat >expected.log <<-EOF &&
@@ -409,7 +409,7 @@ test_expect_success PERL 'required process filter should filter data' '
409
IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK]
410
STOP
411
EOF
412
- test_cmp_exclude_clean expected.log rot13-filter.log &&
412
+ test_cmp_exclude_clean expected.log debug.log &&
413
414
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
415
test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -419,7 +419,7 @@ test_expect_success PERL 'required process filter should filter data' '
419
420
test_expect_success PERL 'required process filter takes precedence' '
421
test_config_global filter.protocol.clean false &&
422
- test_config_global filter.protocol.process "rot13-filter.pl clean" &&
422
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&
423
test_config_global filter.protocol.required true &&
424
rm -rf repo &&
425
mkdir repo &&
@@ -439,12 +439,12 @@ test_expect_success PERL 'required process filter takes precedence' '
439
IN: clean test.r $S [OK] -- OUT: $S . [OK]
440
STOP
441
EOF
442
- test_cmp_count expected.log rot13-filter.log
442
+ test_cmp_count expected.log debug.log
443
)
444
'
445
446
test_expect_success PERL 'required process filter should be used only for "clean" operation only' '
447
- test_config_global filter.protocol.process "rot13-filter.pl clean" &&
447
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" &&
448
rm -rf repo &&
449
mkdir repo &&
450
(
@@ -462,7 +462,7 @@ test_expect_success PERL 'required process filter should be used only for "clean
462
IN: clean test.r $S [OK] -- OUT: $S . [OK]
463
STOP
464
EOF
465
- test_cmp_count expected.log rot13-filter.log &&
465
+ test_cmp_count expected.log debug.log &&
466
467
rm test.r &&
468
@@ -474,12 +474,12 @@ test_expect_success PERL 'required process filter should be used only for "clean
474
init handshake complete
475
STOP
476
EOF
477
- test_cmp_exclude_clean expected.log rot13-filter.log
477
+ test_cmp_exclude_clean expected.log debug.log
478
)
479
'
480
481
test_expect_success PERL 'required process filter should process multiple packets' '
482
- test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
482
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
483
test_config_global filter.protocol.required true &&
484
485
rm -rf repo &&
@@ -514,7 +514,7 @@ test_expect_success PERL 'required process filter should process multiple packet
514
IN: clean 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK]
515
STOP
516
EOF
517
- test_cmp_count expected.log rot13-filter.log &&
517
+ test_cmp_count expected.log debug.log &&
518
519
rm -f *.file &&
520
@@ -529,7 +529,7 @@ test_expect_success PERL 'required process filter should process multiple packet
529
IN: smudge 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK]
530
STOP
531
EOF
532
- test_cmp_exclude_clean expected.log rot13-filter.log &&
532
+ test_cmp_exclude_clean expected.log debug.log &&
533
534
for FILE in *.file
535
do
@@ -539,7 +539,7 @@ test_expect_success PERL 'required process filter should process multiple packet
539
'
540
541
test_expect_success PERL 'required process filter with clean error should fail' '
542
- test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
542
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
543
test_config_global filter.protocol.required true &&
544
rm -rf repo &&
545
mkdir repo &&
@@ -558,7 +558,7 @@ test_expect_success PERL 'required process filter with clean error should fail'
558
'
559
560
test_expect_success PERL 'process filter should restart after unexpected write failure' '
561
- test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
561
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
562
rm -rf repo &&
563
mkdir repo &&
564
(
@@ -579,7 +579,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f
579
git add . &&
580
rm -f *.r &&
581
582
- rm -f rot13-filter.log &&
582
+ rm -f debug.log &&
583
git checkout --quiet --no-progress . 2>git-stderr.log &&
584
585
grep "smudge write error at" git-stderr.log &&
@@ -595,7 +595,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f
595
IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
596
STOP
597
EOF
598
- test_cmp_exclude_clean expected.log rot13-filter.log &&
598
+ test_cmp_exclude_clean expected.log debug.log &&
599
600
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
601
test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -609,7 +609,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f
609
'
610
611
test_expect_success PERL 'process filter should not be restarted if it signals an error' '
612
- test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
612
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
613
rm -rf repo &&
614
mkdir repo &&
615
(
@@ -639,7 +639,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
639
IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK]
640
STOP
641
EOF
642
- test_cmp_exclude_clean expected.log rot13-filter.log &&
642
+ test_cmp_exclude_clean expected.log debug.log &&
643
644
test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r &&
645
test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -648,7 +648,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a
648
'
649
650
test_expect_success PERL 'process filter abort stops processing of all further files' '
651
- test_config_global filter.protocol.process "rot13-filter.pl clean smudge" &&
651
+ test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" &&
652
rm -rf repo &&
653
mkdir repo &&
654
(
@@ -676,7 +676,7 @@ test_expect_success PERL 'process filter abort stops processing of all further f
676
IN: smudge abort.r $SA [OK] -- OUT: 0 [ABORT]
677
STOP
678
EOF
679
- test_cmp_exclude_clean expected.log rot13-filter.log &&
679
+ test_cmp_exclude_clean expected.log debug.log &&
680
681
test_cmp "$TEST_ROOT/test.o" test.r &&
682
test_cmp "$TEST_ROOT/test2.o" test2.r &&
t/t0021/rot13-filter.pl
+5
-3
@@ -2,8 +2,9 @@
2
# Example implementation for the Git filter protocol version 2
3
# See Documentation/gitattributes.txt, section "Filter Protocol"
4
#
5
-# The script takes the list of supported protocol capabilities as
6
-# arguments ("clean", "smudge", etc).
5
+# The first argument defines a debug log file that the script write to.
6
+# All remaining arguments define a list of supported protocol
7
+# capabilities ("clean", "smudge", etc).
8
#
9
# This implementation supports special test cases:
10
# (1) If data with the pathname "clean-write-fail.r" is processed with
@@ -24,9 +25,10 @@ use warnings;
25
use IO::File;
26
27
my $MAX_PACKET_CONTENT_SIZE = 65516;
28
+my $log_file = shift @ARGV;
29
my @capabilities = @ARGV;
30
29
-open my $debug, ">>", "rot13-filter.log" or die "cannot open log file: $!";
31
+open my $debug, ">>", $log_file or die "cannot open log file: $!";
32
33
sub rot13 {
34
my $str = shift;