Skip to content

Commit c966745

Browse files
jrngitster
authored andcommitted
t/README: document more test helpers
There is no documentation in t/README for test_must_fail, test_might_fail, test_cmp, or test_when_finished. Reported-by: Jakub Narebski <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6fd4529 commit c966745

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/README

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,37 @@ library for your script to use.
448448
'Perl API' \
449449
"$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
450450

451+
- test_must_fail <git-command>
452+
453+
Run a git command and ensure it fails in a controlled way. Use
454+
this instead of "! <git-command>" to fail when git commands
455+
segfault.
456+
457+
- test_might_fail <git-command>
458+
459+
Similar to test_must_fail, but tolerate success, too. Use this
460+
instead of "<git-command> || :" to catch failures due to segv.
461+
462+
- test_cmp <expected> <actual>
463+
464+
Check whether the content of the <actual> file matches the
465+
<expected> file. This behaves like "cmp" but produces more
466+
helpful output when the test is run with "-v" option.
467+
468+
- test_when_finished <script>
469+
470+
Prepend <script> to a list of commands to run to clean up
471+
at the end of the current test. If some clean-up command
472+
fails, the test will not pass.
473+
474+
Example:
475+
476+
test_expect_success 'branch pointing to non-commit' '
477+
git rev-parse HEAD^{tree} >.git/refs/heads/invalid &&
478+
test_when_finished "git update-ref -d refs/heads/invalid" &&
479+
...
480+
'
481+
451482

452483
Tips for Writing Tests
453484
----------------------

0 commit comments

Comments
 (0)