Skip to content

Teach 'test_must_fail' to save the command's stderr to a file

SZEDER Gábor git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest3 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3t: document 'test_must_fail ok=<signal-name>'t/README t/test-lib-functions.sh+22 -20 replies
2/3t: teach 'test_must_fail' to save the command's stderr to a filet/README t/test-lib-functions.sh+31 -106 replies
3/3t1404: use 'test_must_fail stderr=<file>'t/t1404-update-ref-errors.sh+23 -233 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/3] Teach 'test_must_fail' to save the command's stderr to a file

To check that a git command fails with the expected error message, we usually execute a command like this:

  test_must_fail git command --option 2>output.err

Alas, this command doesn't limit the redirection to the git command, but it redirects the standard error of the 'test_must_fail' helper function as well, causing various issues discussed in detail in the second patch. Therefore that patch introduces the 'test_must_fail stderr=<file>' option to save the executed git command's standard error to the given file.

The last patch converts one test script to use 'test_must_fail stderr=<file>' to demonstrate its benefits: thereafter that script will succeed with '-x'. There are plenty more places to convert:

  $ git grep -E 'test_(must|might)_fail .* 2>' t/*.sh |wc -l
  430
  $ git grep --name-only -E 'test_(must|might)_fail .* 2>' t/*.sh |wc -l
  135

... and this doesn't even count commands spanning more lines, and there are more in 'pu'.

I didn't convert more test scripts, because it's boring ;) but more importantly because it could give us 135+ GSoC micro projects.

SZEDER Gábor (3):
t: document 'test_must_fail ok=<signal-name>'
t: teach 'test_must_fail' to save the command's stderr to a file
t1404: use 'test_must_fail stderr=<file>'

 t/README                     | 20 +++++++++++++++++--
 t/t1404-update-ref-errors.sh | 46 ++++++++++++++++++++++----------------------
 t/test-lib-functions.sh      | 45 +++++++++++++++++++++++++++++++++----------
 3 files changed, 76 insertions(+), 35 deletions(-)
Signature · 1 line
2.16.1.180.g07550b0b1b