unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in test-lib.sh
@ 2013-11-12 20:41 Tomi Ollila
  2013-11-12 20:41 ` [PATCH 2/3] test: print empty line at the beginning of test script, not at end Tomi Ollila
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Tomi Ollila @ 2013-11-12 20:41 UTC (permalink / raw)
  To: notmuch; +Cc: tomi.ollila

test-lib.sh sometimes did equivalent of `basename "$0" .sh`, sometimes
skipping the basename part and sometimes .sh part. This worked as
we never had path components in $0 (more than ./) nor .sh ending.

Now the equivalent of `basename "$0" .sh` is done once and used
everywhere. In the future we may have .sh suffix in test names
-- removing those is a good idea.
---
 test/test-lib.sh | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/test/test-lib.sh b/test/test-lib.sh
index 2aa4dfc..808bb7f 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -25,6 +25,9 @@ fi
 # Make sure echo builtin does not expand backslash-escape sequences by default.
 shopt -u xpg_echo
 
+this_test=${0##*/}
+this_test=${this_test%.sh}
+
 # if --tee was passed, write the output not only to the terminal, but
 # additionally to the file test-results/$BASENAME.out, too.
 case "$GIT_TEST_TEE_STARTED, $* " in
@@ -33,7 +36,7 @@ done,*)
 	;;
 *' --tee '*|*' --va'*)
 	mkdir -p test-results
-	BASE=test-results/$(basename "$0" .sh)
+	BASE=test-results/$this_test
 	(GIT_TEST_TEE_STARTED=done ${SHELL-sh} "$0" "$@" 2>&1;
 	 echo $? > $BASE.exit) | tee $BASE.out
 	test "$(cat $BASE.exit)" = 0
@@ -187,7 +190,7 @@ then
 	exit 0
 fi
 
-echo $(basename "$0"): "Testing ${test_description}"
+echo $this_test: "Testing ${test_description}"
 
 exec 5>&1
 
@@ -956,7 +959,7 @@ test_done () {
 	GIT_EXIT_OK=t
 	test_results_dir="$TEST_DIRECTORY/test-results"
 	mkdir -p "$test_results_dir"
-	test_results_path="$test_results_dir/${0%.sh}"
+	test_results_path="$test_results_dir/$this_test"
 
 	echo "total $test_count" >> $test_results_path
 	echo "success $test_success" >> $test_results_path
@@ -1015,7 +1018,7 @@ test_emacs () {
 	test -z "$missing_dependencies" || return
 
 	if [ -z "$EMACS_SERVER" ]; then
-		emacs_tests="$(basename $0).el"
+		emacs_tests="${this_test}.el"
 		if [ -f "$TEST_DIRECTORY/$emacs_tests" ]; then
 			load_emacs_tests="--eval '(load \"$emacs_tests\")'"
 		else
@@ -1129,7 +1132,6 @@ else
 	exec 4>test.output 3>&4
 fi
 
-this_test=${0##*/}
 for skp in $NOTMUCH_SKIP_TESTS
 do
 	to_skip=
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2013-12-09 20:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-12 20:41 [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in test-lib.sh Tomi Ollila
2013-11-12 20:41 ` [PATCH 2/3] test: print empty line at the beginning of test script, not at end Tomi Ollila
2013-11-12 20:41 ` [PATCH 3/3] test: implement and document NOTMUCH_TEST_QUIET variable usage Tomi Ollila
2013-11-12 23:02   ` Austin Clements
2013-11-13  8:36     ` Tomi Ollila
2013-11-25 17:08 ` [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in test-lib.sh Tomi Ollila
2013-11-25 17:08   ` [PATCH 2/3] test: print empty line at the beginning of test script, not at end Tomi Ollila
2013-11-25 17:08   ` [PATCH 3/3] test: implement and document NOTMUCH_TEST_QUIET variable usage Tomi Ollila
2013-12-04 16:18     ` Austin Clements
2013-12-04 20:15       ` Austin Clements
2013-12-05 12:46   ` [PATCH v3 part " Tomi Ollila
2013-12-09  0:33     ` Austin Clements
2013-12-09 20:24     ` David Bremner

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).