From: David Bremner <david@tethera.net>
To: notmuch@notmuchmail.org
Subject: [PATCH v4 02/11] test: split variable settings to their own file
Date: Sat, 12 Feb 2022 16:27:33 -0400 [thread overview]
Message-ID: <20220212202742.2577237-3-david@tethera.net> (raw)
In-Reply-To: <20220212202742.2577237-1-david@tethera.net>
This allows sharing more variable settings between the (correctness)
tests and the performance-tests. Unfortunately it seems a bit tricky
to move settings to test-lib-common.sh, as that is sourced late in
test-lib.sh, and moving it earlier breaks things.
---
performance-test/perf-test-lib.sh | 2 ++
test/test-lib.sh | 55 +----------------------------
test/test-vars.sh | 58 +++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 54 deletions(-)
create mode 100644 test/test-vars.sh
diff --git a/performance-test/perf-test-lib.sh b/performance-test/perf-test-lib.sh
index 41b1ddfd..0e4915e3 100644
--- a/performance-test/perf-test-lib.sh
+++ b/performance-test/perf-test-lib.sh
@@ -41,6 +41,8 @@ done
# Ensure NOTMUCH_SRCDIR and NOTMUCH_BUILDDIR are set.
. $(dirname "$0")/../test/export-dirs.sh || exit 1
+. "$NOTMUCH_SRCDIR/test/test-vars.sh" || exit 1
+
# Where to run the tests
TEST_DIRECTORY=$NOTMUCH_BUILDDIR/performance-test
diff --git a/test/test-lib.sh b/test/test-lib.sh
index 833bf5fe..89e5c6d8 100644
--- a/test/test-lib.sh
+++ b/test/test-lib.sh
@@ -64,55 +64,7 @@ exec 6>&1 7>&2
BASH_XTRACEFD=7
export PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
-# Keep the original TERM for say_color and test_emacs
-ORIGINAL_TERM=$TERM
-
-# Set SMART_TERM to vt100 for known dumb/unknown terminal.
-# Otherwise use whatever TERM is currently used so that
-# users' actual TERM environments are being used in tests.
-case ${TERM-} in
- '' | dumb | unknown )
- SMART_TERM=vt100 ;;
- *)
- SMART_TERM=$TERM ;;
-esac
-
-# For repeatability, reset the environment to known value.
-LANG=C
-LC_ALL=C
-PAGER=cat
-TZ=UTC
-TERM=dumb
-export LANG LC_ALL PAGER TERM TZ
-GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
-if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
- ( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then
- echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2
- exit 1
-fi
-TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}
-TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}
-TEST_GDB=${TEST_GDB:-gdb}
-TEST_CC=${TEST_CC:-cc}
-TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
-TEST_SHIM_CFLAGS=${TEST_SHIM_CFLAGS:-"-fpic -shared"}
-TEST_SHIM_LDFLAGS=${TEST_SHIM_LDFLAGS:-"-ldl"}
-
-# Protect ourselves from common misconfiguration to export
-# CDPATH into the environment
-unset CDPATH
-
-unset GREP_OPTIONS
-
-# For lib/open.cc:_load_key_file
-unset XDG_CONFIG_HOME
-
-# For emacsclient
-unset ALTERNATE_EDITOR
-
-# for reproducibility
-unset EMAIL
-unset NAME
+. "$NOTMUCH_SRCDIR/test/test-vars.sh" || exit 1
add_gnupg_home () {
[ -e "${GNUPGHOME}/gpg.conf" ] && return
@@ -330,11 +282,6 @@ die () {
exit 1
}
-GIT_EXIT_OK=
-# Note: TEST_TMPDIR *NOT* exported!
-TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
-# Put GNUPGHOME in TMPDIR to avoid problems with long paths.
-export GNUPGHOME="${TEST_TMPDIR}/gnupg"
trap 'trap_exit' EXIT
trap 'trap_signal' HUP INT TERM
diff --git a/test/test-vars.sh b/test/test-vars.sh
new file mode 100644
index 00000000..812bcf81
--- /dev/null
+++ b/test/test-vars.sh
@@ -0,0 +1,58 @@
+# Common variable settings for (correctness) tests and performance
+# tests.
+
+# Keep the original TERM for say_color and test_emacs
+ORIGINAL_TERM=$TERM
+
+# Set SMART_TERM to vt100 for known dumb/unknown terminal.
+# Otherwise use whatever TERM is currently used so that
+# users' actual TERM environments are being used in tests.
+case ${TERM-} in
+ '' | dumb | unknown )
+ SMART_TERM=vt100 ;;
+ *)
+ SMART_TERM=$TERM ;;
+esac
+
+# For repeatability, reset the environment to known value.
+LANG=C
+LC_ALL=C
+PAGER=cat
+TZ=UTC
+TERM=dumb
+export LANG LC_ALL PAGER TERM TZ
+GIT_TEST_CMP=${GIT_TEST_CMP:-diff -u}
+if [[ ( -n "$TEST_EMACS" && -z "$TEST_EMACSCLIENT" ) || \
+ ( -z "$TEST_EMACS" && -n "$TEST_EMACSCLIENT" ) ]]; then
+ echo "error: must specify both or neither of TEST_EMACS and TEST_EMACSCLIENT" >&2
+ exit 1
+fi
+TEST_EMACS=${TEST_EMACS:-${EMACS:-emacs}}
+TEST_EMACSCLIENT=${TEST_EMACSCLIENT:-emacsclient}
+TEST_GDB=${TEST_GDB:-gdb}
+TEST_CC=${TEST_CC:-cc}
+TEST_CFLAGS=${TEST_CFLAGS:-"-g -O0"}
+TEST_SHIM_CFLAGS=${TEST_SHIM_CFLAGS:-"-fpic -shared"}
+TEST_SHIM_LDFLAGS=${TEST_SHIM_LDFLAGS:-"-ldl"}
+
+# Protect ourselves from common misconfiguration to export
+# CDPATH into the environment
+unset CDPATH
+
+unset GREP_OPTIONS
+
+# For lib/open.cc:_load_key_file
+unset XDG_CONFIG_HOME
+
+# For emacsclient
+unset ALTERNATE_EDITOR
+
+# for reproducibility
+unset EMAIL
+unset NAME
+
+GIT_EXIT_OK=
+# Note: TEST_TMPDIR *NOT* exported!
+TEST_TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/notmuch-test-$$.XXXXXX")
+# Put GNUPGHOME in TMPDIR to avoid problems with long paths.
+export GNUPGHOME="${TEST_TMPDIR}/gnupg"
--
2.34.1
next prev parent reply other threads:[~2022-02-12 20:28 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-12 20:27 v4 undo tagging David Bremner
2022-02-12 20:27 ` [PATCH v4 01/11] doc/emacs: add minimal documentation for notmuch-unthreaded mode David Bremner
2022-02-12 20:27 ` David Bremner [this message]
2022-02-12 20:27 ` [PATCH v4 03/11] test/emacs: split out tagging related tests David Bremner
2022-02-12 20:27 ` [PATCH v4 04/11] perf-test: allow running test_emacs from performance test suite David Bremner
2022-02-12 20:27 ` [PATCH v4 05/11] perf-test: emacs tagging David Bremner
2022-02-12 20:27 ` [PATCH v4 06/11] emacs: remove non-batch code path from function notmuch-tag David Bremner
2022-02-12 20:27 ` [PATCH v4 07/11] emacs/tag: keep tag history David Bremner
2022-02-12 20:27 ` [PATCH v4 08/11] emacs: add notmuch-tag-undo David Bremner
2022-02-12 20:27 ` [PATCH v4 09/11] emacs: redirect undo to notmuch-tag-undo David Bremner
2022-02-12 20:27 ` [PATCH v4 10/11] emacs: Document undo binding David Bremner
2022-02-12 20:27 ` [PATCH v4 11/11] emacs: whitespace cleanup for keybindings David Bremner
2022-02-25 12:53 ` v4 undo tagging David Bremner
2022-02-26 12:12 ` David Bremner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220212202742.2577237-3-david@tethera.net \
--to=david@tethera.net \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).