Skip to content

Commit

Permalink
tests: teach callers of test_i18ngrep to use test_grep
Browse files Browse the repository at this point in the history
They are equivalents and the former still exists, so as long as the
only change this commit makes are to rewrite test_i18ngrep to
test_grep, there won't be any new bug, even if there still are
callers of test_i18ngrep remaining in the tree, or when merged to
other topics that add new uses of test_i18ngrep.

This patch was produced more or less with

    git grep -l -e 'test_i18ngrep ' 't/t[0-9][0-9][0-9][0-9]-*.sh' |
    xargs perl -p -i -e 's/test_i18ngrep /test_grep /'

and a good way to sanity check the result yourself is to run the
above in a checkout of c4603c1c (test framework: further deprecate
test_i18ngrep, 2023-10-31) and compare the resulting working tree
contents with the result of applying this patch to the same commit.
You'll see that test_i18ngrep in a few t/lib-*.sh files corrected,
in addition to the manual reproduction.

Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
gitster committed Nov 2, 2023
1 parent 2e87fca commit 6789275
Show file tree
Hide file tree
Showing 225 changed files with 1,191 additions and 1,191 deletions.
2 changes: 1 addition & 1 deletion contrib/mw-to-git/t/t9363-mw-to-git-export-import.sh
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ test_expect_success 'git push properly warns about insufficient permissions' '
git add foo.forbidden &&
git commit -m "add a file" &&
git push 2>actual &&
test_i18ngrep "foo.forbidden is not a permitted file" actual
test_grep "foo.forbidden is not a permitted file" actual
)
'

Expand Down
2 changes: 1 addition & 1 deletion t/lib-httpd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ test_http_push_nonff () {
'

test_expect_success 'non-fast-forward push shows help message' '
test_i18ngrep "Updates were rejected because" output
test_grep "Updates were rejected because" output
'

test_expect_${EXPECT_CAS_RESULT} 'force with lease aka cas' '
Expand Down
2 changes: 1 addition & 1 deletion t/lib-submodule-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -830,7 +830,7 @@ test_submodule_recursing_with_args_common () {
cd submodule_update &&
git branch -t invalid_sub1 origin/invalid_sub1 &&
test_must_fail $command invalid_sub1 2>err &&
test_i18ngrep sub1 err &&
test_grep sub1 err &&
test_superproject_content origin/add_sub1 &&
test_submodule_content sub1 origin/add_sub1
)
Expand Down
16 changes: 8 additions & 8 deletions t/t0001-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ test_expect_success 'reinit' '
git -c init.defaultBranch=initial init >out1 2>err1 &&
git init >out2 2>err2
) &&
test_i18ngrep "Initialized empty" again/out1 &&
test_i18ngrep "Reinitialized existing" again/out2 &&
test_grep "Initialized empty" again/out1 &&
test_grep "Reinitialized existing" again/out2 &&
test_must_be_empty again/err1 &&
test_must_be_empty again/err2
'
Expand Down Expand Up @@ -332,15 +332,15 @@ test_expect_success 'init with separate gitdir' '

test_expect_success 'explicit bare & --separate-git-dir incompatible' '
test_must_fail git init --bare --separate-git-dir goop.git bare.git 2>err &&
test_i18ngrep "cannot be used together" err
test_grep "cannot be used together" err
'

test_expect_success 'implicit bare & --separate-git-dir incompatible' '
test_when_finished "rm -rf bare.git" &&
mkdir -p bare.git &&
test_must_fail env GIT_DIR=. \
git -C bare.git init --separate-git-dir goop.git 2>err &&
test_i18ngrep "incompatible" err
test_grep "incompatible" err
'

test_expect_success 'bare & --separate-git-dir incompatible within worktree' '
Expand All @@ -349,7 +349,7 @@ test_expect_success 'bare & --separate-git-dir incompatible within worktree' '
git clone --bare . bare.git &&
git -C bare.git worktree add --detach ../linkwt &&
test_must_fail git -C linkwt init --separate-git-dir seprepo 2>err &&
test_i18ngrep "incompatible" err
test_grep "incompatible" err
'

