From: Junio C Hamano Date: Wed, 8 Nov 2023 02:04:02 +0000 (+0900) Subject: Merge branch 'jc/test-i18ngrep' X-Git-Tag: v2.43.0-rc1~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8e2394704d0543f4e1f1ac6ea532d098316d97e;p=thirdparty%2Fgit.git Merge branch 'jc/test-i18ngrep' Another step to deprecate test_i18ngrep. * jc/test-i18ngrep: tests: teach callers of test_i18ngrep to use test_grep test framework: further deprecate test_i18ngrep --- a8e2394704d0543f4e1f1ac6ea532d098316d97e diff --cc t/t0040-parse-options.sh index 06fb9e6457,c8cc0fd8d0..8fdef88b65 --- a/t/t0040-parse-options.sh +++ b/t/t0040-parse-options.sh @@@ -367,41 -360,19 +367,41 @@@ test_expect_success 'OPT_NEGBIT() works ' test_expect_success 'OPT_CMDMODE() works' ' - test-tool parse-options --expect="integer: 1" --mode1 + test-tool parse-options --expect="integer: 1" --mode1 && + test-tool parse-options --expect="integer: 3" --mode34=3 ' -test_expect_success 'OPT_CMDMODE() detects incompatibility' ' +test_expect_success 'OPT_CMDMODE() detects incompatibility (1)' ' test_must_fail test-tool parse-options --mode1 --mode2 >output 2>output.err && test_must_be_empty output && - test_i18ngrep "mode1" output.err && - test_i18ngrep "mode2" output.err && - test_i18ngrep "is incompatible with" output.err - test_grep "incompatible with --mode" output.err ++ test_grep "mode1" output.err && ++ test_grep "mode2" output.err && ++ test_grep "is incompatible with" output.err ' -test_expect_success 'OPT_CMDMODE() detects incompatibility with something else' ' +test_expect_success 'OPT_CMDMODE() detects incompatibility (2)' ' test_must_fail test-tool parse-options --set23 --mode2 >output 2>output.err && test_must_be_empty output && - test_i18ngrep "mode2" output.err && - test_i18ngrep "set23" output.err && - test_i18ngrep "is incompatible with" output.err - test_grep "incompatible with something else" output.err ++ test_grep "mode2" output.err && ++ test_grep "set23" output.err && ++ test_grep "is incompatible with" output.err +' + +test_expect_success 'OPT_CMDMODE() detects incompatibility (3)' ' + test_must_fail test-tool parse-options --mode2 --set23 >output 2>output.err && + test_must_be_empty output && - test_i18ngrep "mode2" output.err && - test_i18ngrep "set23" output.err && - test_i18ngrep "is incompatible with" output.err ++ test_grep "mode2" output.err && ++ test_grep "set23" output.err && ++ test_grep "is incompatible with" output.err +' + +test_expect_success 'OPT_CMDMODE() detects incompatibility (4)' ' + test_must_fail test-tool parse-options --mode2 --mode34=3 \ + >output 2>output.err && + test_must_be_empty output && - test_i18ngrep "mode2" output.err && - test_i18ngrep "mode34.3" output.err && - test_i18ngrep "is incompatible with" output.err ++ test_grep "mode2" output.err && ++ test_grep "mode34.3" output.err && ++ test_grep "is incompatible with" output.err ' test_expect_success 'OPT_COUNTUP() with PARSE_OPT_NODASH works' ' diff --cc t/t0091-bugreport.sh index ae5b7dc31f,150cc1dea2..8798feefe3 --- a/t/t0091-bugreport.sh +++ b/t/t0091-bugreport.sh @@@ -69,13 -69,6 +69,13 @@@ test_expect_success 'incorrect argument test_path_is_missing git-bugreport-* ' +test_expect_success 'incorrect positional arguments abort with usage and hint' ' + test_must_fail git bugreport false 2>output && - grep usage output && - grep false output && ++ test_grep usage output && ++ test_grep false output && + test_path_is_missing git-bugreport-* +' + test_expect_success 'runs outside of a git dir' ' test_when_finished rm non-repo/git-bugreport-* && nongit git bugreport diff --cc t/t1430-bad-ref-name.sh index 7b7d6953c6,4da539cf50..68cc9e73d0 --- a/t/t1430-bad-ref-name.sh +++ b/t/t1430-bad-ref-name.sh @@@ -217,10 -216,9 +217,10 @@@ test_expect_success 'branch -d can dele test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...ref" && test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/badname" && + test_ref_exists refs/heads/badname && git branch -d badname >output 2>error && - test_path_is_missing .git/refs/heads/badname && + test_ref_missing refs/heads/badname && - test_i18ngrep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output && + test_grep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output && test_must_be_empty error ' @@@ -237,10 -234,9 +237,10 @@@ test_expect_success 'update-ref --no-de test_expect_success 'branch -d can delete dangling symref to broken name' ' test-tool ref-store main create-symref refs/heads/badname refs/heads/broken...ref msg && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/badname" && + test_ref_exists refs/heads/badname && git branch -d badname >output 2>error && - test_path_is_missing .git/refs/heads/badname && + test_ref_missing refs/heads/badname && - test_i18ngrep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output && + test_grep "Deleted branch badname (was refs/heads/broken\.\.\.ref)" output && test_must_be_empty error ' @@@ -269,10 -263,9 +269,10 @@@ test_expect_success 'update-ref --no-de test_expect_success 'branch -d can delete symref with broken name' ' printf "ref: refs/heads/main\n" >.git/refs/heads/broken...symref && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && + test_ref_exists refs/heads/broken...symref && git branch -d broken...symref >output 2>error && - test_path_is_missing .git/refs/heads/broken...symref && + test_ref_missing refs/heads/broken...symref && - test_i18ngrep "Deleted branch broken...symref (was refs/heads/main)" output && + test_grep "Deleted branch broken...symref (was refs/heads/main)" output && test_must_be_empty error ' @@@ -289,10 -281,9 +289,10 @@@ test_expect_success 'update-ref --no-de test_expect_success 'branch -d can delete dangling symref with broken name' ' printf "ref: refs/heads/idonotexist\n" >.git/refs/heads/broken...symref && test_when_finished "test-tool ref-store main delete-refs REF_NO_DEREF msg refs/heads/broken...symref" && + test_ref_exists refs/heads/broken...symref && git branch -d broken...symref >output 2>error && - test_path_is_missing .git/refs/heads/broken...symref && + test_ref_missing refs/heads/broken...symref && - test_i18ngrep "Deleted branch broken...symref (was refs/heads/idonotexist)" output && + test_grep "Deleted branch broken...symref (was refs/heads/idonotexist)" output && test_must_be_empty error ' diff --cc t/t3202-show-branch.sh index 2cdb834b37,235c68fb02..6a98b2df76 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@@ -253,7 -253,7 +253,7 @@@ test_expect_success 'error description test_branch_op_in_wt() { test_orphan_error() { test_must_fail git $* 2>actual && - test_i18ngrep "no commit on branch .orphan-branch. yet$" actual - test_grep "No commit on branch .orphan-branch. yet.$" actual ++ test_grep "no commit on branch .orphan-branch. yet$" actual } && test_orphan_error -C wt branch $1 $2 && # implicit branch test_orphan_error -C wt branch $1 orphan-branch $2 && # explicit branch diff --cc t/t3400-rebase.sh index d3df19a51f,621c8ef84c..24a539c662 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@@ -421,7 -421,7 +421,7 @@@ test_expect_success 'refuse to switch t git checkout main && git worktree add wt && test_must_fail git -C wt rebase main main 2>err && - test_i18ngrep "already used by worktree at" err - test_grep "already checked out" err ++ test_grep "already used by worktree at" err ' test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' ' diff --cc t/t3404-rebase-interactive.sh index 8ea2bf1302,dbd5df5aa4..c5f30554c6 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@@ -604,8 -604,7 +604,8 @@@ test_expect_success 'clean error after echo "edited again" > file7 && git add file7 && test_must_fail git rebase --continue 2>error && - test_i18ngrep "you have staged changes in your working tree" error && - test_i18ngrep ! "could not open.*for reading" error - test_grep "you have staged changes in your working tree" error ++ test_grep "you have staged changes in your working tree" error && ++ test_grep ! "could not open.*for reading" error ' test_expect_success 'rebase a detached HEAD' ' diff --cc t/t4068-diff-symmetric-merge-base.sh index 541642650f,3356d91cd4..eff63c16b0 --- a/t/t4068-diff-symmetric-merge-base.sh +++ b/t/t4068-diff-symmetric-merge-base.sh @@@ -150,7 -143,7 +150,7 @@@ d test_expect_success "$cmd --merge-base with non-commit" ' git checkout main && test_must_fail git $cmd --merge-base main^{tree} 2>err && - test_i18ngrep "is a tree, not a commit" err - test_grep "fatal: --merge-base only works with commits" err ++ test_grep "is a tree, not a commit" err ' test_expect_success "$cmd --merge-base with no merge bases and one commit" ' @@@ -176,7 -169,7 +176,7 @@@ d test_expect_success "$cmd --merge-base commit and non-commit" ' test_must_fail git $cmd --merge-base br2 main^{tree} 2>err && - test_i18ngrep "is a tree, not a commit" err - test_grep "fatal: --merge-base only works with commits" err ++ test_grep "is a tree, not a commit" err ' test_expect_success "$cmd --merge-base with no merge bases and two commits" ' diff --cc t/t5324-split-commit-graph.sh index 97eb6d2e72,a48c00ef50..281266f788 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@@ -335,54 -306,27 +335,54 @@@ test_expect_success 'warn on base grap git commit-graph verify && base_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph && corrupt_file "$base_file" $(test_oid base) "\01" && - git commit-graph verify --shallow 2>test_err && + test_must_fail git commit-graph verify --shallow 2>test_err && grep -v "^+" test_err >err && - test_i18ngrep "commit-graph chain does not match" err + test_grep "commit-graph chain does not match" err ) ' -test_expect_success 'verify after commit-graph-chain corruption' ' - git clone --no-hardlinks . verify-chain && +test_expect_success 'verify after commit-graph-chain corruption (base)' ' + git clone --no-hardlinks . verify-chain-base && ( - cd verify-chain && - corrupt_file "$graphdir/commit-graph-chain" 60 "G" && - git commit-graph verify 2>test_err && + cd verify-chain-base && + corrupt_file "$graphdir/commit-graph-chain" 30 "G" && + test_must_fail git commit-graph verify 2>test_err && grep -v "^+" test_err >err && - test_i18ngrep "invalid commit-graph chain" err && + test_grep "invalid commit-graph chain" err && - corrupt_file "$graphdir/commit-graph-chain" 60 "A" && - git commit-graph verify 2>test_err && + corrupt_file "$graphdir/commit-graph-chain" 30 "A" && + test_must_fail git commit-graph verify 2>test_err && grep -v "^+" test_err >err && - test_i18ngrep "unable to find all commit-graph files" err + test_grep "unable to find all commit-graph files" err ) ' +test_expect_success 'verify after commit-graph-chain corruption (tip)' ' + git clone --no-hardlinks . verify-chain-tip && + ( + cd verify-chain-tip && + corrupt_file "$graphdir/commit-graph-chain" 70 "G" && + test_must_fail git commit-graph verify 2>test_err && + grep -v "^+" test_err >err && - test_i18ngrep "invalid commit-graph chain" err && ++ test_grep "invalid commit-graph chain" err && + corrupt_file "$graphdir/commit-graph-chain" 70 "A" && + test_must_fail git commit-graph verify 2>test_err && + grep -v "^+" test_err >err && - test_i18ngrep "unable to find all commit-graph files" err ++ test_grep "unable to find all commit-graph files" err + ) +' + +test_expect_success 'verify notices too-short chain file' ' + git clone --no-hardlinks . verify-chain-short && + ( + cd verify-chain-short && + git commit-graph verify && + echo "garbage" >$graphdir/commit-graph-chain && + test_must_fail git commit-graph verify 2>test_err && + grep -v "^+" test_err >err && + grep "commit-graph chain file too small" err + ) +' + test_expect_success 'verify across alternates' ' git clone --no-hardlinks . verify-alt && ( @@@ -394,23 -338,10 +394,23 @@@ test_commit extra && git commit-graph write --reachable --split && tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph && - corrupt_file "$tip_file" 100 "\01" && + corrupt_file "$tip_file" 1500 "\01" && test_must_fail git commit-graph verify --shallow 2>test_err && grep -v "^+" test_err >err && - test_i18ngrep "incorrect checksum" err - test_grep "commit-graph has incorrect fanout value" err ++ test_grep "incorrect checksum" err + ) +' + +test_expect_success 'reader bounds-checks base-graph chunk' ' + git clone --no-hardlinks . corrupt-base-chunk && + ( + cd corrupt-base-chunk && + tip_file=$graphdir/graph-$(tail -n 1 $graphdir/commit-graph-chain).graph && + corrupt_chunk_file "$tip_file" BASE clear 01020304 && + git -c core.commitGraph=false log >expect.out && + git -c core.commitGraph=true log >out 2>err && + test_cmp expect.out out && + grep "commit-graph base graphs chunk is too small" err ) '