<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/t/t0000-basic.sh, branch v2.43.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.43.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.43.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-05-19T17:08:10Z</updated>
<entry>
<title>t0000-basic: modernize test format</title>
<updated>2023-05-19T17:08:10Z</updated>
<author>
<name>John Cai</name>
<email>johncai86@gmail.com</email>
</author>
<published>2023-05-18T20:03:06Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2f68c99a3beefa5556eca76811deb443599e214a'/>
<id>urn:sha1:2f68c99a3beefa5556eca76811deb443599e214a</id>
<content type='text'>
Some tests in t0000-basic.sh used the older four space indent format.
Update these to use tabs.

Signed-off-by: John Cai &lt;johncai86@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>tests: make 'test_oid' print trailing newline</title>
<updated>2022-12-19T00:49:11Z</updated>
<author>
<name>SZEDER Gábor</name>
<email>szeder.dev@gmail.com</email>
</author>
<published>2022-12-18T16:29:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=a48a88019b408157cf3b76e1a198afd824f4f0a3'/>
<id>urn:sha1:a48a88019b408157cf3b76e1a198afd824f4f0a3</id>
<content type='text'>
Unlike other test helper functions, 'test_oid' doesn't terminate its
output with a LF, but, alas, the reason for this, if any, is not
mentioned in 2c02b110da (t: add test functions to translate
hash-related values, 2018-09-13)).

Now, in the vast majority of cases 'test_oid' is invoked in a command
substitution that is part of a heredoc or supplies an argument to a
command or the value to a variable, and the command substitution would
chop off any trailing LFs, so in these cases the lack or presence of a
trailing LF in its output doesn't matter.  However:

  - There appear to be only three cases where 'test_oid' is not
    invoked in a command substitution:

      $ git grep '\stest_oid ' -- ':/t/*.sh'
      t0000-basic.sh:  test_oid zero &gt;actual &amp;&amp;
      t0000-basic.sh:  test_oid zero &gt;actual &amp;&amp;
      t0000-basic.sh:  test_oid zero &gt;actual &amp;&amp;

    These are all in test cases checking that 'test_oid' actually
    works, and that the size of its output matches the size of the
    corresponding hash function with conditions like

      test $(wc -c &lt;actual) -eq 40

    In these cases the lack of trailing LF does actually matter,
    though they could be trivially updated to account for the presence
    of a trailing LF.

  - There are also a few cases where the lack of trailing LF in
    'test_oid's output actually hurts, because tests need to compare
    its output with LF terminated file contents, forcing developers to
    invoke it as 'echo $(test_oid ...)' to append the missing LF:

      $ git grep 'echo "\?$(test_oid ' -- ':/t/*.sh'
      t1302-repo-version.sh:  echo $(test_oid version) &gt;expect &amp;&amp;
      t1500-rev-parse.sh:     echo "$(test_oid algo)" &gt;expect &amp;&amp;
      t4044-diff-index-unique-abbrev.sh:      echo "$(test_oid val1)" &gt; foo &amp;&amp;
      t4044-diff-index-unique-abbrev.sh:      echo "$(test_oid val2)" &gt; foo &amp;&amp;
      t5313-pack-bounds-checks.sh:    echo $(test_oid oidfff) &gt;file &amp;&amp;

    And there is yet another similar case in an in-flight topic at:

      https://public-inbox.org/git/813e81a058227bd373cec802e443fcd677042fb4.1670862677.git.gitgitgadget@gmail.com/

Arguably we would be better off if 'test_oid' terminated its output
with a LF.  So let's update 'test_oid' accordingly, update its tests
in t0000 to account for the extra character in those size tests, and
remove the now unnecessary 'echo $(...)' command substitutions around
'test_oid' invocations as well.

Signed-off-by: SZEDER Gábor &lt;szeder.dev@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>test-lib: add a --invert-exit-code switch</title>
<updated>2022-07-27T23:35:40Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-07-27T23:13:32Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=46fb057aaad2cfcbf6cdf409fcf241a362ad77b3'/>
<id>urn:sha1:46fb057aaad2cfcbf6cdf409fcf241a362ad77b3</id>
<content type='text'>
Add the ability to have those tests that fail return 0, and those
tests that succeed return 1. This is useful e.g. to run "--stress"
tests on tests that fail 99% of the time on some setup, i.e. to smoke
out the flaky run which yielded success.

In a subsequent commit a new SANITIZE=leak mode will make use of this.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>test-lib: have --immediate emit valid TAP on failure</title>
<updated>2022-03-24T21:47:02Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2022-03-23T20:51:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bbfbcd25b39e9020ce98467cfcf60dfce7e9b484'/>
<id>urn:sha1:bbfbcd25b39e9020ce98467cfcf60dfce7e9b484</id>
<content type='text'>
Change the "--immediate" option so that it emits valid TAP on
failure. Before this it would omit the required plan at the end,
e.g. under SANITIZE=leak we'd show a "No plan found in TAP output"
error from "prove":

    $ prove t0006-date.sh ::  --immediate
    t0006-date.sh .. Dubious, test returned 1 (wstat 256, 0x100)
    Failed 1/22 subtests

    Test Summary Report
    -------------------
    t0006-date.sh (Wstat: 256 Tests: 22 Failed: 1)
      Failed test:  22
      Non-zero exit status: 1
      Parse errors: No plan found in TAP output
    Files=1, Tests=22,  0 wallclock secs ( 0.02 usr  0.01 sys +  0.18 cusr  0.06 csys =  0.27 CPU)
    Result: FAIL