test_lazy_prereq GETCWD_IGNORES_PERMS '
Expand Down Expand Up @@ -563,7 +563,7 @@ test_expect_success '--initial-branch' '
: re-initializing should not change the branch name &&
git init --initial-branch=ignore initial-branch-option 2>err &&
test_i18ngrep "ignored --initial-branch" err &&
test_grep "ignored --initial-branch" err &&
git -C initial-branch-option symbolic-ref HEAD >actual &&
grep hello actual
'
Expand All @@ -579,7 +579,7 @@ test_expect_success 'advice on unconfigured init.defaultBranch' '
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME= git -c color.advice=always \
init unconfigured-default-branch-name 2>err &&
test_decode_color <err >decoded &&
test_i18ngrep "<YELLOW>hint: " decoded
test_grep "<YELLOW>hint: " decoded
'

test_expect_success 'overridden default main branch name (env)' '
Expand All @@ -592,7 +592,7 @@ test_expect_success 'overridden default main branch name (env)' '
test_expect_success 'invalid default branch name' '
test_must_fail env GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME="with space" \
git init initial-branch-invalid 2>err &&
test_i18ngrep "invalid branch name" err
test_grep "invalid branch name" err
'

test_expect_success 'branch -m with the initial branch' '
Expand Down
4 changes: 2 additions & 2 deletions t/t0002-gitfile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ test_expect_success 'initial setup' '
test_expect_success 'bad setup: invalid .git file format' '
echo "gitdir $REAL" >.git &&
test_must_fail git rev-parse 2>.err &&
test_i18ngrep "invalid gitfile format" .err
test_grep "invalid gitfile format" .err
'

test_expect_success 'bad setup: invalid .git file path' '
echo "gitdir: $REAL.not" >.git &&
test_must_fail git rev-parse 2>.err &&
test_i18ngrep "not a git repository" .err
test_grep "not a git repository" .err
'

test_expect_success 'final setup + check rev-parse --git-dir' '
Expand Down
4 changes: 2 additions & 2 deletions t/t0003-attributes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ test_expect_success 'root subdir attribute test' '
test_expect_success 'negative patterns' '
echo "!f test=bar" >.gitattributes &&
git check-attr test -- '"'"'!f'"'"' 2>errors &&
test_i18ngrep "Negative patterns are ignored" errors
test_grep "Negative patterns are ignored" errors
'

test_expect_success 'patterns starting with exclamation' '
Expand Down Expand Up @@ -424,7 +424,7 @@ test_expect_success SYMLINKS 'symlinks not respected in-tree' '
mkdir subdir &&
ln -s ../attr subdir/.gitattributes &&
attr_check_basic subdir/file unspecified &&
test_i18ngrep "unable to access.*gitattributes" err
test_grep "unable to access.*gitattributes" err
'

