From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id AGRBI9fn+2HbIgEAgWs5BA (envelope-from ) for ; Thu, 03 Feb 2022 15:33:59 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id yI2TINfn+2FJcAAA9RJhRA (envelope-from ) for ; Thu, 03 Feb 2022 15:33:59 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [IPv6:2a01:4f9:c011:7a79::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id DC4C13A165 for ; Thu, 3 Feb 2022 15:33:58 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 2193B5F742; Thu, 3 Feb 2022 14:33:13 +0000 (UTC) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id D17045F701 for ; Thu, 3 Feb 2022 14:33:09 +0000 (UTC) Received: by fethera.tethera.net (Postfix, from userid 1001) id 5C0615FC0D; Thu, 3 Feb 2022 09:33:09 -0500 (EST) Received: (nullmailer pid 3348395 invoked by uid 1000); Thu, 03 Feb 2022 14:32:56 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [RFC PATCH v2 02/12] test: split variable settings to their own file Date: Thu, 3 Feb 2022 10:32:44 -0400 Message-Id: <20220203143254.3344753-3-david@tethera.net> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220203143254.3344753-1-david@tethera.net> References: <20220203143254.3344753-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: WIHYJLRQPSRLSLLRVVXRH6YAPLLBVEEI X-Message-ID-Hash: WIHYJLRQPSRLSLLRVVXRH6YAPLLBVEEI X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1643898839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=ZhK0IJQLhmE7f6wc5SrdzZFPjiAh/3/E8S85YlUrNkI=; b=YauCa7uRbfcvVrKzgXf1noWyuJmTGKiILiYHyHsFIjI+rJ5B4pDeQuiN4/F9c7l1qcKqIi 0emUcayC6ka8QLWLLvh24HezV9XAvk6+F+Ociz8iOKyoFiXtYgZlddD1/W3xUTxNvljUh7 AHrNWCWNPPBDw2DtCFFrqPgpwKd5GxFmS1uESvi5bC654O9J0zwVRV2ds6Okw1axj52gt/ 2Bx2qYX/n1r+1DAYPplzZYsBUuE2OR+/wTi36GxM/60+Dy8dsE3hlOTzjBKpRr+FOYhQ3l W5xDUUTCFuDakZ8z8N8VHmw89d7AhvH1aUKPhAwXmlJ/U1bYUlULs4NWQho38w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1643898839; a=rsa-sha256; cv=none; b=gm717INgGxw6ZMEKfVqRL8nCykDCzp4TBwvZoJvRerQaEp/DfUSdfRhuu5+3R6+rY/MJ9B 4koOr7vH+OrRf8J21K2IgTT3PdH/vts2qNc7/WtahT+SvPXlmvEMsU4bSwHEfXjNG1tST6 exVWRz641OesM5zFg3GY5cm9wzGwlqnNW6rhPH3rCzGBQbLrqgAPEvQO6z5KAiEfbZgCi9 YFa8VtMSc40NdwwMRO4ZQuDw2MKtsst2NXlBJvtDkayoafgRfaGfcw2BAA1V9KZ4vUWWYi ajYTtsC0YvBNz2ni+ZUy42RLv2ESD+zS2/bn3RGk9qc2YpyKlhOfzGOk1unLZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.85 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2a01:4f9:c011:7a79::1 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: DC4C13A165 X-Spam-Score: -1.85 X-Migadu-Scanner: scn0.migadu.com X-TUID: xCl4YZ8ylKyf 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