Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Preserve DPUTS output in comptest-based tests
- X-seq: zsh-workers 54794
- From: Philippe Altherr <philippe.altherr@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Preserve DPUTS output in comptest-based tests
- Date: Wed, 17 Jun 2026 01:55:10 +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=to:subject:message-id:date:from:mime-version:dkim-signature; bh=AR9ml2zFoS8HgTczDsldWPIJOfhLgEOfZKYG/CJcSZs=; fh=BgAYDYpL6Ne/A5nWEMVJiHiBtrz8Imz3uf26RDwgQX4=; b=kGCP8C6c8tuENSNN4c4bao1LPuxBdy+EjOePG1WJGjYzgHJPx3H65azqw+Wq6U4YXO DJRgT1zzHN/484D+YK7bkHmxMjjm9/yvHR7aWiROPOLbaym4S4IAPAZG52N8wckboWYG rUnE0MAKDcXS2jxsCtM5/b2qvxzfe58t4B0g0sFTd21EhcV1QyltfFrD7WndyFFF4DOJ U+wmQC1r/kPnSBh8Il8OuEdaQ2gG3Gcq6lBDBFZvK+i8WpShr06jNR73/+9TguAAbw4b myhG0MlNgkpW0WNjIXbyaCgRYCXEfgBJZgGJEpmq5+LGZp293emZSu3soAsUqAfnBegW 1Icg==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1781654122; cv=none; d=google.com; s=arc-20240605; b=ftHYOyZMEUicihzS5UUXLhA/XYH+D3ksjtxBlwgYZ7tiO3jW9+q7vANPfryyZDoi7S l4Bp8I5op7ExaZGVPdFDlQXMuBwNhfNIkUCZdZWtB9x6+I8rWYYq3SHAhnubEuDqOEuK ashpynCMb1crxeu6z95GYEnxVGcB99+MR21QPiFglvkPsWEtDqLdltqJVPsmKtoQL9kD WLc2UHxlbMzB1F7tmBBn0nCvx4scKqB4krIqzpd+NMp62lR3rci/U0et4kwco0m4P7CH Ynu8YBQfBVd0Cf3jD0+P02yrKJM2pi4APCnY79Gedg01ig7g2ApTvoGYi+kAgEmXurVx PKhg==
- Archived-at: <https://zsh.org/workers/54794>
- List-id: <zsh-workers.zsh.org>
This ensures that if a DPUTS triggers during a comptest-based test, the test will fail.
Philippe
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
}
@@ -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
+}
+
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
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author