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

Re: [PATCH] Zptyfy W01history.ztst



On 13 Oct, Philippe Altherr wrote:
> The tests in W01history.ztst print directly to /dev/tty, which is problematic
> when tests are run in parallel. The patch below modifies W01history.ztst to use
> zpty, such that all outputs, including outputs to /dev/tty, are captured by
> ztst.zsh.

The zpty tests have a number of disadvantages like zpty not building on
obscure platforms. This change forces you to run the tests under zpty.
For the completion and zle tests we really need to capture the terminal
output so have no choice but this isn't the case for the history tests.
Being able to run tests without zpty can be easier when debugging a
problem.

For the history tests, I think it makes more sense to run zpty a layer
above in the test driver script. I've attached a patch to do this. This
is only being used where $OSTYPE is linux-gnu because Linux doesn't
support stty flusho for silencing that output. I was more concerned with
the extra noise from those history tests. Do we perhaps need to also
use zpty where tests are being run in parallel even for other platforms?

> +    skip s:$'\e]11;?\e\\' &&   # OSC 11: Query terminal's background color
> +    skip s:$'\e]10;?\e\\' &&   # OSC 10: Query terminal's foreground color
> +    skip s:$'\e]12;?\e\\' &&   # OSC 12: Query terminal's cursor color

If we do end up with a variant of this patch then rather than skip
these escapes, disabling them all is cleaner and likely more robust.
That's with .term.extensions. It also looks like you're skipping the
partial line marker from the PROMPT_SP option - again easier to unset
the option. For anything that comes from termcap, actual termcap
entries may vary. zle -T can cover ZLE but not all termcap output comes
from ZLE.

(As an aside, why is there a $ZTST_failcolour but nothing for the
success and warning colours)

Oliver

diff --git a/Test/W01history.ztst b/Test/W01history.ztst
index 1d61237b7..02d35a0ae 100644
--- a/Test/W01history.ztst
+++ b/Test/W01history.ztst
@@ -1,9 +1,5 @@
 # Tests for BANG_HIST replacements
 
-%prep
-
-  if [[ -t 0 ]]; then print -u $ZTST_fd History tests write to /dev/tty; fi
-
 %test
 
   stty flusho < $TTY
diff --git a/Test/runtests.zsh b/Test/runtests.zsh
index ea862d2b3..63b6e6565 100644
--- a/Test/runtests.zsh
+++ b/Test/runtests.zsh
@@ -8,8 +8,11 @@ emulate zsh
 # We could probably do that with subshells instead.
 
 integer success=0 failure=0 skipped=0 retval
-typeset resln rule col
-typeset -a ffiles res
+typeset resln rule col ZTST_fd
+typeset -a ffiles res usezpty
+
+[[ $OSTYPE = linux-gnu ]] && usezpty=( W01 )
+[[ -d Modules/zsh ]] && module_path=( $PWD/Modules )
 
 # colour to use for ztst failure messages. also used as a signal that colours
 # are available generally
@@ -21,7 +24,13 @@ typeset -x ZTST_failcolour=red
 
 for file in "${(f)ZTST_testlist}"; do
   file=${file#./}
-  $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file
+  if [[ $file = (${(j.|.)usezpty})* ]] && zmodload -i zsh/zpty; then
+    zpty zsh "$ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file"' >&$ZTST_fd' {ZTST_fd}>&1
+    zpty -r zsh >/dev/null
+    zpty -d zsh
+  else
+    $ZTST_exe +Z -f $ZTST_srcdir/ztst.zsh $file
+  fi
   retval=$?
   if (( $retval == 2 )); then
     (( skipped++ ))




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