{"thread":{"id":"19627","subject":"various fixes to the test library","startedAt":"2009-06-01T12:14:39Z","lastAt":"2009-06-01T12:28:25Z","messageCount":5,"participants":["Clemens Buchacher"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"115196","messageId":"1243858482-6353-1-git-send-email-drizzd@aon.at","threadId":"19627","inReplyTo":null,"subject":"various fixes to the test library","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-06-01T12:14:39Z","receivedAt":"2009-06-01T12:14:39Z","isPatch":false,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"If a http test failed, and the test was run with --immediate, the cleanup code\nwould not be executed and stale web server instance were left behind. This is\nfixed by 2/3.\n\nClemens\n\n[PATCH 1/3] test-lib: fail if invalid options are passed\n[PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests\n[PATCH 3/3] test-lib: fix http exit codes\n\n t/lib-httpd.sh |    6 ++++--\n t/test-lib.sh  |   23 +++++++++++++++--------\n 2 files changed, 19 insertions(+), 10 deletions(-)\n"},{"id":"115197","messageId":"1243858482-6353-2-git-send-email-drizzd@aon.at","threadId":"19627","inReplyTo":"1243858482-6353-1-git-send-email-drizzd@aon.at","subject":"[PATCH 1/3] test-lib: fail if invalid options are passed","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-06-01T12:14:40Z","receivedAt":"2009-06-01T12:14:40Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Previously, unknown options would be ignored, including any subsequent\nvalid options.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n t/test-lib.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex dad1437..6e83ceb 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -115,7 +115,7 @@ do\n \t--tee)\n \t\tshift ;; # was handled already\n \t*)\n-\t\tbreak ;;\n+\t\techo \"error: unknown test option '$1'\" >&2; exit 1 ;;\n \tesac\n done\n \n-- \n1.6.3.1.147.g637c3\n"},{"id":"115198","messageId":"1243858482-6353-3-git-send-email-drizzd@aon.at","threadId":"19627","inReplyTo":"1243858482-6353-2-git-send-email-drizzd@aon.at","subject":"[PATCH 2/3] test-lib: allow exit trap to be used for cleanup by tests","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-06-01T12:14:41Z","receivedAt":"2009-06-01T12:14:41Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Exit trap should not be removed in case tests require cleanup code. This\nis especially important if tests are executed with the --immediate option.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n t/test-lib.sh |   21 ++++++++++++++-------\n 1 files changed, 14 insertions(+), 7 deletions(-)\n\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex 6e83ceb..5fdc5d9 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -147,7 +147,7 @@ fi\n \n error () {\n \tsay_color error \"error: $*\"\n-\ttrap - EXIT\n+\tGIT_EXIT_OK=t\n \texit 1\n }\n \n@@ -179,10 +179,17 @@ test_broken=0\n test_success=0\n \n die () {\n-\techo >&5 \"FATAL: Unexpected exit with code $?\"\n-\texit 1\n+\tcode=$?\n+\tif test -n \"$GIT_EXIT_OK\"\n+\tthen\n+\t\texit $code\n+\telse\n+\t\techo >&5 \"FATAL: Unexpected exit with code $code\"\n+\t\texit 1\n+\tfi\n }\n \n+GIT_EXIT_OK=\n trap 'die' EXIT\n \n # The semantics of the editor variables are that of invoking\n@@ -285,7 +292,7 @@ test_failure_ () {\n \tsay_color error \"FAIL $test_count: $1\"\n \tshift\n \techo \"$@\" | sed -e 's/^/\t/'\n-\ttest \"$immediate\" = \"\" || { trap - EXIT; exit 1; }\n+\ttest \"$immediate\" = \"\" || { GIT_EXIT_OK=t; exit 1; }\n }\n \n test_known_broken_ok_ () {\n@@ -347,7 +354,7 @@ test_expect_failure () {\n \t\tthen\n \t\t\ttest_known_broken_ok_ \"$1\"\n \t\telse\n-\t\t    test_known_broken_failure_ \"$1\"\n+\t\t\ttest_known_broken_failure_ \"$1\"\n \t\tfi\n \tfi\n \techo >&3 \"\"\n@@ -498,7 +505,7 @@ test_create_repo () {\n }\n \n test_done () {\n-\ttrap - EXIT\n+\tGIT_EXIT_OK=t\n \ttest_results_dir=\"$TEST_DIRECTORY/test-results\"\n \tmkdir -p \"$test_results_dir\"\n \ttest_results_path=\"$test_results_dir/${0%.sh}-$$\"\n@@ -640,7 +647,7 @@ fi\n test=\"trash directory.$(basename \"$0\" .sh)\"\n test ! -z \"$debug\" || remove_trash=\"$TEST_DIRECTORY/$test\"\n rm -fr \"$test\" || {\n-\ttrap - EXIT\n+\tGIT_EXIT_OK=t\n \techo >&5 \"FATAL: Cannot prepare test area\"\n \texit 1\n }\n-- \n1.6.3.1.147.g637c3\n"},{"id":"115199","messageId":"1243858482-6353-4-git-send-email-drizzd@aon.at","threadId":"19627","inReplyTo":"1243858482-6353-3-git-send-email-drizzd@aon.at","subject":"[PATCH 3/3] test-lib: fix http exit codes","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-06-01T12:14:42Z","receivedAt":"2009-06-01T12:14:42Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Previously, die() would report the exit code of stop_httpd. Instead,\nsave the exit code and pass it to die() explicitly.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n t/lib-httpd.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/lib-httpd.sh b/t/lib-httpd.sh\nindex cde659d..6765b08 100644\n--- a/t/lib-httpd.sh\n+++ b/t/lib-httpd.sh\n@@ -93,14 +93,16 @@ prepare_httpd() {\n start_httpd() {\n \tprepare_httpd >&3 2>&4\n \n-\ttrap 'stop_httpd; die' EXIT\n+\ttrap 'code=$?; stop_httpd; (exit $code); die' EXIT\n \n \t\"$LIB_HTTPD_PATH\" -d \"$HTTPD_ROOT_PATH\" \\\n \t\t-f \"$TEST_PATH/apache.conf\" $HTTPD_PARA \\\n \t\t-c \"Listen 127.0.0.1:$LIB_HTTPD_PORT\" -k start \\\n \t\t>&3 2>&4\n-\tif ! test $? = 0; then\n+\tif test $? -ne 0\n+\tthen\n \t\tsay \"skipping test, web server setup failed\"\n+\t\ttrap 'die' EXIT\n \t\ttest_done\n \tfi\n }\n-- \n1.6.3.1.147.g637c3\n"},{"id":"115200","messageId":"20090601122825.GA29406@localhost","threadId":"19627","inReplyTo":"1243858482-6353-4-git-send-email-drizzd@aon.at","subject":"Re: [PATCH 3/3 v2] test-lib: fix http exit codes","fromName":"Clemens Buchacher","fromEmail":"drizzd@aon.at","sentAt":"2009-06-01T12:28:25Z","receivedAt":"2009-06-01T12:28:25Z","isPatch":true,"sender":{"key":"drizzd@gmx.net","avatar":"https://avatars.githubusercontent.com/u/59082?v=4"},"body":"Previously, die() would report the exit code of stop_httpd. Instead,\nsave and reset the exit code before dying.\n\nSigned-off-by: Clemens Buchacher <drizzd@aon.at>\n---\n\nOn Mon, Jun 01, 2009 at 02:14:42PM +0200, Clemens Buchacher wrote:\n> Previously, die() would report the exit code of stop_httpd. Instead,\n> save the exit code and pass it to die() explicitly.\n\nOops, I forgot to fix the commit message. (I tried to pass the exit code to\ndie() explicitly, but then I realized that this is much easier.)\n\nClemens\n\n t/lib-httpd.sh |    6 ++++--\n 1 files changed, 4 insertions(+), 2 deletions(-)\n\ndiff --git a/t/lib-httpd.sh b/t/lib-httpd.sh\nindex cde659d..6765b08 100644\n--- a/t/lib-httpd.sh\n+++ b/t/lib-httpd.sh\n@@ -93,14 +93,16 @@ prepare_httpd() {\n start_httpd() {\n \tprepare_httpd >&3 2>&4\n \n-\ttrap 'stop_httpd; die' EXIT\n+\ttrap 'code=$?; stop_httpd; (exit $code); die' EXIT\n \n \t\"$LIB_HTTPD_PATH\" -d \"$HTTPD_ROOT_PATH\" \\\n \t\t-f \"$TEST_PATH/apache.conf\" $HTTPD_PARA \\\n \t\t-c \"Listen 127.0.0.1:$LIB_HTTPD_PORT\" -k start \\\n \t\t>&3 2>&4\n-\tif ! test $? = 0; then\n+\tif test $? -ne 0\n+\tthen\n \t\tsay \"skipping test, web server setup failed\"\n+\t\ttrap 'die' EXIT\n \t\ttest_done\n \tfi\n }\n-- \n1.6.3.1.147.g637c3\n"}]}