test_expect_success 'large attributes line ignored in tree' '
Expand Down
4 changes: 2 additions & 2 deletions t/t0008-ignores.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ broken_c_unquote_verbose () {

stderr_contains () {
regexp="$1"
if test_i18ngrep "$regexp" "$HOME/stderr"
if test_grep "$regexp" "$HOME/stderr"
then
return 0
else
Expand Down Expand Up @@ -942,7 +942,7 @@ test_expect_success SYMLINKS 'symlinks not respected in-tree' '
ln -s ignore subdir/.gitignore &&
test_must_fail git check-ignore subdir/file >actual 2>err &&
test_must_be_empty actual &&
test_i18ngrep "unable to access.*gitignore" err
test_grep "unable to access.*gitignore" err
'

test_done
16 changes: 8 additions & 8 deletions t/t0012-help.sh
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,17 @@ test_expect_success "--help does not work for guides" "

test_expect_success 'git help' '
git help >help.output &&
test_i18ngrep "^ clone " help.output &&
test_i18ngrep "^ add " help.output &&
test_i18ngrep "^ log " help.output &&
test_i18ngrep "^ commit " help.output &&
test_i18ngrep "^ fetch " help.output
test_grep "^ clone " help.output &&
test_grep "^ add " help.output &&
test_grep "^ log " help.output &&
test_grep "^ commit " help.output &&
test_grep "^ fetch " help.output
'

test_expect_success 'git help -g' '
git help -g >help.output &&
test_i18ngrep "^ everyday " help.output &&
test_i18ngrep "^ tutorial " help.output
test_grep "^ everyday " help.output &&
test_grep "^ tutorial " help.output
'

test_expect_success 'git help fails for non-existing html pages' '
Expand Down Expand Up @@ -257,7 +257,7 @@ do
export GIT_CEILING_DIRECTORIES &&
test_expect_code 129 git -C sub $builtin -h >output 2>&1
) &&
test_i18ngrep usage output
test_grep usage output
'
done <builtins

Expand Down
2 changes: 1 addition & 1 deletion t/t0013-sha1dc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fi

test_expect_success 'test-sha1 detects shattered pdf' '
test_must_fail test-tool sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
test_i18ngrep collision err &&
test_grep collision err &&
grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
'

Expand Down
8 changes: 4 additions & 4 deletions t/t0014-alias.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ test_expect_success 'nested aliases - internal execution' '
git config alias.nested-internal-1 nested-internal-2 &&
git config alias.nested-internal-2 status &&
git nested-internal-1 >output &&
test_i18ngrep "^On branch " output
test_grep "^On branch " output
'

test_expect_success 'nested aliases - mixed execution' '
git config alias.nested-external-1 nested-external-2 &&
git config alias.nested-external-2 "!git nested-external-3" &&
git config alias.nested-external-3 status &&
git nested-external-1 >output &&
test_i18ngrep "^On branch " output
test_grep "^On branch " output
'

test_expect_success 'looping aliases - internal execution' '
git config alias.loop-internal-1 loop-internal-2 &&
git config alias.loop-internal-2 loop-internal-3 &&
git config alias.loop-internal-3 loop-internal-2 &&
test_must_fail git loop-internal-1 2>output &&
test_i18ngrep "^fatal: alias loop detected: expansion of" output
test_grep "^fatal: alias loop detected: expansion of" output
'

# This test is disabled until external loops are fixed, because would block
Expand All @@ -34,7 +34,7 @@ test_expect_success 'looping aliases - internal execution' '
# git config alias.loop-mixed-1 loop-mixed-2 &&
# git config alias.loop-mixed-2 "!git loop-mixed-1" &&
# test_must_fail git loop-mixed-1 2>output &&
# test_i18ngrep "^fatal: alias loop detected: expansion of" output
# test_grep "^fatal: alias loop detected: expansion of" output
#'

test_expect_success 'run-command formats empty args properly' '
Expand Down
6 changes: 3 additions & 3 deletions t/t0021-conversion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ test_expect_success 'required filter with absent clean field' '
echo test >test.ac &&
test_must_fail git add test.ac 2>stderr &&
test_i18ngrep "fatal: test.ac: clean filter .absentclean. failed" stderr
test_grep "fatal: test.ac: clean filter .absentclean. failed" stderr
'

test_expect_success 'required filter with absent smudge field' '
Expand All @@ -276,7 +276,7 @@ test_expect_success 'required filter with absent smudge field' '
git add test.as &&
rm -f test.as &&
test_must_fail git checkout -- test.as 2>stderr &&
test_i18ngrep "fatal: test.as: smudge filter absentsmudge failed" stderr
test_grep "fatal: test.as: smudge filter absentsmudge failed" stderr
'

test_expect_success 'filtering large input to small output should use little memory' '
Expand Down Expand Up @@ -733,7 +733,7 @@ test_expect_success 'process filter should restart after unexpected write failur
git checkout --quiet --no-progress . 2>git-stderr.log &&
grep "smudge write error" git-stderr.log &&
test_i18ngrep "error: external filter" git-stderr.log &&
test_grep "error: external filter" git-stderr.log &&
cat >expected.log <<-EOF &&
START
Expand Down
32 changes: 16 additions & 16 deletions t/t0028-working-tree-encoding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,23 +92,23 @@ do
# In these cases the BOM is prohibited.
cp bebom.utf${i}be.raw bebom.utf${i}be &&
test_must_fail git add bebom.utf${i}be 2>err.out &&
test_i18ngrep "fatal: BOM is prohibited .* utf-${i}be" err.out &&
test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out &&
test_grep "fatal: BOM is prohibited .* utf-${i}be" err.out &&
test_grep "use UTF-${i} as working-tree-encoding" err.out &&
cp lebom.utf${i}le.raw lebom.utf${i}be &&
test_must_fail git add lebom.utf${i}be 2>err.out &&
test_i18ngrep "fatal: BOM is prohibited .* utf-${i}be" err.out &&
test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out &&
test_grep "fatal: BOM is prohibited .* utf-${i}be" err.out &&
test_grep "use UTF-${i} as working-tree-encoding" err.out &&
cp bebom.utf${i}be.raw bebom.utf${i}le &&
test_must_fail git add bebom.utf${i}le 2>err.out &&
test_i18ngrep "fatal: BOM is prohibited .* utf-${i}LE" err.out &&
test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out &&
test_grep "fatal: BOM is prohibited .* utf-${i}LE" err.out &&
test_grep "use UTF-${i} as working-tree-encoding" err.out &&
cp lebom.utf${i}le.raw lebom.utf${i}le &&
test_must_fail git add lebom.utf${i}le 2>err.out &&
test_i18ngrep "fatal: BOM is prohibited .* utf-${i}LE" err.out &&
test_i18ngrep "use UTF-${i} as working-tree-encoding" err.out
test_grep "fatal: BOM is prohibited .* utf-${i}LE" err.out &&
test_grep "use UTF-${i} as working-tree-encoding" err.out
'

test_expect_success "check required UTF-${i} BOM" '
Expand All @@ -118,13 +118,13 @@ do
cp nobom.utf${i}be.raw nobom.utf${i} &&
test_must_fail git add nobom.utf${i} 2>err.out &&
test_i18ngrep "fatal: BOM is required .* utf-${i}" err.out &&
test_i18ngrep "use UTF-${i}BE or UTF-${i}LE" err.out &&
test_grep "fatal: BOM is required .* utf-${i}" err.out &&
test_grep "use UTF-${i}BE or UTF-${i}LE" err.out &&
cp nobom.utf${i}le.raw nobom.utf${i} &&
test_must_fail git add nobom.utf${i} 2>err.out &&
test_i18ngrep "fatal: BOM is required .* utf-${i}" err.out &&
test_i18ngrep "use UTF-${i}BE or UTF-${i}LE" err.out
test_grep "fatal: BOM is required .* utf-${i}" err.out &&
test_grep "use UTF-${i}BE or UTF-${i}LE" err.out
'

test_expect_success "eol conversion for UTF-${i} encoded files on checkout" '
Expand Down Expand Up @@ -169,7 +169,7 @@ test_expect_success 'check unsupported encodings' '
echo "*.set text working-tree-encoding" >.gitattributes &&
printf "set" >t.set &&
test_must_fail git add t.set 2>err.out &&
test_i18ngrep "true/false are no valid working-tree-encodings" err.out &&
test_grep "true/false are no valid working-tree-encodings" err.out &&
echo "*.unset text -working-tree-encoding" >.gitattributes &&
printf "unset" >t.unset &&
Expand All @@ -182,7 +182,7 @@ test_expect_success 'check unsupported encodings' '
echo "*.garbage text working-tree-encoding=garbage" >.gitattributes &&
printf "garbage" >t.garbage &&
test_must_fail git add t.garbage 2>err.out &&
test_i18ngrep "failed to encode" err.out
test_grep "failed to encode" err.out
'

test_expect_success 'error if encoding round trip is not the same during refresh' '
Expand All @@ -201,7 +201,7 @@ test_expect_success 'error if encoding round trip is not the same during refresh
git update-ref refs/heads/main $COMMIT &&
test_must_fail git checkout HEAD^ 2>err.out &&
test_i18ngrep "error: .* overwritten by checkout:" err.out
test_grep "error: .* overwritten by checkout:" err.out
'

test_expect_success 'error if encoding garbage is already in Git' '
Expand All @@ -217,7 +217,7 @@ test_expect_success 'error if encoding garbage is already in Git' '
git update-ref refs/heads/main $COMMIT &&
git diff 2>err.out &&
test_i18ngrep "error: BOM is required" err.out
test_grep "error: BOM is required" err.out
'

test_lazy_prereq ICONV_SHIFT_JIS '
Expand Down
4 changes: 2 additions & 2 deletions t/t0040-parse-options.sh
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ test_expect_success 'OPT_CMDMODE() works' '
test_expect_success 'OPT_CMDMODE() detects incompatibility' '
test_must_fail test-tool parse-options --mode1 --mode2 >output 2>output.err &&
test_must_be_empty output &&
test_i18ngrep "incompatible with --mode" output.err
test_grep "incompatible with --mode" output.err
'

test_expect_success 'OPT_CMDMODE() detects incompatibility with something else' '
test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err &&
test_must_be_empty output &&
test_i18ngrep "incompatible with something else" output.err
test_grep "incompatible with something else" output.err
'

test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' '
Expand Down
Loading

0 comments on commit 6789275

Please sign in to comment.