Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Preserve DPUTS output in comptest-based tests
- X-seq: zsh-workers 54795
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Preserve DPUTS output in comptest-based tests
- Date: Wed, 17 Jun 2026 02:16:23 +0200
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=AZH872oqhKLltRCyXOIJ3J9Pe8wvBJCQTWZM1XsDfT0=; fh=RngAOd9wlRc8Glv1v2GOfDUnq2FsyrczungEY8JNfXY=; b=kfNQDUwdLpZC4l6nlXwpGlVqPZIXEkkMljqkaQ++jIALlB8dtDBxzhGD5n8oJstTqe lrQTU3Cd35qCe2XQpQnKtNyRua84gT7IRMzEwGnGSpftu5icY48IYwiQ0hucZIZtZ/ZA g3gMO6bT7jeVO0XMv43FMLseiEf4LJ8ALRRqDWZppZbf9EpGNtKaoiM68ZDOZu+Lve8O QRVB9n3/NNX+sGPBZ4gWP5VR92Y4qL4D7xukeD39nmSVgVGCOeGqZW8oW6hVT7WofTlV sCrFqgt1U8QjOJ5J8brUsWqW6lJ3wBgbS6GEjFy/rngcyWCviXtkrLzKrieZoLNk0K22 rvDQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1781655396; cv=none; d=google.com; s=arc-20240605; b=XOzz6MZSber0zhhQXoxZbV9s64oMDs4Ri45VcinphnKVxDy1PvALizfyMV7PRV4j58 CAwpFXKBeUhun8P4kSdNIpS9emyzCZLRTE6DpDBy4Tb+ydKZYk6Gf0XKbmorFMTBAJeY M26oj0Pkzr9nT6dU2bnQp4jgS0mmJaBE6BAjcHMD/boxHtSIweV03Vxbf6/7wL7vekSd 9154dxn/9DDlnK+UkE85wg2nbQnTL8GuvNkuPnsrkWaUPe0qt08hJXP1qhm7mW4NrD7r nTYgMSZNJPXatCi75uqEs73AN+UaEQKtkgGd0HNvbmYxMwXfpYTKtA8TW/AuEjFig9lT 7Sxw==
- Archived-at: <https://zsh.org/workers/54795>
- In-reply-to: <CAGdYcht32_OWShJ-fzd2fZ0XcTdVCu292AWTSquVDKpzHQrhaw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAGdYcht32_OWShJ-fzd2fZ0XcTdVCu292AWTSquVDKpzHQrhaw@mail.gmail.com>
On Wed, Jun 17, 2026 at 1:55 AM Philippe Altherr
<philippe.altherr@xxxxxxxxx> wrote:
>
> This ensures that if a DPUTS triggers during a comptest-based test, the test will fail.
>
> - Preserve DPUTS output in comptest-based tests
> diff --git a/Test/comptest b/Test/comptest
> index 39ad14768..d306198e1 100644
> --- a/Test/comptest
> +++ b/Test/comptest
> @@ -21,7 +21,7 @@ comptestinit () {
> export PS1="<PROMPT>"
> zpty zsh "$comptest_zsh -f +Z"
>
> - zpty -r zsh log1 "*<PROMPT>*" || {
> + zpty_read log1 "*<PROMPT>*" || {
> print "first prompt hasn't appeared."
> return 1
> }
this zpty call didn't use -m before, was that a bug? If so, you should
probably mention it in the commit message, if not, mention why adding
it is not a problem.
> @@ -99,20 +99,41 @@ bindkey -a "^X" zle-finish
> '
> }
>
> +zpty_read() {
> + local logvar=$1 pattern=$2
> + zpty -r -m zsh $logvar $pattern
> + local -i result=$?
> + zpty_handle_dputs $logvar
> + return result
> +}
> +
> zpty_flush() {
> local junk
> if zpty -r -t zsh junk \*; then
> + zpty_handle_dputs junk
> (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "$*: ${(V)junk}"
> while zpty -r -t zsh junk \* ; do
> + zpty_handle_dputs junk
> (( ZTST_verbose > 2 )) && print -n -u $ZTST_fd "${(V)junk}"
> done
> (( ZTST_verbose > 2 )) && print -u $ZTST_fd ''
> fi
> }
>
> +zpty_handle_dputs() {
> + local -nu log=$1
> + local -i lastend=0
> + while (( ${(N)${log[lastend+1,-1]}#*(#b)((<->:|) *.c:<->: *[$'\r\n'])} )); do
> + print -r "DPUTS:{${match[1][1,-2]}}"
> + log[lastend+$mbegin[1],lastend+$mend[1]]=""
> + [[ log[lastend+$mbegin[1]] != $'\n' ]] || log[lastend+$mbegin[1]]=""
> + lastend+=$mbegin[1]
> + done
> +}
???
Can you at least write something about what mechanism you're trying to
implement instead of just "handle DPUTS"? For example, at a glance a
reader would wonder "If there is spurious DPUTS output, surely this
will already fail the test because the test expects a certain output"?
Maybe you could mention that some tests discarded zpty output without
reading it, if that's indeed what is happening?
> zpty_run() {
> zpty -w zsh "$*"
> - zpty -r -m zsh log "*<PROMPT>*" || {
> + zpty_read log "*<PROMPT>*" || {
> print "prompt hasn't appeared."
> return 1
> }
> @@ -130,7 +151,7 @@ comptesteval () {
>
> # zpty_flush Before comptesteval
> zpty -w zsh ". ${(q)tmp}"
> - zpty -r -m zsh log_eval "*<PROMPT>*" || {
> + zpty_read log_eval "*<PROMPT>*" || {
> print "prompt hasn't appeared."
> return 1
> }
> @@ -144,7 +165,7 @@ comptesteval () {
> comptest () {
> input="$*"
> zpty -n -w zsh "$input"$'\C-Z'
> - zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
> + zpty_read log "*<WIDGET><finish>*<PROMPT>*" || {
> print "failed to invoke finish widget."
> return 1
> }
> @@ -184,7 +205,7 @@ zletest () {
> zpty -n -w zsh "$input"
> done
> zpty -n -w zsh $'\C-X'
> - zpty -r -m zsh log "*<WIDGET><finish>*<PROMPT>*" || {
> + zpty_read log "*<WIDGET><finish>*<PROMPT>*" || {
> print "failed to invoke finish widget."
> return 1
> }
ok, these ones all use -m so this is presumably not a change in behavior.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author