From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6MqICjkhqWBKWAEAgWs5BA (envelope-from ) for ; Sat, 22 May 2021 17:20:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 8Ho+BjkhqWDdTQAA1q6Kng (envelope-from ) for ; Sat, 22 May 2021 15:20:25 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 BBC542BAAA for ; Sat, 22 May 2021 17:20:23 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id BA6E32AA1C; Sat, 22 May 2021 11:20:19 -0400 (EDT) Received: from meesny.iki.fi (meesny.iki.fi [195.140.195.201]) by mail.notmuchmail.org (Postfix) with ESMTPS id 192E02AA17 for ; Sat, 22 May 2021 11:20:17 -0400 (EDT) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: too) by meesny.iki.fi (Postfix) with ESMTPSA id 3AE2720553; Sat, 22 May 2021 18:20:10 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1621696810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Q/2wf8YbOCjn3WF8xMkI9tDXhzCZBN7zHdjR8H3Pg/Y=; b=U/sd7LoV780vEuuyuION4EdgIsL4Pa6X/BQfJ6kkrj5dpl3odNPv6f1co7wM9Uo0aaFunb CmrFd3Nv//G6duzftuNNO2L133crMo+Xdq142ZuqqAweGD3PwMCsQq+jH/VRZrlEnwRqZl GAyM1OxEjBGKpS5ODM37wyZXSNxtONg= From: Tomi Ollila To: notmuch@notmuchmail.org Subject: [PATCH 1/2] test-lib-emacs: re-define test_emacs() after initialization Date: Sat, 22 May 2021 18:20:08 +0300 Message-Id: <20210522152008.27059-1-tomi.ollila@iki.fi> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=too smtp.mailfrom=tomi.ollila@iki.fi ARC-Seal: i=1; s=meesny; d=iki.fi; t=1621696810; a=rsa-sha256; cv=none; b=MClwZdL2BpHMRruzEDPdC+5cuD14DvPQCZ8vG+xj7E9L9jjLtqLFJD8zjPPofoqu8RiJZd vUQDVlaXClBcv4jPTM+f3dQEbWHmLDrAbW6giC/ocbYkVsRmUF4b2K77KGkKB2hepk2ezq z4GPcQXNCcQ0rda/EjyragvSUmGMLM8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1621696810; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=Q/2wf8YbOCjn3WF8xMkI9tDXhzCZBN7zHdjR8H3Pg/Y=; b=QB51QOtbHI2/yplTe/WEXp+GcxE/6qUZmh7SSUAO1wPB1tEM73XDjNvakv2se5krkZiEN1 L+ZuyJuYqKHHCDV/0cbIqLZuGdjVpUf72TB4Q+ZLcgh67OE/ydvpRH8d14Fmv88ND9bcjV m54wql/FJ/8xt48NaJY9C+D7zP4mOoE= Message-ID-Hash: LEDVGYAOVCYURCZGJKDULIUC742QW5CE X-Message-ID-Hash: LEDVGYAOVCYURCZGJKDULIUC742QW5CE X-MailFrom: tomi.ollila@iki.fi 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; suspicious-header CC: tomi.ollila@iki.fi X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1621696824; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=GVYYE2tN9dqhswVZtX8xKMxKkZ3HEs6Q+6/EIodMbwQ=; b=SlvJbjtzJ+iTvGUWmK5WWoyqAxvBIEvNXtXPkn4On30XGcsWrGPcVtfhmGw0juhPWpLZGT QiISIWkIQPWE107Netm1IYvaZLdQtvfS+sOehgN/NCuxvSeweK5RVK2JZMRJNIJ9w4Y5nJ iNkuyUCLOCGbsoHyN3B2hnt4e0gLtTsxYm8KZOtZH206kQVFkjwd7SHYTjiC9h1S/gtmxa mnSSIfToK3/C70krCB3xu53/UuTTJjUQEgUWAtHrMKNKoYdDqiEtbJG8i/PeMj1nZzHgXe hd3z4FC28vzJ9E34mRADU277xrRUV8/xxT17DlGlrQm0613ECElNcshkyzyiWg== ARC-Seal: i=2; s=key1; d=yhetil.org; t=1621696824; a=rsa-sha256; cv=fail; b=eo5A3pXgqOjJNGsprYuSlfexwcMxql/ASM0xfMZC+JB3P84A+d7MNskkge0EUOvDKq4T1k OQqcpc8PrA8sfEgP0/bvRBqIHwhLO3fm0wpGk8tx32yJ20U4VyJES9wXaORa45/j75Bu4n qZ50IkZlXs8pS4t8YRUsS3nnT8SWOcmmQfzO/TQKXpfa93vV0BwuiWvCsj47Bq0QF/EeWd VP9alQdhzOPooELH1ukkRJ0FElMpByFJqftWJNbmJBJtBbyL+Nb6IJ3+gA9efPL8q5Ap4q kib+RWtSUsF667bzR8OtAMxm9J8UYf33Fw05lZIB7Ef4+RxObanU1M4kZ+CQSw== ARC-Authentication-Results: i=2; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=meesny header.b="U/sd7LoV"; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 1.93 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=iki.fi header.s=meesny header.b="U/sd7LoV"; arc=reject ("signature check failed: fail, {[1] = sig:iki.fi:reject}"); dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: BBC542BAAA X-Spam-Score: 1.93 X-Migadu-Scanner: scn0.migadu.com X-TUID: V2Hn0vRCkJ2i After test_emacs() has started emacs, it re-defines itself as just calling the started emacs. First call to test_emacs() will execute to the end of it; next calls will just execute the 2 lines, first clearing OUTPUT, second and last executing TEST_EMACSCLIENT... This simplifies away one if constructs and reduces xtrace output when doing test debugging with set -x. --- This has been laying around like 6 years, every now thinking whether to post or not. Now needed to rebase so finally polished to a sendable format. re-defining functions just may be too much to understand (or not)... test/test-lib-emacs.sh | 79 +++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 36 deletions(-) diff --git a/test/test-lib-emacs.sh b/test/test-lib-emacs.sh index dde32177..b2b490be 100644 --- a/test/test-lib-emacs.sh +++ b/test/test-lib-emacs.sh @@ -1,5 +1,5 @@ # -# Copyright (c) 2010-2020 Notmuch Developers +# Copyright (c) 2010-2021 Notmuch Developers # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -166,44 +166,51 @@ EOF } test_emacs () { - # test dependencies beforehand to avoid the waiting loop below + # Note: This test_emacs() is re-defined after emacs started below. test_require_emacs || return - if [ -z "$EMACS_SERVER" ]; then - emacs_tests="$NOTMUCH_SRCDIR/test/${this_test_bare}.el" - if [ -f "$emacs_tests" ]; then - load_emacs_tests="--eval '(load \"$emacs_tests\")'" - else - load_emacs_tests= - fi - server_name="notmuch-test-suite-$$" - # start a detached session with an emacs server - # user's TERM (or 'vt100' in case user's TERM is known dumb - # or unknown) is given to dtach which assumes a minimally - # VT100-compatible terminal -- and emacs inherits that - TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \ - sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \ - --no-window-system \ - $load_emacs_tests \ - --eval '(setq server-name \"$server_name\")' \ - --eval '(server-start)' \ - --eval '(orphan-watchdog $$)'" || return - EMACS_SERVER="$server_name" - # wait until the emacs server is up - until test_emacs '()' >/dev/null 2>/dev/null; do - sleep 1 - done - fi + local emacs_tests load_emacs_tests server_name - # Clear test-output output file. Most Emacs tests end with a - # call to (test-output). If the test code fails with an - # exception before this call, the output file won't get - # updated. Since we don't want to compare against an output - # file from another test, so start out with an empty file. - rm -f OUTPUT - touch OUTPUT - - ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" --eval "(notmuch-test-progn $*)" + emacs_tests=$NOTMUCH_SRCDIR/test/${this_test_bare}.el + if [ -f "$emacs_tests" ]; then + load_emacs_tests="--eval '(load \"$emacs_tests\")'" + else + load_emacs_tests= + fi + server_name=notmuch-test-suite-$$ + # start a detached session with an emacs server + # user's TERM (or 'vt100' in case user's TERM is known dumb + # or unknown) is given to dtach which assumes a minimally + # VT100-compatible terminal -- and emacs inherits that + TERM=$SMART_TERM dtach -n "$TEST_TMPDIR/emacs-dtach-socket.$$" \ + sh -c "stty rows 24 cols 80; exec '$TMP_DIRECTORY/run_emacs' \ + --no-window-system \ + $load_emacs_tests \ + --eval '(setq server-name \"$server_name\")' \ + --eval '(server-start)' \ + --eval '(orphan-watchdog $$)'" || return + + EMACS_SERVER=$server_name + + # re-define test_emacs() -- further calls will use this one + test_emacs () { + # Clear test-output output file. Most Emacs tests end with a + # call to (test-output). If the test code fails with an + # exception before this call, the output file won't get + # updated. Since we don't want to compare against an output + # file from another test, so start out with an empty file. + : > OUTPUT + ${TEST_EMACSCLIENT} --socket-name="$EMACS_SERVER" \ + --eval "(notmuch-test-progn $*)" + } + + # wait until the emacs server is up (now calling "new" test_emacs()) + until test_emacs '()' >/dev/null 2>/dev/null; do + sleep 1 + done + + # and finally, call new test_emacs() with given args + test_emacs "$@" } emacs_generate_script -- 2.25.1