Now we'll emit output that doesn't result in TAP parsing failures:

    $ prove t0006-date.sh ::  --immediate
    t0006-date.sh .. Dubious, test returned 1 (wstat 256, 0x100)
    Failed 1/22 subtests

    Test Summary Report
    -------------------
    t0006-date.sh (Wstat: 256 Tests: 22 Failed: 1)
      Failed test:  22
      Non-zero exit status: 1
    Files=1, Tests=22,  0 wallclock secs ( 0.02 usr  0.00 sys +  0.19 cusr  0.05 csys =  0.26 CPU)
    Result: FAIL

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t0001-t0028: avoid pipes with Git on LHS</title>
<updated>2022-03-13T00:22:01Z</updated>
<author>
<name>Shubham Mishra</name>
<email>shivam828787@gmail.com</email>
</author>
<published>2022-03-12T06:21:25Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9b6d1fc48a29abdd49c267ce1bf06bac5151a0e4'/>
<id>urn:sha1:9b6d1fc48a29abdd49c267ce1bf06bac5151a0e4</id>
<content type='text'>
Pipes ignore error codes of LHS command and thus we should not use
them with Git in tests. As an alternative, use a 'tmp' file to write
the Git output so we can test the exit code.

Signed-off-by: Shubham Mishra &lt;shivam828787@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'ab/lib-subtest'</title>
<updated>2021-10-13T22:15:57Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-10-13T22:15:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=cf006037bf93589053a747a482e2f7c77cf0967e'/>
<id>urn:sha1:cf006037bf93589053a747a482e2f7c77cf0967e</id>
<content type='text'>
Updates to the tests in t0000 to test the test framework.

* ab/lib-subtest:
  test-lib tests: get rid of copy/pasted mock test code
  test-lib tests: assert 1 exit code, not non-zero
  test-lib tests: refactor common part of check_sub_test_lib_test*()
  test-lib tests: avoid subshell for "test_cmp" for readability
  test-lib tests: don't provide a description for the sub-tests
  test-lib tests: split up "write and run" into two functions
  test-lib tests: move "run_sub_test" to a new lib-subtest.sh
</content>
</entry>
<entry>
<title>test-lib tests: get rid of copy/pasted mock test code</title>
<updated>2021-09-22T23:22:41Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-09-22T11:19:53Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=2e54907e83febc637484255491c6a65b004fd648'/>
<id>urn:sha1:2e54907e83febc637484255491c6a65b004fd648</id>
<content type='text'>
Now that we've split up the write_sub_test_lib_test*() and
run_sub_test_lib_test*() functions let's fix those tests in
t0000-basic.sh that were verbosely copy/pasting earlier tests.

That we caught all of them was asserted with a follow-up change that's
not part of this series[1], we might add such a duplication check at
some later time, but for now let's just one-off remove the duplicate
boilerplate.

1. https://lore.kernel.org/git/patch-v3-6.9-bc79b29f3c-20210805T103237Z-avarab@gmail.com/

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>test-lib tests: don't provide a description for the sub-tests</title>
<updated>2021-09-22T23:22:41Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-09-22T11:19:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=c3ff7be6fb04c3150a8496271901a4a918c2c70c'/>
<id>urn:sha1:c3ff7be6fb04c3150a8496271901a4a918c2c70c</id>
<content type='text'>
Change the $test_description provided for the generated subtests to be
constant, since the only purpose of having it is that test-lib.sh will
barf if it isn't supplied.

The other purpose of having it was to effectively split up the test
description between the argument to test_expect_success and the
argument to "write_and_run_sub_test_lib_test". Let's only use one of
the two.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>test-lib tests: split up "write and run" into two functions</title>
<updated>2021-09-22T23:22:41Z</updated>
<author>
<name>Ævar Arnfjörð Bjarmason</name>
<email>avarab@gmail.com</email>
</author>
<published>2021-09-22T11:19:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9f0a45208dbc488da790d0f2ef1491eb2aa858c2'/>
<id>urn:sha1:9f0a45208dbc488da790d0f2ef1491eb2aa858c2</id>
<content type='text'>
Refactor the function to write and run tests of the test-lib.sh output
into two functions.

When this was added back in 565b6fa87bb (tests: refactor mechanics of
testing in a sub test-lib, 2012-12-16) there was no reason to do this,
but since we started supporting test arguments in
517cd55fd51 (test-lib: self-test that --verbose works, 2013-06-23)
we've started to write out duplicate tests simply to test different
arguments, now we'll be able to re-use them.

This change doesn't consolidate any of those tests yet, it just makes
it possible to do so. All the changes in t0000-basic.sh are a simple
search-replacement.

Since the _run_sub_test_lib_test_common() function doesn't handle
running the test anymore we can do away with the sub-shell, which was
used to scope an "unset" and "export" shell variables.

Signed-off-by: Ævar Arnfjörð Bjarmason &lt;avarab@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>t0000: avoid masking git exit value through pipes</title>
<updated>2021-09-16T20:43:42Z</updated>
<author>
<name>Carlo Marcelo Arenas Belón</name>
<email>carenas@gmail.com</email>
</author>
<published>2021-09-16T08:55:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=66c0c44df617446763845a71a8fe0fab4cb848a9'/>
<id>urn:sha1:66c0c44df617446763845a71a8fe0fab4cb848a9</id>
<content type='text'>
9af0b8dbe2 (t0000-basic: more commit-tree tests., 2006-04-26) adds
tests for commit-tree that mask the return exit from git as described
in a378fee5b07 (Documentation: add shell guidelines, 2018-10-05).

Fix the tests, to avoid pipes by using a temporary file instead.

Signed-off-by: Carlo Marcelo Arenas Belón &lt;carenas@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
