git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/6] tests: fix ignored & hidden exit codes

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 21, 2022, 06:51 UTC
Message-ID
<cover-0.6-00000000000-20220721T064349Z-avarab@gmail.com>

A small set of fixes to correct git on the LHS of a pipe, and in $() within a "test" expression, or where its exit code is otherwise hidden.

This also includes a (reworded) version of a case where we exit'd out of test-lib.sh itself, which Junio requested by spun off in: https://lore.kernel.org/git/xmqqmtd33e1h.fsf@gitster.g/

As noted in [1] there's no need to rebase the other series on top of this, it benefits from 6/6 here, but the two can proceed independently.

This is still just the tip of the iceberg in terms of hidden exit codes in the test suite, as can be seen with e.g.:

	git grep 'test.*\$\((git|test-tool)' -- 't/*.sh'

But these are all cases I've run into actual issues with, almost all when testing with SANITIZE=leak. In most cases just with one of the hunks in a given commit, but then I converted the rest of the file to fix a similar bad pattern.

That doesn't mean that these are more important than e.g. the output of the "grep" above, but we've got to start somewhere...

The range-diff below is to the tip of [2], to show how 6/6 was reworded.

1. https://lore.kernel.org/git/cover-v2-00.14-00000000000-20220720T211221Z-avarab@gmail.com/
2. https://lore.kernel.org/git/cover-00.10-00000000000-20220719T205710Z-avarab@gmail.com/
Ævar Arnfjörð Bjarmason (6):
  diff tests: fix ignored exit codes in t4023
  t/lib-patch-mode.sh: fix ignored "git" exit codes
  auto-crlf tests: check "git checkout" exit code
  test-lib-functions: add and use test_cmp_cmd
  merge tests: don't ignore "rev-parse" exit code in helper
  log tests: don't use "exit 1" outside a sub-shell
 t/lib-patch-mode.sh               | 13 ++++++---
 t/t0027-auto-crlf.sh              | 14 +++++++---
 t/t0060-path-utils.sh             | 45 +++++++++++++++++--------------
 t/t4023-diff-rename-typechange.sh | 12 ++++-----
 t/t4205-log-pretty-formats.sh     |  2 +-
 t/t7600-merge.sh                  |  9 +++----
 t/test-lib-functions.sh           | 18 +++++++++++++
 7 files changed, 74 insertions(+), 39 deletions(-)
