42722: Replace ed with dc in fg/bg tests.

This should be even simpler.

Also more fix ups for failed pattern diffs.
This commit is contained in:
Peter Stephenson 2018-04-25 18:15:21 +01:00
parent 76b5b3a504
commit bdd595321f
3 changed files with 29 additions and 33 deletions

View file

@ -5,6 +5,9 @@
2018-04-25 Peter Stephenson <p.stephenson@samsung.com>
* 42722: Test/ztst.zsh, Test/W02jobs.ztst: replace ed with
dc and hope for better times.
* 42714: Test/W02jobs.ztst, Test/ztst.zsh: add basic fg and bg
tests using ed. Improve output on pattern difference failure in
tests.

View file

@ -192,52 +192,46 @@
*>\[1] ? kill*sleep*
zpty_start
zpty_input $'ed 2>/dev/null\n=\n'
zpty_input $'dc 2>/dev/null\n1\np\n'
zpty_line
zpty_input $'a\nstuff1\n.\nw tmpfile\nq\n'
zpty_input $'1\n+\np\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
*>1
*>2
F:This test checks we can run the simple calculator dc 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_input $'dc 2>/dev/null\n1\np\n'
zpty_line
zpty_input $'\C-z'
zpty_input 'fg'
zpty_input $'a\nstuff2\n.\nw tmpfile\nq\n'
zpty_input $'1\n+\np\nq\n'
zpty_stop
cat tmpfile
rm -f tmpfile
0:Basic fg with subsequent user interaction
*>0
*>zsh:*(stopped|suspended)*ed*
*>*continued*ed*
*>stuff2
*>1
*>zsh:*(stopped|suspended)*dc*
*>*continued*dc*
*>2
zpty_start
zpty_input $'ed 2>/dev/null\n=\n'
zpty_input $'dc 2>/dev/null\n1\np\n'
zpty_line
zpty_input $'\C-z'
zpty_input 'bg'
zpty_input 'fg'
zpty_input $'a\nstuff3\n.\nw tmpfile\nq\n'
zpty_input $'1\n+\np\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
*>1
*>zsh:*(stopped|suspended)*dc*
*>*continued*dc*
*>*(stopped|suspended)*dc*
*>*continued*dc*
*>2
%clean

View file

@ -315,26 +315,25 @@ ZTST_diff() {
if (( diff_pat )); then
local -a diff_lines1 diff_lines2
integer failed i l n
integer failed i l
local p
diff_lines1=("${(f)$(<$argv[-2])}")
diff_lines2=("${(f)$(<$argv[-1])}")
diff_lines1=("${(f@)$(<$argv[-2])}")
diff_lines2=("${(f@)$(<$argv[-1])}")
if (( ${#diff_lines1} != ${#diff_lines2} )); then
failed=1
print -r "Pattern match filead, line mismatch (${#diff_lines1}/${#diff_lines2}):"
else
for (( i = 1; i <= ${#diff_lines1}; i++ )); do
if [[ ${diff_lines2[i]} != ${~diff_lines1[i]} ]]; then
failed=1
print -r "Pattern match failed, line $i:"
break
fi
done
fi
if (( failed )); then
print -r "Pattern match failed, line $i:"
n=${#diff_lines1}
(( ${#diff_lines2} > $n )) && n=${#diff_lines2}
for (( l = 1; l <= n; ++l )); do
for (( l = 1; l <= ${#diff_lines1}; ++l )); do
if (( l == i )); then
p="-"
else
@ -342,7 +341,7 @@ ZTST_diff() {
fi
print -r -- "$p<${diff_lines1[l]}"
done
for (( l = 1; l <= n; ++l )); do
for (( l = 1; l <= ${#diff_lines2}; ++l )); do
if (( l == i )); then
p="+"
else