From: Tomi Ollila Date: Mon, 25 Nov 2013 17:08:17 +0000 (+0200) Subject: [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in test-lib.sh X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=8a3fea1e459d5603a8b739c7219d6d983128c435;p=notmuch-archives.git [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in test-lib.sh --- diff --git a/6d/986207c764d4f8aee6895fd7a89d013ca577ba b/6d/986207c764d4f8aee6895fd7a89d013ca577ba new file mode 100644 index 000000000..51a5d0a03 --- /dev/null +++ b/6d/986207c764d4f8aee6895fd7a89d013ca577ba @@ -0,0 +1,138 @@ +Return-Path: +X-Original-To: notmuch@notmuchmail.org +Delivered-To: notmuch@notmuchmail.org +Received: from localhost (localhost [127.0.0.1]) + by olra.theworths.org (Postfix) with ESMTP id 3CDC6429E27 + for ; Mon, 25 Nov 2013 09:08:46 -0800 (PST) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0 +X-Spam-Level: +X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] + autolearn=disabled +Received: from olra.theworths.org ([127.0.0.1]) + by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) + with ESMTP id YByIVZYlm4gf for ; + Mon, 25 Nov 2013 09:08:40 -0800 (PST) +Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) + by olra.theworths.org (Postfix) with ESMTP id 8670E431FDD + for ; Mon, 25 Nov 2013 09:08:37 -0800 (PST) +Received: by guru.guru-group.fi (Postfix, from userid 501) + id 95939100063; Mon, 25 Nov 2013 19:08:27 +0200 (EET) +From: Tomi Ollila +To: notmuch@notmuchmail.org +Subject: [PATCH 1/3] test: resolve `basename "$0" .sh` once for all in + test-lib.sh +Date: Mon, 25 Nov 2013 19:08:17 +0200 +Message-Id: <1385399299-12936-1-git-send-email-tomi.ollila@iki.fi> +X-Mailer: git-send-email 1.8.0 +In-Reply-To: <1384288868-23903-1-git-send-email-tomi.ollila@iki.fi> +References: <1384288868-23903-1-git-send-email-tomi.ollila@iki.fi> +Cc: tomi.ollila@iki.fi +X-BeenThere: notmuch@notmuchmail.org +X-Mailman-Version: 2.1.13 +Precedence: list +List-Id: "Use and development of the notmuch mail system." + +List-Unsubscribe: , + +List-Archive: +List-Post: +List-Help: +List-Subscribe: , + +X-List-Received-Date: Mon, 25 Nov 2013 17:08:46 -0000 + +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 8611ba5..6e47545 100644 +--- a/test/test-lib.sh ++++ b/test/test-lib.sh +@@ -23,19 +23,22 @@ if [ ${BASH_VERSINFO[0]} -lt 4 ]; then + 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 + done,*) + # do not redirect again + ;; + *' --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 + exit + ;; +@@ -185,11 +188,11 @@ if test "$help" = "t" + then + echo "Tests ${test_description}" + exit 0 + fi + +-echo $(basename "$0"): "Testing ${test_description}" ++echo $this_test: "Testing ${test_description}" + + exec 5>&1 + + test_failure=0 + test_count=0 +@@ -965,11 +968,11 @@ test_when_finished () { + + 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 + echo "fixed $test_fixed" >> $test_results_path + echo "broken $test_broken" >> $test_results_path +@@ -1024,11 +1027,11 @@ test_emacs () { + test_require_external_prereq emacs || missing_dependencies=1 + test_require_external_prereq ${TEST_EMACSCLIENT} || missing_dependencies=1 + 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 + load_emacs_tests= + fi +@@ -1138,11 +1141,10 @@ then + exec 4>&2 3>&1 + else + exec 4>test.output 3>&4 + fi + +-this_test=${0##*/} + for skp in $NOTMUCH_SKIP_TESTS + do + to_skip= + for skp in $NOTMUCH_SKIP_TESTS + do +-- +1.8.4.2 +