Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: fg and bg tests
- X-seq: zsh-workers 42714
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh hackers' list <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: fg and bg tests
- Date: Wed, 25 Apr 2018 10:09:40 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20180425090950euoutp026663f3b4c63bf4667ead8f72f70342dc~oorlGdKOv1592515925euoutp02b
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1524647390; bh=9exqcK/H288gPW161Qax7jUnx080S6C1+YEuedBMuZA=; h=Date:From:To:Subject:In-reply-to:References:From; b=qE61Zqjevt0G15QzY8SxgBgnCdXd+0RcnKK2+SkrISjqO8v3YcZrh4DHMNrUKzWkZ 0L5E4v60j4T7xo8SrPJkjMipdqAZB4w/KxQcpFomNdIncPpvZIZnPoeN89YEVSjmTo O6R/gT7lVpEl9Fd7WWk6HEKGAeBsGyPUZm2dOp+4=
- In-reply-to: <20180424135944.64e73c62@camnpupstephen.cam.scsc.local>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <20180424135944.64e73c62@camnpupstephen.cam.scsc.local> <CGME20180425090941eucas1p187cf5d07341d2041c15e9947962f3bd9@eucas1p1.samsung.com>
On Tue, 24 Apr 2018 13:59:44 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> Here's a way of testing fg and bg. See if you can spot any problems
> before the tests become too hairy to debug.
>
> The time waiting for the ^z is already there in previous tests ---
> nobody's apparently noticed any problems there. Maybe we can avoid
> them all with carefully chosen output, but I don't think it's trivial.
This improves matters in this case by using output from the zpty
process, but it's still there in other cases and is all a bit scary ---
the sleep with the comment next to it was needed because otherwise the
reported termination status of the background job with the "kill -HUP"
mysteriously turned from "hangup" into "done". However, the new tests
I've added seem to be working OK and as far as I can see I haven't used
any non-standard ed commands.
The last change improves visibility of differences if a pattern match on
multiple lines fails.
I will commit this to see what happens on other systems.
pws
diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index 65b8600..1ec0b8e 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -13,6 +13,14 @@
zpty_input() {
zpty -w zsh "${(F)@}" $'\n'
}
+ zpty_line() {
+ local REPLY
+ integer i
+ for (( i = 0; i < ${1:-1}; ++i )); do
+ zpty -r zsh REPLY
+ print -r -- ${REPLY%%($'\r\n'|$'\n')}
+ done
+ }
zpty_stop() {
# exit twice in case of check_jobs
zpty -w zsh $'exit\nexit\n'
@@ -161,15 +169,17 @@
zpty_start
zpty_input 'sleep 10 & sleep 9 & sleep 8 & sleep 7 &'
- sleep 0.1
+ zpty_line 4
zpty_input 'kill %4'
+ # Dunno why we need this when checking input...
sleep 0.1
+ zpty_line
zpty_input 'kill -HUP %3'
- sleep 0.1
+ zpty_line
zpty_input 'kill -INT %2'
- sleep 0.1
+ zpty_line
zpty_input 'kill -KILL %1'
- sleep 0.1
+ zpty_line
zpty_stop
0:various `kill` signals with multiple running jobs
*>\[1] [0-9]##
@@ -181,6 +191,54 @@
*>\[2] ? interrupt*sleep*
*>\[1] ? kill*sleep*
+ zpty_start
+ zpty_input $'ed 2>/dev/null\n=\n'
+ zpty_line
+ zpty_input $'a\nstuff1\n.\nw tmpfile\nq\n'
+ zpty_stop
+ cat tmpfile
+ rm -f tmpfile
+0:Sanity check of "ed" as foreground process
+*>0
+*>stuff1
+F:This test checks we can run the simple editor "ed" as a way of testing
+F:user interaction for later job control tests . The test itself is
+F:trivial; its failure may simply indicate our test methodology does not
+F:work on this system.
+
+ zpty_start
+ zpty_input $'ed 2>/dev/null\n=\n'
+ zpty_line
+ zpty_input $'\C-z'
+ zpty_input 'fg'
+ zpty_input $'a\nstuff2\n.\nw tmpfile\nq\n'
+ zpty_stop
+ cat tmpfile
+ rm -f tmpfile
+0:Basic fg with subsequent user interaction
+*>0
+*>zsh:*(stopped|suspended)*ed*
+*>*continued*ed*
+*>stuff2
+
+ zpty_start
+ zpty_input $'ed 2>/dev/null\n=\n'
+ zpty_line
+ zpty_input $'\C-z'
+ zpty_input 'bg'
+ zpty_input 'fg'
+ zpty_input $'a\nstuff3\n.\nw tmpfile\nq\n'
+ zpty_stop
+ cat tmpfile
+ rm -f tmpfile
+0:bg and fg with user input
+*>0
+*>zsh:*(stopped|suspended)*ed*
+*>*continued*ed*
+*>*(stopped|suspended)*ed*
+*>*continued*ed*
+*>stuff3
+
%clean
zmodload -ui zsh/zpty
diff --git a/Test/ztst.zsh b/Test/ztst.zsh
index 0b26799..1a6a0b5 100755
--- a/Test/ztst.zsh
+++ b/Test/ztst.zsh
@@ -315,7 +315,8 @@ ZTST_diff() {
if (( diff_pat )); then
local -a diff_lines1 diff_lines2
- integer failed i
+ integer failed i l n
+ local p
diff_lines1=("${(f)$(<$argv[-2])}")
diff_lines2=("${(f)$(<$argv[-1])}")
@@ -330,7 +331,25 @@ ZTST_diff() {
done
fi
if (( failed )); then
- print -rl "Pattern match failed:" \<${^diff_lines1} \>${^diff_lines2}
+ print -r "Pattern match failed, line $i:"
+ n=${#diff_lines1}
+ (( ${#diff_lines2} > $n )) && n=${#diff_lines2}
+ for (( l = 1; l <= n; ++l )); do
+ if (( l == i )); then
+ p="-"
+ else
+ p=" "
+ fi
+ print -r -- "$p<${diff_lines1[l]}"
+ done
+ for (( l = 1; l <= n; ++l )); do
+ if (( l == i )); then
+ p="+"
+ else
+ p=" "
+ fi
+ print -r -- "$p>${diff_lines2[l]}"
+ done
diff_ret=1
fi
else
Messages sorted by:
Reverse Date,
Date,
Thread,
Author