Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [Bug] $jobstates does not work in $()



I don't see how you could have provoked this, Peter, but in the latest sources, I'm seeing a test failure under i3 in Arch:

ZTST_verbose=2 make TESTNUM=W03 check
cd Test ; make check
make[1]: Entering directory '/opt/build/zsh-2022-03-03/Test'
if test -n "gcc"; then \
  cd .. && DESTDIR= \
  make MODDIR=`pwd`/Test/Modules install.modules > /dev/null; \
fi
if test -z "$ZTST_handler"; then \
  ZTST_handler=runtests.zsh; \
fi; \
if ZTST_testlist="`for f in ../../../src/zsh-2022-03-03/Test/W03*.ztst; \
           do echo $f; done`" \
 ZTST_srcdir="../../../src/zsh-2022-03-03/Test" \
 ZTST_exe=../Src/zsh \
 ../Src/zsh +Z -f ../../../src/zsh-2022-03-03/Test/$ZTST_handler; then \
 stat=0; \
else \
 stat=1; \
fi; \
sleep 1; \
rm -rf Modules .zcompdump; \
exit $stat
../../../src/zsh-2022-03-03/Test/W03jobparameters.ztst: starting.
ZTST_getsect: read section name: prep
ZTST_getchunk: read code chunk:
  if zmodload zsh/zpty 2> /dev/null; then
    zpty_start() {
      export PS1= PS2=
      zpty -d
      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
    }
    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'
      # zpty gives no output when piped without these braces (?)
      { zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;'
      zpty -d
      :
    }
    if ! zmodload zsh/parameter 2> /dev/null; then
      ZTST_unimplemented='the zsh/parameter module is not available'
    fi
  else
    ZTST_unimplemented='the zsh/zpty module is not available'
  fi
ZTST_execchunk: status 0
ZTST_getchunk: read code chunk:

ZTST_getsect: read section name: test
ZTST_test: looking for new test
ZTST_test: examining line:

ZTST_test: examining line:
  zpty_start
ZTST_getchunk: read code chunk:
  zpty_start
  zpty_input 'sleep 3 &'
  zpty_input 'print $jobstates'
  zpty_input '(print $jobstates)'
  zpty_input 'jobs -s'
  zpty_stop
ZTST_test: examining line:
*>\[1] [0-9]##
ZTST_getredir: read redir for '>':
\[1] [0-9]##
ZTST_test: examining line:
*>running:+:*=running
ZTST_getredir: read redir for '>':
running:+:*=running
ZTST_test: examining line:
*>running:+:*=running
ZTST_getredir: read redir for '>':
running:+:*=running
ZTST_test: examining line:
*>zsh:*SIGHUPed*
ZTST_getredir: read redir for '>':
zsh:*SIGHUPed*
ZTST_test: examining line:

Running test: $jobstate for running job in main shell and subshell
ZTST_test: expecting status: 0
Input: /tmp/zsh.ztst.46005/ztst.in, output: /tmp/zsh.ztst.46005/ztst.out, error: /tmp/zsh.ztst.46005/ztst.terr
ZTST_execchunk: status 0
ZTST_test: test produced standard output:
[1] 46016
zsh: failed to load module `zsh/parameter': /opt/zsh-2022-03-03/lib/zsh/5.8.1.1-dev/zsh/parameter.so: cannot open shared object file: No such file or directory
zsh/parameter
zsh: failed to load module `zsh/parameter': /opt/zsh-2022-03-03/lib/zsh/5.8.1.1-dev/zsh/parameter.so: cannot open shared object file: No such file or directory
zsh/parameter
zsh: warning: 1 jobs SIGHUPed
ZTST_test: and standard error:

Pattern match failed, line mismatch (4/6):
 <\[1] [0-9]##
 <running:+:*=running
 <running:+:*=running
 <zsh:*SIGHUPed*
 >[1] 46016
 >zsh: failed to load module `zsh/parameter': /opt/zsh-2022-03-03/lib/zsh/5.8.1.1-dev/zsh/parameter.so: cannot open shared object file: No such file or directory
 >zsh/parameter
 >zsh: failed to load module `zsh/parameter': /opt/zsh-2022-03-03/lib/zsh/5.8.1.1-dev/zsh/parameter.so: cannot open shared object file: No such file or directory
 >zsh/parameter
 >zsh: warning: 1 jobs SIGHUPed
Test ../../../src/zsh-2022-03-03/Test/W03jobparameters.ztst failed: output differs from expected as shown above for:
  zpty_start
  zpty_input 'sleep 3 &'
  zpty_input 'print $jobstates'
  zpty_input '(print $jobstates)'
  zpty_input 'jobs -s'
  zpty_stop
Was testing: $jobstate for running job in main shell and subshell
../../../src/zsh-2022-03-03/Test/W03jobparameters.ztst: test failed.
**************************************
0 successful test scripts, 1 failure, 0 skipped
**************************************
make[1]: *** [Makefile:190: check] Error 1
make[1]: Leaving directory '/opt/build/zsh-2022-03-03/Test'
make: *** [Makefile:263: check] Error 2

TIA,
  Vin

On Wed, Mar 2, 2022 at 3:19 PM Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
On Wed, 2022-03-02 at 09:44 +0000, Daniel Shahaf wrote:
> Peter Stephenson wrote on Tue, 01 Mar 2022 10:40 +00:00:
> Is this testable?  Sorry, haven't got time to write a test myself right now.

We could do something like this.

pws

diff --git a/Test/W02jobs.ztst b/Test/W02jobs.ztst
index b09f2ac62..d52888dd9 100644
--- a/Test/W02jobs.ztst
+++ b/Test/W02jobs.ztst
@@ -144,12 +144,14 @@
   zpty_start
   zpty_input 'sleep 3 &'
   zpty_input 'jobs -r'
+  zpty_input '(jobs -r)'
   zpty_input 'print -- -'
   zpty_input 'jobs -s'
   zpty_stop
 0:`jobs -r` and `jobs -s` with running job
 *>\[1] [0-9]##
 *>\[1]  + running*sleep*
+*>\[1]  + running*sleep*
 *>-
 *>zsh:*SIGHUPed*

diff --git a/Test/W03jobparameters.ztst b/Test/W03jobparameters.ztst
new file mode 100644
index 000000000..474adfaec
--- /dev/null
+++ b/Test/W03jobparameters.ztst
@@ -0,0 +1,49 @@
+# Tests for interactive job control with parameter state
+
+%prep
+
+  if zmodload zsh/zpty 2> /dev/null; then
+    zpty_start() {
+      export PS1= PS2=
+      zpty -d
+      zpty zsh "${(q)ZTST_testdir}/../Src/zsh -fiV +Z"
+    }
+    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'
+      # zpty gives no output when piped without these braces (?)
+      { zpty -r zsh } | sed $'/[^[:space:]]/!d; s/\r$//;'
+      zpty -d
+      :
+    }
+    if ! zmodload zsh/parameter 2> /dev/null; then
+      ZTST_unimplemented='the zsh/parameter module is not available'
+    fi
+  else
+    ZTST_unimplemented='the zsh/zpty module is not available'
+  fi
+
+%test
+
+  zpty_start
+  zpty_input 'sleep 3 &'
+  zpty_input 'print $jobstates'
+  zpty_input '(print $jobstates)'
+  zpty_input 'jobs -s'
+  zpty_stop
+0:$jobstate for running job in main shell and subshell
+*>\[1] [0-9]##
+*>running:+:*=running
+*>running:+:*=running
+*>zsh:*SIGHUPed*




Messages sorted by: Reverse Date, Date, Thread, Author