Range-diff:
-:  ----------- > 1:  f8a382841d5 diff tests: fix ignored exit codes in t4023
-:  ----------- > 2:  85c6ab40e91 t/lib-patch-mode.sh: fix ignored "git" exit codes
-:  ----------- > 3:  cfc1abbf7e3 auto-crlf tests: check "git checkout" exit code
-:  ----------- > 4:  df1b674b8a7 test-lib-functions: add and use test_cmp_cmd
-:  ----------- > 5:  563666f9426 merge tests: don't ignore "rev-parse" exit code in helper
1:  9cedf0cb0e2 ! 6:  259b4618fcb log tests: don't use "exit 1" outside a sub-shell
    @@ Commit message
         Using "exit 1" outside a sub-shell will cause the test framework
         itself to exit on failure, which isn't what we want to do here.
     
    -    This issue was spotted with the new
    -    "GIT_TEST_PASSING_SANITIZE_LEAK=check" mode, i.e. that "git show"
    -    command leaks memory, and we'd thus "exit 1". Another implementation
    -    of "GIT_TEST_PASSING_SANITIZE_LEAK=check" or "--invert-exit-code"
    -    might have intercepted the "exit 1", and thus hidden the underlying
    -    issue here, but we correctly distinguish the two.
    +    This issue was spotted with the in-flight
    +    "GIT_TEST_PASSING_SANITIZE_LEAK=check" test mode[1]. This "git show"
    +    invocation currently leaks memory, and we'd thus "exit 1". This change
    +    was initially part of that topic[2] to demonstrate the correctness of
    +    the "check" implementation.
    +
    +    1. https://lore.kernel.org/git/patch-07.10-0961df2ab6c-20220719T205710Z-avarab@gmail.com/
    +    2. https://lore.kernel.org/git/patch-10.10-9cedf0cb0e2-20220719T205710Z-avarab@gmail.com/
     
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
-- 
2.37.1.1095.g64a1e8362fd
Next: Ævar Arnfjörð Bjarmason
Message 1 of 83 in “tests: fix ignored & hidden exit codes”
  1. 0/6 tests: fix ignored & hidden exit codesÆvar Arnfjörð Bjarmason, Jul 21, 2022
  2. 1/6 diff tests: fix ignored exit codes in t4023Ævar Arnfjörð Bjarmason, Jul 21, 2022
  3. 2/6 t/lib-patch-mode.sh: fix ignored "git" exit codesÆvar Arnfjörð Bjarmason, Jul 21, 2022
  4. 3/6 auto-crlf tests: check "git checkout" exit codeÆvar Arnfjörð Bjarmason, Jul 21, 2022
  5. 4/6 test-lib-functions: add and use test_cmp_cmdÆvar Arnfjörð Bjarmason, Jul 21, 2022
  6. 5/6 merge tests: don't ignore "rev-parse" exit code in helperÆvar Arnfjörð Bjarmason, Jul 21, 2022
  7. 6/6 log tests: don't use "exit 1" outside a sub-shellÆvar Arnfjörð Bjarmason, Jul 21, 2022
  8. 0/8 tests: fix ignored & hidden exit codesÆvar Arnfjörð Bjarmason, Dec 2, 2022
  9. 1/8 log tests: don't use "exit 1" outside a sub-shellÆvar Arnfjörð Bjarmason, Dec 2, 2022
  10. Eric SunshineDec 2, 2022
  11. Junio C HamanoDec 2, 2022
  12. Ævar Arnfjörð BjarmasonDec 2, 2022
  13. Eric SunshineDec 2, 2022
  14. Ævar Arnfjörð BjarmasonDec 2, 2022
  15. Eric SunshineDec 7, 2022
  16. Junio C HamanoDec 2, 2022
  17. 2/8 auto-crlf tests: check "git checkout" exit codeÆvar Arnfjörð Bjarmason, Dec 2, 2022
  18. René ScharfeDec 2, 2022
  19. Eric SunshineDec 2, 2022
  20. Torsten BögershausenDec 2, 2022
  21. Eric SunshineDec 2, 2022
  22. 3/8 diff tests: fix ignored exit codes in t4023Ævar Arnfjörð Bjarmason, Dec 2, 2022
  23. Junio C HamanoDec 2, 2022
  24. 5/8 t/lib-patch-mode.sh: fix ignored "git" exit codesÆvar Arnfjörð Bjarmason, Dec 2, 2022
  25. René ScharfeDec 2, 2022
  26. 4/8 test-lib-functions: add and use test_cmp_cmdÆvar Arnfjörð Bjarmason, Dec 2, 2022
  27. René ScharfeDec 2, 2022
  28. Eric SunshineDec 2, 2022
  29. Eric SunshineDec 2, 2022
  30. Eric SunshineDec 2, 2022
  31. Junio C HamanoDec 2, 2022
  32. 6/8 merge tests: don't ignore "rev-parse" exit code in helperÆvar Arnfjörð Bjarmason, Dec 2, 2022
  33. René ScharfeDec 2, 2022
  34. 7/8 tests: use "test_cmp_cmd" instead of "test" in sub-shellsÆvar Arnfjörð Bjarmason, Dec 2, 2022
  35. 8/8 tests: use "test_cmp_cmd" in misc testsÆvar Arnfjörð Bjarmason, Dec 2, 2022
  36. Junio C HamanoDec 2, 2022
  37. 0/8 tests: fix ignored & hidden exit codesÆvar Arnfjörð Bjarmason, Dec 2, 2022
  38. 1/8 merge tests: don't ignore "rev-parse" exit code in helperÆvar Arnfjörð Bjarmason, Dec 2, 2022
  39. Junio C HamanoDec 5, 2022
  40. 2/8 auto-crlf tests: don't lose exit code in loops and outside testsÆvar Arnfjörð Bjarmason, Dec 2, 2022
  41. René ScharfeDec 2, 2022
  42. 3/8 diff tests: fix ignored exit codes in t4023Ævar Arnfjörð Bjarmason, Dec 2, 2022
  43. Junio C HamanoDec 5, 2022
  44. 4/8 t/lib-patch-mode.sh: fix ignored exit codesÆvar Arnfjörð Bjarmason, Dec 2, 2022
  45. René ScharfeDec 2, 2022
  46. Eric SunshineDec 4, 2022
  47. 5/8 tests: use "test_cmp" instead of "test" in sub-shellsÆvar Arnfjörð Bjarmason, Dec 2, 2022
  48. Junio C HamanoDec 5, 2022
  49. 7/8 tests: don't lose "git" exit codes in "! ( git ... | grep )"Ævar Arnfjörð Bjarmason, Dec 2, 2022
  50. René ScharfeDec 2, 2022
  51. 6/8 tests: don't lose 'test <str> = $(cmd ...)"' exit codeÆvar Arnfjörð Bjarmason, Dec 2, 2022
  52. 8/8 tests: don't lose mist "git" exit codesÆvar Arnfjörð Bjarmason, Dec 2, 2022
  53. Eric SunshineDec 4, 2022
  54. Junio C HamanoDec 5, 2022
  55. 0/6 tests: fix ignored & hidden exit codesÆvar Arnfjörð Bjarmason, Dec 19, 2022
  56. 1/6 auto-crlf tests: don't lose exit code in loops and outside testsÆvar Arnfjörð Bjarmason, Dec 19, 2022
  57. René ScharfeDec 19, 2022
  58. 2/6 t/lib-patch-mode.sh: fix ignored exit codesÆvar Arnfjörð Bjarmason, Dec 19, 2022
  59. Junio C HamanoDec 20, 2022
  60. Phillip WoodDec 27, 2022
  61. Ævar Arnfjörð BjarmasonDec 27, 2022
  62. 3/6 tests: don't lose exit status with "(cd ...; test <op> $(git ...))"Ævar Arnfjörð Bjarmason, Dec 19, 2022
  63. Junio C HamanoDec 20, 2022
  64. 4/6 tests: don't lose exit status with "test <op> $(git ...)"Ævar Arnfjörð Bjarmason, Dec 19, 2022
  65. Junio C HamanoDec 26, 2022
  66. 5/6 tests: don't lose "git" exit codes in "! ( git ... | grep )"Ævar Arnfjörð Bjarmason, Dec 19, 2022
  67. Junio C HamanoDec 26, 2022
  68. Phillip WoodDec 27, 2022
  69. Phillip WoodDec 27, 2022
  70. Junio C HamanoDec 27, 2022
  71. 6/6 tests: don't lose misc "git" exit codesÆvar Arnfjörð Bjarmason, Dec 19, 2022
  72. Phillip WoodDec 27, 2022
  73. Ævar Arnfjörð BjarmasonDec 27, 2022
  74. Junio C HamanoDec 27, 2022
  75. Junio C HamanoDec 20, 2022
  76. 0/6 tests: fix ignored & hidden exit codesÆvar Arnfjörð Bjarmason, Feb 6, 2023
  77. 1/6 auto-crlf tests: don't lose exit code in loops and outside testsÆvar Arnfjörð Bjarmason, Feb 6, 2023
  78. 2/6 t/lib-patch-mode.sh: fix ignored exit codesÆvar Arnfjörð Bjarmason, Feb 6, 2023
  79. 3/6 tests: don't lose exit status with "(cd ...; test <op> $(git ...))"Ævar Arnfjörð Bjarmason, Feb 6, 2023
  80. 5/6 tests: don't lose "git" exit codes in "! ( git ... | grep )"Ævar Arnfjörð Bjarmason, Feb 6, 2023
  81. 4/6 tests: don't lose exit status with "test <op> $(git ...)"Ævar Arnfjörð Bjarmason, Feb 6, 2023
  82. 6/6 tests: don't lose misc "git" exit codesÆvar Arnfjörð Bjarmason, Feb 6, 2023
  83. Junio C HamanoFeb 6, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.