@matheusbsbs / matheus-bagliano / commits / c9667456d2
Fork 0

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 <jnareb@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jonathan Nieder committed Jul 6, 2010 at 15:04 UTC c9667456d201c435af523ffb7d583efd1784232a
1 file changed +31
t/README
+31
@@ -448,6 +448,37 @@ library for your script to use.
448 'Perl API' \
449 "$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
450
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 +
482
483 Tips for Writing Tests
484 ----------------------