From: "Daniel Shahaf" <d.s@daniel.shahaf.name>
To: zsh-workers@zsh.org
Cc: "Martijn Dekker" <martijn@inlv.org>
Subject: Re: Bug with traps and exit
Date: Tue, 31 Dec 2019 02:03:45 +0000 [thread overview]
Message-ID: <bd67222d-3436-4565-9b00-32a68381c4dd@www.fastmail.com> (raw)
In-Reply-To: <10a2ca98-ae46-4975-93f8-7db835f47690@www.fastmail.com>
[-- Attachment #1: Type: text/plain, Size: 77 bytes --]
I'm attaching an expected-to-fail regression test for 44007.
Cheers,
Daniel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-In-the-test-suite-allow-test-cases-to-be-marked-as-e.patch --]
[-- Type: text/x-patch; name="0001-In-the-test-suite-allow-test-cases-to-be-marked-as-e.patch", Size: 4569 bytes --]
From b49f856b21eba759e503164a97b61343b9cbbf34 Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <danielsh@apache.org>
Date: Tue, 31 Dec 2019 01:52:03 +0000
Subject: [PATCH 1/2] In the test suite, allow test cases to be marked as
expected to fail.
See next commit for a use-case.
---
Test/B01cd.ztst | 4 +++-
Test/ztst.zsh | 30 ++++++++++++++++++++++++++++--
Util/ztst-syntax.vim | 2 +-
3 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/Test/B01cd.ztst b/Test/B01cd.ztst
index f79e18f..977cbdf 100644
--- a/Test/B01cd.ztst
+++ b/Test/B01cd.ztst
@@ -70,11 +70,13 @@
# the expected status returned by the code when run, or - if it is
# irrelevant. An optional set of single-letter flags follows the status
# or -. The following are understood:
-# . d Don't diff stdout against the expected stdout.
+# . d Don't diff stdout against the expected stdout.
# D Don't diff stderr against the expected stderr.
# q All redirection lines given in the test script (not the lines
# actually produced by the test) are subject to ordinary quoted shell
# expansion (i.e. not globbing).
+# f Test is expected to fail. If the test's exit code, stdout, and stderr
+# match, report a problem; otherwise, carry on to the next test case.
# This can be followed by a `:' and a message describing the
# test, which will be printed if the test fails, along with a
# description of the failure that occurred. The `:' and message are
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index a4c6252..0c71f9d 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -366,6 +366,7 @@ ZTST_test() {
local last match mbegin mend found substlines
local diff_out diff_err
local ZTST_skip
+ integer expected_to_fail
while true; do
rm -f $ZTST_in $ZTST_out $ZTST_err
@@ -460,8 +461,21 @@ $ZTST_curline"
fi
fi
+ if [[ $ZTST_flags = *f* ]]; then
+ expected_to_fail=1
+ ZTST_xfail_diff() { ZTST_diff "$@" > /dev/null }
+ ZTST_diff=ZTST_xfail_diff
+ else
+ expected_to_fail=0
+ ZTST_diff=ZTST_diff
+ fi
+
# First check we got the right status, if specified.
if [[ $ZTST_xstatus != - && $ZTST_xstatus != $ZTST_status ]]; then
+ if (( expected_to_fail )); then
+ ZTST_verbose 1 "Test failed, as expected."
+ continue
+ fi
ZTST_testfailed "bad status $ZTST_status, expected $ZTST_xstatus from:
$ZTST_code${$(<$ZTST_terr):+
Error output:
@@ -480,7 +494,11 @@ $(<$ZTST_terr)"
rm -rf $ZTST_out
print -r -- "${(e)substlines}" >$ZTST_out
fi
- if [[ $ZTST_flags != *d* ]] && ! ZTST_diff $diff_out -u $ZTST_out $ZTST_tout; then
+ if [[ $ZTST_flags != *d* ]] && ! $ZTST_diff $diff_out -u $ZTST_out $ZTST_tout; then
+ if (( expected_to_fail )); then
+ ZTST_verbose 1 "Test failed, as expected."
+ continue
+ fi
ZTST_testfailed "output differs from expected as shown above for:
$ZTST_code${$(<$ZTST_terr):+
Error output:
@@ -488,15 +506,23 @@ $(<$ZTST_terr)}"
return 1
fi
if [[ $ZTST_flags = *q* && -s $ZTST_err ]]; then
+ if (( expected_to_fail )); then
+ ZTST_verbose 1 "Test failed, as expected."
+ continue
+ fi
substlines="$(<$ZTST_err)"
rm -rf $ZTST_err
print -r -- "${(e)substlines}" >$ZTST_err
fi
- if [[ $ZTST_flags != *D* ]] && ! ZTST_diff $diff_err -u $ZTST_err $ZTST_terr; then
+ if [[ $ZTST_flags != *D* ]] && ! $ZTST_diff $diff_err -u $ZTST_err $ZTST_terr; then
ZTST_testfailed "error output differs from expected as shown above for:
$ZTST_code"
return 1
fi
+ if (( expected_to_fail )); then
+ ZTST_testfailed "test was expected to fail, but passed."
+ return 1
+ fi
fi
ZTST_verbose 1 "Test successful."
[[ -n $last ]] && break
diff --git a/Util/ztst-syntax.vim b/Util/ztst-syntax.vim
index 8d8becf..f0c82d7 100644
--- a/Util/ztst-syntax.vim
+++ b/Util/ztst-syntax.vim
@@ -28,7 +28,7 @@ syn include @zsh syntax/zsh.vim
syn match ztstPayload /^\s\+\zs.*/ contains=@zsh
syn match ztstExitCode /^\d\+\|^-/ nextgroup=ztstFlags
-syn match ztstFlags /[.dDq]*:/ contained nextgroup=ztstTestName contains=ztstColon
+syn match ztstFlags /[.dDqf]*:/ contained nextgroup=ztstTestName contains=ztstColon
syn match ztstColon /:/ contained
syn region ztstTestName start=// end=/$/ contained
--
2.20.1
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-Add-an-expected-to-fail-test-for-workers-44007.patch --]
[-- Type: text/x-patch; name="0002-Add-an-expected-to-fail-test-for-workers-44007.patch", Size: 1860 bytes --]
From 87b1f05911e3369897307f81c04b8ed4db240d6e Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <danielsh@apache.org>
Date: Tue, 31 Dec 2019 01:52:32 +0000
Subject: [PATCH 2/2] Add an expected-to-fail test for workers/44007.
---
Etc/BUGS | 14 ++------------
Test/C03traps.ztst | 15 +++++++++++++++
2 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/Etc/BUGS b/Etc/BUGS
index 3fbe818..8112299 100644
--- a/Etc/BUGS
+++ b/Etc/BUGS
@@ -26,16 +26,6 @@ skipped when STTY=... is set for that command
41203 and others: Make it easier to maintain C modules out of tree.
(May require defining a stable API for modules, see 41254)
------------------------------------------------------------------------
-44007 - Martijn - exit in trap executes rest of function (prints "fn2")
-[[[
-trap 'echo $1; exit; echo $2' USR1
-fn() {
- echo fn1
- kill -USR1 $$
- echo fn2
-}
-echo out1
-fn trap1 trap2
-echo out2
-]]]
+44007 - Martijn - exit in trap executes rest of function
+See test case in Test/C03traps.ztst.
------------------------------------------------------------------------
diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst
index 4aebd92..8fdd780 100644
--- a/Test/C03traps.ztst
+++ b/Test/C03traps.ztst
@@ -881,6 +881,21 @@ F:Must be tested with a top-level script rather than source or function
$ZTST_testdir/../Src/zsh -f <<<'fn() { exit 0; }; trap fn EXIT; false'
0:Explicit exit status overrides implicit: script-like code path
+ $ZTST_testdir/../Src/zsh -f <<<$'
+ trap \'printf $1; exit; printf $2\' USR1
+ fn() {
+ printf fn1
+ kill -s USR1 $$
+ printf fn2
+ }
+ printf out1
+ fn trap1 trap2
+ printf out2
+ '
+0f:(workers/44007) function execution continues after 'exit' in trap
+>out1fn1trap1
+# As of 5.7.1-test-2, the output was "out1fn1trap1fn2".
+
%clean
rm -f TRAPEXIT
--
2.20.1
next prev parent reply other threads:[~2019-12-31 2:05 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-05 7:08 Test release: 5.6.2-test-3 dana
2019-01-05 17:49 ` Peter Stephenson
2019-01-05 18:42 ` dana
2019-01-05 20:58 ` Martijn Dekker
2019-01-05 21:55 ` Daniel Shahaf
2019-01-06 2:37 ` Axel Beckert
2019-01-06 15:12 ` Jun T.
2019-01-06 16:37 ` dana
2019-01-06 16:43 ` Daniel Shahaf
2019-01-06 16:56 ` dana
2019-01-06 21:34 ` Daniel Tameling
2019-01-07 3:25 ` Jun T
2019-01-07 7:02 ` dana
2019-01-21 12:54 ` ETA for zsh 5.7? (was: Test release: 5.6.2-test-3) Axel Beckert
2019-01-21 14:26 ` Peter Stephenson
2019-01-21 19:14 ` Mikael Magnusson
2019-01-21 19:32 ` Mikael Magnusson
2019-01-21 19:32 ` Mikael Magnusson
2019-01-21 21:56 ` Sebastian Gniazdowski
2019-01-22 9:29 ` Peter Stephenson
2019-01-21 23:00 ` Bug with traps and exit Martijn Dekker
2019-11-24 5:54 ` Martijn Dekker
2019-11-25 16:42 ` Sebastian Gniazdowski
2019-12-10 19:23 ` Martijn Dekker
2019-12-11 2:40 ` Daniel Shahaf
2019-12-12 10:14 ` Peter Stephenson
2019-12-13 14:26 ` Martijn Dekker
2019-12-13 14:49 ` Peter Stephenson
2019-12-14 11:28 ` Daniel Shahaf
2019-12-15 18:59 ` Peter Stephenson
2019-12-16 5:24 ` Daniel Shahaf
2019-12-16 6:37 ` Bart Schaefer
2019-12-17 7:31 ` Daniel Shahaf
2019-12-17 20:29 ` Peter Stephenson
2019-12-18 0:31 ` Daniel Shahaf
2019-12-31 2:03 ` Daniel Shahaf [this message]
2019-12-31 13:46 ` Daniel Shahaf
2019-12-16 10:09 ` Peter Stephenson
2019-12-16 5:27 ` The bug from workers/44922 (was: " Daniel Shahaf
2020-01-30 13:49 ` The bug from workers/44922 Martijn Dekker
2020-01-30 14:01 ` Bug with traps and exit Martijn Dekker
2020-01-31 4:29 ` Daniel Shahaf
2022-11-26 3:00 ` Bart Schaefer
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bd67222d-3436-4565-9b00-32a68381c4dd@www.fastmail.com \
--to=d.s@daniel.shahaf.name \
--cc=martijn@inlv.org \
--cc=zsh-workers@zsh.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://git.vuxu.org/mirror/zsh/
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 NNTP newsgroup(s).