{"thread":{"id":"614","subject":"[PATCH 1/2] Test suite fixup.","startedAt":"2005-05-14T07:24:27Z","lastAt":"2005-05-14T07:24:27Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"3286","messageId":"7vzmuy46dw.fsf@assigned-by-dhcp.cox.net","threadId":"614","inReplyTo":null,"subject":"[PATCH 1/2] Test suite fixup.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-05-14T07:24:27Z","receivedAt":"2005-05-14T07:24:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Exposing test_expect_success and test_expect_failure turns out\nto be enough for the test scripts and there is no need for\nexposing test_ok or test_failure.  This patch cleans it up and\nfixes the users of test_ok and test_failure.\n\nAlso test scripts have acquired a new command line flag\n'--immediate' to cause them to exit upon the first failure.\nThis is useful especially during the development of a new test.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\nThis is on top of the two \"test suite take 2\" patches.\n\nt/t1000-checkout-cache.sh |    9 +++------\nt/t1001-checkout-cache.sh |   15 ++++++---------\nt/test-lib.sh             |   15 +++++++++------\n3 files changed, 18 insertions(+), 21 deletions(-)\n\n--- a/t/t1000-checkout-cache.sh\n+++ b/t/t1000-checkout-cache.sh\n@@ -44,12 +44,9 @@\n     'git-checkout-cache with -f should succeed.' \\\n     'git-checkout-cache -f -a'\n \n-if test -f path0 && test -d path1 && test -f path1/file1\n-then\n-\ttest_ok \"checkout successful\"\n-else\n-\ttest_failure \"checkout failed\"\n-fi\n+test_expect_success \\\n+    'git-checkout-cache conflicting paths.' \\\n+    'test -f path0 && test -d path1 && test -f path1/file1'\n \n test_done\n \n--- a/t/t1001-checkout-cache.sh\n+++ b/t/t1001-checkout-cache.sh\n@@ -76,15 +76,12 @@\n     'git-read-tree $tree2 && git-checkout-cache -f -a'\n test_debug show_files $tree2\n \n-if test ! -h path0 && test -d path0 &&\n-   test ! -h path1 && test -d path1 &&\n-   test ! -h path0/file0 && test -f path0/file0 &&\n-   test ! -h path1/file1 && test -f path1/file1\n-then\n-    test_ok \"checked out correctly.\"\n-else\n-    test_failure \"did not check out correctly.\"\n-fi\n+test_expect_success \\\n+    'checking out conflicting path with -f' \\\n+    'test ! -h path0 && test -d path0 &&\n+     test ! -h path1 && test -d path1 &&\n+     test ! -h path0/file0 && test -f path0/file0 &&\n+     test ! -h path1/file1 && test -f path1/file1'\n \n test_done\n \n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -50,6 +50,8 @@\n \tcase \"$1\" in\n \t-d|--d|--de|--deb|--debu|--debug)\n \t\tdebug=t; shift ;;\n+\t-i|--i|--im|--imm|--imme|--immed|--immedi|--immedia|--immediat|--immediate)\n+\timmediate=t; shift ;;\n \t-h|--h|--he|--hel|--help)\n \t\techo \"$test_description\"\n \t\texit 0 ;;\n@@ -74,15 +76,16 @@\n \ttest \"$debug\" == \"\" || eval \"$1\"\n }\n \n-test_ok () {\n+test_ok_ () {\n \ttest_count=$(expr \"$test_count\" + 1)\n \tsay \"ok #$test_count: $@\"\n }\n \n-test_failure () {\n+test_failure_ () {\n \ttest_count=$(expr \"$test_count\" + 1)\n \ttest_failure=$(expr \"$test_failure\" + 1);\n \tsay \"NO #$test_count: $@\"\n+\ttest \"$immediate\" == \"\" || exit 1\n }\n \n test_expect_failure () {\n@@ -91,9 +94,9 @@\n \tsay >&3 \"expecting failure: $2\"\n \tif eval >&3 2>&4 \"$2\"\n \tthen\n-\t\ttest_failure \"$@\"\n+\t\ttest_failure_ \"$@\"\n \telse\n-\t\ttest_ok \"$1\"\n+\t\ttest_ok_ \"$1\"\n \tfi\n }\n \n@@ -103,9 +106,9 @@\n \tsay >&3 \"expecting success: $2\"\n \tif eval >&3 2>&4 \"$2\"\n \tthen\n-\t\ttest_ok \"$1\"\n+\t\ttest_ok_ \"$1\"\n \telse\n-\t\ttest_failure \"$@\"\n+\t\ttest_failure_ \"$@\"\n \tfi\n }\n \n\n\n"}]}