[PATCH 1/3] test: resolve `basename "$0" .sh` once for all in test-lib.sh
authorTomi Ollila <tomi.ollila@iki.fi>
Tue, 12 Nov 2013 20:41:06 +0000 (22:41 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:58:13 +0000 (09:58 -0800)
a1/ce5a6af753e3fb539d2a1c26cb16ae0ee1a570 [new file with mode: 0644]

diff --git a/a1/ce5a6af753e3fb539d2a1c26cb16ae0ee1a570 b/a1/ce5a6af753e3fb539d2a1c26cb16ae0ee1a570
new file mode 100644 (file)
index 0000000..092a351
--- /dev/null
@@ -0,0 +1,115 @@
+Return-Path: <too@guru-group.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 308CF431FDC\r
+       for <notmuch@notmuchmail.org>; Tue, 12 Nov 2013 12:41:22 -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 hF8o721EUuIK for <notmuch@notmuchmail.org>;\r
+       Tue, 12 Nov 2013 12:41:16 -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 8722D431FCF\r
+       for <notmuch@notmuchmail.org>; Tue, 12 Nov 2013 12:41:16 -0800 (PST)\r
+Received: by guru.guru-group.fi (Postfix, from userid 501)\r
+       id 30DE810009D; Tue, 12 Nov 2013 22:41:10 +0200 (EET)\r
+From: Tomi Ollila <tomi.ollila@iki.fi>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in\r
+       test-lib.sh\r
+Date: Tue, 12 Nov 2013 22:41:06 +0200\r
+Message-Id: <1384288868-23903-1-git-send-email-tomi.ollila@iki.fi>\r
+X-Mailer: git-send-email 1.8.0\r
+Cc: tomi.ollila@iki.fi\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: Tue, 12 Nov 2013 20:41:22 -0000\r
+\r
+test-lib.sh sometimes did equivalent of `basename "$0" .sh`, sometimes\r
+skipping the basename part and sometimes .sh part. This worked as\r
+we never had path components in $0 (more than ./) nor .sh ending.\r
+\r
+Now the equivalent of `basename "$0" .sh` is done once and used\r
+everywhere. In the future we may have .sh suffix in test names\r
+-- removing those is a good idea.\r
+---\r
+ test/test-lib.sh | 12 +++++++-----\r
+ 1 file changed, 7 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/test/test-lib.sh b/test/test-lib.sh\r
+index 2aa4dfc..808bb7f 100644\r
+--- a/test/test-lib.sh\r
++++ b/test/test-lib.sh\r
+@@ -25,6 +25,9 @@ fi\r
+ # Make sure echo builtin does not expand backslash-escape sequences by default.\r
+ shopt -u xpg_echo\r
\r
++this_test=${0##*/}\r
++this_test=${this_test%.sh}\r
++\r
+ # if --tee was passed, write the output not only to the terminal, but\r
+ # additionally to the file test-results/$BASENAME.out, too.\r
+ case "$GIT_TEST_TEE_STARTED, $* " in\r
+@@ -33,7 +36,7 @@ done,*)\r
+       ;;\r
+ *' --tee '*|*' --va'*)\r
+       mkdir -p test-results\r
+-      BASE=test-results/$(basename "$0" .sh)\r
++      BASE=test-results/$this_test\r
+       (GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1;\r
+        echo $? > $BASE.exit) | tee $BASE.out\r
+       test "$(cat $BASE.exit)" = 0\r
+@@ -187,7 +190,7 @@ then\r
+       exit 0\r
+ fi\r
\r
+-echo $(basename "$0"): "Testing ${test_description}"\r
++echo $this_test: "Testing ${test_description}"\r
\r
+ exec 5>&1\r
\r
+@@ -956,7 +959,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/$this_test"\r
\r
+       echo "total $test_count" >> $test_results_path\r
+       echo "success $test_success" >> $test_results_path\r
+@@ -1015,7 +1018,7 @@ test_emacs () {\r
+       test -z "$missing_dependencies" || return\r
\r
+       if [ -z "$EMACS_SERVER" ]; then\r
+-              emacs_tests="$(basename $0).el"\r
++              emacs_tests="${this_test}.el"\r
+               if [ -f "$TEST_DIRECTORY/$emacs_tests" ]; then\r
+                       load_emacs_tests="--eval '(load \"$emacs_tests\")'"\r
+               else\r
+@@ -1129,7 +1132,6 @@ else\r
+       exec 4>test.output 3>&4\r
+ fi\r
\r
+-this_test=${0##*/}\r
+ for skp in $NOTMUCH_SKIP_TESTS\r
+ do\r
+       to_skip=\r
+-- \r
+1.8.3.1\r
+\r