tests: remove "cat foo" before "test_i18ngrep bar foo"

Some tests print a file before searching for a pattern using test_i18ngrep. This is useful when debugging tests with --verbose when the pattern is not found as expected. Since 63b1a175ee (t: make 'test_i18ngrep' more informative on failure, 2018-02-08) test_i18ngrep already shows the contents of a file that doesn't match the expected pattern, though. So don't bother doing the same unconditionally up-front. The contents are not interesting if the expected pattern is found, and showing it twice if it doesn't match is of no use. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Oct 6, 2019 at 15:26 UTC f537485fa5535c65ec7e0cbe156eb60eb260f18e
4 files changed -32
t/t1450-fsck.sh
-16
@@ -70,7 +70,6 @@ test_expect_success 'object with bad sha1' '
70 test_when_finished "git update-ref -d refs/heads/bogus" &&
71
72 test_must_fail git fsck 2>out &&
73 - cat out &&
73 test_i18ngrep "$sha.*corrupt" out
74 '
75
@@ -78,7 +77,6 @@ test_expect_success 'branch pointing to non-commit' '
77 git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
78 test_when_finished "git update-ref -d refs/heads/invalid" &&
79 test_must_fail git fsck 2>out &&
81 - cat out &&
80 test_i18ngrep "not a commit" out
81 '
82
@@ -88,7 +86,6 @@ test_expect_success 'HEAD link pointing at a funny object' '
86 echo $ZERO_OID >.git/HEAD &&
87 # avoid corrupt/broken HEAD from interfering with repo discovery
88 test_must_fail env GIT_DIR=.git git fsck 2>out &&
91 - cat out &&
89 test_i18ngrep "detached HEAD points" out
90 '
91
@@ -98,7 +95,6 @@ test_expect_success 'HEAD link pointing at a funny place' '
95 echo "ref: refs/funny/place" >.git/HEAD &&
96 # avoid corrupt/broken HEAD from interfering with repo discovery
97 test_must_fail env GIT_DIR=.git git fsck 2>out &&
101 - cat out &&
98 test_i18ngrep "HEAD points to something strange" out
99 '
100
@@ -157,7 +153,6 @@ test_expect_success 'email with embedded > is not okay' '
153 git update-ref refs/heads/bogus "$new" &&
154 test_when_finished "git update-ref -d refs/heads/bogus" &&
155 test_must_fail git fsck 2>out &&
160 - cat out &&
156 test_i18ngrep "error in commit $new" out
157 '
158
@@ -169,7 +164,6 @@ test_expect_success 'missing < email delimiter is reported nicely' '
164 git update-ref refs/heads/bogus "$new" &&
165 test_when_finished "git update-ref -d refs/heads/bogus" &&
166 test_must_fail git fsck 2>out &&
172 - cat out &&
167 test_i18ngrep "error in commit $new.* - bad name" out
168 '
169
@@ -181,7 +175,6 @@ test_expect_success 'missing email is reported nicely' '
175 git update-ref refs/heads/bogus "$new" &&
176 test_when_finished "git update-ref -d refs/heads/bogus" &&
177 test_must_fail git fsck 2>out &&
184 - cat out &&
178 test_i18ngrep "error in commit $new.* - missing email" out
179 '
180
@@ -193,7 +186,6 @@ test_expect_success '> in name is reported' '
186 git update-ref refs/heads/bogus "$new" &&
187 test_when_finished "git update-ref -d refs/heads/bogus" &&
188 test_must_fail git fsck 2>out &&
196 - cat out &&
189 test_i18ngrep "error in commit $new" out
190 '
191
@@ -207,7 +199,6 @@ test_expect_success 'integer overflow in timestamps is reported' '
199 git update-ref refs/heads/bogus "$new" &&
200 test_when_finished "git update-ref -d refs/heads/bogus" &&
201 test_must_fail git fsck 2>out &&
210 - cat out &&
202 test_i18ngrep "error in commit $new.*integer overflow" out
203 '
204
@@ -219,7 +210,6 @@ test_expect_success 'commit with NUL in header' '
210 git update-ref refs/heads/bogus "$new" &&
211 test_when_finished "git update-ref -d refs/heads/bogus" &&
212 test_must_fail git fsck 2>out &&
222 - cat out &&
213 test_i18ngrep "error in commit $new.*unterminated header: NUL at offset" out
214 '
215
@@ -297,7 +287,6 @@ test_expect_success 'tag pointing to nonexistent' '
287 echo $tag >.git/refs/tags/invalid &&
288 test_when_finished "git update-ref -d refs/tags/invalid" &&
289 test_must_fail git fsck --tags >out &&
300 - cat out &&
290 test_i18ngrep "broken link" out
291 '
292
@@ -378,7 +367,6 @@ test_expect_success 'tag with NUL in header' '
367 echo $tag >.git/refs/tags/wrong &&
368 test_when_finished "git update-ref -d refs/tags/wrong" &&
369 test_must_fail git fsck --tags 2>out &&
381 - cat out &&
370 test_i18ngrep "error in tag $tag.*unterminated header: NUL at offset" out
371 '
372
@@ -409,7 +397,6 @@ test_expect_success 'rev-list --verify-objects with bad sha1' '
397 test_when_finished "git update-ref -d refs/heads/bogus" &&
398
399 test_might_fail git rev-list --verify-objects refs/heads/bogus >/dev/null 2>out &&
412 - cat out &&
400 test_i18ngrep -q "error: hash mismatch $(dirname $new)$(test_oid ff_2)" out
401 '
402
@@ -433,7 +420,6 @@ test_expect_success 'fsck notices blob entry pointing to null sha1' '
420 sha=$(printf "100644 file$_bz$_bzoid" |
421 git hash-object -w --stdin -t tree) &&
422 git fsck 2>out &&
436 - cat out &&
423 test_i18ngrep "warning.*null sha1" out
424 )
425 '
@@ -444,7 +430,6 @@ test_expect_success 'fsck notices submodule entry pointing to null sha1' '
430 sha=$(printf "160000 submodule$_bz$_bzoid" |
431 git hash-object -w --stdin -t tree) &&
432 git fsck 2>out &&
447 - cat out &&
433 test_i18ngrep "warning.*null sha1" out
434 )
435 '
@@ -465,7 +450,6 @@ while read name path pretty; do
450 printf "$mode $type %s\t%s" "$value" "$path" >bad &&
451 bad_tree=$(git mktree <bad) &&
452 git fsck 2>out &&
468 - cat out &&
453 test_i18ngrep "warning.*tree $bad_tree" out
454 )'
455 done <<-\EOF
t/t5801-remote-helpers.sh
-1
@@ -247,7 +247,6 @@ clean_mark () {
247 test_expect_success 'proper failure checks for fetching' '
248 (cd local &&
249 test_must_fail env GIT_REMOTE_TESTGIT_FAILURE=1 git fetch 2>error &&
250 - cat error &&
250 test_i18ngrep -q "error while running fast-import" error
251 )
252 '
t/t7400-submodule-basic.sh
-2
@@ -527,7 +527,6 @@ test_expect_success 'update --init' '
527 test_must_fail git config submodule.example.url &&
528
529 git submodule update init 2> update.out &&
530 - cat update.out &&
530 test_i18ngrep "not initialized" update.out &&
531 test_must_fail git rev-parse --resolve-git-dir init/.git &&
532
@@ -545,7 +544,6 @@ test_expect_success 'update --init from subdirectory' '
544 (
545 cd sub &&
546 git submodule update ../init 2>update.out &&
548 - cat update.out &&
547 test_i18ngrep "not initialized" update.out &&
548 test_must_fail git rev-parse --resolve-git-dir ../init/.git &&
549
t/t9300-fast-import.sh
-13
@@ -2781,7 +2781,6 @@ test_expect_success 'S: filemodify with garbage after mark must fail' '
2781 COMMIT
2782 M 100644 :403x hello.c
2783 EOF
2784 - cat err &&
2784 test_i18ngrep "space after mark" err
2785 '
2786
@@ -2798,7 +2797,6 @@ test_expect_success 'S: filemodify with garbage after inline must fail' '
2797 inline
2798 BLOB
2799 EOF
2801 - cat err &&
2800 test_i18ngrep "nvalid dataref" err
2801 '
2802
@@ -2812,7 +2810,6 @@ test_expect_success 'S: filemodify with garbage after sha1 must fail' '
2810 COMMIT
2811 M 100644 ${sha1}x hello.c
2812 EOF
2815 - cat err &&
2813 test_i18ngrep "space after SHA1" err
2814 '
2815
@@ -2828,7 +2825,6 @@ test_expect_success 'S: notemodify with garbage after mark dataref must fail' '
2825 COMMIT
2826 N :202x :302
2827 EOF
2831 - cat err &&
2828 test_i18ngrep "space after mark" err
2829 '
2830
@@ -2844,7 +2840,6 @@ test_expect_success 'S: notemodify with garbage after inline dataref must fail'
2840 note blob
2841 BLOB
2842 EOF
2847 - cat err &&
2843 test_i18ngrep "nvalid dataref" err
2844 '
2845
@@ -2858,7 +2853,6 @@ test_expect_success 'S: notemodify with garbage after sha1 dataref must fail' '
2853 COMMIT
2854 N ${sha1}x :302
2855 EOF
2861 - cat err &&
2856 test_i18ngrep "space after SHA1" err
2857 '
2858
@@ -2874,7 +2868,6 @@ test_expect_success 'S: notemodify with garbage after mark commit-ish must fail'
2868 COMMIT
2869 N :202 :302x
2870 EOF
2877 - cat err &&
2871 test_i18ngrep "after mark" err
2872 '
2873
@@ -2908,7 +2901,6 @@ test_expect_success 'S: from with garbage after mark must fail' '
2901 EOF
2902
2903 # now evaluate the error
2911 - cat err &&
2904 test_i18ngrep "after mark" err
2905 '
2906
@@ -2928,7 +2920,6 @@ test_expect_success 'S: merge with garbage after mark must fail' '
2920 merge :303x
2921 M 100644 :403 hello.c
2922 EOF
2931 - cat err &&
2923 test_i18ngrep "after mark" err
2924 '
2925
@@ -2944,7 +2935,6 @@ test_expect_success 'S: tag with garbage after mark must fail' '
2935 tag S
2936 TAG
2937 EOF
2947 - cat err &&
2938 test_i18ngrep "after mark" err
2939 '
2940
@@ -2955,7 +2945,6 @@ test_expect_success 'S: cat-blob with garbage after mark must fail' '
2945 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2946 cat-blob :403x
2947 EOF
2958 - cat err &&
2948 test_i18ngrep "after mark" err
2949 '
2950
@@ -2966,7 +2955,6 @@ test_expect_success 'S: ls with garbage after mark must fail' '
2955 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2956 ls :302x hello.c
2957 EOF
2969 - cat err &&
2958 test_i18ngrep "space after mark" err
2959 '
2960
@@ -2975,7 +2963,6 @@ test_expect_success 'S: ls with garbage after sha1 must fail' '
2963 test_must_fail git fast-import --import-marks=marks <<-EOF 2>err &&
2964 ls ${sha1}x hello.c
2965 EOF
2978 - cat err &&
2966 test_i18ngrep "space after tree-ish" err
2967 '
2968