From 41ac414ea2bef81af94474cbef25a38868b4788e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 1 Feb 2008 01:50:53 -0800 Subject: [PATCH] Sane use of test_expect_failure Originally, test_expect_failure was designed to be the opposite of test_expect_success, but this was a bad decision. Most tests run a series of commands that leads to the single command that needs to be tested, like this: test_expect_{success,failure} 'test title' ' setup1 && setup2 && setup3 && what is to be tested ' And expecting a failure exit from the whole sequence misses the point of writing tests. Your setup$N that are supposed to succeed may have failed without even reaching what you are trying to test. The only valid use of test_expect_failure is to check a trivial single command that is expected to fail, which is a minority in tests of Porcelain-ish commands. This large-ish patch rewrites all uses of test_expect_failure to use test_expect_success and rewrites the condition of what is tested, like this: test_expect_success 'test title' ' setup1 && setup2 && setup3 && ! this command should fail ' test_expect_failure is redefined to serve as a reminder that that test *should* succeed but due to a known breakage in git it currently does not pass. So if git-foo command should create a file 'bar' but you discovered a bug that it doesn't, you can write a test like this: test_expect_failure 'git-foo should create bar' ' rm -f bar && git foo && test -f bar ' This construct acts similar to test_expect_success, but instead of reporting "ok/FAIL" like test_expect_success does, the outcome is reported as "FIXED/still broken". Signed-off-by: Junio C Hamano --- t/README | 14 +- t/t0000-basic.sh | 30 ++-- t/t0030-stripspace.sh | 40 +++--- t/t0040-parse-options.sh | 4 +- t/t1000-read-tree-m-3way.sh | 161 ++++++++++++---------- t/t1200-tutorial.sh | 8 +- t/t1300-repo-config.sh | 39 +++--- t/t1302-repo-version.sh | 5 +- t/t1400-update-ref.sh | 24 ++-- t/t2000-checkout-cache-clash.sh | 4 +- t/t2002-checkout-cache-u.sh | 4 +- t/t2008-checkout-subdir.sh | 16 +-- t/t2100-update-cache-badpath.sh | 4 +- t/t3020-ls-files-error-unmatch.sh | 4 +- t/t3200-branch.sh | 36 ++--- t/t3210-pack-refs.sh | 26 ++-- t/t3400-rebase.sh | 4 +- t/t3403-rebase-skip.sh | 6 +- t/t3600-rm.sh | 17 +-- t/t4103-apply-binary.sh | 68 ++++----- t/t4113-apply-ending.sh | 8 +- t/t5300-pack-object.sh | 4 +- t/t5302-pack-index.sh | 32 ++--- t/t5401-update-hooks.sh | 8 +- t/t5402-post-merge-hook.sh | 4 +- t/t5500-fetch-pack.sh | 4 +- t/t5510-fetch.sh | 12 +- t/t5530-upload-pack-error.sh | 14 +- t/t5600-clone-fail-cleanup.sh | 12 +- t/t5710-info-alternate.sh | 14 +- t/t6023-merge-file.sh | 12 +- t/t6024-recursive-merge.sh | 2 +- t/t6025-merge-symlinks.sh | 21 ++- t/t6101-rev-parse-parents.sh | 2 +- t/t6300-for-each-ref.sh | 8 +- t/t7001-mv.sh | 4 +- t/t7002-grep.sh | 4 +- t/t7004-tag.sh | 36 ++--- t/t7101-reset.sh | 24 ++-- t/t7501-commit.sh | 40 +++--- t/t7503-pre-commit-hook.sh | 4 +- t/t7504-commit-msg-hook.sh | 8 +- t/t9100-git-svn-basic.sh | 28 ++-- t/t9106-git-svn-commit-diff-clobber.sh | 18 +-- t/t9106-git-svn-dcommit-clobber-series.sh | 4 +- t/t9300-fast-import.sh | 24 ++-- t/t9400-git-cvsserver-server.sh | 30 ++-- t/test-lib.sh | 30 +++- 48 files changed, 498 insertions(+), 427 deletions(-) diff --git a/t/README b/t/README index 36f251761..73ed11bfe 100644 --- a/t/README +++ b/t/README @@ -160,14 +160,12 @@ library for your script to use. - test_expect_failure