Re: [PATCH] test: Abort driver if a test script aborts
authorTomi Ollila <tomi.ollila@iki.fi>
Wed, 28 Nov 2012 07:25:07 +0000 (09:25 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:51:05 +0000 (09:51 -0800)
28/159b614abad2c248f226bbeee1a943db97d284 [new file with mode: 0644]

diff --git a/28/159b614abad2c248f226bbeee1a943db97d284 b/28/159b614abad2c248f226bbeee1a943db97d284
new file mode 100644 (file)
index 0000000..0a83e61
--- /dev/null
@@ -0,0 +1,129 @@
+Return-Path: <tomi.ollila@iki.fi>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1F7C6431FAF\r
+       for <notmuch@notmuchmail.org>; Tue, 27 Nov 2012 23:25:12 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
+       autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id q6qaPtFzYEre for <notmuch@notmuchmail.org>;\r
+       Tue, 27 Nov 2012 23:25:11 -0800 (PST)\r
+Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
+       by olra.theworths.org (Postfix) with ESMTP id 0EE59431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 27 Nov 2012 23:25:11 -0800 (PST)\r
+Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
+       by guru.guru-group.fi (Postfix) with ESMTP id 4FFC31000E5;\r
+       Wed, 28 Nov 2012 09:25:07 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH] test: Abort driver if a test script aborts\r
+In-Reply-To: <1354075997-29140-1-git-send-email-amdragon@mit.edu>\r
+References: <1354075997-29140-1-git-send-email-amdragon@mit.edu>\r
+User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1\r
+       (x86_64-unknown-linux-gnu)\r
+X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
+       $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
+       !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
+Date: Wed, 28 Nov 2012 09:25:07 +0200\r
+Message-ID: <m28v9mxk8c.fsf@guru.guru-group.fi>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Wed, 28 Nov 2012 07:25:12 -0000\r
+\r
+On Wed, Nov 28 2012, Austin Clements <amdragon@MIT.EDU> wrote:\r
+\r
+> Previously, if a test script aborted (e.g., because it passed too few\r
+> arguments to a test function), the test driver loop would simply\r
+> continue on to the next test script and the final results would\r
+> declare that everything passed (except that the test count would look\r
+> suspiciously low, but maybe you just misremembered how many tests\r
+> there were).\r
+>\r
+> Now, if a test script exits with a non-zero status and did not produce\r
+> a final results file, we propagate that failure out of the driver loop\r
+> immediately.\r
+>\r
+> To keep this simple, this patch removes the PID from the test-results\r
+> file name.  This PID was inherited from the git test system and seems\r
+> unnecessary, since the file name already includes the name of the test\r
+> script and the test-results directory is created anew for each run.\r
+> ---\r
+\r
++1\r
+\r
+Tomi\r
+\r
+\r
+>  test/basic        |    2 +-\r
+>  test/notmuch-test |    6 ++++++\r
+>  test/test-lib.sh  |    2 +-\r
+>  3 files changed, 8 insertions(+), 2 deletions(-)\r
+>\r
+> diff --git a/test/basic b/test/basic\r
+> index 1b842d2..b7feb07 100755\r
+> --- a/test/basic\r
+> +++ b/test/basic\r
+> @@ -79,7 +79,7 @@ test_begin_subtest "Ensure that -v does not suppress test output"\r
+>  output=$(cd $TEST_DIRECTORY; ./test-verbose -v 2>&1 | suppress_diff_date)\r
+>  expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)\r
+>  # Do not include the results of test-verbose in totals\r
+> -rm $TEST_DIRECTORY/test-results/test-verbose-*\r
+> +rm $TEST_DIRECTORY/test-results/test-verbose\r
+>  rm -r $TEST_DIRECTORY/tmp.test-verbose\r
+>  test_expect_equal "$output" "$expected"\r
+>  \r
+> diff --git a/test/notmuch-test b/test/notmuch-test\r
+> index 9a1b375..f275439 100755\r
+> --- a/test/notmuch-test\r
+> +++ b/test/notmuch-test\r
+> @@ -81,6 +81,12 @@ trap 'e=$?; kill $!; exit $e' HUP INT TERM\r
+>  for test in $TESTS; do\r
+>      $TEST_TIMEOUT_CMD ./$test "$@" &\r
+>      wait $!\r
+> +    # If the test failed without producing results, then it aborted,\r
+> +    # so we should abort, too.\r
+> +    RES=$?\r
+> +    if [[ $RES != 0 && ! -e "test-results/${test%.sh}" ]]; then\r
+> +        exit $RES\r
+> +    fi\r
+>  done\r
+>  trap - HUP INT TERM\r
+>  \r
+> diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+> index e092231..77063a4 100644\r
+> --- a/test/test-lib.sh\r
+> +++ b/test/test-lib.sh\r
+> @@ -920,7 +920,7 @@ test_done () {\r
+>      GIT_EXIT_OK=t\r
+>      test_results_dir="$TEST_DIRECTORY/test-results"\r
+>      mkdir -p "$test_results_dir"\r
+> -    test_results_path="$test_results_dir/${0%.sh}-$$"\r
+> +    test_results_path="$test_results_dir/${0%.sh}"\r
+>  \r
+>      echo "total $test_count" >> $test_results_path\r
+>      echo "success $test_success" >> $test_results_path\r
+> -- \r
+> 1.7.10.4\r
+>\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r