{"thread":{"id":"55925","subject":"[PATCH 5/8] test-lib tests: get rid of copy/pasted mock test code","startedAt":"2021-06-14T10:51:28Z","lastAt":"2021-09-22T11:20:16Z","messageCount":44,"participants":["Ævar Arnfjörð Bjarmason","Junio C Hamano","Felipe Contreras","Carlo Arenas"],"isPatch":true,"patchVersion":1,"patchTotal":8},"messages":[{"id":"427317","messageId":"patch-5.8-1909616d9ca-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 5/8] test-lib tests: get rid of copy/pasted mock test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:11Z","receivedAt":"2021-06-14T10:51:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that we've split up the write_sub_test_lib_test*() and\nrun_sub_test_lib_test*() functions let's fix those tests in\nt0000-basic.sh that were verbosely copy/pasting earlier tests.\n\nI'm (ab)using writing a tag object under a ref-name that's\ncontent-addressable from the content of the test script. If we can\nupdate-ref that it's unique, if not we've got a duplicate. The tag\nobject stores the name of the earlier test for reporting the error.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh |  34 ++++++-\n t/t0000-basic.sh | 224 ++++++++++++-----------------------------------\n 2 files changed, 88 insertions(+), 170 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 4a50e380506..4834db6c4ca 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,3 +1,34 @@\n+_assert_unique_sub_test () {\n+\tname=$1 &&\n+\n+\t# Alert about the copy/paste programming\n+\thash=$(git hash-object -w \"$name\") &&\n+\tcat >tag.sig <<-EOF &&\n+\tobject $hash\n+\ttype blob\n+\ttag $hash\n+\ttagger . <> 0 +0000\n+\n+\tduplicate script detected!\n+\n+\tThis test script was already written as:\n+\n+\t$name\n+\n+\tYou can just re-use its test code with your own\n+\trun_sub_test_lib_test*()\n+\tEOF\n+\n+\ttag=$(git mktag <tag.sig) &&\n+\tif ! git update-ref refs/tags/blob-$hash $tag $(test_oid zero) 2>/dev/null\n+\tthen\n+\t\tmsg=$(git for-each-ref refs/tags/blob-$hash \\\n+\t\t\t--format='%(contents)' refs/tags/blob-$hash)\n+\t\terror \"on write of $name: $msg\"\n+\t\treturn 1\n+\tfi\n+}\n+\n write_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n@@ -7,7 +38,8 @@ write_sub_test_lib_test () {\n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \tEOF\n-\tcat >>\"$name/$name.sh\"\n+\tcat >>\"$name/$name.sh\" &&\n+\t_assert_unique_sub_test \"$name/$name.sh\"\n }\n \n _run_sub_test_lib_test_common () {\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex b93a8ced7f6..886329d1f8e 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -226,18 +226,13 @@ test_expect_success 'subtest: --verbose option' '\n '\n \n test_expect_success 'subtest: --verbose-only option' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \\\n-\t\t--verbose-only=2 <<-\\EOF &&\n-\ttest_expect_success \"passing test\" true\n-\ttest_expect_success \"test with output\" \"echo foo\"\n-\ttest_expect_success \"failing test\" false\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test t2345-verbose-only-2 <<-\\EOF\n+\trun_sub_test_lib_test_err \\\n+\t\tt1234-verbose \\\n+\t\t--verbose-only=2 &&\n+\tcheck_sub_test_lib_test t1234-verbose <<-\\EOF\n \t> ok 1 - passing test\n \t> Z\n-\t> expecting success of 2345.2 '\\''test with output'\\'': echo foo\n+\t> expecting success of 1234.2 '\\''test with output'\\'': echo foo\n \t> foo\n \t> ok 2 - test with output\n \t> Z\n@@ -250,16 +245,9 @@ test_expect_success 'subtest: --verbose-only option' '\n \n test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n-\t\tGIT_SKIP_TESTS=\"git.2\" && export GIT_SKIP_TESTS &&\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t<<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-basic <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"full.2\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test full-pass &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 - passing test #3\n@@ -296,15 +284,8 @@ test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.[2-5]\" && export GIT_SKIP_TESTS &&\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t<<-\\EOF &&\n-\t\tfor i in 1 2 3 4 5 6\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF\n+\t\trun_sub_test_lib_test git-skip-tests-several &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 # skip passing test #3 (GIT_SKIP_TESTS)\n@@ -320,15 +301,8 @@ test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t<<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF\n+\t\trun_sub_test_lib_test git-skip-tests-several &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> 1..0 # SKIP skip all tests in git\n \t\tEOF\n \t)\n@@ -337,15 +311,8 @@ test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n \t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t<<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF\n+\t\trun_sub_test_lib_test full-pass &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 - passing test #2\n \t\t> ok 3 - passing test #3\n@@ -356,14 +323,8 @@ test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success 'subtest: --run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several --run=\"1,3,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -376,15 +337,9 @@ test_expect_success 'subtest: --run basic' '\n '\n \n test_expect_success 'subtest: --run with a range' '\n-\twrite_and_run_sub_test_lib_test run-range \\\n-\t\t--run=\"1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -397,15 +352,9 @@ test_expect_success 'subtest: --run with a range' '\n '\n \n test_expect_success 'subtest: --run with two ranges' '\n-\twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-ranges <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-2,5-6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -418,15 +367,9 @@ test_expect_success 'subtest: --run with two ranges' '\n '\n \n test_expect_success 'subtest: --run with a left open range' '\n-\twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t--run=\"-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-left-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -439,15 +382,9 @@ test_expect_success 'subtest: --run with a left open range' '\n '\n \n test_expect_success 'subtest: --run with a right open range' '\n-\twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t--run=\"4-\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-right-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"4-\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -460,15 +397,9 @@ test_expect_success 'subtest: --run with a right open range' '\n '\n \n test_expect_success 'subtest: --run with basic negation' '\n-\twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t--run=\"!3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -481,15 +412,9 @@ test_expect_success 'subtest: --run with basic negation' '\n '\n \n test_expect_success 'subtest: --run with two negations' '\n-\twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t--run=\"!3,!6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3,!6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -502,15 +427,9 @@ test_expect_success 'subtest: --run with two negations' '\n '\n \n test_expect_success 'subtest: --run a range and negation' '\n-\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t--run=\"-4,!2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-and-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-4,!2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -523,15 +442,9 @@ test_expect_success 'subtest: --run a range and negation' '\n '\n \n test_expect_success 'subtest: --run range negation' '\n-\twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t--run=\"!1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -544,15 +457,9 @@ test_expect_success 'subtest: --run range negation' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-5,!1-3,2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -565,15 +472,9 @@ test_expect_success 'subtest: --run include, exclude and include' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t--run=1-5,!1-3,2 <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=1-5,!1-3,2 &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -586,15 +487,9 @@ test_expect_success 'subtest: --run include, exclude and include, comma separate\n '\n \n test_expect_success 'subtest: --run exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t--run=\"!3-,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3-,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -607,15 +502,9 @@ test_expect_success 'subtest: --run exclude and include' '\n '\n \n test_expect_success 'subtest: --run empty selectors' '\n-\twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-empty-sel <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1,,3,,,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -665,12 +554,9 @@ test_expect_success 'subtest: --run keyword selection' '\n '\n \n test_expect_success 'subtest: --run invalid range end' '\n-\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t--run=\"1-z\" <<-\\EOF &&\n-\ttest_expect_success \"passing test #1\" \"true\"\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test_err run-inv-range-end \\\n+\trun_sub_test_lib_test_err run-inv-range-start \\\n+\t\t--run=\"1-z\" &&\n+\tcheck_sub_test_lib_test_err run-inv-range-start \\\n \t\t<<-\\EOF_OUT 3<<-EOF_ERR\n \t> FATAL: Unexpected exit with code 1\n \tEOF_OUT\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427318","messageId":"patch-8.8-ddbc8db2802-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 8/8] test-lib tests: assert 1 exit code, not non-zero","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:14Z","receivedAt":"2021-06-14T10:51:37Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Improve the testing for test-lib.sh itself to assert that we have a\nexit code of 1, not any non-zero. Improves code added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 02864c9d0e0..bb7153ac9e5 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -43,8 +43,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n-\tshift 2\n+\tcmp_op=\"$1\" want_code=\"$2\" name=\"$3\" # stdin is the body of the test code\n+\tshift 3\n \t(\n \t\tcd \"$name\" &&\n \n@@ -58,33 +58,30 @@ _run_sub_test_lib_test_common () {\n \t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n \t\texport TEST_OUTPUT_DIRECTORY &&\n \t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n+\t\t./\"$name.sh\" \"$@\" >out 2>err;\n+\t\tret=$? &&\n+\t\ttest \"$ret\" \"$cmp_op\" \"$want_code\"\n \t)\n }\n \n write_and_run_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n write_and_run_sub_test_lib_test_err () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n _check_sub_test_lib_test_common () {\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427319","messageId":"patch-4.8-0578470d899-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 4/8] test-lib tests: don't provide a description for the sub-tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:10Z","receivedAt":"2021-06-14T10:51:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the $test_description provided for the generated subtests to be\nconstant, since the only purpose of having it is that test-lib.sh will\nbarf if it isn't supplied.\n\nThe other purpose of having it was to effectively split up the test\ndescription between the argument to test_expect_success and the\nargument to \"write_and_run_sub_test_lib_test\". Let's only use one of\nthe two.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh |  12 ++--\n t/t0000-basic.sh | 147 +++++++++++++++++++++--------------------------\n 2 files changed, 71 insertions(+), 88 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 465f8f373e9..4a50e380506 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,12 +1,8 @@\n write_sub_test_lib_test () {\n-\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n \twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\ttest_description='$descr (run in sub test-lib)\n-\n-\tThis is run in a sub test-lib so that we do not get incorrect\n-\tpassing metrics\n-\t'\n+\ttest_description='A test of test-lib.sh itself'\n \n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n@@ -15,8 +11,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n+\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n+\tshift 2\n \t(\n \t\tcd \"$name\" &&\n \ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 7f6714a5fc5..b93a8ced7f6 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -67,8 +67,8 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-test_expect_success 'pretend we have a fully passing test suite' '\n-\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+test_expect_success 'subtest: 3 passing tests' '\n+\twrite_and_run_sub_test_lib_test full-pass <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -84,9 +84,8 @@ test_expect_success 'pretend we have a fully passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a partially passing test suite' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2/3 tests passing' '\n+\twrite_and_run_sub_test_lib_test_err partial-pass <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n \ttest_expect_success \"passing test #3\" \"true\"\n@@ -102,8 +101,8 @@ test_expect_success 'pretend we have a partially passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a known breakage' '\n-\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a failing TODO test' '\n+\twrite_and_run_sub_test_lib_test failing-todo <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -117,8 +116,8 @@ test_expect_success 'pretend we have a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed a known breakage' '\n-\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a passing TODO test' '\n+\twrite_and_run_sub_test_lib_test passing-todo <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -129,9 +128,8 @@ test_expect_success 'pretend we have fixed a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n-\t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2 TODO tests, one passin' '\n+\twrite_and_run_sub_test_lib_test partially-passing-todos <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n \ttest_expect_failure \"pretend we have fixed another known breakage\" \"true\"\n@@ -148,9 +146,8 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n \tEOF\n '\n \n-test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: pass, failure and a TODO test' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results1 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n@@ -167,9 +164,8 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a mix of all possible results' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: a mixture of all possible results' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -203,9 +199,8 @@ test_expect_success 'pretend we have a mix of all possible results' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n+test_expect_success 'subtest: --verbose option' '\n+\twrite_and_run_sub_test_lib_test_err t1234-verbose --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n \ttest_expect_success \"failing test\" false\n@@ -230,9 +225,9 @@ test_expect_success 'test --verbose' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose-only' '\n+test_expect_success 'subtest: --verbose-only option' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n+\t\tt2345-verbose-only-2 \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -253,11 +248,11 @@ test_expect_success 'test --verbose-only' '\n \tEOF\n '\n \n-test_expect_success 'GIT_SKIP_TESTS' '\n+test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.2\" && export GIT_SKIP_TESTS &&\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t\"GIT_SKIP_TESTS\" <<-\\EOF &&\n+\t\t\t<<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -274,11 +269,11 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS several tests' '\n+test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.2 git.5\" && export GIT_SKIP_TESTS &&\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n-\t\t\t\"GIT_SKIP_TESTS several tests\" <<-\\EOF &&\n+\t\t\t<<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -298,11 +293,11 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n+test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.[2-5]\" && export GIT_SKIP_TESTS &&\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t\"GIT_SKIP_TESTS sh pattern\" <<-\\EOF &&\n+\t\t\t<<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -322,11 +317,11 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS entire suite' '\n+test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t\"GIT_SKIP_TESTS entire suite\" <<-\\EOF &&\n+\t\t\t<<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -339,11 +334,11 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n+test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n \t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" <<-\\EOF &&\n+\t\t\t<<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -360,9 +355,8 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t)\n '\n \n-test_expect_success '--run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic \\\n-\t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n+test_expect_success 'subtest: --run basic' '\n+\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -381,9 +375,9 @@ test_expect_success '--run basic' '\n \tEOF\n '\n \n-test_expect_success '--run with a range' '\n+test_expect_success 'subtest: --run with a range' '\n \twrite_and_run_sub_test_lib_test run-range \\\n-\t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n+\t\t--run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -402,9 +396,9 @@ test_expect_success '--run with a range' '\n \tEOF\n '\n \n-test_expect_success '--run with two ranges' '\n+test_expect_success 'subtest: --run with two ranges' '\n \twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n+\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -423,9 +417,9 @@ test_expect_success '--run with two ranges' '\n \tEOF\n '\n \n-test_expect_success '--run with a left open range' '\n+test_expect_success 'subtest: --run with a left open range' '\n \twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n+\t\t--run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -444,9 +438,9 @@ test_expect_success '--run with a left open range' '\n \tEOF\n '\n \n-test_expect_success '--run with a right open range' '\n+test_expect_success 'subtest: --run with a right open range' '\n \twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n+\t\t--run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -465,9 +459,9 @@ test_expect_success '--run with a right open range' '\n \tEOF\n '\n \n-test_expect_success '--run with basic negation' '\n+test_expect_success 'subtest: --run with basic negation' '\n \twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n+\t\t--run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -486,9 +480,9 @@ test_expect_success '--run with basic negation' '\n \tEOF\n '\n \n-test_expect_success '--run with two negations' '\n+test_expect_success 'subtest: --run with two negations' '\n \twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n+\t\t--run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -507,9 +501,9 @@ test_expect_success '--run with two negations' '\n \tEOF\n '\n \n-test_expect_success '--run a range and negation' '\n+test_expect_success 'subtest: --run a range and negation' '\n \twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n+\t\t--run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -528,9 +522,9 @@ test_expect_success '--run a range and negation' '\n \tEOF\n '\n \n-test_expect_success '--run range negation' '\n+test_expect_success 'subtest: --run range negation' '\n \twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n+\t\t--run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -549,9 +543,8 @@ test_expect_success '--run range negation' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include' '\n+test_expect_success 'subtest: --run include, exclude and include' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -571,9 +564,8 @@ test_expect_success '--run include, exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include, comma separated' '\n+test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -593,9 +585,8 @@ test_expect_success '--run include, exclude and include, comma separated' '\n \tEOF\n '\n \n-test_expect_success '--run exclude and include' '\n+test_expect_success 'subtest: --run exclude and include' '\n \twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -615,9 +606,8 @@ test_expect_success '--run exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run empty selectors' '\n+test_expect_success 'subtest: --run empty selectors' '\n \twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -637,9 +627,8 @@ test_expect_success '--run empty selectors' '\n \tEOF\n '\n \n-test_expect_success '--run substring selector' '\n+test_expect_success 'subtest: --run substring selector' '\n \twrite_and_run_sub_test_lib_test run-substring-selector \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n \tfor i in 1 2 3 4 5 6\n@@ -661,9 +650,8 @@ test_expect_success '--run substring selector' '\n \tEOF\n '\n \n-test_expect_success '--run keyword selection' '\n+test_expect_success 'subtest: --run keyword selection' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n-\t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -676,9 +664,8 @@ test_expect_success '--run keyword selection' '\n \tEOF_ERR\n '\n \n-test_expect_success '--run invalid range end' '\n+test_expect_success 'subtest: --run invalid range end' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -691,8 +678,8 @@ test_expect_success '--run invalid range end' '\n \tEOF_ERR\n '\n \n-test_expect_success 'tests respect prerequisites' '\n-\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect prerequisites' '\n+\twrite_and_run_sub_test_lib_test prereqs <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -721,8 +708,8 @@ test_expect_success 'tests respect prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'tests respect lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test lazy-prereqs <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -745,8 +732,8 @@ test_expect_success 'tests respect lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'nested lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: nested lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test nested-lazy <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -771,9 +758,9 @@ test_expect_success 'nested lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'lazy prereqs do not turn off tracing' '\n+test_expect_success 'subtest: lazy prereqs do not turn off tracing' '\n \twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n-\t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n+\t\t-v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n \ttest_expect_success lazy \"test_have_prereq LAZY && echo trace\"\n@@ -784,8 +771,8 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n \tgrep \"echo trace\" lazy-prereq-and-tracing/err\n '\n \n-test_expect_success 'tests clean up after themselves' '\n-\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+test_expect_success 'subtest: tests clean up after themselves' '\n+\twrite_and_run_sub_test_lib_test cleanup <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -804,9 +791,9 @@ test_expect_success 'tests clean up after themselves' '\n \tEOF\n '\n \n-test_expect_success 'tests clean up even on failures' '\n+test_expect_success 'subtest: tests clean up even on failures' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n+\t\tfailing-cleanup <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n \t\ttest_when_finished rm clean-after-failure &&\n@@ -833,9 +820,9 @@ test_expect_success 'tests clean up even on failures' '\n \tEOF\n '\n \n-test_expect_success 'test_atexit is run' '\n+test_expect_success 'subtest: test_atexit is run' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n+\t\tatexit-cleanup -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n \t\ttest_atexit rm ../../clean-atexit &&\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427320","messageId":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":null,"subject":"[PATCH 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:06Z","receivedAt":"2021-06-14T10:53:28Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This refactors the testing of test-lib.sh itself in t0000 into a\nlib-subtest.sh, fixing duplicate setup, bugs and various shell nits\nalong the way.\n\nThis was waiting on my now-merged 2019256717d (Merge branch\n'ab/test-lib-updates', 2021-06-14).\n\nThere's a conflict here with Felipe's proposed\nhttp://lore.kernel.org/git/20210609170520.67014-1-felipe.contreras@gmail.com,\nbut it's just a matter of moving the fix around and solving a trivial\nconflict. I thought it was better to submit this now anyway, while\nthis code is fresh in people's minds.\n\nI'm hoping Felipe will take some variant of my\nhttp://lore.kernel.org/git/8735tk22if.fsf@evledraar.gmail.com and\nperhaps review this series & base his patch on top of these changes,\nbut alternatively they can go in independently with Junio solving the\nconflict.\n\nÆvar Arnfjörð Bjarmason (8):\n  test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n  test-lib tests: split up \"write and run\" into two functions\n  test-lib tests: stop using a subshell in write_sub_test_lib_test()\n  test-lib tests: don't provide a description for the sub-tests\n  test-lib tests: get rid of copy/pasted mock test code\n  test-lib tests: avoid subshell for \"test_cmp\" for readability\n  test-lib tests: refactor common part of check_sub_test_lib_test*()\n  test-lib tests: assert 1 exit code, not non-zero\n\n t/lib-subtest.sh | 105 ++++++++++++\n t/t0000-basic.sh | 419 +++++++++++++----------------------------------\n 2 files changed, 219 insertions(+), 305 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427321","messageId":"patch-1.8-3c0a78530d2-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 1/8] test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:07Z","receivedAt":"2021-06-14T10:54:09Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the \"check_sub_test_lib_test()\" and its sister functions to a new\nlib-subtest.sh.\n\nIn the future (not in this series) I'd like to test test-lib's output\nin a more targeted and smaller test, and I'll need these functions to\ndo that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++\n t/t0000-basic.sh | 66 +-----------------------------------------------\n 2 files changed, 65 insertions(+), 65 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nnew file mode 100644\nindex 00000000000..0c613e00da3\n--- /dev/null\n+++ b/t/lib-subtest.sh\n@@ -0,0 +1,64 @@\n+_run_sub_test_lib_test_common () {\n+\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n+\tshift 3\n+\tmkdir \"$name\" &&\n+\t(\n+\t\t# Pretend we're not running under a test harness, whether we\n+\t\t# are or not. The test-lib output depends on the setting of\n+\t\t# this variable, so we need a stable setting under which to run\n+\t\t# the sub-test.\n+\t\tsane_unset HARNESS_ACTIVE &&\n+\t\tcd \"$name\" &&\n+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\t\ttest_description='$descr (run in sub test-lib)\n+\n+\t\tThis is run in a sub test-lib so that we do not get incorrect\n+\t\tpassing metrics\n+\t\t'\n+\n+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\t\tEOF\n+\t\tcat >>\"$name.sh\" &&\n+\t\texport TEST_DIRECTORY &&\n+\t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n+\t\texport TEST_OUTPUT_DIRECTORY &&\n+\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n+\t\tif test -z \"$neg\"\n+\t\tthen\n+\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n+\t\telse\n+\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n+\t\tfi\n+\t)\n+}\n+\n+run_sub_test_lib_test () {\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+run_sub_test_lib_test_err () {\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n+check_sub_test_lib_test () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t(\n+\t\tcd \"$name\" &&\n+\t\ttest_must_be_empty err &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n+\t\ttest_cmp expect out\n+\t)\n+}\n+\n+check_sub_test_lib_test_err () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t# expected error output is in descriptor 3\n+\t(\n+\t\tcd \"$name\" &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n+\t\ttest_cmp expect.out out &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n+\t\ttest_cmp expect.err err\n+\t)\n+}\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 2c6e34b9478..72809477645 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -19,6 +19,7 @@ modification *should* take notice and update the test vectors here.\n '\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-subtest.sh\n \n try_local_xy () {\n \tlocal x=\"local\" y=\"alsolocal\" &&\n@@ -66,71 +67,6 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-_run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n-\tmkdir \"$name\" &&\n-\t(\n-\t\t# Pretend we're not running under a test harness, whether we\n-\t\t# are or not. The test-lib output depends on the setting of\n-\t\t# this variable, so we need a stable setting under which to run\n-\t\t# the sub-test.\n-\t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n-\n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n-\n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n-\t\texport TEST_DIRECTORY &&\n-\t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n-\t\texport TEST_OUTPUT_DIRECTORY &&\n-\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n-\t)\n-}\n-\n-run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n-}\n-\n-run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n-}\n-\n-check_sub_test_lib_test () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n-}\n-\n-check_sub_test_lib_test_err () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n-}\n-\n test_expect_success 'pretend we have a fully passing test suite' '\n \trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427322","messageId":"patch-3.8-cd6c740c912-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 3/8] test-lib tests: stop using a subshell in write_sub_test_lib_test()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:09Z","receivedAt":"2021-06-14T10:55:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that this function doesn't handle running the test anymore we can\ndo away with the sub-shell, which was used to scope an \"unset\" and\n\"export\" shell variables.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 0ece41c0e5f..465f8f373e9 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,20 +1,17 @@\n write_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n-\t(\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n+\twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\ttest_description='$descr (run in sub test-lib)\n \n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n+\tThis is run in a sub test-lib so that we do not get incorrect\n+\tpassing metrics\n+\t'\n \n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\"\n-\t)\n+\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\tEOF\n+\tcat >>\"$name/$name.sh\"\n }\n \n _run_sub_test_lib_test_common () {\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427323","messageId":"patch-6.8-2f717e437e6-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 6/8] test-lib tests: avoid subshell for \"test_cmp\" for readability","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:12Z","receivedAt":"2021-06-14T10:55:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The use of a sub-shell for running the test_cmp of stdout/stderr for\nthe test author was introduced in this form in 565b6fa87bb (tests:\nrefactor mechanics of testing in a sub test-lib, 2012-12-16), but from\nlooking at the history that seemed to have diligently copied my\noriginal ad-hoc implementation in 7b905119703 (t/t0000-basic.sh: Run\nthe passing TODO test inside its own test-lib, 2010-08-19).\n\nThere's no reason to use a subshell here, we try to avoid it in\ngeneral. It also improves readability, if the test fails we print out\nthe relative path in the trash directory that needs to be looked\nat.\n\nBefore that was mostly obscured, since the \"write_sub_test_lib_test\"\nwill pick the directory for you from the test name.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 20 +++++++-------------\n 1 file changed, 7 insertions(+), 13 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 4834db6c4ca..8f4935faf43 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -89,22 +89,16 @@ run_sub_test_lib_test_err () {\n \n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n+\ttest_must_be_empty \"$name\"/err &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n+\ttest_cmp \"$name/\"expect \"$name\"/out\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n \t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n+\tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n+\ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427324","messageId":"patch-7.8-1f32eb60411-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 7/8] test-lib tests: refactor common part of check_sub_test_lib_test*()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:13Z","receivedAt":"2021-06-14T10:55:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the two check_sub_test_lib_test*() functions to avoid\nduplicating the same comparison they did of stdout. This duplication\nwas initially added when check_sub_test_lib_test_err() was added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 8f4935faf43..02864c9d0e0 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -87,18 +87,22 @@ run_sub_test_lib_test_err () {\n \t_run_sub_test_lib_test_common '!' \"$@\"\n }\n \n+_check_sub_test_lib_test_common () {\n+\tname=\"$1\" &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out\n+}\n+\n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\ttest_must_be_empty \"$name\"/err &&\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n-\ttest_cmp \"$name/\"expect \"$name\"/out\n+\t_check_sub_test_lib_test_common \"$name\" &&\n+\ttest_must_be_empty \"$name\"/err\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n+\t_check_sub_test_lib_test_common \"$name\" &&\n \t# expected error output is in descriptor 3\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n-\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n \tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n \ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427325","messageId":"patch-2.8-9e2715d2e20-20210614T104351Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH 2/8] test-lib tests: split up \"write and run\" into two functions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-14T10:48:08Z","receivedAt":"2021-06-14T10:55:50Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the function to write and run tests of the test-lib.sh output\ninto two functions.\n\nWhen this was added back in 565b6fa87bb (tests: refactor mechanics of\ntesting in a sub test-lib, 2012-12-16) there was no reason to do this,\nbut since we started supporting test arguments in\n517cd55fd51 (test-lib: self-test that --verbose works, 2013-06-23)\nwe've started to write out duplicate tests simply to test different\narguments, now we'll be able to re-use them.\n\nThis change doesn't consolidate any of those tests yet, it just makes\nit possible to do so. All the changes in t0000-basic.sh are a simple\nsearch-replacement.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 39 +++++++++++++++++++------\n t/t0000-basic.sh | 74 ++++++++++++++++++++++++------------------------\n 2 files changed, 67 insertions(+), 46 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 0c613e00da3..0ece41c0e5f 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,13 +1,7 @@\n-_run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n+write_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n \t(\n-\t\t# Pretend we're not running under a test harness, whether we\n-\t\t# are or not. The test-lib output depends on the setting of\n-\t\t# this variable, so we need a stable setting under which to run\n-\t\t# the sub-test.\n-\t\tsane_unset HARNESS_ACTIVE &&\n \t\tcd \"$name\" &&\n \t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n \t\ttest_description='$descr (run in sub test-lib)\n@@ -19,7 +13,22 @@ _run_sub_test_lib_test_common () {\n \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n+\t\tcat >>\"$name.sh\"\n+\t)\n+}\n+\n+_run_sub_test_lib_test_common () {\n+\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n+\tshift 3\n+\t(\n+\t\tcd \"$name\" &&\n+\n+\t\t# Pretend we're not running under a test harness, whether we\n+\t\t# are or not. The test-lib output depends on the setting of\n+\t\t# this variable, so we need a stable setting under which to run\n+\t\t# the sub-test.\n+\t\tsane_unset HARNESS_ACTIVE &&\n+\n \t\texport TEST_DIRECTORY &&\n \t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n \t\texport TEST_OUTPUT_DIRECTORY &&\n@@ -33,6 +42,18 @@ _run_sub_test_lib_test_common () {\n \t)\n }\n \n+write_and_run_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+write_and_run_sub_test_lib_test_err () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n run_sub_test_lib_test () {\n \t_run_sub_test_lib_test_common '' \"$@\"\n }\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 72809477645..7f6714a5fc5 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -68,7 +68,7 @@ test_expect_success 'success is reported like this' '\n '\n \n test_expect_success 'pretend we have a fully passing test suite' '\n-\trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -85,7 +85,7 @@ test_expect_success 'pretend we have a fully passing test suite' '\n '\n \n test_expect_success 'pretend we have a partially passing test suite' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n@@ -103,7 +103,7 @@ test_expect_success 'pretend we have a partially passing test suite' '\n '\n \n test_expect_success 'pretend we have a known breakage' '\n-\trun_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -118,7 +118,7 @@ test_expect_success 'pretend we have a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed a known breakage' '\n-\trun_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -130,7 +130,7 @@ test_expect_success 'pretend we have fixed a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\trun_sub_test_lib_test partially-passing-todos \\\n+\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n \t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n@@ -149,7 +149,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n '\n \n test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n@@ -168,7 +168,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n '\n \n test_expect_success 'pretend we have a mix of all possible results' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -204,7 +204,7 @@ test_expect_success 'pretend we have a mix of all possible results' '\n '\n \n test_expect_success 'test --verbose' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -231,7 +231,7 @@ test_expect_success 'test --verbose' '\n '\n \n test_expect_success 'test --verbose-only' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n@@ -256,7 +256,7 @@ test_expect_success 'test --verbose-only' '\n test_expect_success 'GIT_SKIP_TESTS' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.2\" && export GIT_SKIP_TESTS &&\n-\t\trun_sub_test_lib_test git-skip-tests-basic \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n \t\t\t\"GIT_SKIP_TESTS\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -277,7 +277,7 @@ test_expect_success 'GIT_SKIP_TESTS' '\n test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.2 git.5\" && export GIT_SKIP_TESTS &&\n-\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n \t\t\t\"GIT_SKIP_TESTS several tests\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -301,7 +301,7 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git.[2-5]\" && export GIT_SKIP_TESTS &&\n-\t\trun_sub_test_lib_test git-skip-tests-sh-pattern \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n \t\t\t\"GIT_SKIP_TESTS sh pattern\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -325,7 +325,7 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t(\n \t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n-\t\trun_sub_test_lib_test git-skip-tests-entire-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n \t\t\t\"GIT_SKIP_TESTS entire suite\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -342,7 +342,7 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n \t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n-\t\trun_sub_test_lib_test git-skip-tests-unmatched-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n \t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -361,7 +361,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success '--run basic' '\n-\trun_sub_test_lib_test run-basic \\\n+\twrite_and_run_sub_test_lib_test run-basic \\\n \t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -382,7 +382,7 @@ test_expect_success '--run basic' '\n '\n \n test_expect_success '--run with a range' '\n-\trun_sub_test_lib_test run-range \\\n+\twrite_and_run_sub_test_lib_test run-range \\\n \t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -403,7 +403,7 @@ test_expect_success '--run with a range' '\n '\n \n test_expect_success '--run with two ranges' '\n-\trun_sub_test_lib_test run-two-ranges \\\n+\twrite_and_run_sub_test_lib_test run-two-ranges \\\n \t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -424,7 +424,7 @@ test_expect_success '--run with two ranges' '\n '\n \n test_expect_success '--run with a left open range' '\n-\trun_sub_test_lib_test run-left-open-range \\\n+\twrite_and_run_sub_test_lib_test run-left-open-range \\\n \t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -445,7 +445,7 @@ test_expect_success '--run with a left open range' '\n '\n \n test_expect_success '--run with a right open range' '\n-\trun_sub_test_lib_test run-right-open-range \\\n+\twrite_and_run_sub_test_lib_test run-right-open-range \\\n \t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -466,7 +466,7 @@ test_expect_success '--run with a right open range' '\n '\n \n test_expect_success '--run with basic negation' '\n-\trun_sub_test_lib_test run-basic-neg \\\n+\twrite_and_run_sub_test_lib_test run-basic-neg \\\n \t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -487,7 +487,7 @@ test_expect_success '--run with basic negation' '\n '\n \n test_expect_success '--run with two negations' '\n-\trun_sub_test_lib_test run-two-neg \\\n+\twrite_and_run_sub_test_lib_test run-two-neg \\\n \t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -508,7 +508,7 @@ test_expect_success '--run with two negations' '\n '\n \n test_expect_success '--run a range and negation' '\n-\trun_sub_test_lib_test run-range-and-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n \t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -529,7 +529,7 @@ test_expect_success '--run a range and negation' '\n '\n \n test_expect_success '--run range negation' '\n-\trun_sub_test_lib_test run-range-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-neg \\\n \t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -550,7 +550,7 @@ test_expect_success '--run range negation' '\n '\n \n test_expect_success '--run include, exclude and include' '\n-\trun_sub_test_lib_test run-inc-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n \t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -572,7 +572,7 @@ test_expect_success '--run include, exclude and include' '\n '\n \n test_expect_success '--run include, exclude and include, comma separated' '\n-\trun_sub_test_lib_test run-inc-neg-inc-comma \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n \t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -594,7 +594,7 @@ test_expect_success '--run include, exclude and include, comma separated' '\n '\n \n test_expect_success '--run exclude and include' '\n-\trun_sub_test_lib_test run-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-neg-inc \\\n \t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -616,7 +616,7 @@ test_expect_success '--run exclude and include' '\n '\n \n test_expect_success '--run empty selectors' '\n-\trun_sub_test_lib_test run-empty-sel \\\n+\twrite_and_run_sub_test_lib_test run-empty-sel \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -638,7 +638,7 @@ test_expect_success '--run empty selectors' '\n '\n \n test_expect_success '--run substring selector' '\n-\trun_sub_test_lib_test run-substring-selector \\\n+\twrite_and_run_sub_test_lib_test run-substring-selector \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n@@ -662,7 +662,7 @@ test_expect_success '--run substring selector' '\n '\n \n test_expect_success '--run keyword selection' '\n-\trun_sub_test_lib_test_err run-inv-range-start \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n \t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -677,7 +677,7 @@ test_expect_success '--run keyword selection' '\n '\n \n test_expect_success '--run invalid range end' '\n-\trun_sub_test_lib_test_err run-inv-range-end \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n \t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -692,7 +692,7 @@ test_expect_success '--run invalid range end' '\n '\n \n test_expect_success 'tests respect prerequisites' '\n-\trun_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -722,7 +722,7 @@ test_expect_success 'tests respect prerequisites' '\n '\n \n test_expect_success 'tests respect lazy prerequisites' '\n-\trun_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -746,7 +746,7 @@ test_expect_success 'tests respect lazy prerequisites' '\n '\n \n test_expect_success 'nested lazy prerequisites' '\n-\trun_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -772,7 +772,7 @@ test_expect_success 'nested lazy prerequisites' '\n '\n \n test_expect_success 'lazy prereqs do not turn off tracing' '\n-\trun_sub_test_lib_test lazy-prereq-and-tracing \\\n+\twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n \t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n@@ -785,7 +785,7 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n '\n \n test_expect_success 'tests clean up after themselves' '\n-\trun_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -805,7 +805,7 @@ test_expect_success 'tests clean up after themselves' '\n '\n \n test_expect_success 'tests clean up even on failures' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n@@ -834,7 +834,7 @@ test_expect_success 'tests clean up even on failures' '\n '\n \n test_expect_success 'test_atexit is run' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n-- \n2.32.0.rc3.434.gd8aed1f08a7\n\n"},{"id":"427391","messageId":"xmqq35tjzwz2.fsf@gitster.g","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"Re: [PATCH 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-06-15T02:24:17Z","receivedAt":"2021-06-15T02:24:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> This refactors the testing of test-lib.sh itself in t0000 into a\n> lib-subtest.sh, fixing duplicate setup, bugs and various shell nits\n> along the way.\n> ...\n> I thought it was better to submit this now anyway, while\n> this code is fresh in people's minds.\n\nAny time you send it anew is the time it is fresh in people's minds\nif they read it, no?  I am not sure I understand the reasoning.\n\n> I'm hoping Felipe will take some variant of my\n> http://lore.kernel.org/git/8735tk22if.fsf@evledraar.gmail.com and\n> perhaps review this series & base his patch on top of these changes,\n> but alternatively they can go in independently with Junio solving the\n> conflict.\n\nI'd rather not if it can be avoided.  Please scale the process by\ncoordinating among contributors yourselves.\n"},{"id":"427515","messageId":"60c8ebfeb5779_1928f208f8@natae.notmuch","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"RE: [PATCH 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Felipe Contreras","fromEmail":"felipe.contreras@gmail.com","sentAt":"2021-06-15T18:05:50Z","receivedAt":"2021-06-15T18:05:54Z","isPatch":true,"sender":{"key":"felipe.contreras@gmail.com","avatar":"https://avatars.githubusercontent.com/u/8358?v=4"},"body":"Ævar Arnfjörð Bjarmason wrote:\n\n> There's a conflict here with Felipe's proposed\n> http://lore.kernel.org/git/20210609170520.67014-1-felipe.contreras@gmail.com,\n> but it's just a matter of moving the fix around and solving a trivial\n> conflict. I thought it was better to submit this now anyway, while\n> this code is fresh in people's minds.\n> \n> I'm hoping Felipe will take some variant of my\n> http://lore.kernel.org/git/8735tk22if.fsf@evledraar.gmail.com and\n> perhaps review this series & base his patch on top of these changes,\n> but alternatively they can go in independently with Junio solving the\n> conflict.\n\nI have no problem rebasing my patch on top of your series, but my\ncurrent v2 doesn't touch _run_sub_test_lib_test_common at all, and I'm\nnot sure your proposal of TEST_NO_RESULTS_OUTPUT is the way to go, so\nperhaps there's no need to rebase at all.\n\nUnless there's something on this series that would help\nTEST_OUTPUT_DIRECTORY, which at a quick glance doesn't seem to be the\ncase.\n\nCheers.\n\n-- \nFelipe Contreras"},{"id":"428368","messageId":"87czsb1r85.fsf@evledraar.gmail.com","threadId":"55925","inReplyTo":"xmqq35tjzwz2.fsf@gitster.g","subject":"Re: [PATCH 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-24T10:38:32Z","receivedAt":"2021-06-24T10:39:44Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Tue, Jun 15 2021, Junio C Hamano wrote:\n\n> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>\n>> This refactors the testing of test-lib.sh itself in t0000 into a\n>> lib-subtest.sh, fixing duplicate setup, bugs and various shell nits\n>> along the way.\n>> ...\n>> I thought it was better to submit this now anyway, while\n>> this code is fresh in people's minds.\n>\n> Any time you send it anew is the time it is fresh in people's minds\n> if they read it, no?  I am not sure I understand the reasoning.\n>\n>> I'm hoping Felipe will take some variant of my\n>> http://lore.kernel.org/git/8735tk22if.fsf@evledraar.gmail.com and\n>> perhaps review this series & base his patch on top of these changes,\n>> but alternatively they can go in independently with Junio solving the\n>> conflict.\n>\n> I'd rather not if it can be avoided.  Please scale the process by\n> coordinating among contributors yourselves.\n\nPer Felipe's reply and his\nhttps://lore.kernel.org/git/20210615183157.104999-1-felipe.contreras@gmail.com/\nI don't think there's any conflict anymore, so this series should apply\non master without any conflicts.\n\nIt would be great to have it picked up, it's another set of test\ncleanups I need for a subsequent series...\n"},{"id":"428808","messageId":"877dibg7d2.fsf@evledraar.gmail.com","threadId":"55925","inReplyTo":"87czsb1r85.fsf@evledraar.gmail.com","subject":"Re: [PATCH 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-06-30T07:04:35Z","receivedAt":"2021-06-30T07:05:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"\nOn Thu, Jun 24 2021, Ævar Arnfjörð Bjarmason wrote:\n\n> On Tue, Jun 15 2021, Junio C Hamano wrote:\n>\n>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>\n>>> This refactors the testing of test-lib.sh itself in t0000 into a\n>>> lib-subtest.sh, fixing duplicate setup, bugs and various shell nits\n>>> along the way.\n>>> ...\n>>> I thought it was better to submit this now anyway, while\n>>> this code is fresh in people's minds.\n>>\n>> Any time you send it anew is the time it is fresh in people's minds\n>> if they read it, no?  I am not sure I understand the reasoning.\n>>\n>>> I'm hoping Felipe will take some variant of my\n>>> http://lore.kernel.org/git/8735tk22if.fsf@evledraar.gmail.com and\n>>> perhaps review this series & base his patch on top of these changes,\n>>> but alternatively they can go in independently with Junio solving the\n>>> conflict.\n>>\n>> I'd rather not if it can be avoided.  Please scale the process by\n>> coordinating among contributors yourselves.\n>\n> Per Felipe's reply and his\n> https://lore.kernel.org/git/20210615183157.104999-1-felipe.contreras@gmail.com/\n> I don't think there's any conflict anymore, so this series should apply\n> on master without any conflicts.\n>\n> It would be great to have it picked up, it's another set of test\n> cleanups I need for a subsequent series...\n\nJunio, just a reminder about this series: It has no conflicts with\n\"seen\", and that WIP patch it would have conflicted with it was replaced\nby another approach.\n\nI've got some other non-testing changes queued on top of this, it would\nbe great to have it picked up. Thanks!\n"},{"id":"428901","messageId":"xmqqmtr6rtrx.fsf@gitster.g","threadId":"55925","inReplyTo":"877dibg7d2.fsf@evledraar.gmail.com","subject":"Re: [PATCH 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-07-01T14:30:26Z","receivedAt":"2021-07-01T14:30:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:\n\n> On Thu, Jun 24 2021, Ævar Arnfjörð Bjarmason wrote:\n>\n>> On Tue, Jun 15 2021, Junio C Hamano wrote:\n>>\n>>> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n>>>\n>>>> This refactors the testing of test-lib.sh itself in t0000 into a\n>>>> lib-subtest.sh, fixing duplicate setup, bugs and various shell nits\n>>>> along the way.\n> ...\n> Junio, just a reminder about this series: It has no conflicts with\n> \"seen\", and that WIP patch it would have conflicted with it was replaced\n> by another approach.\n\nhttps://lore.kernel.org/git/cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com/\nreveals that this hasn't seen much reviews, though.  I'll try to\nfind time to read it through; no promises if it will be done by the\nend of the week, though.\n\nThanks.\n\n"},{"id":"430811","messageId":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com","subject":"[PATCH v2 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:39Z","receivedAt":"2021-07-21T22:58:31Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This refactors the testing of test-lib.sh itself in t0000 into a\nlib-subtest.sh, fixing duplicate setup, bugs and various shell nits\nalong the way.\n\nThe v1[1] of this recently started conflicting with the cooking\njk/t0000-subtests-fix and ps/t0000-output-directory-fix, and got\nejected from \"seen\". This v2 is rebased on top of those two, so it\nmerges cleanly with \"seen\".\n\n1. https://lore.kernel.org/git/cover-0.8-00000000000-20210614T104351Z-avarab@gmail.com/\n\nÆvar Arnfjörð Bjarmason (8):\n  test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n  test-lib tests: split up \"write and run\" into two functions\n  test-lib tests: stop using a subshell in write_sub_test_lib_test()\n  test-lib tests: don't provide a description for the sub-tests\n  test-lib tests: get rid of copy/pasted mock test code\n  test-lib tests: avoid subshell for \"test_cmp\" for readability\n  test-lib tests: refactor common part of check_sub_test_lib_test*()\n  test-lib tests: assert 1 exit code, not non-zero\n\n t/lib-subtest.sh | 128 ++++++++++++++\n t/t0000-basic.sh | 448 +++++++++++++----------------------------------\n 2 files changed, 246 insertions(+), 330 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\nRange-diff against v1:\n1:  3c0a78530d2 ! 1:  7a06ea3a7b7 test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n    @@ t/lib-subtest.sh (new)\n     +_run_sub_test_lib_test_common () {\n     +\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n     +\tshift 3\n    ++\n    ++\t# intercept pseudo-options at the front of the argument list that we\n    ++\t# will not pass to child script\n    ++\tskip=\n    ++\twhile test $# -gt 0\n    ++\tdo\n    ++\t\tcase \"$1\" in\n    ++\t\t--skip=*)\n    ++\t\t\tskip=${1#--*=}\n    ++\t\t\tshift\n    ++\t\t\t;;\n    ++\t\t*)\n    ++\t\t\tbreak\n    ++\t\t\t;;\n    ++\t\tesac\n    ++\tdone\n    ++\n     +\tmkdir \"$name\" &&\n     +\t(\n     +\t\t# Pretend we're not running under a test harness, whether we\n    @@ t/lib-subtest.sh (new)\n     +\t\tEOF\n     +\t\tcat >>\"$name.sh\" &&\n     +\t\texport TEST_DIRECTORY &&\n    -+\t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n    -+\t\texport TEST_OUTPUT_DIRECTORY &&\n    ++\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n    ++\t\t# override the test output directory. We thus pass it as an\n    ++\t\t# explicit override to the child.\n    ++\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n    ++\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n    ++\t\tGIT_SKIP_TESTS=$skip &&\n    ++\t\texport GIT_SKIP_TESTS &&\n     +\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n     +\t\tif test -z \"$neg\"\n     +\t\tthen\n    @@ t/t0000-basic.sh: test_expect_success 'success is reported like this' '\n     -_run_sub_test_lib_test_common () {\n     -\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n     -\tshift 3\n    +-\n    +-\t# intercept pseudo-options at the front of the argument list that we\n    +-\t# will not pass to child script\n    +-\tskip=\n    +-\twhile test $# -gt 0\n    +-\tdo\n    +-\t\tcase \"$1\" in\n    +-\t\t--skip=*)\n    +-\t\t\tskip=${1#--*=}\n    +-\t\t\tshift\n    +-\t\t\t;;\n    +-\t\t*)\n    +-\t\t\tbreak\n    +-\t\t\t;;\n    +-\t\tesac\n    +-\tdone\n    +-\n     -\tmkdir \"$name\" &&\n     -\t(\n     -\t\t# Pretend we're not running under a test harness, whether we\n    @@ t/t0000-basic.sh: test_expect_success 'success is reported like this' '\n     -\t\tEOF\n     -\t\tcat >>\"$name.sh\" &&\n     -\t\texport TEST_DIRECTORY &&\n    --\t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n    --\t\texport TEST_OUTPUT_DIRECTORY &&\n    +-\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n    +-\t\t# override the test output directory. We thus pass it as an\n    +-\t\t# explicit override to the child.\n    +-\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n    +-\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n    +-\t\tGIT_SKIP_TESTS=$skip &&\n    +-\t\texport GIT_SKIP_TESTS &&\n     -\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n     -\t\tif test -z \"$neg\"\n     -\t\tthen\n2:  9e2715d2e20 ! 2:  28117b84abf test-lib tests: split up \"write and run\" into two functions\n    @@ Commit message\n     \n      ## t/lib-subtest.sh ##\n     @@\n    --_run_sub_test_lib_test_common () {\n    --\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n    --\tshift 3\n     +write_sub_test_lib_test () {\n     +\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n    - \tmkdir \"$name\" &&\n    - \t(\n    --\t\t# Pretend we're not running under a test harness, whether we\n    --\t\t# are or not. The test-lib output depends on the setting of\n    --\t\t# this variable, so we need a stable setting under which to run\n    --\t\t# the sub-test.\n    --\t\tsane_unset HARNESS_ACTIVE &&\n    - \t\tcd \"$name\" &&\n    - \t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n    - \t\ttest_description='$descr (run in sub test-lib)\n    -@@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n    - \t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n    - \t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n    - \t\tEOF\n    --\t\tcat >>\"$name.sh\" &&\n    ++\tmkdir \"$name\" &&\n    ++\t(\n    ++\t\tcd \"$name\" &&\n    ++\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n    ++\t\ttest_description='$descr (run in sub test-lib)\n    ++\n    ++\t\tThis is run in a sub test-lib so that we do not get incorrect\n    ++\t\tpassing metrics\n    ++\t\t'\n    ++\n    ++\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n    ++\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n    ++\t\tEOF\n     +\t\tcat >>\"$name.sh\"\n     +\t)\n     +}\n     +\n    -+_run_sub_test_lib_test_common () {\n    -+\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n    -+\tshift 3\n    -+\t(\n    + _run_sub_test_lib_test_common () {\n    + \tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n    + \tshift 3\n    +@@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n    + \t\tesac\n    + \tdone\n    + \n    +-\tmkdir \"$name\" &&\n    + \t(\n     +\t\tcd \"$name\" &&\n     +\n    -+\t\t# Pretend we're not running under a test harness, whether we\n    -+\t\t# are or not. The test-lib output depends on the setting of\n    -+\t\t# this variable, so we need a stable setting under which to run\n    -+\t\t# the sub-test.\n    -+\t\tsane_unset HARNESS_ACTIVE &&\n    -+\n    + \t\t# Pretend we're not running under a test harness, whether we\n    + \t\t# are or not. The test-lib output depends on the setting of\n    + \t\t# this variable, so we need a stable setting under which to run\n    + \t\t# the sub-test.\n    + \t\tsane_unset HARNESS_ACTIVE &&\n    +-\t\tcd \"$name\" &&\n    +-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n    +-\t\ttest_description='$descr (run in sub test-lib)\n    + \n    +-\t\tThis is run in a sub test-lib so that we do not get incorrect\n    +-\t\tpassing metrics\n    +-\t\t'\n    +-\n    +-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n    +-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n    +-\t\tEOF\n    +-\t\tcat >>\"$name.sh\" &&\n      \t\texport TEST_DIRECTORY &&\n    - \t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n    - \t\texport TEST_OUTPUT_DIRECTORY &&\n    + \t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n    + \t\t# override the test output directory. We thus pass it as an\n     @@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n      \t)\n      }\n    @@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n      run_sub_test_lib_test () {\n      \t_run_sub_test_lib_test_common '' \"$@\"\n      }\n    +@@ t/lib-subtest.sh: check_sub_test_lib_test_err () {\n    + \t\ttest_cmp expect.err err\n    + \t)\n    + }\n    ++\n     \n      ## t/t0000-basic.sh ##\n     @@ t/t0000-basic.sh: test_expect_success 'success is reported like this' '\n    @@ t/t0000-basic.sh: test_expect_success 'test --verbose' '\n      \t\t--verbose-only=2 <<-\\EOF &&\n      \ttest_expect_success \"passing test\" true\n     @@ t/t0000-basic.sh: test_expect_success 'test --verbose-only' '\n    + \n      test_expect_success 'GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.2\" && export GIT_SKIP_TESTS &&\n     -\t\trun_sub_test_lib_test git-skip-tests-basic \\\n     +\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n    - \t\t\t\"GIT_SKIP_TESTS\" <<-\\EOF &&\n    + \t\t\t\"GIT_SKIP_TESTS\" \\\n    + \t\t\t--skip=\"git.2\" <<-\\EOF &&\n      \t\tfor i in 1 2 3\n    - \t\tdo\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS' '\n    + \n      test_expect_success 'GIT_SKIP_TESTS several tests' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.2 git.5\" && export GIT_SKIP_TESTS &&\n     -\t\trun_sub_test_lib_test git-skip-tests-several \\\n     +\t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n    - \t\t\t\"GIT_SKIP_TESTS several tests\" <<-\\EOF &&\n    + \t\t\t\"GIT_SKIP_TESTS several tests\" \\\n    + \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n      \t\tfor i in 1 2 3 4 5 6\n    - \t\tdo\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS several tests' '\n    + \n      test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.[2-5]\" && export GIT_SKIP_TESTS &&\n     -\t\trun_sub_test_lib_test git-skip-tests-sh-pattern \\\n     +\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n    - \t\t\t\"GIT_SKIP_TESTS sh pattern\" <<-\\EOF &&\n    + \t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n    + \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n      \t\tfor i in 1 2 3 4 5 6\n    - \t\tdo\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n    + \n      test_expect_success 'GIT_SKIP_TESTS entire suite' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n     -\t\trun_sub_test_lib_test git-skip-tests-entire-suite \\\n     +\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n    - \t\t\t\"GIT_SKIP_TESTS entire suite\" <<-\\EOF &&\n    + \t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n    + \t\t\t--skip=\"git\" <<-\\EOF &&\n      \t\tfor i in 1 2 3\n    - \t\tdo\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS entire suite' '\n    + \n      test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n     -\t\trun_sub_test_lib_test git-skip-tests-unmatched-suite \\\n     +\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n    - \t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" <<-\\EOF &&\n    + \t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n    + \t\t\t--skip=\"notgit\" <<-\\EOF &&\n      \t\tfor i in 1 2 3\n    - \t\tdo\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n      '\n      \n3:  cd6c740c912 = 3:  7d5ed335a36 test-lib tests: stop using a subshell in write_sub_test_lib_test()\n4:  0578470d899 ! 4:  2a0dd64da90 test-lib tests: don't provide a description for the sub-tests\n    @@ t/lib-subtest.sh: write_sub_test_lib_test () {\n     -\tshift 3\n     +\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n     +\tshift 2\n    - \t(\n    - \t\tcd \"$name\" &&\n      \n    + \t# intercept pseudo-options at the front of the argument list that we\n    + \t# will not pass to child script\n     \n      ## t/t0000-basic.sh ##\n     @@ t/t0000-basic.sh: test_expect_success 'success is reported like this' '\n    @@ t/t0000-basic.sh: test_expect_success 'test --verbose-only' '\n     -test_expect_success 'GIT_SKIP_TESTS' '\n     +test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.2\" && export GIT_SKIP_TESTS &&\n      \t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n    --\t\t\t\"GIT_SKIP_TESTS\" <<-\\EOF &&\n    -+\t\t\t<<-\\EOF &&\n    +-\t\t\t\"GIT_SKIP_TESTS\" \\\n    + \t\t\t--skip=\"git.2\" <<-\\EOF &&\n      \t\tfor i in 1 2 3\n      \t\tdo\n    - \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS' '\n      \t)\n      '\n    @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS' '\n     -test_expect_success 'GIT_SKIP_TESTS several tests' '\n     +test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.2 git.5\" && export GIT_SKIP_TESTS &&\n      \t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n    --\t\t\t\"GIT_SKIP_TESTS several tests\" <<-\\EOF &&\n    -+\t\t\t<<-\\EOF &&\n    +-\t\t\t\"GIT_SKIP_TESTS several tests\" \\\n    + \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n      \t\tfor i in 1 2 3 4 5 6\n      \t\tdo\n    - \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS several tests' '\n      \t)\n      '\n    @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS several tests' '\n     -test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n     +test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.[2-5]\" && export GIT_SKIP_TESTS &&\n      \t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n    --\t\t\t\"GIT_SKIP_TESTS sh pattern\" <<-\\EOF &&\n    -+\t\t\t<<-\\EOF &&\n    +-\t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n    + \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n      \t\tfor i in 1 2 3 4 5 6\n      \t\tdo\n    - \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n      \t)\n      '\n    @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n     -test_expect_success 'GIT_SKIP_TESTS entire suite' '\n     +test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n      \t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n    --\t\t\t\"GIT_SKIP_TESTS entire suite\" <<-\\EOF &&\n    -+\t\t\t<<-\\EOF &&\n    +-\t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n    + \t\t\t--skip=\"git\" <<-\\EOF &&\n      \t\tfor i in 1 2 3\n      \t\tdo\n    - \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS entire suite' '\n      \t)\n      '\n    @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS entire suite' '\n     -test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n     +test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n      \t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n    --\t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" <<-\\EOF &&\n    -+\t\t\t<<-\\EOF &&\n    +-\t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n    + \t\t\t--skip=\"notgit\" <<-\\EOF &&\n      \t\tfor i in 1 2 3\n      \t\tdo\n    - \t\t\ttest_expect_success \"passing test #$i\" \"true\"\n     @@ t/t0000-basic.sh: test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n      \t)\n      '\n5:  1909616d9ca ! 5:  f60190dec6a test-lib tests: get rid of copy/pasted mock test code\n    @@ t/t0000-basic.sh: test_expect_success 'subtest: --verbose-only option' '\n      \n      test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n      \t(\n    --\t\tGIT_SKIP_TESTS=\"git.2\" && export GIT_SKIP_TESTS &&\n     -\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n    --\t\t\t<<-\\EOF &&\n    +-\t\t\t--skip=\"git.2\" <<-\\EOF &&\n     -\t\tfor i in 1 2 3\n     -\t\tdo\n     -\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n    @@ t/t0000-basic.sh: test_expect_success 'subtest: --verbose-only option' '\n     -\t\ttest_done\n     -\t\tEOF\n     -\t\tcheck_sub_test_lib_test git-skip-tests-basic <<-\\EOF\n    -+\t\tGIT_SKIP_TESTS=\"full.2\" && export GIT_SKIP_TESTS &&\n    -+\t\trun_sub_test_lib_test full-pass &&\n    ++\t\trun_sub_test_lib_test full-pass \\\n    ++\t\t\t--skip=\"full.2\" &&\n     +\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n      \t\t> ok 1 - passing test #1\n      \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n      \t\t> ok 3 - passing test #3\n     @@ t/t0000-basic.sh: test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n    + \n      test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git.[2-5]\" && export GIT_SKIP_TESTS &&\n     -\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n    --\t\t\t<<-\\EOF &&\n    +-\t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n     -\t\tfor i in 1 2 3 4 5 6\n     -\t\tdo\n     -\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n    @@ t/t0000-basic.sh: test_expect_success 'subtest: skip several with GIT_SKIP_TESTS\n     -\t\ttest_done\n     -\t\tEOF\n     -\t\tcheck_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF\n    -+\t\trun_sub_test_lib_test git-skip-tests-several &&\n    ++\t\trun_sub_test_lib_test git-skip-tests-several \\\n    ++\t\t\t--skip=\"git.[2-5]\" &&\n     +\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n      \t\t> ok 1 - passing test #1\n      \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n      \t\t> ok 3 # skip passing test #3 (GIT_SKIP_TESTS)\n     @@ t/t0000-basic.sh: test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n    + \n      test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n     -\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n    --\t\t\t<<-\\EOF &&\n    +-\t\t\t--skip=\"git\" <<-\\EOF &&\n     -\t\tfor i in 1 2 3\n     -\t\tdo\n     -\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n    @@ t/t0000-basic.sh: test_expect_success 'subtest: sh pattern skipping with GIT_SKI\n     -\t\ttest_done\n     -\t\tEOF\n     -\t\tcheck_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF\n    -+\t\trun_sub_test_lib_test git-skip-tests-several &&\n    ++\t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n    ++\t\trun_sub_test_lib_test git-skip-tests-several \\\n    ++\t\t\t--skip=\"git\" &&\n     +\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n      \t\t> 1..0 # SKIP skip all tests in git\n      \t\tEOF\n      \t)\n     @@ t/t0000-basic.sh: test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n    + \n      test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n      \t(\n    - \t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n     -\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n    --\t\t\t<<-\\EOF &&\n    +-\t\t\t--skip=\"notgit\" <<-\\EOF &&\n     -\t\tfor i in 1 2 3\n     -\t\tdo\n     -\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n    @@ t/t0000-basic.sh: test_expect_success 'subtest: skip entire test suite with GIT_\n     -\t\ttest_done\n     -\t\tEOF\n     -\t\tcheck_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF\n    -+\t\trun_sub_test_lib_test full-pass &&\n    ++\t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n    ++\t\trun_sub_test_lib_test full-pass \\\n    ++\t\t\t--skip=\"notfull\" &&\n     +\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n      \t\t> ok 1 - passing test #1\n      \t\t> ok 2 - passing test #2\n6:  2f717e437e6 ! 6:  022ddbabf63 test-lib tests: avoid subshell for \"test_cmp\" for readability\n    @@ t/lib-subtest.sh: run_sub_test_lib_test_err () {\n     +\tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n     +\ttest_cmp \"$name\"/expect.err \"$name\"/err\n      }\n    + \n7:  1f32eb60411 = 7:  ae0226e164c test-lib tests: refactor common part of check_sub_test_lib_test*()\n8:  ddbc8db2802 ! 8:  676547e001e test-lib tests: assert 1 exit code, not non-zero\n    @@ t/lib-subtest.sh: write_sub_test_lib_test () {\n     -\tshift 2\n     +\tcmp_op=\"$1\" want_code=\"$2\" name=\"$3\" # stdin is the body of the test code\n     +\tshift 3\n    - \t(\n    - \t\tcd \"$name\" &&\n      \n    + \t# intercept pseudo-options at the front of the argument list that we\n    + \t# will not pass to child script\n     @@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n    - \t\tTEST_OUTPUT_DIRECTORY=$(pwd) &&\n    - \t\texport TEST_OUTPUT_DIRECTORY &&\n    + \t\tGIT_SKIP_TESTS=$skip &&\n    + \t\texport GIT_SKIP_TESTS &&\n      \t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n     -\t\tif test -z \"$neg\"\n     -\t\tthen\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430812","messageId":"patch-1.8-7a06ea3a7b7-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 1/8] test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:40Z","receivedAt":"2021-07-21T22:58:32Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the \"check_sub_test_lib_test()\" and its sister functions to a new\nlib-subtest.sh.\n\nIn the future (not in this series) I'd like to test test-lib's output\nin a more targeted and smaller test, and I'll need these functions to\ndo that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++\n t/t0000-basic.sh | 88 +-----------------------------------------------\n 2 files changed, 87 insertions(+), 87 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nnew file mode 100644\nindex 00000000000..3cfe09911a2\n--- /dev/null\n+++ b/t/lib-subtest.sh\n@@ -0,0 +1,86 @@\n+_run_sub_test_lib_test_common () {\n+\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n+\tshift 3\n+\n+\t# intercept pseudo-options at the front of the argument list that we\n+\t# will not pass to child script\n+\tskip=\n+\twhile test $# -gt 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--skip=*)\n+\t\t\tskip=${1#--*=}\n+\t\t\tshift\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\n+\tmkdir \"$name\" &&\n+\t(\n+\t\t# Pretend we're not running under a test harness, whether we\n+\t\t# are or not. The test-lib output depends on the setting of\n+\t\t# this variable, so we need a stable setting under which to run\n+\t\t# the sub-test.\n+\t\tsane_unset HARNESS_ACTIVE &&\n+\t\tcd \"$name\" &&\n+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\t\ttest_description='$descr (run in sub test-lib)\n+\n+\t\tThis is run in a sub test-lib so that we do not get incorrect\n+\t\tpassing metrics\n+\t\t'\n+\n+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\t\tEOF\n+\t\tcat >>\"$name.sh\" &&\n+\t\texport TEST_DIRECTORY &&\n+\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n+\t\t# override the test output directory. We thus pass it as an\n+\t\t# explicit override to the child.\n+\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n+\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n+\t\tGIT_SKIP_TESTS=$skip &&\n+\t\texport GIT_SKIP_TESTS &&\n+\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n+\t\tif test -z \"$neg\"\n+\t\tthen\n+\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n+\t\telse\n+\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n+\t\tfi\n+\t)\n+}\n+\n+run_sub_test_lib_test () {\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+run_sub_test_lib_test_err () {\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n+check_sub_test_lib_test () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t(\n+\t\tcd \"$name\" &&\n+\t\ttest_must_be_empty err &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n+\t\ttest_cmp expect out\n+\t)\n+}\n+\n+check_sub_test_lib_test_err () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t# expected error output is in descriptor 3\n+\t(\n+\t\tcd \"$name\" &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n+\t\ttest_cmp expect.out out &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n+\t\ttest_cmp expect.err err\n+\t)\n+}\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex cb87768513c..a3865dd77ba 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -19,6 +19,7 @@ modification *should* take notice and update the test vectors here.\n '\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-subtest.sh\n \n try_local_xy () {\n \tlocal x=\"local\" y=\"alsolocal\" &&\n@@ -66,93 +67,6 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-_run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n-\n-\t# intercept pseudo-options at the front of the argument list that we\n-\t# will not pass to child script\n-\tskip=\n-\twhile test $# -gt 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t--skip=*)\n-\t\t\tskip=${1#--*=}\n-\t\t\tshift\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\tdone\n-\n-\tmkdir \"$name\" &&\n-\t(\n-\t\t# Pretend we're not running under a test harness, whether we\n-\t\t# are or not. The test-lib output depends on the setting of\n-\t\t# this variable, so we need a stable setting under which to run\n-\t\t# the sub-test.\n-\t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n-\n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n-\n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n-\t\texport TEST_DIRECTORY &&\n-\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n-\t\t# override the test output directory. We thus pass it as an\n-\t\t# explicit override to the child.\n-\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n-\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n-\t\tGIT_SKIP_TESTS=$skip &&\n-\t\texport GIT_SKIP_TESTS &&\n-\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n-\t)\n-}\n-\n-run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n-}\n-\n-run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n-}\n-\n-check_sub_test_lib_test () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n-}\n-\n-check_sub_test_lib_test_err () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n-}\n-\n test_expect_success 'pretend we have a fully passing test suite' '\n \trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430813","messageId":"patch-2.8-28117b84abf-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 2/8] test-lib tests: split up \"write and run\" into two functions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:41Z","receivedAt":"2021-07-21T22:58:33Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the function to write and run tests of the test-lib.sh output\ninto two functions.\n\nWhen this was added back in 565b6fa87bb (tests: refactor mechanics of\ntesting in a sub test-lib, 2012-12-16) there was no reason to do this,\nbut since we started supporting test arguments in\n517cd55fd51 (test-lib: self-test that --verbose works, 2013-06-23)\nwe've started to write out duplicate tests simply to test different\narguments, now we'll be able to re-use them.\n\nThis change doesn't consolidate any of those tests yet, it just makes\nit possible to do so. All the changes in t0000-basic.sh are a simple\nsearch-replacement.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 46 ++++++++++++++++++++++--------\n t/t0000-basic.sh | 74 ++++++++++++++++++++++++------------------------\n 2 files changed, 71 insertions(+), 49 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 3cfe09911a2..8f3f6dddcf4 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,3 +1,22 @@\n+write_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tmkdir \"$name\" &&\n+\t(\n+\t\tcd \"$name\" &&\n+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\t\ttest_description='$descr (run in sub test-lib)\n+\n+\t\tThis is run in a sub test-lib so that we do not get incorrect\n+\t\tpassing metrics\n+\t\t'\n+\n+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\t\tEOF\n+\t\tcat >>\"$name.sh\"\n+\t)\n+}\n+\n _run_sub_test_lib_test_common () {\n \tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n \tshift 3\n@@ -18,25 +37,15 @@ _run_sub_test_lib_test_common () {\n \t\tesac\n \tdone\n \n-\tmkdir \"$name\" &&\n \t(\n+\t\tcd \"$name\" &&\n+\n \t\t# Pretend we're not running under a test harness, whether we\n \t\t# are or not. The test-lib output depends on the setting of\n \t\t# this variable, so we need a stable setting under which to run\n \t\t# the sub-test.\n \t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n \n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n-\n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n \t\texport TEST_DIRECTORY &&\n \t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n \t\t# override the test output directory. We thus pass it as an\n@@ -55,6 +64,18 @@ _run_sub_test_lib_test_common () {\n \t)\n }\n \n+write_and_run_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+write_and_run_sub_test_lib_test_err () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n run_sub_test_lib_test () {\n \t_run_sub_test_lib_test_common '' \"$@\"\n }\n@@ -84,3 +105,4 @@ check_sub_test_lib_test_err () {\n \t\ttest_cmp expect.err err\n \t)\n }\n+\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex a3865dd77ba..a7c5aaacab6 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -68,7 +68,7 @@ test_expect_success 'success is reported like this' '\n '\n \n test_expect_success 'pretend we have a fully passing test suite' '\n-\trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -85,7 +85,7 @@ test_expect_success 'pretend we have a fully passing test suite' '\n '\n \n test_expect_success 'pretend we have a partially passing test suite' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n@@ -103,7 +103,7 @@ test_expect_success 'pretend we have a partially passing test suite' '\n '\n \n test_expect_success 'pretend we have a known breakage' '\n-\trun_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -118,7 +118,7 @@ test_expect_success 'pretend we have a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed a known breakage' '\n-\trun_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -130,7 +130,7 @@ test_expect_success 'pretend we have fixed a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\trun_sub_test_lib_test partially-passing-todos \\\n+\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n \t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n@@ -149,7 +149,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n '\n \n test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n@@ -168,7 +168,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n '\n \n test_expect_success 'pretend we have a mix of all possible results' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -204,7 +204,7 @@ test_expect_success 'pretend we have a mix of all possible results' '\n '\n \n test_expect_success 'test --verbose' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -231,7 +231,7 @@ test_expect_success 'test --verbose' '\n '\n \n test_expect_success 'test --verbose-only' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n@@ -255,7 +255,7 @@ test_expect_success 'test --verbose-only' '\n \n test_expect_success 'GIT_SKIP_TESTS' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-basic \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n \t\t\t\"GIT_SKIP_TESTS\" \\\n \t\t\t--skip=\"git.2\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -276,7 +276,7 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \n test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n \t\t\t\"GIT_SKIP_TESTS several tests\" \\\n \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n@@ -300,7 +300,7 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \n test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-sh-pattern \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n \t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n@@ -324,7 +324,7 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \n test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-entire-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n \t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n \t\t\t--skip=\"git\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -341,7 +341,7 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \n test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-unmatched-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n \t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n \t\t\t--skip=\"notgit\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -361,7 +361,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success '--run basic' '\n-\trun_sub_test_lib_test run-basic \\\n+\twrite_and_run_sub_test_lib_test run-basic \\\n \t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -382,7 +382,7 @@ test_expect_success '--run basic' '\n '\n \n test_expect_success '--run with a range' '\n-\trun_sub_test_lib_test run-range \\\n+\twrite_and_run_sub_test_lib_test run-range \\\n \t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -403,7 +403,7 @@ test_expect_success '--run with a range' '\n '\n \n test_expect_success '--run with two ranges' '\n-\trun_sub_test_lib_test run-two-ranges \\\n+\twrite_and_run_sub_test_lib_test run-two-ranges \\\n \t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -424,7 +424,7 @@ test_expect_success '--run with two ranges' '\n '\n \n test_expect_success '--run with a left open range' '\n-\trun_sub_test_lib_test run-left-open-range \\\n+\twrite_and_run_sub_test_lib_test run-left-open-range \\\n \t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -445,7 +445,7 @@ test_expect_success '--run with a left open range' '\n '\n \n test_expect_success '--run with a right open range' '\n-\trun_sub_test_lib_test run-right-open-range \\\n+\twrite_and_run_sub_test_lib_test run-right-open-range \\\n \t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -466,7 +466,7 @@ test_expect_success '--run with a right open range' '\n '\n \n test_expect_success '--run with basic negation' '\n-\trun_sub_test_lib_test run-basic-neg \\\n+\twrite_and_run_sub_test_lib_test run-basic-neg \\\n \t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -487,7 +487,7 @@ test_expect_success '--run with basic negation' '\n '\n \n test_expect_success '--run with two negations' '\n-\trun_sub_test_lib_test run-two-neg \\\n+\twrite_and_run_sub_test_lib_test run-two-neg \\\n \t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -508,7 +508,7 @@ test_expect_success '--run with two negations' '\n '\n \n test_expect_success '--run a range and negation' '\n-\trun_sub_test_lib_test run-range-and-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n \t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -529,7 +529,7 @@ test_expect_success '--run a range and negation' '\n '\n \n test_expect_success '--run range negation' '\n-\trun_sub_test_lib_test run-range-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-neg \\\n \t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -550,7 +550,7 @@ test_expect_success '--run range negation' '\n '\n \n test_expect_success '--run include, exclude and include' '\n-\trun_sub_test_lib_test run-inc-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n \t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -572,7 +572,7 @@ test_expect_success '--run include, exclude and include' '\n '\n \n test_expect_success '--run include, exclude and include, comma separated' '\n-\trun_sub_test_lib_test run-inc-neg-inc-comma \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n \t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -594,7 +594,7 @@ test_expect_success '--run include, exclude and include, comma separated' '\n '\n \n test_expect_success '--run exclude and include' '\n-\trun_sub_test_lib_test run-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-neg-inc \\\n \t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -616,7 +616,7 @@ test_expect_success '--run exclude and include' '\n '\n \n test_expect_success '--run empty selectors' '\n-\trun_sub_test_lib_test run-empty-sel \\\n+\twrite_and_run_sub_test_lib_test run-empty-sel \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -638,7 +638,7 @@ test_expect_success '--run empty selectors' '\n '\n \n test_expect_success '--run substring selector' '\n-\trun_sub_test_lib_test run-substring-selector \\\n+\twrite_and_run_sub_test_lib_test run-substring-selector \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n@@ -662,7 +662,7 @@ test_expect_success '--run substring selector' '\n '\n \n test_expect_success '--run keyword selection' '\n-\trun_sub_test_lib_test_err run-inv-range-start \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n \t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -677,7 +677,7 @@ test_expect_success '--run keyword selection' '\n '\n \n test_expect_success '--run invalid range end' '\n-\trun_sub_test_lib_test_err run-inv-range-end \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n \t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -692,7 +692,7 @@ test_expect_success '--run invalid range end' '\n '\n \n test_expect_success 'tests respect prerequisites' '\n-\trun_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -722,7 +722,7 @@ test_expect_success 'tests respect prerequisites' '\n '\n \n test_expect_success 'tests respect lazy prerequisites' '\n-\trun_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -746,7 +746,7 @@ test_expect_success 'tests respect lazy prerequisites' '\n '\n \n test_expect_success 'nested lazy prerequisites' '\n-\trun_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -772,7 +772,7 @@ test_expect_success 'nested lazy prerequisites' '\n '\n \n test_expect_success 'lazy prereqs do not turn off tracing' '\n-\trun_sub_test_lib_test lazy-prereq-and-tracing \\\n+\twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n \t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n@@ -785,7 +785,7 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n '\n \n test_expect_success 'tests clean up after themselves' '\n-\trun_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -805,7 +805,7 @@ test_expect_success 'tests clean up after themselves' '\n '\n \n test_expect_success 'tests clean up even on failures' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n@@ -834,7 +834,7 @@ test_expect_success 'tests clean up even on failures' '\n '\n \n test_expect_success 'test_atexit is run' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430814","messageId":"patch-5.8-f60190dec6a-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 5/8] test-lib tests: get rid of copy/pasted mock test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:44Z","receivedAt":"2021-07-21T22:58:35Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that we've split up the write_sub_test_lib_test*() and\nrun_sub_test_lib_test*() functions let's fix those tests in\nt0000-basic.sh that were verbosely copy/pasting earlier tests.\n\nI'm (ab)using writing a tag object under a ref-name that's\ncontent-addressable from the content of the test script. If we can\nupdate-ref that it's unique, if not we've got a duplicate. The tag\nobject stores the name of the earlier test for reporting the error.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh |  34 ++++++-\n t/t0000-basic.sh | 228 +++++++++++++----------------------------------\n 2 files changed, 93 insertions(+), 169 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 7899518abb0..d98390606b8 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,3 +1,34 @@\n+_assert_unique_sub_test () {\n+\tname=$1 &&\n+\n+\t# Alert about the copy/paste programming\n+\thash=$(git hash-object -w \"$name\") &&\n+\tcat >tag.sig <<-EOF &&\n+\tobject $hash\n+\ttype blob\n+\ttag $hash\n+\ttagger . <> 0 +0000\n+\n+\tduplicate script detected!\n+\n+\tThis test script was already written as:\n+\n+\t$name\n+\n+\tYou can just re-use its test code with your own\n+\trun_sub_test_lib_test*()\n+\tEOF\n+\n+\ttag=$(git mktag <tag.sig) &&\n+\tif ! git update-ref refs/tags/blob-$hash $tag $(test_oid zero) 2>/dev/null\n+\tthen\n+\t\tmsg=$(git for-each-ref refs/tags/blob-$hash \\\n+\t\t\t--format='%(contents)' refs/tags/blob-$hash)\n+\t\terror \"on write of $name: $msg\"\n+\t\treturn 1\n+\tfi\n+}\n+\n write_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n@@ -7,7 +38,8 @@ write_sub_test_lib_test () {\n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \tEOF\n-\tcat >>\"$name/$name.sh\"\n+\tcat >>\"$name/$name.sh\" &&\n+\t_assert_unique_sub_test \"$name/$name.sh\"\n }\n \n _run_sub_test_lib_test_common () {\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 6fdd5f43cae..a0b99d83349 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -226,18 +226,13 @@ test_expect_success 'subtest: --verbose option' '\n '\n \n test_expect_success 'subtest: --verbose-only option' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \\\n-\t\t--verbose-only=2 <<-\\EOF &&\n-\ttest_expect_success \"passing test\" true\n-\ttest_expect_success \"test with output\" \"echo foo\"\n-\ttest_expect_success \"failing test\" false\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test t2345-verbose-only-2 <<-\\EOF\n+\trun_sub_test_lib_test_err \\\n+\t\tt1234-verbose \\\n+\t\t--verbose-only=2 &&\n+\tcheck_sub_test_lib_test t1234-verbose <<-\\EOF\n \t> ok 1 - passing test\n \t> Z\n-\t> expecting success of 2345.2 '\\''test with output'\\'': echo foo\n+\t> expecting success of 1234.2 '\\''test with output'\\'': echo foo\n \t> foo\n \t> ok 2 - test with output\n \t> Z\n@@ -250,15 +245,9 @@ test_expect_success 'subtest: --verbose-only option' '\n \n test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t--skip=\"git.2\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-basic <<-\\EOF\n+\t\trun_sub_test_lib_test full-pass \\\n+\t\t\t--skip=\"full.2\" &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 - passing test #3\n@@ -293,15 +282,9 @@ test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n-\t\tfor i in 1 2 3 4 5 6\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF\n+\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t\t--skip=\"git.[2-5]\" &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 # skip passing test #3 (GIT_SKIP_TESTS)\n@@ -316,15 +299,10 @@ test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t--skip=\"git\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t\t--skip=\"git\" &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> 1..0 # SKIP skip all tests in git\n \t\tEOF\n \t)\n@@ -332,15 +310,10 @@ test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t--skip=\"notgit\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test full-pass \\\n+\t\t\t--skip=\"notfull\" &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 - passing test #2\n \t\t> ok 3 - passing test #3\n@@ -351,14 +324,8 @@ test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success 'subtest: --run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several --run=\"1,3,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -371,15 +338,9 @@ test_expect_success 'subtest: --run basic' '\n '\n \n test_expect_success 'subtest: --run with a range' '\n-\twrite_and_run_sub_test_lib_test run-range \\\n-\t\t--run=\"1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -392,15 +353,9 @@ test_expect_success 'subtest: --run with a range' '\n '\n \n test_expect_success 'subtest: --run with two ranges' '\n-\twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-ranges <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-2,5-6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -413,15 +368,9 @@ test_expect_success 'subtest: --run with two ranges' '\n '\n \n test_expect_success 'subtest: --run with a left open range' '\n-\twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t--run=\"-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-left-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -434,15 +383,9 @@ test_expect_success 'subtest: --run with a left open range' '\n '\n \n test_expect_success 'subtest: --run with a right open range' '\n-\twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t--run=\"4-\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-right-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"4-\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -455,15 +398,9 @@ test_expect_success 'subtest: --run with a right open range' '\n '\n \n test_expect_success 'subtest: --run with basic negation' '\n-\twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t--run=\"!3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -476,15 +413,9 @@ test_expect_success 'subtest: --run with basic negation' '\n '\n \n test_expect_success 'subtest: --run with two negations' '\n-\twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t--run=\"!3,!6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3,!6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -497,15 +428,9 @@ test_expect_success 'subtest: --run with two negations' '\n '\n \n test_expect_success 'subtest: --run a range and negation' '\n-\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t--run=\"-4,!2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-and-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-4,!2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -518,15 +443,9 @@ test_expect_success 'subtest: --run a range and negation' '\n '\n \n test_expect_success 'subtest: --run range negation' '\n-\twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t--run=\"!1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -539,15 +458,9 @@ test_expect_success 'subtest: --run range negation' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-5,!1-3,2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -560,15 +473,9 @@ test_expect_success 'subtest: --run include, exclude and include' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t--run=1-5,!1-3,2 <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=1-5,!1-3,2 &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -581,15 +488,9 @@ test_expect_success 'subtest: --run include, exclude and include, comma separate\n '\n \n test_expect_success 'subtest: --run exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t--run=\"!3-,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3-,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -602,15 +503,9 @@ test_expect_success 'subtest: --run exclude and include' '\n '\n \n test_expect_success 'subtest: --run empty selectors' '\n-\twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-empty-sel <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1,,3,,,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -660,12 +555,9 @@ test_expect_success 'subtest: --run keyword selection' '\n '\n \n test_expect_success 'subtest: --run invalid range end' '\n-\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t--run=\"1-z\" <<-\\EOF &&\n-\ttest_expect_success \"passing test #1\" \"true\"\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test_err run-inv-range-end \\\n+\trun_sub_test_lib_test_err run-inv-range-start \\\n+\t\t--run=\"1-z\" &&\n+\tcheck_sub_test_lib_test_err run-inv-range-start \\\n \t\t<<-\\EOF_OUT 3<<-EOF_ERR\n \t> FATAL: Unexpected exit with code 1\n \tEOF_OUT\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430815","messageId":"patch-4.8-2a0dd64da90-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 4/8] test-lib tests: don't provide a description for the sub-tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:43Z","receivedAt":"2021-07-21T22:58:36Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the $test_description provided for the generated subtests to be\nconstant, since the only purpose of having it is that test-lib.sh will\nbarf if it isn't supplied.\n\nThe other purpose of having it was to effectively split up the test\ndescription between the argument to test_expect_success and the\nargument to \"write_and_run_sub_test_lib_test\". Let's only use one of\nthe two.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh |  12 ++--\n t/t0000-basic.sh | 142 +++++++++++++++++++++--------------------------\n 2 files changed, 66 insertions(+), 88 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 727b0850e9b..7899518abb0 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,12 +1,8 @@\n write_sub_test_lib_test () {\n-\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n \twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\ttest_description='$descr (run in sub test-lib)\n-\n-\tThis is run in a sub test-lib so that we do not get incorrect\n-\tpassing metrics\n-\t'\n+\ttest_description='A test of test-lib.sh itself'\n \n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n@@ -15,8 +11,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n+\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n+\tshift 2\n \n \t# intercept pseudo-options at the front of the argument list that we\n \t# will not pass to child script\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex a7c5aaacab6..6fdd5f43cae 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -67,8 +67,8 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-test_expect_success 'pretend we have a fully passing test suite' '\n-\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+test_expect_success 'subtest: 3 passing tests' '\n+\twrite_and_run_sub_test_lib_test full-pass <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -84,9 +84,8 @@ test_expect_success 'pretend we have a fully passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a partially passing test suite' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2/3 tests passing' '\n+\twrite_and_run_sub_test_lib_test_err partial-pass <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n \ttest_expect_success \"passing test #3\" \"true\"\n@@ -102,8 +101,8 @@ test_expect_success 'pretend we have a partially passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a known breakage' '\n-\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a failing TODO test' '\n+\twrite_and_run_sub_test_lib_test failing-todo <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -117,8 +116,8 @@ test_expect_success 'pretend we have a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed a known breakage' '\n-\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a passing TODO test' '\n+\twrite_and_run_sub_test_lib_test passing-todo <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -129,9 +128,8 @@ test_expect_success 'pretend we have fixed a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n-\t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2 TODO tests, one passin' '\n+\twrite_and_run_sub_test_lib_test partially-passing-todos <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n \ttest_expect_failure \"pretend we have fixed another known breakage\" \"true\"\n@@ -148,9 +146,8 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n \tEOF\n '\n \n-test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: pass, failure and a TODO test' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results1 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n@@ -167,9 +164,8 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a mix of all possible results' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: a mixture of all possible results' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -203,9 +199,8 @@ test_expect_success 'pretend we have a mix of all possible results' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n+test_expect_success 'subtest: --verbose option' '\n+\twrite_and_run_sub_test_lib_test_err t1234-verbose --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n \ttest_expect_success \"failing test\" false\n@@ -230,9 +225,9 @@ test_expect_success 'test --verbose' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose-only' '\n+test_expect_success 'subtest: --verbose-only option' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n+\t\tt2345-verbose-only-2 \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -253,10 +248,9 @@ test_expect_success 'test --verbose-only' '\n \tEOF\n '\n \n-test_expect_success 'GIT_SKIP_TESTS' '\n+test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t\"GIT_SKIP_TESTS\" \\\n \t\t\t--skip=\"git.2\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -274,10 +268,9 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS several tests' '\n+test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n-\t\t\t\"GIT_SKIP_TESTS several tests\" \\\n \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -298,10 +291,9 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n+test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -322,10 +314,9 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS entire suite' '\n+test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n \t\t\t--skip=\"git\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -339,10 +330,9 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n+test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n \t\t\t--skip=\"notgit\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -360,9 +350,8 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t)\n '\n \n-test_expect_success '--run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic \\\n-\t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n+test_expect_success 'subtest: --run basic' '\n+\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -381,9 +370,9 @@ test_expect_success '--run basic' '\n \tEOF\n '\n \n-test_expect_success '--run with a range' '\n+test_expect_success 'subtest: --run with a range' '\n \twrite_and_run_sub_test_lib_test run-range \\\n-\t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n+\t\t--run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -402,9 +391,9 @@ test_expect_success '--run with a range' '\n \tEOF\n '\n \n-test_expect_success '--run with two ranges' '\n+test_expect_success 'subtest: --run with two ranges' '\n \twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n+\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -423,9 +412,9 @@ test_expect_success '--run with two ranges' '\n \tEOF\n '\n \n-test_expect_success '--run with a left open range' '\n+test_expect_success 'subtest: --run with a left open range' '\n \twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n+\t\t--run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -444,9 +433,9 @@ test_expect_success '--run with a left open range' '\n \tEOF\n '\n \n-test_expect_success '--run with a right open range' '\n+test_expect_success 'subtest: --run with a right open range' '\n \twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n+\t\t--run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -465,9 +454,9 @@ test_expect_success '--run with a right open range' '\n \tEOF\n '\n \n-test_expect_success '--run with basic negation' '\n+test_expect_success 'subtest: --run with basic negation' '\n \twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n+\t\t--run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -486,9 +475,9 @@ test_expect_success '--run with basic negation' '\n \tEOF\n '\n \n-test_expect_success '--run with two negations' '\n+test_expect_success 'subtest: --run with two negations' '\n \twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n+\t\t--run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -507,9 +496,9 @@ test_expect_success '--run with two negations' '\n \tEOF\n '\n \n-test_expect_success '--run a range and negation' '\n+test_expect_success 'subtest: --run a range and negation' '\n \twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n+\t\t--run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -528,9 +517,9 @@ test_expect_success '--run a range and negation' '\n \tEOF\n '\n \n-test_expect_success '--run range negation' '\n+test_expect_success 'subtest: --run range negation' '\n \twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n+\t\t--run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -549,9 +538,8 @@ test_expect_success '--run range negation' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include' '\n+test_expect_success 'subtest: --run include, exclude and include' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -571,9 +559,8 @@ test_expect_success '--run include, exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include, comma separated' '\n+test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -593,9 +580,8 @@ test_expect_success '--run include, exclude and include, comma separated' '\n \tEOF\n '\n \n-test_expect_success '--run exclude and include' '\n+test_expect_success 'subtest: --run exclude and include' '\n \twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -615,9 +601,8 @@ test_expect_success '--run exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run empty selectors' '\n+test_expect_success 'subtest: --run empty selectors' '\n \twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -637,9 +622,8 @@ test_expect_success '--run empty selectors' '\n \tEOF\n '\n \n-test_expect_success '--run substring selector' '\n+test_expect_success 'subtest: --run substring selector' '\n \twrite_and_run_sub_test_lib_test run-substring-selector \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n \tfor i in 1 2 3 4 5 6\n@@ -661,9 +645,8 @@ test_expect_success '--run substring selector' '\n \tEOF\n '\n \n-test_expect_success '--run keyword selection' '\n+test_expect_success 'subtest: --run keyword selection' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n-\t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -676,9 +659,8 @@ test_expect_success '--run keyword selection' '\n \tEOF_ERR\n '\n \n-test_expect_success '--run invalid range end' '\n+test_expect_success 'subtest: --run invalid range end' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -691,8 +673,8 @@ test_expect_success '--run invalid range end' '\n \tEOF_ERR\n '\n \n-test_expect_success 'tests respect prerequisites' '\n-\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect prerequisites' '\n+\twrite_and_run_sub_test_lib_test prereqs <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -721,8 +703,8 @@ test_expect_success 'tests respect prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'tests respect lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test lazy-prereqs <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -745,8 +727,8 @@ test_expect_success 'tests respect lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'nested lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: nested lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test nested-lazy <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -771,9 +753,9 @@ test_expect_success 'nested lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'lazy prereqs do not turn off tracing' '\n+test_expect_success 'subtest: lazy prereqs do not turn off tracing' '\n \twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n-\t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n+\t\t-v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n \ttest_expect_success lazy \"test_have_prereq LAZY && echo trace\"\n@@ -784,8 +766,8 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n \tgrep \"echo trace\" lazy-prereq-and-tracing/err\n '\n \n-test_expect_success 'tests clean up after themselves' '\n-\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+test_expect_success 'subtest: tests clean up after themselves' '\n+\twrite_and_run_sub_test_lib_test cleanup <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -804,9 +786,9 @@ test_expect_success 'tests clean up after themselves' '\n \tEOF\n '\n \n-test_expect_success 'tests clean up even on failures' '\n+test_expect_success 'subtest: tests clean up even on failures' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n+\t\tfailing-cleanup <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n \t\ttest_when_finished rm clean-after-failure &&\n@@ -833,9 +815,9 @@ test_expect_success 'tests clean up even on failures' '\n \tEOF\n '\n \n-test_expect_success 'test_atexit is run' '\n+test_expect_success 'subtest: test_atexit is run' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n+\t\tatexit-cleanup -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n \t\ttest_atexit rm ../../clean-atexit &&\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430816","messageId":"patch-3.8-7d5ed335a36-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 3/8] test-lib tests: stop using a subshell in write_sub_test_lib_test()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:42Z","receivedAt":"2021-07-21T22:58:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that this function doesn't handle running the test anymore we can\ndo away with the sub-shell, which was used to scope an \"unset\" and\n\"export\" shell variables.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 8f3f6dddcf4..727b0850e9b 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,20 +1,17 @@\n write_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n-\t(\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n+\twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\ttest_description='$descr (run in sub test-lib)\n \n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n+\tThis is run in a sub test-lib so that we do not get incorrect\n+\tpassing metrics\n+\t'\n \n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\"\n-\t)\n+\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\tEOF\n+\tcat >>\"$name/$name.sh\"\n }\n \n _run_sub_test_lib_test_common () {\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430817","messageId":"patch-6.8-022ddbabf63-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 6/8] test-lib tests: avoid subshell for \"test_cmp\" for readability","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:45Z","receivedAt":"2021-07-21T22:58:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The use of a sub-shell for running the test_cmp of stdout/stderr for\nthe test author was introduced in this form in 565b6fa87bb (tests:\nrefactor mechanics of testing in a sub test-lib, 2012-12-16), but from\nlooking at the history that seemed to have diligently copied my\noriginal ad-hoc implementation in 7b905119703 (t/t0000-basic.sh: Run\nthe passing TODO test inside its own test-lib, 2010-08-19).\n\nThere's no reason to use a subshell here, we try to avoid it in\ngeneral. It also improves readability, if the test fails we print out\nthe relative path in the trash directory that needs to be looked\nat.\n\nBefore that was mostly obscured, since the \"write_sub_test_lib_test\"\nwill pick the directory for you from the test name.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 20 +++++++-------------\n 1 file changed, 7 insertions(+), 13 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex d98390606b8..96a4e6e259a 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -111,23 +111,17 @@ run_sub_test_lib_test_err () {\n \n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n+\ttest_must_be_empty \"$name\"/err &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n+\ttest_cmp \"$name/\"expect \"$name\"/out\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n \t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n+\tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n+\ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n \n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430818","messageId":"patch-7.8-ae0226e164c-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 7/8] test-lib tests: refactor common part of check_sub_test_lib_test*()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:46Z","receivedAt":"2021-07-21T22:58:40Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the two check_sub_test_lib_test*() functions to avoid\nduplicating the same comparison they did of stdout. This duplication\nwas initially added when check_sub_test_lib_test_err() was added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 96a4e6e259a..2fde75e8863 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -109,18 +109,22 @@ run_sub_test_lib_test_err () {\n \t_run_sub_test_lib_test_common '!' \"$@\"\n }\n \n+_check_sub_test_lib_test_common () {\n+\tname=\"$1\" &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out\n+}\n+\n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\ttest_must_be_empty \"$name\"/err &&\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n-\ttest_cmp \"$name/\"expect \"$name\"/out\n+\t_check_sub_test_lib_test_common \"$name\" &&\n+\ttest_must_be_empty \"$name\"/err\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n+\t_check_sub_test_lib_test_common \"$name\" &&\n \t# expected error output is in descriptor 3\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n-\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n \tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n \ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430819","messageId":"patch-8.8-676547e001e-20210721T225504Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v2 8/8] test-lib tests: assert 1 exit code, not non-zero","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-07-21T22:57:47Z","receivedAt":"2021-07-21T22:58:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Improve the testing for test-lib.sh itself to assert that we have a\nexit code of 1, not any non-zero. Improves code added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 2fde75e8863..f7ad7bc7d7d 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -43,8 +43,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n-\tshift 2\n+\tcmp_op=\"$1\" want_code=\"$2\" name=\"$3\" # stdin is the body of the test code\n+\tshift 3\n \n \t# intercept pseudo-options at the front of the argument list that we\n \t# will not pass to child script\n@@ -80,33 +80,30 @@ _run_sub_test_lib_test_common () {\n \t\tGIT_SKIP_TESTS=$skip &&\n \t\texport GIT_SKIP_TESTS &&\n \t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n+\t\t./\"$name.sh\" \"$@\" >out 2>err;\n+\t\tret=$? &&\n+\t\ttest \"$ret\" \"$cmp_op\" \"$want_code\"\n \t)\n }\n \n write_and_run_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n write_and_run_sub_test_lib_test_err () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n _check_sub_test_lib_test_common () {\n-- \n2.32.0.955.ge7c5360f7e7\n\n"},{"id":"430831","messageId":"xmqq35s7b69q.fsf@gitster.g","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"Re: [PATCH v2 0/8] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2021-07-21T23:23:45Z","receivedAt":"2021-07-21T23:23:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:\n\n> The v1[1] of this recently started conflicting with the cooking\n> jk/t0000-subtests-fix and ps/t0000-output-directory-fix, and got\n> ejected from \"seen\". This v2 is rebased on top of those two, so it\n> merges cleanly with \"seen\".\n\nThanks for noticing and proactively updating before I got around to\nasking you ;-)\n"},{"id":"432078","messageId":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com","subject":"[PATCH v3 0/9] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:19Z","receivedAt":"2021-08-05T10:37:38Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"This series has been looking for reviewer attention for a while. It\nsplits up the testing of test-lib.sh itself from t0000-basic.sh into a\nlib-subtest.sh library, a subsequent series of mine makes use of that\nlibrary.\n\nThe diffstat is nicely negative since a lot of the test code is\nsomething we could delete as redundant, the tests are also made\nstricter as a result (e.g. now checking 1 exit code, not any\nnon-zero).\n\nFor v2, see:\nhttps://lore.kernel.org/git/cover-0.8-00000000000-20210721T225504Z-avarab@gmail.com/\n\nThe ony tricky part of this series is the \"clever\" way of (ab)using\nthe object store and tags to detect copy/pasted tests. For this v3\nI've split that up into its own commit, see [56]/9 for the removal of\nthe copy/pasting and the assertion, respectively.\n\nThis series also depended on ps/t0000-output-directory-fix and\njk/t0000-subtests-fix, since both made it mo \"master\" it's been\nrebased on \"master\". The range-diff that's not the split-up around\n[56]/9 is due to that rebasing.\n\nÆvar Arnfjörð Bjarmason (9):\n  test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n  test-lib tests: split up \"write and run\" into two functions\n  test-lib tests: stop using a subshell in write_sub_test_lib_test()\n  test-lib tests: don't provide a description for the sub-tests\n  test-lib tests: get rid of copy/pasted mock test code\n  test-lib tests: assert no copy/pasted mock test code\n  test-lib tests: avoid subshell for \"test_cmp\" for readability\n  test-lib tests: refactor common part of check_sub_test_lib_test*()\n  test-lib tests: assert 1 exit code, not non-zero\n\n t/lib-subtest.sh | 127 ++++++++++++++\n t/t0000-basic.sh | 448 +++++++++++++----------------------------------\n 2 files changed, 245 insertions(+), 330 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\nRange-diff against v2:\n 1:  7a06ea3a7b =  1:  3f34420a3e test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n 2:  28117b84ab !  2:  c9c16016da test-lib tests: split up \"write and run\" into two functions\n    @@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n      run_sub_test_lib_test () {\n      \t_run_sub_test_lib_test_common '' \"$@\"\n      }\n    -@@ t/lib-subtest.sh: check_sub_test_lib_test_err () {\n    - \t\ttest_cmp expect.err err\n    - \t)\n    - }\n    -+\n     \n      ## t/t0000-basic.sh ##\n     @@ t/t0000-basic.sh: test_expect_success 'success is reported like this' '\n 3:  7d5ed335a3 =  3:  76f57eadcd test-lib tests: stop using a subshell in write_sub_test_lib_test()\n 4:  2a0dd64da9 =  4:  cde015c7dd test-lib tests: don't provide a description for the sub-tests\n 5:  f60190dec6 !  5:  7d1e6b9a3e test-lib tests: get rid of copy/pasted mock test code\n    @@ Commit message\n         run_sub_test_lib_test*() functions let's fix those tests in\n         t0000-basic.sh that were verbosely copy/pasting earlier tests.\n     \n    -    I'm (ab)using writing a tag object under a ref-name that's\n    -    content-addressable from the content of the test script. If we can\n    -    update-ref that it's unique, if not we've got a duplicate. The tag\n    -    object stores the name of the earlier test for reporting the error.\n    +    In a subsequent commit we'll add an assertion to check whether we\n    +    caught all of the copy/pasting.\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n    - ## t/lib-subtest.sh ##\n    -@@\n    -+_assert_unique_sub_test () {\n    -+\tname=$1 &&\n    -+\n    -+\t# Alert about the copy/paste programming\n    -+\thash=$(git hash-object -w \"$name\") &&\n    -+\tcat >tag.sig <<-EOF &&\n    -+\tobject $hash\n    -+\ttype blob\n    -+\ttag $hash\n    -+\ttagger . <> 0 +0000\n    -+\n    -+\tduplicate script detected!\n    -+\n    -+\tThis test script was already written as:\n    -+\n    -+\t$name\n    -+\n    -+\tYou can just re-use its test code with your own\n    -+\trun_sub_test_lib_test*()\n    -+\tEOF\n    -+\n    -+\ttag=$(git mktag <tag.sig) &&\n    -+\tif ! git update-ref refs/tags/blob-$hash $tag $(test_oid zero) 2>/dev/null\n    -+\tthen\n    -+\t\tmsg=$(git for-each-ref refs/tags/blob-$hash \\\n    -+\t\t\t--format='%(contents)' refs/tags/blob-$hash)\n    -+\t\terror \"on write of $name: $msg\"\n    -+\t\treturn 1\n    -+\tfi\n    -+}\n    -+\n    - write_sub_test_lib_test () {\n    - \tname=\"$1\" # stdin is the body of the test code\n    - \tmkdir \"$name\" &&\n    -@@ t/lib-subtest.sh: write_sub_test_lib_test () {\n    - \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n    - \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n    - \tEOF\n    --\tcat >>\"$name/$name.sh\"\n    -+\tcat >>\"$name/$name.sh\" &&\n    -+\t_assert_unique_sub_test \"$name/$name.sh\"\n    - }\n    - \n    - _run_sub_test_lib_test_common () {\n    -\n      ## t/t0000-basic.sh ##\n     @@ t/t0000-basic.sh: test_expect_success 'subtest: --verbose option' '\n      '\n -:  ---------- >  6:  bc79b29f3c test-lib tests: assert no copy/pasted mock test code\n 6:  022ddbabf6 !  7:  48176f3e60 test-lib tests: avoid subshell for \"test_cmp\" for readability\n    @@ t/lib-subtest.sh: run_sub_test_lib_test_err () {\n     +\tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n     +\ttest_cmp \"$name\"/expect.err \"$name\"/err\n      }\n    - \n 7:  ae0226e164 =  8:  fda7c4fbe3 test-lib tests: refactor common part of check_sub_test_lib_test*()\n 8:  676547e001 =  9:  dd0af5bd6c test-lib tests: assert 1 exit code, not non-zero\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432079","messageId":"patch-v3-1.9-3f34420a3e-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 1/9] test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:20Z","receivedAt":"2021-08-05T10:37:39Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the \"check_sub_test_lib_test()\" and its sister functions to a new\nlib-subtest.sh.\n\nIn the future (not in this series) I'd like to test test-lib's output\nin a more targeted and smaller test, and I'll need these functions to\ndo that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++\n t/t0000-basic.sh | 88 +-----------------------------------------------\n 2 files changed, 87 insertions(+), 87 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nnew file mode 100644\nindex 0000000000..3cfe09911a\n--- /dev/null\n+++ b/t/lib-subtest.sh\n@@ -0,0 +1,86 @@\n+_run_sub_test_lib_test_common () {\n+\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n+\tshift 3\n+\n+\t# intercept pseudo-options at the front of the argument list that we\n+\t# will not pass to child script\n+\tskip=\n+\twhile test $# -gt 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--skip=*)\n+\t\t\tskip=${1#--*=}\n+\t\t\tshift\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\n+\tmkdir \"$name\" &&\n+\t(\n+\t\t# Pretend we're not running under a test harness, whether we\n+\t\t# are or not. The test-lib output depends on the setting of\n+\t\t# this variable, so we need a stable setting under which to run\n+\t\t# the sub-test.\n+\t\tsane_unset HARNESS_ACTIVE &&\n+\t\tcd \"$name\" &&\n+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\t\ttest_description='$descr (run in sub test-lib)\n+\n+\t\tThis is run in a sub test-lib so that we do not get incorrect\n+\t\tpassing metrics\n+\t\t'\n+\n+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\t\tEOF\n+\t\tcat >>\"$name.sh\" &&\n+\t\texport TEST_DIRECTORY &&\n+\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n+\t\t# override the test output directory. We thus pass it as an\n+\t\t# explicit override to the child.\n+\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n+\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n+\t\tGIT_SKIP_TESTS=$skip &&\n+\t\texport GIT_SKIP_TESTS &&\n+\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n+\t\tif test -z \"$neg\"\n+\t\tthen\n+\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n+\t\telse\n+\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n+\t\tfi\n+\t)\n+}\n+\n+run_sub_test_lib_test () {\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+run_sub_test_lib_test_err () {\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n+check_sub_test_lib_test () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t(\n+\t\tcd \"$name\" &&\n+\t\ttest_must_be_empty err &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n+\t\ttest_cmp expect out\n+\t)\n+}\n+\n+check_sub_test_lib_test_err () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t# expected error output is in descriptor 3\n+\t(\n+\t\tcd \"$name\" &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n+\t\ttest_cmp expect.out out &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n+\t\ttest_cmp expect.err err\n+\t)\n+}\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex cb87768513..a3865dd77b 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -19,6 +19,7 @@ modification *should* take notice and update the test vectors here.\n '\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-subtest.sh\n \n try_local_xy () {\n \tlocal x=\"local\" y=\"alsolocal\" &&\n@@ -66,93 +67,6 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-_run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n-\n-\t# intercept pseudo-options at the front of the argument list that we\n-\t# will not pass to child script\n-\tskip=\n-\twhile test $# -gt 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t--skip=*)\n-\t\t\tskip=${1#--*=}\n-\t\t\tshift\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\tdone\n-\n-\tmkdir \"$name\" &&\n-\t(\n-\t\t# Pretend we're not running under a test harness, whether we\n-\t\t# are or not. The test-lib output depends on the setting of\n-\t\t# this variable, so we need a stable setting under which to run\n-\t\t# the sub-test.\n-\t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n-\n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n-\n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n-\t\texport TEST_DIRECTORY &&\n-\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n-\t\t# override the test output directory. We thus pass it as an\n-\t\t# explicit override to the child.\n-\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n-\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n-\t\tGIT_SKIP_TESTS=$skip &&\n-\t\texport GIT_SKIP_TESTS &&\n-\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n-\t)\n-}\n-\n-run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n-}\n-\n-run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n-}\n-\n-check_sub_test_lib_test () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n-}\n-\n-check_sub_test_lib_test_err () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n-}\n-\n test_expect_success 'pretend we have a fully passing test suite' '\n \trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432081","messageId":"patch-v3-2.9-c9c16016da-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 2/9] test-lib tests: split up \"write and run\" into two functions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:21Z","receivedAt":"2021-08-05T10:37:41Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the function to write and run tests of the test-lib.sh output\ninto two functions.\n\nWhen this was added back in 565b6fa87bb (tests: refactor mechanics of\ntesting in a sub test-lib, 2012-12-16) there was no reason to do this,\nbut since we started supporting test arguments in\n517cd55fd51 (test-lib: self-test that --verbose works, 2013-06-23)\nwe've started to write out duplicate tests simply to test different\narguments, now we'll be able to re-use them.\n\nThis change doesn't consolidate any of those tests yet, it just makes\nit possible to do so. All the changes in t0000-basic.sh are a simple\nsearch-replacement.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 45 +++++++++++++++++++++--------\n t/t0000-basic.sh | 74 ++++++++++++++++++++++++------------------------\n 2 files changed, 70 insertions(+), 49 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 3cfe09911a..58ae316ad5 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,3 +1,22 @@\n+write_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tmkdir \"$name\" &&\n+\t(\n+\t\tcd \"$name\" &&\n+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\t\ttest_description='$descr (run in sub test-lib)\n+\n+\t\tThis is run in a sub test-lib so that we do not get incorrect\n+\t\tpassing metrics\n+\t\t'\n+\n+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\t\tEOF\n+\t\tcat >>\"$name.sh\"\n+\t)\n+}\n+\n _run_sub_test_lib_test_common () {\n \tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n \tshift 3\n@@ -18,25 +37,15 @@ _run_sub_test_lib_test_common () {\n \t\tesac\n \tdone\n \n-\tmkdir \"$name\" &&\n \t(\n+\t\tcd \"$name\" &&\n+\n \t\t# Pretend we're not running under a test harness, whether we\n \t\t# are or not. The test-lib output depends on the setting of\n \t\t# this variable, so we need a stable setting under which to run\n \t\t# the sub-test.\n \t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n \n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n-\n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n \t\texport TEST_DIRECTORY &&\n \t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n \t\t# override the test output directory. We thus pass it as an\n@@ -55,6 +64,18 @@ _run_sub_test_lib_test_common () {\n \t)\n }\n \n+write_and_run_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+write_and_run_sub_test_lib_test_err () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n run_sub_test_lib_test () {\n \t_run_sub_test_lib_test_common '' \"$@\"\n }\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex a3865dd77b..a7c5aaacab 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -68,7 +68,7 @@ test_expect_success 'success is reported like this' '\n '\n \n test_expect_success 'pretend we have a fully passing test suite' '\n-\trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -85,7 +85,7 @@ test_expect_success 'pretend we have a fully passing test suite' '\n '\n \n test_expect_success 'pretend we have a partially passing test suite' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n@@ -103,7 +103,7 @@ test_expect_success 'pretend we have a partially passing test suite' '\n '\n \n test_expect_success 'pretend we have a known breakage' '\n-\trun_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -118,7 +118,7 @@ test_expect_success 'pretend we have a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed a known breakage' '\n-\trun_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -130,7 +130,7 @@ test_expect_success 'pretend we have fixed a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\trun_sub_test_lib_test partially-passing-todos \\\n+\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n \t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n@@ -149,7 +149,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n '\n \n test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n@@ -168,7 +168,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n '\n \n test_expect_success 'pretend we have a mix of all possible results' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -204,7 +204,7 @@ test_expect_success 'pretend we have a mix of all possible results' '\n '\n \n test_expect_success 'test --verbose' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -231,7 +231,7 @@ test_expect_success 'test --verbose' '\n '\n \n test_expect_success 'test --verbose-only' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n@@ -255,7 +255,7 @@ test_expect_success 'test --verbose-only' '\n \n test_expect_success 'GIT_SKIP_TESTS' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-basic \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n \t\t\t\"GIT_SKIP_TESTS\" \\\n \t\t\t--skip=\"git.2\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -276,7 +276,7 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \n test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n \t\t\t\"GIT_SKIP_TESTS several tests\" \\\n \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n@@ -300,7 +300,7 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \n test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-sh-pattern \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n \t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n@@ -324,7 +324,7 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \n test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-entire-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n \t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n \t\t\t--skip=\"git\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -341,7 +341,7 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \n test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-unmatched-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n \t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n \t\t\t--skip=\"notgit\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -361,7 +361,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success '--run basic' '\n-\trun_sub_test_lib_test run-basic \\\n+\twrite_and_run_sub_test_lib_test run-basic \\\n \t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -382,7 +382,7 @@ test_expect_success '--run basic' '\n '\n \n test_expect_success '--run with a range' '\n-\trun_sub_test_lib_test run-range \\\n+\twrite_and_run_sub_test_lib_test run-range \\\n \t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -403,7 +403,7 @@ test_expect_success '--run with a range' '\n '\n \n test_expect_success '--run with two ranges' '\n-\trun_sub_test_lib_test run-two-ranges \\\n+\twrite_and_run_sub_test_lib_test run-two-ranges \\\n \t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -424,7 +424,7 @@ test_expect_success '--run with two ranges' '\n '\n \n test_expect_success '--run with a left open range' '\n-\trun_sub_test_lib_test run-left-open-range \\\n+\twrite_and_run_sub_test_lib_test run-left-open-range \\\n \t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -445,7 +445,7 @@ test_expect_success '--run with a left open range' '\n '\n \n test_expect_success '--run with a right open range' '\n-\trun_sub_test_lib_test run-right-open-range \\\n+\twrite_and_run_sub_test_lib_test run-right-open-range \\\n \t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -466,7 +466,7 @@ test_expect_success '--run with a right open range' '\n '\n \n test_expect_success '--run with basic negation' '\n-\trun_sub_test_lib_test run-basic-neg \\\n+\twrite_and_run_sub_test_lib_test run-basic-neg \\\n \t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -487,7 +487,7 @@ test_expect_success '--run with basic negation' '\n '\n \n test_expect_success '--run with two negations' '\n-\trun_sub_test_lib_test run-two-neg \\\n+\twrite_and_run_sub_test_lib_test run-two-neg \\\n \t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -508,7 +508,7 @@ test_expect_success '--run with two negations' '\n '\n \n test_expect_success '--run a range and negation' '\n-\trun_sub_test_lib_test run-range-and-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n \t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -529,7 +529,7 @@ test_expect_success '--run a range and negation' '\n '\n \n test_expect_success '--run range negation' '\n-\trun_sub_test_lib_test run-range-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-neg \\\n \t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -550,7 +550,7 @@ test_expect_success '--run range negation' '\n '\n \n test_expect_success '--run include, exclude and include' '\n-\trun_sub_test_lib_test run-inc-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n \t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -572,7 +572,7 @@ test_expect_success '--run include, exclude and include' '\n '\n \n test_expect_success '--run include, exclude and include, comma separated' '\n-\trun_sub_test_lib_test run-inc-neg-inc-comma \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n \t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -594,7 +594,7 @@ test_expect_success '--run include, exclude and include, comma separated' '\n '\n \n test_expect_success '--run exclude and include' '\n-\trun_sub_test_lib_test run-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-neg-inc \\\n \t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -616,7 +616,7 @@ test_expect_success '--run exclude and include' '\n '\n \n test_expect_success '--run empty selectors' '\n-\trun_sub_test_lib_test run-empty-sel \\\n+\twrite_and_run_sub_test_lib_test run-empty-sel \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -638,7 +638,7 @@ test_expect_success '--run empty selectors' '\n '\n \n test_expect_success '--run substring selector' '\n-\trun_sub_test_lib_test run-substring-selector \\\n+\twrite_and_run_sub_test_lib_test run-substring-selector \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n@@ -662,7 +662,7 @@ test_expect_success '--run substring selector' '\n '\n \n test_expect_success '--run keyword selection' '\n-\trun_sub_test_lib_test_err run-inv-range-start \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n \t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -677,7 +677,7 @@ test_expect_success '--run keyword selection' '\n '\n \n test_expect_success '--run invalid range end' '\n-\trun_sub_test_lib_test_err run-inv-range-end \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n \t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -692,7 +692,7 @@ test_expect_success '--run invalid range end' '\n '\n \n test_expect_success 'tests respect prerequisites' '\n-\trun_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -722,7 +722,7 @@ test_expect_success 'tests respect prerequisites' '\n '\n \n test_expect_success 'tests respect lazy prerequisites' '\n-\trun_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -746,7 +746,7 @@ test_expect_success 'tests respect lazy prerequisites' '\n '\n \n test_expect_success 'nested lazy prerequisites' '\n-\trun_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -772,7 +772,7 @@ test_expect_success 'nested lazy prerequisites' '\n '\n \n test_expect_success 'lazy prereqs do not turn off tracing' '\n-\trun_sub_test_lib_test lazy-prereq-and-tracing \\\n+\twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n \t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n@@ -785,7 +785,7 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n '\n \n test_expect_success 'tests clean up after themselves' '\n-\trun_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -805,7 +805,7 @@ test_expect_success 'tests clean up after themselves' '\n '\n \n test_expect_success 'tests clean up even on failures' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n@@ -834,7 +834,7 @@ test_expect_success 'tests clean up even on failures' '\n '\n \n test_expect_success 'test_atexit is run' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432080","messageId":"patch-v3-3.9-76f57eadcd-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 3/9] test-lib tests: stop using a subshell in write_sub_test_lib_test()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:22Z","receivedAt":"2021-08-05T10:37:43Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that this function doesn't handle running the test anymore we can\ndo away with the sub-shell, which was used to scope an \"unset\" and\n\"export\" shell variables.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 58ae316ad5..21fa570d0b 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,20 +1,17 @@\n write_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n-\t(\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n+\twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\ttest_description='$descr (run in sub test-lib)\n \n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n+\tThis is run in a sub test-lib so that we do not get incorrect\n+\tpassing metrics\n+\t'\n \n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\"\n-\t)\n+\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\tEOF\n+\tcat >>\"$name/$name.sh\"\n }\n \n _run_sub_test_lib_test_common () {\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432082","messageId":"patch-v3-5.9-7d1e6b9a3e-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 5/9] test-lib tests: get rid of copy/pasted mock test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:24Z","receivedAt":"2021-08-05T10:37:45Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that we've split up the write_sub_test_lib_test*() and\nrun_sub_test_lib_test*() functions let's fix those tests in\nt0000-basic.sh that were verbosely copy/pasting earlier tests.\n\nIn a subsequent commit we'll add an assertion to check whether we\ncaught all of the copy/pasting.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 228 +++++++++++++----------------------------------\n 1 file changed, 60 insertions(+), 168 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 6fdd5f43ca..a0b99d8334 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -226,18 +226,13 @@ test_expect_success 'subtest: --verbose option' '\n '\n \n test_expect_success 'subtest: --verbose-only option' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \\\n-\t\t--verbose-only=2 <<-\\EOF &&\n-\ttest_expect_success \"passing test\" true\n-\ttest_expect_success \"test with output\" \"echo foo\"\n-\ttest_expect_success \"failing test\" false\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test t2345-verbose-only-2 <<-\\EOF\n+\trun_sub_test_lib_test_err \\\n+\t\tt1234-verbose \\\n+\t\t--verbose-only=2 &&\n+\tcheck_sub_test_lib_test t1234-verbose <<-\\EOF\n \t> ok 1 - passing test\n \t> Z\n-\t> expecting success of 2345.2 '\\''test with output'\\'': echo foo\n+\t> expecting success of 1234.2 '\\''test with output'\\'': echo foo\n \t> foo\n \t> ok 2 - test with output\n \t> Z\n@@ -250,15 +245,9 @@ test_expect_success 'subtest: --verbose-only option' '\n \n test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t--skip=\"git.2\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-basic <<-\\EOF\n+\t\trun_sub_test_lib_test full-pass \\\n+\t\t\t--skip=\"full.2\" &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 - passing test #3\n@@ -293,15 +282,9 @@ test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n-\t\tfor i in 1 2 3 4 5 6\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF\n+\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t\t--skip=\"git.[2-5]\" &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 # skip passing test #3 (GIT_SKIP_TESTS)\n@@ -316,15 +299,10 @@ test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t--skip=\"git\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t\t--skip=\"git\" &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> 1..0 # SKIP skip all tests in git\n \t\tEOF\n \t)\n@@ -332,15 +310,10 @@ test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t--skip=\"notgit\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test full-pass \\\n+\t\t\t--skip=\"notfull\" &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 - passing test #2\n \t\t> ok 3 - passing test #3\n@@ -351,14 +324,8 @@ test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success 'subtest: --run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several --run=\"1,3,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -371,15 +338,9 @@ test_expect_success 'subtest: --run basic' '\n '\n \n test_expect_success 'subtest: --run with a range' '\n-\twrite_and_run_sub_test_lib_test run-range \\\n-\t\t--run=\"1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -392,15 +353,9 @@ test_expect_success 'subtest: --run with a range' '\n '\n \n test_expect_success 'subtest: --run with two ranges' '\n-\twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-ranges <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-2,5-6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -413,15 +368,9 @@ test_expect_success 'subtest: --run with two ranges' '\n '\n \n test_expect_success 'subtest: --run with a left open range' '\n-\twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t--run=\"-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-left-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -434,15 +383,9 @@ test_expect_success 'subtest: --run with a left open range' '\n '\n \n test_expect_success 'subtest: --run with a right open range' '\n-\twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t--run=\"4-\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-right-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"4-\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -455,15 +398,9 @@ test_expect_success 'subtest: --run with a right open range' '\n '\n \n test_expect_success 'subtest: --run with basic negation' '\n-\twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t--run=\"!3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -476,15 +413,9 @@ test_expect_success 'subtest: --run with basic negation' '\n '\n \n test_expect_success 'subtest: --run with two negations' '\n-\twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t--run=\"!3,!6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3,!6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -497,15 +428,9 @@ test_expect_success 'subtest: --run with two negations' '\n '\n \n test_expect_success 'subtest: --run a range and negation' '\n-\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t--run=\"-4,!2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-and-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-4,!2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -518,15 +443,9 @@ test_expect_success 'subtest: --run a range and negation' '\n '\n \n test_expect_success 'subtest: --run range negation' '\n-\twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t--run=\"!1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -539,15 +458,9 @@ test_expect_success 'subtest: --run range negation' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-5,!1-3,2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -560,15 +473,9 @@ test_expect_success 'subtest: --run include, exclude and include' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t--run=1-5,!1-3,2 <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=1-5,!1-3,2 &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -581,15 +488,9 @@ test_expect_success 'subtest: --run include, exclude and include, comma separate\n '\n \n test_expect_success 'subtest: --run exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t--run=\"!3-,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3-,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -602,15 +503,9 @@ test_expect_success 'subtest: --run exclude and include' '\n '\n \n test_expect_success 'subtest: --run empty selectors' '\n-\twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-empty-sel <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1,,3,,,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -660,12 +555,9 @@ test_expect_success 'subtest: --run keyword selection' '\n '\n \n test_expect_success 'subtest: --run invalid range end' '\n-\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t--run=\"1-z\" <<-\\EOF &&\n-\ttest_expect_success \"passing test #1\" \"true\"\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test_err run-inv-range-end \\\n+\trun_sub_test_lib_test_err run-inv-range-start \\\n+\t\t--run=\"1-z\" &&\n+\tcheck_sub_test_lib_test_err run-inv-range-start \\\n \t\t<<-\\EOF_OUT 3<<-EOF_ERR\n \t> FATAL: Unexpected exit with code 1\n \tEOF_OUT\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432083","messageId":"patch-v3-4.9-cde015c7dd-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 4/9] test-lib tests: don't provide a description for the sub-tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:23Z","receivedAt":"2021-08-05T10:37:46Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the $test_description provided for the generated subtests to be\nconstant, since the only purpose of having it is that test-lib.sh will\nbarf if it isn't supplied.\n\nThe other purpose of having it was to effectively split up the test\ndescription between the argument to test_expect_success and the\nargument to \"write_and_run_sub_test_lib_test\". Let's only use one of\nthe two.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh |  12 ++--\n t/t0000-basic.sh | 142 +++++++++++++++++++++--------------------------\n 2 files changed, 66 insertions(+), 88 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 21fa570d0b..cdbc2d9332 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,12 +1,8 @@\n write_sub_test_lib_test () {\n-\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n \twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\ttest_description='$descr (run in sub test-lib)\n-\n-\tThis is run in a sub test-lib so that we do not get incorrect\n-\tpassing metrics\n-\t'\n+\ttest_description='A test of test-lib.sh itself'\n \n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n@@ -15,8 +11,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n+\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n+\tshift 2\n \n \t# intercept pseudo-options at the front of the argument list that we\n \t# will not pass to child script\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex a7c5aaacab..6fdd5f43ca 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -67,8 +67,8 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-test_expect_success 'pretend we have a fully passing test suite' '\n-\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+test_expect_success 'subtest: 3 passing tests' '\n+\twrite_and_run_sub_test_lib_test full-pass <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -84,9 +84,8 @@ test_expect_success 'pretend we have a fully passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a partially passing test suite' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2/3 tests passing' '\n+\twrite_and_run_sub_test_lib_test_err partial-pass <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n \ttest_expect_success \"passing test #3\" \"true\"\n@@ -102,8 +101,8 @@ test_expect_success 'pretend we have a partially passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a known breakage' '\n-\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a failing TODO test' '\n+\twrite_and_run_sub_test_lib_test failing-todo <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -117,8 +116,8 @@ test_expect_success 'pretend we have a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed a known breakage' '\n-\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a passing TODO test' '\n+\twrite_and_run_sub_test_lib_test passing-todo <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -129,9 +128,8 @@ test_expect_success 'pretend we have fixed a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n-\t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2 TODO tests, one passin' '\n+\twrite_and_run_sub_test_lib_test partially-passing-todos <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n \ttest_expect_failure \"pretend we have fixed another known breakage\" \"true\"\n@@ -148,9 +146,8 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n \tEOF\n '\n \n-test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: pass, failure and a TODO test' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results1 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n@@ -167,9 +164,8 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a mix of all possible results' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: a mixture of all possible results' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -203,9 +199,8 @@ test_expect_success 'pretend we have a mix of all possible results' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n+test_expect_success 'subtest: --verbose option' '\n+\twrite_and_run_sub_test_lib_test_err t1234-verbose --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n \ttest_expect_success \"failing test\" false\n@@ -230,9 +225,9 @@ test_expect_success 'test --verbose' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose-only' '\n+test_expect_success 'subtest: --verbose-only option' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n+\t\tt2345-verbose-only-2 \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -253,10 +248,9 @@ test_expect_success 'test --verbose-only' '\n \tEOF\n '\n \n-test_expect_success 'GIT_SKIP_TESTS' '\n+test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t\"GIT_SKIP_TESTS\" \\\n \t\t\t--skip=\"git.2\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -274,10 +268,9 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS several tests' '\n+test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n-\t\t\t\"GIT_SKIP_TESTS several tests\" \\\n \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -298,10 +291,9 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n+test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -322,10 +314,9 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS entire suite' '\n+test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n \t\t\t--skip=\"git\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -339,10 +330,9 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n+test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n \t\t\t--skip=\"notgit\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -360,9 +350,8 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t)\n '\n \n-test_expect_success '--run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic \\\n-\t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n+test_expect_success 'subtest: --run basic' '\n+\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -381,9 +370,9 @@ test_expect_success '--run basic' '\n \tEOF\n '\n \n-test_expect_success '--run with a range' '\n+test_expect_success 'subtest: --run with a range' '\n \twrite_and_run_sub_test_lib_test run-range \\\n-\t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n+\t\t--run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -402,9 +391,9 @@ test_expect_success '--run with a range' '\n \tEOF\n '\n \n-test_expect_success '--run with two ranges' '\n+test_expect_success 'subtest: --run with two ranges' '\n \twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n+\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -423,9 +412,9 @@ test_expect_success '--run with two ranges' '\n \tEOF\n '\n \n-test_expect_success '--run with a left open range' '\n+test_expect_success 'subtest: --run with a left open range' '\n \twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n+\t\t--run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -444,9 +433,9 @@ test_expect_success '--run with a left open range' '\n \tEOF\n '\n \n-test_expect_success '--run with a right open range' '\n+test_expect_success 'subtest: --run with a right open range' '\n \twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n+\t\t--run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -465,9 +454,9 @@ test_expect_success '--run with a right open range' '\n \tEOF\n '\n \n-test_expect_success '--run with basic negation' '\n+test_expect_success 'subtest: --run with basic negation' '\n \twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n+\t\t--run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -486,9 +475,9 @@ test_expect_success '--run with basic negation' '\n \tEOF\n '\n \n-test_expect_success '--run with two negations' '\n+test_expect_success 'subtest: --run with two negations' '\n \twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n+\t\t--run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -507,9 +496,9 @@ test_expect_success '--run with two negations' '\n \tEOF\n '\n \n-test_expect_success '--run a range and negation' '\n+test_expect_success 'subtest: --run a range and negation' '\n \twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n+\t\t--run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -528,9 +517,9 @@ test_expect_success '--run a range and negation' '\n \tEOF\n '\n \n-test_expect_success '--run range negation' '\n+test_expect_success 'subtest: --run range negation' '\n \twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n+\t\t--run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -549,9 +538,8 @@ test_expect_success '--run range negation' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include' '\n+test_expect_success 'subtest: --run include, exclude and include' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -571,9 +559,8 @@ test_expect_success '--run include, exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include, comma separated' '\n+test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -593,9 +580,8 @@ test_expect_success '--run include, exclude and include, comma separated' '\n \tEOF\n '\n \n-test_expect_success '--run exclude and include' '\n+test_expect_success 'subtest: --run exclude and include' '\n \twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -615,9 +601,8 @@ test_expect_success '--run exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run empty selectors' '\n+test_expect_success 'subtest: --run empty selectors' '\n \twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -637,9 +622,8 @@ test_expect_success '--run empty selectors' '\n \tEOF\n '\n \n-test_expect_success '--run substring selector' '\n+test_expect_success 'subtest: --run substring selector' '\n \twrite_and_run_sub_test_lib_test run-substring-selector \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n \tfor i in 1 2 3 4 5 6\n@@ -661,9 +645,8 @@ test_expect_success '--run substring selector' '\n \tEOF\n '\n \n-test_expect_success '--run keyword selection' '\n+test_expect_success 'subtest: --run keyword selection' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n-\t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -676,9 +659,8 @@ test_expect_success '--run keyword selection' '\n \tEOF_ERR\n '\n \n-test_expect_success '--run invalid range end' '\n+test_expect_success 'subtest: --run invalid range end' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -691,8 +673,8 @@ test_expect_success '--run invalid range end' '\n \tEOF_ERR\n '\n \n-test_expect_success 'tests respect prerequisites' '\n-\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect prerequisites' '\n+\twrite_and_run_sub_test_lib_test prereqs <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -721,8 +703,8 @@ test_expect_success 'tests respect prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'tests respect lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test lazy-prereqs <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -745,8 +727,8 @@ test_expect_success 'tests respect lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'nested lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: nested lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test nested-lazy <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -771,9 +753,9 @@ test_expect_success 'nested lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'lazy prereqs do not turn off tracing' '\n+test_expect_success 'subtest: lazy prereqs do not turn off tracing' '\n \twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n-\t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n+\t\t-v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n \ttest_expect_success lazy \"test_have_prereq LAZY && echo trace\"\n@@ -784,8 +766,8 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n \tgrep \"echo trace\" lazy-prereq-and-tracing/err\n '\n \n-test_expect_success 'tests clean up after themselves' '\n-\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+test_expect_success 'subtest: tests clean up after themselves' '\n+\twrite_and_run_sub_test_lib_test cleanup <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -804,9 +786,9 @@ test_expect_success 'tests clean up after themselves' '\n \tEOF\n '\n \n-test_expect_success 'tests clean up even on failures' '\n+test_expect_success 'subtest: tests clean up even on failures' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n+\t\tfailing-cleanup <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n \t\ttest_when_finished rm clean-after-failure &&\n@@ -833,9 +815,9 @@ test_expect_success 'tests clean up even on failures' '\n \tEOF\n '\n \n-test_expect_success 'test_atexit is run' '\n+test_expect_success 'subtest: test_atexit is run' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n+\t\tatexit-cleanup -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n \t\ttest_atexit rm ../../clean-atexit &&\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432084","messageId":"patch-v3-6.9-bc79b29f3c-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 6/9] test-lib tests: assert no copy/pasted mock test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:25Z","receivedAt":"2021-08-05T10:37:47Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"In the preceding commit we got rid of a bunch of copy/pasted test code\nfrom t0000-basic.sh in favor of re-using earlier already set up tests.\n\nSince copy/pasting the tests is likely to be something done by mistake\nin the future, let's add an assertion that detects whether this has\nhappened.\n\nNow that we don't provide a unique test_description=\"\" to these tests\nwe can rely on the content written out being the same in this\ncase. Let's use the object store to hash it, and attempt to create a\n\"blob-<CONTENT_OID>\" tag. If another test has already written out the\nsame content we'll fail, and the tag envelope will provide an error\nmessage pointing us in the right direction..\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 34 +++++++++++++++++++++++++++++++++-\n 1 file changed, 33 insertions(+), 1 deletion(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex cdbc2d9332..6857afdaa5 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,3 +1,34 @@\n+_assert_unique_sub_test () {\n+\tname=$1 &&\n+\n+\t# Alert about the copy/paste programming\n+\thash=$(git hash-object -w \"$name\") &&\n+\tcat >tag.sig <<-EOF &&\n+\tobject $hash\n+\ttype blob\n+\ttag $hash\n+\ttagger . <> 0 +0000\n+\n+\tduplicate script detected!\n+\n+\tThis test script was already written as:\n+\n+\t$name\n+\n+\tYou can just re-use its test code with your own\n+\trun_sub_test_lib_test*()\n+\tEOF\n+\n+\ttag=$(git mktag <tag.sig) &&\n+\tif ! git update-ref refs/tags/blob-$hash $tag $(test_oid zero) 2>/dev/null\n+\tthen\n+\t\tmsg=$(git for-each-ref refs/tags/blob-$hash \\\n+\t\t\t--format='%(contents)' refs/tags/blob-$hash)\n+\t\terror \"on write of $name: $msg\"\n+\t\treturn 1\n+\tfi\n+}\n+\n write_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n@@ -7,7 +38,8 @@ write_sub_test_lib_test () {\n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n \tEOF\n-\tcat >>\"$name/$name.sh\"\n+\tcat >>\"$name/$name.sh\" &&\n+\t_assert_unique_sub_test \"$name/$name.sh\"\n }\n \n _run_sub_test_lib_test_common () {\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432085","messageId":"patch-v3-7.9-48176f3e60-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 7/9] test-lib tests: avoid subshell for \"test_cmp\" for readability","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:26Z","receivedAt":"2021-08-05T10:37:48Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The use of a sub-shell for running the test_cmp of stdout/stderr for\nthe test author was introduced in this form in 565b6fa87bb (tests:\nrefactor mechanics of testing in a sub test-lib, 2012-12-16), but from\nlooking at the history that seemed to have diligently copied my\noriginal ad-hoc implementation in 7b905119703 (t/t0000-basic.sh: Run\nthe passing TODO test inside its own test-lib, 2010-08-19).\n\nThere's no reason to use a subshell here, we try to avoid it in\ngeneral. It also improves readability, if the test fails we print out\nthe relative path in the trash directory that needs to be looked\nat.\n\nBefore that was mostly obscured, since the \"write_sub_test_lib_test\"\nwill pick the directory for you from the test name.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 20 +++++++-------------\n 1 file changed, 7 insertions(+), 13 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 6857afdaa5..529f3a4d08 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -111,22 +111,16 @@ run_sub_test_lib_test_err () {\n \n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n+\ttest_must_be_empty \"$name\"/err &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n+\ttest_cmp \"$name/\"expect \"$name\"/out\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n \t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n+\tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n+\ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432086","messageId":"patch-v3-8.9-fda7c4fbe3-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 8/9] test-lib tests: refactor common part of check_sub_test_lib_test*()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:27Z","receivedAt":"2021-08-05T10:37:51Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the two check_sub_test_lib_test*() functions to avoid\nduplicating the same comparison they did of stdout. This duplication\nwas initially added when check_sub_test_lib_test_err() was added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 529f3a4d08..0b9ecdb6db 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -109,18 +109,22 @@ run_sub_test_lib_test_err () {\n \t_run_sub_test_lib_test_common '!' \"$@\"\n }\n \n+_check_sub_test_lib_test_common () {\n+\tname=\"$1\" &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out\n+}\n+\n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\ttest_must_be_empty \"$name\"/err &&\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n-\ttest_cmp \"$name/\"expect \"$name\"/out\n+\t_check_sub_test_lib_test_common \"$name\" &&\n+\ttest_must_be_empty \"$name\"/err\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n+\t_check_sub_test_lib_test_common \"$name\" &&\n \t# expected error output is in descriptor 3\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n-\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n \tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n \ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"432087","messageId":"patch-v3-9.9-dd0af5bd6c-20210805T103237Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v3 9/9] test-lib tests: assert 1 exit code, not non-zero","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-08-05T10:37:28Z","receivedAt":"2021-08-05T10:37:53Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Improve the testing for test-lib.sh itself to assert that we have a\nexit code of 1, not any non-zero. Improves code added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 0b9ecdb6db..d6b625d397 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -43,8 +43,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n-\tshift 2\n+\tcmp_op=\"$1\" want_code=\"$2\" name=\"$3\" # stdin is the body of the test code\n+\tshift 3\n \n \t# intercept pseudo-options at the front of the argument list that we\n \t# will not pass to child script\n@@ -80,33 +80,30 @@ _run_sub_test_lib_test_common () {\n \t\tGIT_SKIP_TESTS=$skip &&\n \t\texport GIT_SKIP_TESTS &&\n \t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n+\t\t./\"$name.sh\" \"$@\" >out 2>err;\n+\t\tret=$? &&\n+\t\ttest \"$ret\" \"$cmp_op\" \"$want_code\"\n \t)\n }\n \n write_and_run_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n write_and_run_sub_test_lib_test_err () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n _check_sub_test_lib_test_common () {\n-- \n2.33.0.rc0.635.g0ab9d6d3b5a\n\n"},{"id":"436708","messageId":"CAPUEsphB3cdCx3js3-_7-o7nvqsREPcqLwsTwTfaRDNT8v863g@mail.gmail.com","threadId":"55925","inReplyTo":"patch-v3-3.9-76f57eadcd-20210805T103237Z-avarab@gmail.com","subject":"Re: [PATCH v3 3/9] test-lib tests: stop using a subshell in write_sub_test_lib_test()","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2021-09-22T07:54:16Z","receivedAt":"2021-09-22T07:54:33Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"Why does this need to be independent and can't be squashed into patch 2?\n\nCarlo\n"},{"id":"436709","messageId":"CAPUEspg3pT1F5YMwGuwvmiyMGoYLUB0neHeunXnLxwc_G9zN-A@mail.gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"Re: [PATCH v3 0/9] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Carlo Arenas","fromEmail":"carenas@gmail.com","sentAt":"2021-09-22T08:33:12Z","receivedAt":"2021-09-22T08:33:26Z","isPatch":true,"sender":{"key":"carenas@gmail.com","avatar":"https://avatars.githubusercontent.com/u/76036?v=4"},"body":"On Thu, Aug 5, 2021 at 5:37 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:\n>\n> The only tricky part of this series is the \"clever\" way of (ab)using\n> the object store and tags to detect copy/pasted tests. For this v3\n> I've split that up into its own commit, see [56]/9 for the removal of\n> the copy/pasting and the assertion, respectively.\n\nI think this series would be better without that assertion (commit).\n\nWhile it is cool, it seems misplaced as it makes sense running ONLY\nwhen subtests had been added, and therefore probably as part of some\n\"lint\" job (ex: \"as part of the static analysis CI job\"), instead of\nevery time this is called.\n\nFWIW, it is not only the conceptual misplacement that is a problem,\nbut as coded a bug in git, could make these tests fail for a totally\nunrelated reason and therefore be confusing.\n\nOther than that and my comment about probably avoiding the in series\nrewriting of a function which might have been me not understanding the\ncommit message, got my \"Reviewed-by\" for what it is worth.\n\nCarlo\n"},{"id":"436716","messageId":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com","subject":"[PATCH v4 0/7] test-lib tests: split off subtest code in t0000 into lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:46Z","receivedAt":"2021-09-22T11:20:02Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"A re-roll of v3[1] of this cleanup/refactoring of t0000-basic.sh\nseries which addresses Carlo's comments on it, thanks for the review\nCarlo!\n\nI.e. the old 3/9 is squashed into a 2/7, and the assertion of\nnon-duplicate tests is now ejected. I left a note in 7/7 that we may\nwant it in the future, but for now let's punt on it.\n\n1. https://lore.kernel.org/git/cover-v3-0.9-0000000000-20210805T103237Z-avarab@gmail.com/\n2. https://lore.kernel.org/git/CAPUEspg3pT1F5YMwGuwvmiyMGoYLUB0neHeunXnLxwc_G9zN-A@mail.gmail.com/\n\nÆvar Arnfjörð Bjarmason (7):\n  test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n  test-lib tests: split up \"write and run\" into two functions\n  test-lib tests: don't provide a description for the sub-tests\n  test-lib tests: avoid subshell for \"test_cmp\" for readability\n  test-lib tests: refactor common part of check_sub_test_lib_test*()\n  test-lib tests: assert 1 exit code, not non-zero\n  test-lib tests: get rid of copy/pasted mock test code\n\n t/lib-subtest.sh |  95 ++++++++++\n t/t0000-basic.sh | 448 +++++++++++++----------------------------------\n 2 files changed, 213 insertions(+), 330 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\nRange-diff against v3:\n 1:  3f34420a3e1 =  1:  f915bc2ee77 test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh\n 2:  c9c16016da6 !  2:  5b5038867df test-lib tests: split up \"write and run\" into two functions\n    @@ Commit message\n         it possible to do so. All the changes in t0000-basic.sh are a simple\n         search-replacement.\n     \n    +    Since the _run_sub_test_lib_test_common() function doesn't handle\n    +    running the test anymore we can do away with the sub-shell, which was\n    +    used to scope an \"unset\" and \"export\" shell variables.\n    +\n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n      ## t/lib-subtest.sh ##\n    @@ t/lib-subtest.sh\n     +write_sub_test_lib_test () {\n     +\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n     +\tmkdir \"$name\" &&\n    -+\t(\n    -+\t\tcd \"$name\" &&\n    -+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n    -+\t\ttest_description='$descr (run in sub test-lib)\n    ++\twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n    ++\ttest_description='$descr (run in sub test-lib)\n     +\n    -+\t\tThis is run in a sub test-lib so that we do not get incorrect\n    -+\t\tpassing metrics\n    -+\t\t'\n    ++\tThis is run in a sub test-lib so that we do not get incorrect\n    ++\tpassing metrics\n    ++\t'\n     +\n    -+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n    -+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n    -+\t\tEOF\n    -+\t\tcat >>\"$name.sh\"\n    -+\t)\n    ++\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n    ++\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n    ++\tEOF\n    ++\tcat >>\"$name/$name.sh\"\n     +}\n     +\n      _run_sub_test_lib_test_common () {\n    @@ t/lib-subtest.sh: _run_sub_test_lib_test_common () {\n     -\t\tcd \"$name\" &&\n     -\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n     -\t\ttest_description='$descr (run in sub test-lib)\n    - \n    +-\n     -\t\tThis is run in a sub test-lib so that we do not get incorrect\n     -\t\tpassing metrics\n     -\t\t'\n    --\n    + \n     -\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n     -\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n     -\t\tEOF\n 3:  76f57eadcdd <  -:  ----------- test-lib tests: stop using a subshell in write_sub_test_lib_test()\n 4:  cde015c7dd0 =  3:  78177ce1729 test-lib tests: don't provide a description for the sub-tests\n 7:  48176f3e60c =  4:  a581bff6e62 test-lib tests: avoid subshell for \"test_cmp\" for readability\n 8:  fda7c4fbe34 =  5:  5e95484fb61 test-lib tests: refactor common part of check_sub_test_lib_test*()\n 9:  dd0af5bd6ce =  6:  1e0a49c1a70 test-lib tests: assert 1 exit code, not non-zero\n 5:  7d1e6b9a3e4 !  7:  68f8fabaa1e test-lib tests: get rid of copy/pasted mock test code\n    @@ Commit message\n         run_sub_test_lib_test*() functions let's fix those tests in\n         t0000-basic.sh that were verbosely copy/pasting earlier tests.\n     \n    -    In a subsequent commit we'll add an assertion to check whether we\n    -    caught all of the copy/pasting.\n    +    That we caught all of them was asserted with a follow-up change that's\n    +    not part of this series[1], we might add such a duplication check at\n    +    some later time, but for now let's just one-off remove the duplicate\n    +    boilerplate.\n    +\n    +    1. https://lore.kernel.org/git/patch-v3-6.9-bc79b29f3c-20210805T103237Z-avarab@gmail.com/\n     \n         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n     \n 6:  bc79b29f3cd <  -:  ----------- test-lib tests: assert no copy/pasted mock test code\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436717","messageId":"patch-v4-1.7-f915bc2ee77-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 1/7] test-lib tests: move \"run_sub_test\" to a new lib-subtest.sh","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:47Z","receivedAt":"2021-09-22T11:20:05Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Move the \"check_sub_test_lib_test()\" and its sister functions to a new\nlib-subtest.sh.\n\nIn the future (not in this series) I'd like to test test-lib's output\nin a more targeted and smaller test, and I'll need these functions to\ndo that.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 86 ++++++++++++++++++++++++++++++++++++++++++++++\n t/t0000-basic.sh | 88 +-----------------------------------------------\n 2 files changed, 87 insertions(+), 87 deletions(-)\n create mode 100644 t/lib-subtest.sh\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nnew file mode 100644\nindex 00000000000..3cfe09911a2\n--- /dev/null\n+++ b/t/lib-subtest.sh\n@@ -0,0 +1,86 @@\n+_run_sub_test_lib_test_common () {\n+\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n+\tshift 3\n+\n+\t# intercept pseudo-options at the front of the argument list that we\n+\t# will not pass to child script\n+\tskip=\n+\twhile test $# -gt 0\n+\tdo\n+\t\tcase \"$1\" in\n+\t\t--skip=*)\n+\t\t\tskip=${1#--*=}\n+\t\t\tshift\n+\t\t\t;;\n+\t\t*)\n+\t\t\tbreak\n+\t\t\t;;\n+\t\tesac\n+\tdone\n+\n+\tmkdir \"$name\" &&\n+\t(\n+\t\t# Pretend we're not running under a test harness, whether we\n+\t\t# are or not. The test-lib output depends on the setting of\n+\t\t# this variable, so we need a stable setting under which to run\n+\t\t# the sub-test.\n+\t\tsane_unset HARNESS_ACTIVE &&\n+\t\tcd \"$name\" &&\n+\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\t\ttest_description='$descr (run in sub test-lib)\n+\n+\t\tThis is run in a sub test-lib so that we do not get incorrect\n+\t\tpassing metrics\n+\t\t'\n+\n+\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\t\tEOF\n+\t\tcat >>\"$name.sh\" &&\n+\t\texport TEST_DIRECTORY &&\n+\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n+\t\t# override the test output directory. We thus pass it as an\n+\t\t# explicit override to the child.\n+\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n+\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n+\t\tGIT_SKIP_TESTS=$skip &&\n+\t\texport GIT_SKIP_TESTS &&\n+\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n+\t\tif test -z \"$neg\"\n+\t\tthen\n+\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n+\t\telse\n+\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n+\t\tfi\n+\t)\n+}\n+\n+run_sub_test_lib_test () {\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+run_sub_test_lib_test_err () {\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n+check_sub_test_lib_test () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t(\n+\t\tcd \"$name\" &&\n+\t\ttest_must_be_empty err &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n+\t\ttest_cmp expect out\n+\t)\n+}\n+\n+check_sub_test_lib_test_err () {\n+\tname=\"$1\" # stdin is the expected output from the test\n+\t# expected error output is in descriptor 3\n+\t(\n+\t\tcd \"$name\" &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n+\t\ttest_cmp expect.out out &&\n+\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n+\t\ttest_cmp expect.err err\n+\t)\n+}\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex cb87768513c..a3865dd77ba 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -19,6 +19,7 @@ modification *should* take notice and update the test vectors here.\n '\n \n . ./test-lib.sh\n+. \"$TEST_DIRECTORY\"/lib-subtest.sh\n \n try_local_xy () {\n \tlocal x=\"local\" y=\"alsolocal\" &&\n@@ -66,93 +67,6 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-_run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n-\n-\t# intercept pseudo-options at the front of the argument list that we\n-\t# will not pass to child script\n-\tskip=\n-\twhile test $# -gt 0\n-\tdo\n-\t\tcase \"$1\" in\n-\t\t--skip=*)\n-\t\t\tskip=${1#--*=}\n-\t\t\tshift\n-\t\t\t;;\n-\t\t*)\n-\t\t\tbreak\n-\t\t\t;;\n-\t\tesac\n-\tdone\n-\n-\tmkdir \"$name\" &&\n-\t(\n-\t\t# Pretend we're not running under a test harness, whether we\n-\t\t# are or not. The test-lib output depends on the setting of\n-\t\t# this variable, so we need a stable setting under which to run\n-\t\t# the sub-test.\n-\t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n-\n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n-\n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n-\t\texport TEST_DIRECTORY &&\n-\t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n-\t\t# override the test output directory. We thus pass it as an\n-\t\t# explicit override to the child.\n-\t\tTEST_OUTPUT_DIRECTORY_OVERRIDE=$(pwd) &&\n-\t\texport TEST_OUTPUT_DIRECTORY_OVERRIDE &&\n-\t\tGIT_SKIP_TESTS=$skip &&\n-\t\texport GIT_SKIP_TESTS &&\n-\t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n-\t)\n-}\n-\n-run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n-}\n-\n-run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n-}\n-\n-check_sub_test_lib_test () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n-}\n-\n-check_sub_test_lib_test_err () {\n-\tname=\"$1\" # stdin is the expected output from the test\n-\t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n-}\n-\n test_expect_success 'pretend we have a fully passing test suite' '\n \trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436718","messageId":"patch-v4-2.7-5b5038867df-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 2/7] test-lib tests: split up \"write and run\" into two functions","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:48Z","receivedAt":"2021-09-22T11:20:06Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the function to write and run tests of the test-lib.sh output\ninto two functions.\n\nWhen this was added back in 565b6fa87bb (tests: refactor mechanics of\ntesting in a sub test-lib, 2012-12-16) there was no reason to do this,\nbut since we started supporting test arguments in\n517cd55fd51 (test-lib: self-test that --verbose works, 2013-06-23)\nwe've started to write out duplicate tests simply to test different\narguments, now we'll be able to re-use them.\n\nThis change doesn't consolidate any of those tests yet, it just makes\nit possible to do so. All the changes in t0000-basic.sh are a simple\nsearch-replacement.\n\nSince the _run_sub_test_lib_test_common() function doesn't handle\nrunning the test anymore we can do away with the sub-shell, which was\nused to scope an \"unset\" and \"export\" shell variables.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 42 +++++++++++++++++++--------\n t/t0000-basic.sh | 74 ++++++++++++++++++++++++------------------------\n 2 files changed, 67 insertions(+), 49 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 3cfe09911a2..21fa570d0b2 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,3 +1,19 @@\n+write_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tmkdir \"$name\" &&\n+\twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n+\ttest_description='$descr (run in sub test-lib)\n+\n+\tThis is run in a sub test-lib so that we do not get incorrect\n+\tpassing metrics\n+\t'\n+\n+\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n+\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n+\tEOF\n+\tcat >>\"$name/$name.sh\"\n+}\n+\n _run_sub_test_lib_test_common () {\n \tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n \tshift 3\n@@ -18,25 +34,15 @@ _run_sub_test_lib_test_common () {\n \t\tesac\n \tdone\n \n-\tmkdir \"$name\" &&\n \t(\n+\t\tcd \"$name\" &&\n+\n \t\t# Pretend we're not running under a test harness, whether we\n \t\t# are or not. The test-lib output depends on the setting of\n \t\t# this variable, so we need a stable setting under which to run\n \t\t# the sub-test.\n \t\tsane_unset HARNESS_ACTIVE &&\n-\t\tcd \"$name\" &&\n-\t\twrite_script \"$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\t\ttest_description='$descr (run in sub test-lib)\n-\n-\t\tThis is run in a sub test-lib so that we do not get incorrect\n-\t\tpassing metrics\n-\t\t'\n \n-\t\t# Point to the t/test-lib.sh, which isn't in ../ as usual\n-\t\t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n-\t\tEOF\n-\t\tcat >>\"$name.sh\" &&\n \t\texport TEST_DIRECTORY &&\n \t\t# The child test re-sources GIT-BUILD-OPTIONS and may thus\n \t\t# override the test output directory. We thus pass it as an\n@@ -55,6 +61,18 @@ _run_sub_test_lib_test_common () {\n \t)\n }\n \n+write_and_run_sub_test_lib_test () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '' \"$@\"\n+}\n+\n+write_and_run_sub_test_lib_test_err () {\n+\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\twrite_sub_test_lib_test \"$@\" || return 1\n+\t_run_sub_test_lib_test_common '!' \"$@\"\n+}\n+\n run_sub_test_lib_test () {\n \t_run_sub_test_lib_test_common '' \"$@\"\n }\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex a3865dd77ba..a7c5aaacab6 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -68,7 +68,7 @@ test_expect_success 'success is reported like this' '\n '\n \n test_expect_success 'pretend we have a fully passing test suite' '\n-\trun_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -85,7 +85,7 @@ test_expect_success 'pretend we have a fully passing test suite' '\n '\n \n test_expect_success 'pretend we have a partially passing test suite' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n@@ -103,7 +103,7 @@ test_expect_success 'pretend we have a partially passing test suite' '\n '\n \n test_expect_success 'pretend we have a known breakage' '\n-\trun_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -118,7 +118,7 @@ test_expect_success 'pretend we have a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed a known breakage' '\n-\trun_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -130,7 +130,7 @@ test_expect_success 'pretend we have fixed a known breakage' '\n '\n \n test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\trun_sub_test_lib_test partially-passing-todos \\\n+\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n \t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n@@ -149,7 +149,7 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n '\n \n test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n@@ -168,7 +168,7 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n '\n \n test_expect_success 'pretend we have a mix of all possible results' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -204,7 +204,7 @@ test_expect_success 'pretend we have a mix of all possible results' '\n '\n \n test_expect_success 'test --verbose' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -231,7 +231,7 @@ test_expect_success 'test --verbose' '\n '\n \n test_expect_success 'test --verbose-only' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n@@ -255,7 +255,7 @@ test_expect_success 'test --verbose-only' '\n \n test_expect_success 'GIT_SKIP_TESTS' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-basic \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n \t\t\t\"GIT_SKIP_TESTS\" \\\n \t\t\t--skip=\"git.2\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -276,7 +276,7 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \n test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n \t\t\t\"GIT_SKIP_TESTS several tests\" \\\n \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n@@ -300,7 +300,7 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \n test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-sh-pattern \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n \t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n@@ -324,7 +324,7 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \n test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-entire-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n \t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n \t\t\t--skip=\"git\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -341,7 +341,7 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \n test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n-\t\trun_sub_test_lib_test git-skip-tests-unmatched-suite \\\n+\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n \t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n \t\t\t--skip=\"notgit\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n@@ -361,7 +361,7 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success '--run basic' '\n-\trun_sub_test_lib_test run-basic \\\n+\twrite_and_run_sub_test_lib_test run-basic \\\n \t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -382,7 +382,7 @@ test_expect_success '--run basic' '\n '\n \n test_expect_success '--run with a range' '\n-\trun_sub_test_lib_test run-range \\\n+\twrite_and_run_sub_test_lib_test run-range \\\n \t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -403,7 +403,7 @@ test_expect_success '--run with a range' '\n '\n \n test_expect_success '--run with two ranges' '\n-\trun_sub_test_lib_test run-two-ranges \\\n+\twrite_and_run_sub_test_lib_test run-two-ranges \\\n \t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -424,7 +424,7 @@ test_expect_success '--run with two ranges' '\n '\n \n test_expect_success '--run with a left open range' '\n-\trun_sub_test_lib_test run-left-open-range \\\n+\twrite_and_run_sub_test_lib_test run-left-open-range \\\n \t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -445,7 +445,7 @@ test_expect_success '--run with a left open range' '\n '\n \n test_expect_success '--run with a right open range' '\n-\trun_sub_test_lib_test run-right-open-range \\\n+\twrite_and_run_sub_test_lib_test run-right-open-range \\\n \t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -466,7 +466,7 @@ test_expect_success '--run with a right open range' '\n '\n \n test_expect_success '--run with basic negation' '\n-\trun_sub_test_lib_test run-basic-neg \\\n+\twrite_and_run_sub_test_lib_test run-basic-neg \\\n \t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -487,7 +487,7 @@ test_expect_success '--run with basic negation' '\n '\n \n test_expect_success '--run with two negations' '\n-\trun_sub_test_lib_test run-two-neg \\\n+\twrite_and_run_sub_test_lib_test run-two-neg \\\n \t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -508,7 +508,7 @@ test_expect_success '--run with two negations' '\n '\n \n test_expect_success '--run a range and negation' '\n-\trun_sub_test_lib_test run-range-and-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n \t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -529,7 +529,7 @@ test_expect_success '--run a range and negation' '\n '\n \n test_expect_success '--run range negation' '\n-\trun_sub_test_lib_test run-range-neg \\\n+\twrite_and_run_sub_test_lib_test run-range-neg \\\n \t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -550,7 +550,7 @@ test_expect_success '--run range negation' '\n '\n \n test_expect_success '--run include, exclude and include' '\n-\trun_sub_test_lib_test run-inc-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n \t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -572,7 +572,7 @@ test_expect_success '--run include, exclude and include' '\n '\n \n test_expect_success '--run include, exclude and include, comma separated' '\n-\trun_sub_test_lib_test run-inc-neg-inc-comma \\\n+\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n \t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -594,7 +594,7 @@ test_expect_success '--run include, exclude and include, comma separated' '\n '\n \n test_expect_success '--run exclude and include' '\n-\trun_sub_test_lib_test run-neg-inc \\\n+\twrite_and_run_sub_test_lib_test run-neg-inc \\\n \t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -616,7 +616,7 @@ test_expect_success '--run exclude and include' '\n '\n \n test_expect_success '--run empty selectors' '\n-\trun_sub_test_lib_test run-empty-sel \\\n+\twrite_and_run_sub_test_lib_test run-empty-sel \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n@@ -638,7 +638,7 @@ test_expect_success '--run empty selectors' '\n '\n \n test_expect_success '--run substring selector' '\n-\trun_sub_test_lib_test run-substring-selector \\\n+\twrite_and_run_sub_test_lib_test run-substring-selector \\\n \t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n@@ -662,7 +662,7 @@ test_expect_success '--run substring selector' '\n '\n \n test_expect_success '--run keyword selection' '\n-\trun_sub_test_lib_test_err run-inv-range-start \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n \t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -677,7 +677,7 @@ test_expect_success '--run keyword selection' '\n '\n \n test_expect_success '--run invalid range end' '\n-\trun_sub_test_lib_test_err run-inv-range-end \\\n+\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n \t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n@@ -692,7 +692,7 @@ test_expect_success '--run invalid range end' '\n '\n \n test_expect_success 'tests respect prerequisites' '\n-\trun_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -722,7 +722,7 @@ test_expect_success 'tests respect prerequisites' '\n '\n \n test_expect_success 'tests respect lazy prerequisites' '\n-\trun_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -746,7 +746,7 @@ test_expect_success 'tests respect lazy prerequisites' '\n '\n \n test_expect_success 'nested lazy prerequisites' '\n-\trun_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -772,7 +772,7 @@ test_expect_success 'nested lazy prerequisites' '\n '\n \n test_expect_success 'lazy prereqs do not turn off tracing' '\n-\trun_sub_test_lib_test lazy-prereq-and-tracing \\\n+\twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n \t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n@@ -785,7 +785,7 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n '\n \n test_expect_success 'tests clean up after themselves' '\n-\trun_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -805,7 +805,7 @@ test_expect_success 'tests clean up after themselves' '\n '\n \n test_expect_success 'tests clean up even on failures' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n@@ -834,7 +834,7 @@ test_expect_success 'tests clean up even on failures' '\n '\n \n test_expect_success 'test_atexit is run' '\n-\trun_sub_test_lib_test_err \\\n+\twrite_and_run_sub_test_lib_test_err \\\n \t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436719","messageId":"patch-v4-3.7-78177ce1729-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 3/7] test-lib tests: don't provide a description for the sub-tests","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:49Z","receivedAt":"2021-09-22T11:20:07Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Change the $test_description provided for the generated subtests to be\nconstant, since the only purpose of having it is that test-lib.sh will\nbarf if it isn't supplied.\n\nThe other purpose of having it was to effectively split up the test\ndescription between the argument to test_expect_success and the\nargument to \"write_and_run_sub_test_lib_test\". Let's only use one of\nthe two.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh |  12 ++--\n t/t0000-basic.sh | 142 +++++++++++++++++++++--------------------------\n 2 files changed, 66 insertions(+), 88 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 21fa570d0b2..cdbc2d93320 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -1,12 +1,8 @@\n write_sub_test_lib_test () {\n-\tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n+\tname=\"$1\" # stdin is the body of the test code\n \tmkdir \"$name\" &&\n \twrite_script \"$name/$name.sh\" \"$TEST_SHELL_PATH\" <<-EOF &&\n-\ttest_description='$descr (run in sub test-lib)\n-\n-\tThis is run in a sub test-lib so that we do not get incorrect\n-\tpassing metrics\n-\t'\n+\ttest_description='A test of test-lib.sh itself'\n \n \t# Point to the t/test-lib.sh, which isn't in ../ as usual\n \t. \"\\$TEST_DIRECTORY\"/test-lib.sh\n@@ -15,8 +11,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" descr=\"$3\" # stdin is the body of the test code\n-\tshift 3\n+\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n+\tshift 2\n \n \t# intercept pseudo-options at the front of the argument list that we\n \t# will not pass to child script\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex a7c5aaacab6..6fdd5f43cae 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -67,8 +67,8 @@ test_expect_success 'success is reported like this' '\n \t:\n '\n \n-test_expect_success 'pretend we have a fully passing test suite' '\n-\twrite_and_run_sub_test_lib_test full-pass \"3 passing tests\" <<-\\EOF &&\n+test_expect_success 'subtest: 3 passing tests' '\n+\twrite_and_run_sub_test_lib_test full-pass <<-\\EOF &&\n \tfor i in 1 2 3\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -84,9 +84,8 @@ test_expect_success 'pretend we have a fully passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a partially passing test suite' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tpartial-pass \"2/3 tests passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2/3 tests passing' '\n+\twrite_and_run_sub_test_lib_test_err partial-pass <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_expect_success \"failing test #2\" \"false\"\n \ttest_expect_success \"passing test #3\" \"true\"\n@@ -102,8 +101,8 @@ test_expect_success 'pretend we have a partially passing test suite' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a known breakage' '\n-\twrite_and_run_sub_test_lib_test failing-todo \"A failing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a failing TODO test' '\n+\twrite_and_run_sub_test_lib_test failing-todo <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_done\n@@ -117,8 +116,8 @@ test_expect_success 'pretend we have a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed a known breakage' '\n-\twrite_and_run_sub_test_lib_test passing-todo \"A passing TODO test\" <<-\\EOF &&\n+test_expect_success 'subtest: a passing TODO test' '\n+\twrite_and_run_sub_test_lib_test passing-todo <<-\\EOF &&\n \ttest_expect_failure \"pretend we have fixed a known breakage\" \"true\"\n \ttest_done\n \tEOF\n@@ -129,9 +128,8 @@ test_expect_success 'pretend we have fixed a known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have fixed one of two known breakages (run in sub test-lib)' '\n-\twrite_and_run_sub_test_lib_test partially-passing-todos \\\n-\t\t\"2 TODO tests, one passing\" <<-\\EOF &&\n+test_expect_success 'subtest: 2 TODO tests, one passin' '\n+\twrite_and_run_sub_test_lib_test partially-passing-todos <<-\\EOF &&\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n \ttest_expect_success \"pretend we have a passing test\" \"true\"\n \ttest_expect_failure \"pretend we have fixed another known breakage\" \"true\"\n@@ -148,9 +146,8 @@ test_expect_success 'pretend we have fixed one of two known breakages (run in su\n \tEOF\n '\n \n-test_expect_success 'pretend we have a pass, fail, and known breakage' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results1 \"mixed results #1\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: pass, failure and a TODO test' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results1 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"failing test\" \"false\"\n \ttest_expect_failure \"pretend we have a known breakage\" \"false\"\n@@ -167,9 +164,8 @@ test_expect_success 'pretend we have a pass, fail, and known breakage' '\n \tEOF\n '\n \n-test_expect_success 'pretend we have a mix of all possible results' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tmixed-results2 \"mixed results #2\" <<-\\EOF &&\n+test_expect_success 'subtest: mixed results: a mixture of all possible results' '\n+\twrite_and_run_sub_test_lib_test_err mixed-results2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n \ttest_expect_success \"passing test\" \"true\"\n@@ -203,9 +199,8 @@ test_expect_success 'pretend we have a mix of all possible results' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt1234-verbose \"test verbose\" --verbose <<-\\EOF &&\n+test_expect_success 'subtest: --verbose option' '\n+\twrite_and_run_sub_test_lib_test_err t1234-verbose --verbose <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n \ttest_expect_success \"failing test\" false\n@@ -230,9 +225,9 @@ test_expect_success 'test --verbose' '\n \tEOF\n '\n \n-test_expect_success 'test --verbose-only' '\n+test_expect_success 'subtest: --verbose-only option' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \"test verbose-only=2\" \\\n+\t\tt2345-verbose-only-2 \\\n \t\t--verbose-only=2 <<-\\EOF &&\n \ttest_expect_success \"passing test\" true\n \ttest_expect_success \"test with output\" \"echo foo\"\n@@ -253,10 +248,9 @@ test_expect_success 'test --verbose-only' '\n \tEOF\n '\n \n-test_expect_success 'GIT_SKIP_TESTS' '\n+test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t\"GIT_SKIP_TESTS\" \\\n \t\t\t--skip=\"git.2\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -274,10 +268,9 @@ test_expect_success 'GIT_SKIP_TESTS' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS several tests' '\n+test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-several \\\n-\t\t\t\"GIT_SKIP_TESTS several tests\" \\\n \t\t\t--skip=\"git.2 git.5\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -298,10 +291,9 @@ test_expect_success 'GIT_SKIP_TESTS several tests' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n+test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t\"GIT_SKIP_TESTS sh pattern\" \\\n \t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n \t\tfor i in 1 2 3 4 5 6\n \t\tdo\n@@ -322,10 +314,9 @@ test_expect_success 'GIT_SKIP_TESTS sh pattern' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS entire suite' '\n+test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t\"GIT_SKIP_TESTS entire suite\" \\\n \t\t\t--skip=\"git\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -339,10 +330,9 @@ test_expect_success 'GIT_SKIP_TESTS entire suite' '\n \t)\n '\n \n-test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n+test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n \t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t\"GIT_SKIP_TESTS does not skip unmatched suite\" \\\n \t\t\t--skip=\"notgit\" <<-\\EOF &&\n \t\tfor i in 1 2 3\n \t\tdo\n@@ -360,9 +350,8 @@ test_expect_success 'GIT_SKIP_TESTS does not skip unmatched suite' '\n \t)\n '\n \n-test_expect_success '--run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic \\\n-\t\t\"--run basic\" --run=\"1,3,5\" <<-\\EOF &&\n+test_expect_success 'subtest: --run basic' '\n+\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -381,9 +370,9 @@ test_expect_success '--run basic' '\n \tEOF\n '\n \n-test_expect_success '--run with a range' '\n+test_expect_success 'subtest: --run with a range' '\n \twrite_and_run_sub_test_lib_test run-range \\\n-\t\t\"--run with a range\" --run=\"1-3\" <<-\\EOF &&\n+\t\t--run=\"1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -402,9 +391,9 @@ test_expect_success '--run with a range' '\n \tEOF\n '\n \n-test_expect_success '--run with two ranges' '\n+test_expect_success 'subtest: --run with two ranges' '\n \twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t\"--run with two ranges\" --run=\"1-2,5-6\" <<-\\EOF &&\n+\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -423,9 +412,9 @@ test_expect_success '--run with two ranges' '\n \tEOF\n '\n \n-test_expect_success '--run with a left open range' '\n+test_expect_success 'subtest: --run with a left open range' '\n \twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t\"--run with a left open range\" --run=\"-3\" <<-\\EOF &&\n+\t\t--run=\"-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -444,9 +433,9 @@ test_expect_success '--run with a left open range' '\n \tEOF\n '\n \n-test_expect_success '--run with a right open range' '\n+test_expect_success 'subtest: --run with a right open range' '\n \twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t\"--run with a right open range\" --run=\"4-\" <<-\\EOF &&\n+\t\t--run=\"4-\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -465,9 +454,9 @@ test_expect_success '--run with a right open range' '\n \tEOF\n '\n \n-test_expect_success '--run with basic negation' '\n+test_expect_success 'subtest: --run with basic negation' '\n \twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t\"--run with basic negation\" --run=\"!3\" <<-\\EOF &&\n+\t\t--run=\"!3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -486,9 +475,9 @@ test_expect_success '--run with basic negation' '\n \tEOF\n '\n \n-test_expect_success '--run with two negations' '\n+test_expect_success 'subtest: --run with two negations' '\n \twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t\"--run with two negations\" --run=\"!3,!6\" <<-\\EOF &&\n+\t\t--run=\"!3,!6\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -507,9 +496,9 @@ test_expect_success '--run with two negations' '\n \tEOF\n '\n \n-test_expect_success '--run a range and negation' '\n+test_expect_success 'subtest: --run a range and negation' '\n \twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t\"--run a range and negation\" --run=\"-4,!2\" <<-\\EOF &&\n+\t\t--run=\"-4,!2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -528,9 +517,9 @@ test_expect_success '--run a range and negation' '\n \tEOF\n '\n \n-test_expect_success '--run range negation' '\n+test_expect_success 'subtest: --run range negation' '\n \twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t\"--run range negation\" --run=\"!1-3\" <<-\\EOF &&\n+\t\t--run=\"!1-3\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n \t\ttest_expect_success \"passing test #$i\" \"true\"\n@@ -549,9 +538,8 @@ test_expect_success '--run range negation' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include' '\n+test_expect_success 'subtest: --run include, exclude and include' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t\"--run include, exclude and include\" \\\n \t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -571,9 +559,8 @@ test_expect_success '--run include, exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run include, exclude and include, comma separated' '\n+test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n \twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t\"--run include, exclude and include, comma separated\" \\\n \t\t--run=1-5,!1-3,2 <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -593,9 +580,8 @@ test_expect_success '--run include, exclude and include, comma separated' '\n \tEOF\n '\n \n-test_expect_success '--run exclude and include' '\n+test_expect_success 'subtest: --run exclude and include' '\n \twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t\"--run exclude and include\" \\\n \t\t--run=\"!3-,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -615,9 +601,8 @@ test_expect_success '--run exclude and include' '\n \tEOF\n '\n \n-test_expect_success '--run empty selectors' '\n+test_expect_success 'subtest: --run empty selectors' '\n \twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n \tfor i in 1 2 3 4 5 6\n \tdo\n@@ -637,9 +622,8 @@ test_expect_success '--run empty selectors' '\n \tEOF\n '\n \n-test_expect_success '--run substring selector' '\n+test_expect_success 'subtest: --run substring selector' '\n \twrite_and_run_sub_test_lib_test run-substring-selector \\\n-\t\t\"--run empty selectors\" \\\n \t\t--run=\"relevant\" <<-\\EOF &&\n \ttest_expect_success \"relevant test\" \"true\"\n \tfor i in 1 2 3 4 5 6\n@@ -661,9 +645,8 @@ test_expect_success '--run substring selector' '\n \tEOF\n '\n \n-test_expect_success '--run keyword selection' '\n+test_expect_success 'subtest: --run keyword selection' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-start \\\n-\t\t\"--run invalid range start\" \\\n \t\t--run=\"a-5\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -676,9 +659,8 @@ test_expect_success '--run keyword selection' '\n \tEOF_ERR\n '\n \n-test_expect_success '--run invalid range end' '\n+test_expect_success 'subtest: --run invalid range end' '\n \twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t\"--run invalid range end\" \\\n \t\t--run=\"1-z\" <<-\\EOF &&\n \ttest_expect_success \"passing test #1\" \"true\"\n \ttest_done\n@@ -691,8 +673,8 @@ test_expect_success '--run invalid range end' '\n \tEOF_ERR\n '\n \n-test_expect_success 'tests respect prerequisites' '\n-\twrite_and_run_sub_test_lib_test prereqs \"tests respect prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect prerequisites' '\n+\twrite_and_run_sub_test_lib_test prereqs <<-\\EOF &&\n \n \ttest_set_prereq HAVEIT\n \ttest_expect_success HAVEIT \"prereq is satisfied\" \"true\"\n@@ -721,8 +703,8 @@ test_expect_success 'tests respect prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'tests respect lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test lazy-prereqs \"respect lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: tests respect lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test lazy-prereqs <<-\\EOF &&\n \n \ttest_lazy_prereq LAZY_TRUE true\n \ttest_expect_success LAZY_TRUE \"lazy prereq is satisifed\" \"true\"\n@@ -745,8 +727,8 @@ test_expect_success 'tests respect lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'nested lazy prerequisites' '\n-\twrite_and_run_sub_test_lib_test nested-lazy \"nested lazy prereqs\" <<-\\EOF &&\n+test_expect_success 'subtest: nested lazy prerequisites' '\n+\twrite_and_run_sub_test_lib_test nested-lazy <<-\\EOF &&\n \n \ttest_lazy_prereq NESTED_INNER \"\n \t\t>inner &&\n@@ -771,9 +753,9 @@ test_expect_success 'nested lazy prerequisites' '\n \tEOF\n '\n \n-test_expect_success 'lazy prereqs do not turn off tracing' '\n+test_expect_success 'subtest: lazy prereqs do not turn off tracing' '\n \twrite_and_run_sub_test_lib_test lazy-prereq-and-tracing \\\n-\t\t\"lazy prereqs and -x\" -v -x <<-\\EOF &&\n+\t\t-v -x <<-\\EOF &&\n \ttest_lazy_prereq LAZY true\n \n \ttest_expect_success lazy \"test_have_prereq LAZY && echo trace\"\n@@ -784,8 +766,8 @@ test_expect_success 'lazy prereqs do not turn off tracing' '\n \tgrep \"echo trace\" lazy-prereq-and-tracing/err\n '\n \n-test_expect_success 'tests clean up after themselves' '\n-\twrite_and_run_sub_test_lib_test cleanup \"test with cleanup\" <<-\\EOF &&\n+test_expect_success 'subtest: tests clean up after themselves' '\n+\twrite_and_run_sub_test_lib_test cleanup <<-\\EOF &&\n \tclean=no\n \ttest_expect_success \"do cleanup\" \"\n \t\ttest_when_finished clean=yes\n@@ -804,9 +786,9 @@ test_expect_success 'tests clean up after themselves' '\n \tEOF\n '\n \n-test_expect_success 'tests clean up even on failures' '\n+test_expect_success 'subtest: tests clean up even on failures' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tfailing-cleanup \"Failing tests with cleanup commands\" <<-\\EOF &&\n+\t\tfailing-cleanup <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\ttouch clean-after-failure &&\n \t\ttest_when_finished rm clean-after-failure &&\n@@ -833,9 +815,9 @@ test_expect_success 'tests clean up even on failures' '\n \tEOF\n '\n \n-test_expect_success 'test_atexit is run' '\n+test_expect_success 'subtest: test_atexit is run' '\n \twrite_and_run_sub_test_lib_test_err \\\n-\t\tatexit-cleanup \"Run atexit commands\" -i <<-\\EOF &&\n+\t\tatexit-cleanup -i <<-\\EOF &&\n \ttest_expect_success \"tests clean up even after a failure\" \"\n \t\t> ../../clean-atexit &&\n \t\ttest_atexit rm ../../clean-atexit &&\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436720","messageId":"patch-v4-4.7-a581bff6e62-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 4/7] test-lib tests: avoid subshell for \"test_cmp\" for readability","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:50Z","receivedAt":"2021-09-22T11:20:09Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"The use of a sub-shell for running the test_cmp of stdout/stderr for\nthe test author was introduced in this form in 565b6fa87bb (tests:\nrefactor mechanics of testing in a sub test-lib, 2012-12-16), but from\nlooking at the history that seemed to have diligently copied my\noriginal ad-hoc implementation in 7b905119703 (t/t0000-basic.sh: Run\nthe passing TODO test inside its own test-lib, 2010-08-19).\n\nThere's no reason to use a subshell here, we try to avoid it in\ngeneral. It also improves readability, if the test fails we print out\nthe relative path in the trash directory that needs to be looked\nat.\n\nBefore that was mostly obscured, since the \"write_sub_test_lib_test\"\nwill pick the directory for you from the test name.\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 20 +++++++-------------\n 1 file changed, 7 insertions(+), 13 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex cdbc2d93320..0737fab98ad 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -79,22 +79,16 @@ run_sub_test_lib_test_err () {\n \n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\t(\n-\t\tcd \"$name\" &&\n-\t\ttest_must_be_empty err &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect &&\n-\t\ttest_cmp expect out\n-\t)\n+\ttest_must_be_empty \"$name\"/err &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n+\ttest_cmp \"$name/\"expect \"$name\"/out\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n \t# expected error output is in descriptor 3\n-\t(\n-\t\tcd \"$name\" &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' >expect.out &&\n-\t\ttest_cmp expect.out out &&\n-\t\tsed -e 's/^> //' -e 's/Z$//' <&3 >expect.err &&\n-\t\ttest_cmp expect.err err\n-\t)\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n+\tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n+\ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436721","messageId":"patch-v4-5.7-5e95484fb61-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 5/7] test-lib tests: refactor common part of check_sub_test_lib_test*()","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:51Z","receivedAt":"2021-09-22T11:20:11Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Refactor the two check_sub_test_lib_test*() functions to avoid\nduplicating the same comparison they did of stdout. This duplication\nwas initially added when check_sub_test_lib_test_err() was added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 14 +++++++++-----\n 1 file changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex 0737fab98ad..cdadc0c7fc2 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -77,18 +77,22 @@ run_sub_test_lib_test_err () {\n \t_run_sub_test_lib_test_common '!' \"$@\"\n }\n \n+_check_sub_test_lib_test_common () {\n+\tname=\"$1\" &&\n+\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n+\ttest_cmp \"$name\"/expect.out \"$name\"/out\n+}\n+\n check_sub_test_lib_test () {\n \tname=\"$1\" # stdin is the expected output from the test\n-\ttest_must_be_empty \"$name\"/err &&\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect &&\n-\ttest_cmp \"$name/\"expect \"$name\"/out\n+\t_check_sub_test_lib_test_common \"$name\" &&\n+\ttest_must_be_empty \"$name\"/err\n }\n \n check_sub_test_lib_test_err () {\n \tname=\"$1\" # stdin is the expected output from the test\n+\t_check_sub_test_lib_test_common \"$name\" &&\n \t# expected error output is in descriptor 3\n-\tsed -e 's/^> //' -e 's/Z$//' >\"$name\"/expect.out &&\n-\ttest_cmp \"$name\"/expect.out \"$name\"/out &&\n \tsed -e 's/^> //' -e 's/Z$//' <&3 >\"$name\"/expect.err &&\n \ttest_cmp \"$name\"/expect.err \"$name\"/err\n }\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436722","messageId":"patch-v4-6.7-1e0a49c1a70-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 6/7] test-lib tests: assert 1 exit code, not non-zero","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:52Z","receivedAt":"2021-09-22T11:20:12Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Improve the testing for test-lib.sh itself to assert that we have a\nexit code of 1, not any non-zero. Improves code added in\n0445e6f0a12 (test-lib: '--run' to run only specific tests,\n2014-04-30).\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/lib-subtest.sh | 21 +++++++++------------\n 1 file changed, 9 insertions(+), 12 deletions(-)\n\ndiff --git a/t/lib-subtest.sh b/t/lib-subtest.sh\nindex cdadc0c7fc2..56ee927f0c4 100644\n--- a/t/lib-subtest.sh\n+++ b/t/lib-subtest.sh\n@@ -11,8 +11,8 @@ write_sub_test_lib_test () {\n }\n \n _run_sub_test_lib_test_common () {\n-\tneg=\"$1\" name=\"$2\" # stdin is the body of the test code\n-\tshift 2\n+\tcmp_op=\"$1\" want_code=\"$2\" name=\"$3\" # stdin is the body of the test code\n+\tshift 3\n \n \t# intercept pseudo-options at the front of the argument list that we\n \t# will not pass to child script\n@@ -48,33 +48,30 @@ _run_sub_test_lib_test_common () {\n \t\tGIT_SKIP_TESTS=$skip &&\n \t\texport GIT_SKIP_TESTS &&\n \t\tsane_unset GIT_TEST_FAIL_PREREQS &&\n-\t\tif test -z \"$neg\"\n-\t\tthen\n-\t\t\t./\"$name.sh\" \"$@\" >out 2>err\n-\t\telse\n-\t\t\t! ./\"$name.sh\" \"$@\" >out 2>err\n-\t\tfi\n+\t\t./\"$name.sh\" \"$@\" >out 2>err;\n+\t\tret=$? &&\n+\t\ttest \"$ret\" \"$cmp_op\" \"$want_code\"\n \t)\n }\n \n write_and_run_sub_test_lib_test () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n write_and_run_sub_test_lib_test_err () {\n \tname=\"$1\" descr=\"$2\" # stdin is the body of the test code\n \twrite_sub_test_lib_test \"$@\" || return 1\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n run_sub_test_lib_test () {\n-\t_run_sub_test_lib_test_common '' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 0 \"$@\"\n }\n \n run_sub_test_lib_test_err () {\n-\t_run_sub_test_lib_test_common '!' \"$@\"\n+\t_run_sub_test_lib_test_common -eq 1 \"$@\"\n }\n \n _check_sub_test_lib_test_common () {\n-- \n2.33.0.1225.g9f062250122\n\n"},{"id":"436723","messageId":"patch-v4-7.7-68f8fabaa1e-20210922T111734Z-avarab@gmail.com","threadId":"55925","inReplyTo":"cover-v4-0.7-00000000000-20210922T111734Z-avarab@gmail.com","subject":"[PATCH v4 7/7] test-lib tests: get rid of copy/pasted mock test code","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2021-09-22T11:19:53Z","receivedAt":"2021-09-22T11:20:16Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"Now that we've split up the write_sub_test_lib_test*() and\nrun_sub_test_lib_test*() functions let's fix those tests in\nt0000-basic.sh that were verbosely copy/pasting earlier tests.\n\nThat we caught all of them was asserted with a follow-up change that's\nnot part of this series[1], we might add such a duplication check at\nsome later time, but for now let's just one-off remove the duplicate\nboilerplate.\n\n1. https://lore.kernel.org/git/patch-v3-6.9-bc79b29f3c-20210805T103237Z-avarab@gmail.com/\n\nSigned-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>\n---\n t/t0000-basic.sh | 228 +++++++++++++----------------------------------\n 1 file changed, 60 insertions(+), 168 deletions(-)\n\ndiff --git a/t/t0000-basic.sh b/t/t0000-basic.sh\nindex 6fdd5f43cae..a0b99d83349 100755\n--- a/t/t0000-basic.sh\n+++ b/t/t0000-basic.sh\n@@ -226,18 +226,13 @@ test_expect_success 'subtest: --verbose option' '\n '\n \n test_expect_success 'subtest: --verbose-only option' '\n-\twrite_and_run_sub_test_lib_test_err \\\n-\t\tt2345-verbose-only-2 \\\n-\t\t--verbose-only=2 <<-\\EOF &&\n-\ttest_expect_success \"passing test\" true\n-\ttest_expect_success \"test with output\" \"echo foo\"\n-\ttest_expect_success \"failing test\" false\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test t2345-verbose-only-2 <<-\\EOF\n+\trun_sub_test_lib_test_err \\\n+\t\tt1234-verbose \\\n+\t\t--verbose-only=2 &&\n+\tcheck_sub_test_lib_test t1234-verbose <<-\\EOF\n \t> ok 1 - passing test\n \t> Z\n-\t> expecting success of 2345.2 '\\''test with output'\\'': echo foo\n+\t> expecting success of 1234.2 '\\''test with output'\\'': echo foo\n \t> foo\n \t> ok 2 - test with output\n \t> Z\n@@ -250,15 +245,9 @@ test_expect_success 'subtest: --verbose-only option' '\n \n test_expect_success 'subtest: skip one with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-basic \\\n-\t\t\t--skip=\"git.2\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-basic <<-\\EOF\n+\t\trun_sub_test_lib_test full-pass \\\n+\t\t\t--skip=\"full.2\" &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 - passing test #3\n@@ -293,15 +282,9 @@ test_expect_success 'subtest: skip several with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-sh-pattern \\\n-\t\t\t--skip=\"git.[2-5]\" <<-\\EOF &&\n-\t\tfor i in 1 2 3 4 5 6\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-sh-pattern <<-\\EOF\n+\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t\t--skip=\"git.[2-5]\" &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 # skip passing test #2 (GIT_SKIP_TESTS)\n \t\t> ok 3 # skip passing test #3 (GIT_SKIP_TESTS)\n@@ -316,15 +299,10 @@ test_expect_success 'subtest: sh pattern skipping with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-entire-suite \\\n-\t\t\t--skip=\"git\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-entire-suite <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"git\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t\t--skip=\"git\" &&\n+\t\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t\t> 1..0 # SKIP skip all tests in git\n \t\tEOF\n \t)\n@@ -332,15 +310,10 @@ test_expect_success 'subtest: skip entire test suite with GIT_SKIP_TESTS' '\n \n test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n \t(\n-\t\twrite_and_run_sub_test_lib_test git-skip-tests-unmatched-suite \\\n-\t\t\t--skip=\"notgit\" <<-\\EOF &&\n-\t\tfor i in 1 2 3\n-\t\tdo\n-\t\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\t\tdone\n-\t\ttest_done\n-\t\tEOF\n-\t\tcheck_sub_test_lib_test git-skip-tests-unmatched-suite <<-\\EOF\n+\t\tGIT_SKIP_TESTS=\"notgit\" && export GIT_SKIP_TESTS &&\n+\t\trun_sub_test_lib_test full-pass \\\n+\t\t\t--skip=\"notfull\" &&\n+\t\tcheck_sub_test_lib_test full-pass <<-\\EOF\n \t\t> ok 1 - passing test #1\n \t\t> ok 2 - passing test #2\n \t\t> ok 3 - passing test #3\n@@ -351,14 +324,8 @@ test_expect_success 'subtest: GIT_SKIP_TESTS does not skip unmatched suite' '\n '\n \n test_expect_success 'subtest: --run basic' '\n-\twrite_and_run_sub_test_lib_test run-basic --run=\"1,3,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several --run=\"1,3,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -371,15 +338,9 @@ test_expect_success 'subtest: --run basic' '\n '\n \n test_expect_success 'subtest: --run with a range' '\n-\twrite_and_run_sub_test_lib_test run-range \\\n-\t\t--run=\"1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -392,15 +353,9 @@ test_expect_success 'subtest: --run with a range' '\n '\n \n test_expect_success 'subtest: --run with two ranges' '\n-\twrite_and_run_sub_test_lib_test run-two-ranges \\\n-\t\t--run=\"1-2,5-6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-ranges <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-2,5-6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -413,15 +368,9 @@ test_expect_success 'subtest: --run with two ranges' '\n '\n \n test_expect_success 'subtest: --run with a left open range' '\n-\twrite_and_run_sub_test_lib_test run-left-open-range \\\n-\t\t--run=\"-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-left-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 - passing test #3\n@@ -434,15 +383,9 @@ test_expect_success 'subtest: --run with a left open range' '\n '\n \n test_expect_success 'subtest: --run with a right open range' '\n-\twrite_and_run_sub_test_lib_test run-right-open-range \\\n-\t\t--run=\"4-\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-right-open-range <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"4-\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -455,15 +398,9 @@ test_expect_success 'subtest: --run with a right open range' '\n '\n \n test_expect_success 'subtest: --run with basic negation' '\n-\twrite_and_run_sub_test_lib_test run-basic-neg \\\n-\t\t--run=\"!3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-basic-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -476,15 +413,9 @@ test_expect_success 'subtest: --run with basic negation' '\n '\n \n test_expect_success 'subtest: --run with two negations' '\n-\twrite_and_run_sub_test_lib_test run-two-neg \\\n-\t\t--run=\"!3,!6\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-two-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3,!6\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -497,15 +428,9 @@ test_expect_success 'subtest: --run with two negations' '\n '\n \n test_expect_success 'subtest: --run a range and negation' '\n-\twrite_and_run_sub_test_lib_test run-range-and-neg \\\n-\t\t--run=\"-4,!2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-and-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"-4,!2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -518,15 +443,9 @@ test_expect_success 'subtest: --run a range and negation' '\n '\n \n test_expect_success 'subtest: --run range negation' '\n-\twrite_and_run_sub_test_lib_test run-range-neg \\\n-\t\t--run=\"!1-3\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-range-neg <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!1-3\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 # skip passing test #3 (--run)\n@@ -539,15 +458,9 @@ test_expect_success 'subtest: --run range negation' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc \\\n-\t\t--run=\"1-5,!1-3,2\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1-5,!1-3,2\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -560,15 +473,9 @@ test_expect_success 'subtest: --run include, exclude and include' '\n '\n \n test_expect_success 'subtest: --run include, exclude and include, comma separated' '\n-\twrite_and_run_sub_test_lib_test run-inc-neg-inc-comma \\\n-\t\t--run=1-5,!1-3,2 <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-inc-neg-inc-comma <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=1-5,!1-3,2 &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 # skip passing test #1 (--run)\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -581,15 +488,9 @@ test_expect_success 'subtest: --run include, exclude and include, comma separate\n '\n \n test_expect_success 'subtest: --run exclude and include' '\n-\twrite_and_run_sub_test_lib_test run-neg-inc \\\n-\t\t--run=\"!3-,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-neg-inc <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"!3-,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 - passing test #2\n \t> ok 3 # skip passing test #3 (--run)\n@@ -602,15 +503,9 @@ test_expect_success 'subtest: --run exclude and include' '\n '\n \n test_expect_success 'subtest: --run empty selectors' '\n-\twrite_and_run_sub_test_lib_test run-empty-sel \\\n-\t\t--run=\"1,,3,,,5\" <<-\\EOF &&\n-\tfor i in 1 2 3 4 5 6\n-\tdo\n-\t\ttest_expect_success \"passing test #$i\" \"true\"\n-\tdone\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test run-empty-sel <<-\\EOF\n+\trun_sub_test_lib_test git-skip-tests-several \\\n+\t\t--run=\"1,,3,,,5\" &&\n+\tcheck_sub_test_lib_test git-skip-tests-several <<-\\EOF\n \t> ok 1 - passing test #1\n \t> ok 2 # skip passing test #2 (--run)\n \t> ok 3 - passing test #3\n@@ -660,12 +555,9 @@ test_expect_success 'subtest: --run keyword selection' '\n '\n \n test_expect_success 'subtest: --run invalid range end' '\n-\twrite_and_run_sub_test_lib_test_err run-inv-range-end \\\n-\t\t--run=\"1-z\" <<-\\EOF &&\n-\ttest_expect_success \"passing test #1\" \"true\"\n-\ttest_done\n-\tEOF\n-\tcheck_sub_test_lib_test_err run-inv-range-end \\\n+\trun_sub_test_lib_test_err run-inv-range-start \\\n+\t\t--run=\"1-z\" &&\n+\tcheck_sub_test_lib_test_err run-inv-range-start \\\n \t\t<<-\\EOF_OUT 3<<-EOF_ERR\n \t> FATAL: Unexpected exit with code 1\n \tEOF_OUT\n-- \n2.33.0.1225.g9f062250122\n\n"}]}