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

Re: [PATCH] Use null prompts in interactive tests.



Would it be possible to separate the functional changes from the
formatting changes to make it easier to see the actual differences?

I have split the patch into a functional part and a formatting part:

Use null prompts in interactive tests
 
I'm also unsure that changing tests where a similar technique was
already being used (e.g., PS1=%%) is necessarily an improvement, but I
won't object if no one else does.

The external PS1= has the advantage that you no longer need a blanket *?*%* which I think could for example potentially swallow DPUTS messages.

Philippe

diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index 1c6969e74..90f9e7c72 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -58,30 +58,24 @@
 >And this too
 >And aliases are expanded
 
-  $ZTST_testdir/../Src/zsh -fis <<<'
-  unsetopt PROMPT_SP
-  PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
-  exec 2>&1
+  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
   alias \{=echo
   { begin
   {end
-  fc -l -2' 2>/dev/null
+  fc -l -2'
 0:Aliasing reserved tokens
 >begin
 >end
-*>*5*{ begin
-*>*6*{end
+*>*2*{ begin
+*>*3*{end
 
-  $ZTST_testdir/../Src/zsh -fis <<<'
-  unsetopt PROMPT_SP
-  PROMPT="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
-  exec 2>&1
+  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
   alias -g S=\"
   echo S a string S "
-  fc -l -1' 2>/dev/null
+  fc -l -1'
 0:Global aliasing quotes
 > a string S 
-*>*5*echo S a string S "
+*>*2*echo S a string S "
 # "
 # Note there is a trailing space on the "> a string S " line
 
diff --git a/Test/B06fc.ztst b/Test/B06fc.ztst
index 922b0010f..31ec27087 100644
--- a/Test/B06fc.ztst
+++ b/Test/B06fc.ztst
@@ -10,16 +10,13 @@
 1:Checking that fc -l foo doesn't core dump when history is empty
 ?./fcl:fc:1: event not found: foo
 
-  PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
+  PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< $'fc -p /dev/null 0 0\n:'
 0:Checking that fc -p doesn't core dump when history size is zero
-*?*%*
 
-  PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0'
+  PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null a 0'
 1:Checking that fc -p rejects non-integer history size
-*?*% fc: HISTSIZE must be an integer
-*?*%*
+?fc: HISTSIZE must be an integer
 
-  PS1='%% ' $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
+  PS1= $ZTST_testdir/../Src/zsh +Z -fsi <<< 'fc -p /dev/null 0 a'
 1:Checking that fc -p rejects non-integer history save size
-*?*% fc: SAVEHIST must be an integer
-*?*%*
+?fc: SAVEHIST must be an integer
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index e44af8ad7..6e7943def 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -108,9 +108,7 @@
 ?(eval):1: unset1: exiting1
 ?(eval):2: null1: exiting2
 
-  PROMPT="" $ZTST_testdir/../Src/zsh -fis <<<'
-  unsetopt PROMPT_SP
-  PS1="" PS2="" PS3="" PS4="" RPS1="" RPS2=""
+  PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
   exec 2>&1
   foo() {
       print ${1:?no arguments given}
@@ -118,9 +116,9 @@
   }
   foo
   print reached
-  ' 2>/dev/null
+  '
 0:interactive shell returns to top level on ${...?...} error
-*>*foo:1: 1: no arguments given
+>foo:1: 1: no arguments given
 >reached
 
   message="expand me and remove quotes"
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index 6cfe6d1d0..ec6239b54 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -1541,13 +1541,13 @@ F:previously this could create an infinite recursion and crash
 >tst aaa
 
 #
-# The following tests are run in interactive mode, using PS1 as an
+# The following tests are run in interactive mode, using PS3 as an
 # assignable special with side-effects.  This crashed at one time.
 #
 
  # Note bypassing TYPESET_TO_UNSET here
- $ZTST_testdir/../Src/zsh -fis <<<$'
- typeset -n p=PS1
+ PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
+ typeset -n p=PS3
  () {
   typeset -p p
   local p
@@ -1557,23 +1557,21 @@ F:previously this could create an infinite recursion and crash
  }
  '
 0:regression: assign to local that shadows global named reference
->typeset -g -n p=PS1
+>typeset -g -n p=PS3
 >typeset p=''
 >typeset p=xx
-*?*
 
  # Note bypassing TYPESET_TO_UNSET here
- $ZTST_testdir/../Src/zsh -fis <<<$'
+ PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
  () {
-   typeset p=PS1
+   typeset p=PS3
    typeset -n p
    p=zz
  }
- typeset -p PS1
+ typeset -p PS3
  '
 0:regression - converting a string into a named reference
->typeset PS1=zz
-*?*
+>typeset PS3=zz
 
  unset var1 var2
  typeset -n ref1=var1
diff --git a/Test/W01history.ztst b/Test/W01history.ztst
index 1d3f3cf6f..06a8556b9 100644
--- a/Test/W01history.ztst
+++ b/Test/W01history.ztst
@@ -6,26 +6,26 @@
 
 %test
 
-  $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
   print one two three four five six seven eight nine ten
   print !:$ !:10 !:9 !:1 !:0
   print one two three four five six seven eight nine ten
   print !:0-$ !:1-2
-  ' 2>/dev/null
+  '
 0:History word references
 >one two three four five six seven eight nine ten
 >ten ten nine one print
 >one two three four five six seven eight nine ten
 >print one two three four five six seven eight nine ten one two
 
-  $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
   print line one of an arbitrary series
   print issue two for some mystery sequence
   print !-1:5-$
   print !1:2
   print !2:2
   print !-3:1-$
-  ' 2>/dev/null
+  '
 0:History line numbering
 >line one of an arbitrary series
 >issue two for some mystery sequence
@@ -34,12 +34,12 @@
 >two
 >mystery sequence
 
-  $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
   print All metaphor, Malachi, stilts and all
   print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
   print !1:2:&
   print -l !1:2-3:gs/a/o/
-  ' 2>/dev/null
+  '
 0:History substitution
 >All metaphor, Malachi, stilts and all
 >metaphor? shmetaphor!
@@ -47,10 +47,10 @@
 >metophor,
 >Molochi,
 
-  $ZTST_testdir/../Src/zsh -fis <<<'
+  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
   echo foo bar
   echo $(!!) again
-  echo more $( !! )' 2>/dev/null
+  echo more $( !! )'
 0:Regression test for history references in command substitution
 >foo bar
 >foo bar again
@@ -59,7 +59,7 @@
 F:Check that a history bug introduced by workers/34160 is working again.
 # Discarded line of error output consumes prompts printed by "zsh -i".
 
- $ZTST_testdir/../Src/zsh -fis <<<'
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
  echo /my/path/for/testing
  echo !1:1:h10
  echo !1:1:h3
@@ -69,7 +69,7 @@ F:Check that a history bug introduced by workers/34160 is working again.
  echo !1:1:t3
  echo !1:1:t2
  echo !1:1:t1
- echo !1:1:t3:h2' 2>/dev/null
+ echo !1:1:t3:h2'
 0:Modifiers :h and :t with arguments
 >/my/path/for/testing
 >/my/path/for/testing
@@ -82,14 +82,14 @@ F:Check that a history bug introduced by workers/34160 is working again.
 >testing
 >path/for
 
- $ZTST_testdir/../Src/zsh -fis <<<'
+ PS1= $ZTST_testdir/../Src/zsh -fis <<<'
  echo /my/path/for/testing
- echo !1:1:P' 2>/dev/null
+ echo !1:1:P'
 0:Modifier :P
 >/my/path/for/testing
 >/my/path/for/testing
 
- $ZTST_testdir/../Src/zsh -fgis <<<'
+ PS1= $ZTST_testdir/../Src/zsh -fgis <<<'
  SAVEHIST=7
  print -rs "one\\"
  print -rs "two\\\\"
@@ -101,7 +101,7 @@ F:Check that a history bug introduced by workers/34160 is working again.
  fc -W hist
  fc -p -R hist
  fc -l
- rm hist' 2>/dev/null
+ rm hist'
 0:Lines ending in backslash saved and restored to history
 >    1  one\
 >    2  two\\
diff --git a/Test/A02alias.ztst b/Test/A02alias.ztst
index 90f9e7c72..f866ab4d1 100644
--- a/Test/A02alias.ztst
+++ b/Test/A02alias.ztst
@@ -59,10 +59,11 @@
 >And aliases are expanded
 
   PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-  alias \{=echo
-  { begin
-  {end
-  fc -l -2'
+    alias \{=echo
+    { begin
+    {end
+    fc -l -2
+  '
 0:Aliasing reserved tokens
 >begin
 >end
@@ -70,9 +71,10 @@
 *>*3*{end
 
   PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-  alias -g S=\"
-  echo S a string S "
-  fc -l -1'
+    alias -g S=\"
+    echo S a string S "
+    fc -l -1
+  '
 0:Global aliasing quotes
 > a string S 
 *>*2*echo S a string S "
diff --git a/Test/D04parameter.ztst b/Test/D04parameter.ztst
index 6e7943def..be8ac2068 100644
--- a/Test/D04parameter.ztst
+++ b/Test/D04parameter.ztst
@@ -109,13 +109,13 @@
 ?(eval):2: null1: exiting2
 
   PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
-  exec 2>&1
-  foo() {
-      print ${1:?no arguments given}
-      print not reached
-  }
-  foo
-  print reached
+    exec 2>&1
+    foo() {
+        print ${1:?no arguments given}
+        print not reached
+    }
+    foo
+    print reached
   '
 0:interactive shell returns to top level on ${...?...} error
 >foo:1: 1: no arguments given
diff --git a/Test/K01nameref.ztst b/Test/K01nameref.ztst
index ec6239b54..aadd01f11 100644
--- a/Test/K01nameref.ztst
+++ b/Test/K01nameref.ztst
@@ -1547,14 +1547,14 @@ F:previously this could create an infinite recursion and crash
 
  # Note bypassing TYPESET_TO_UNSET here
  PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
- typeset -n p=PS3
- () {
-  typeset -p p
-  local p
-  typeset -p p
-  p=xx
-  typeset -p p
- }
+   typeset -n p=PS3
+   () {
+    typeset -p p
+    local p
+    typeset -p p
+    p=xx
+    typeset -p p
+   }
  '
 0:regression: assign to local that shadows global named reference
 >typeset -g -n p=PS3
@@ -1563,12 +1563,12 @@ F:previously this could create an infinite recursion and crash
 
  # Note bypassing TYPESET_TO_UNSET here
  PS1= PS2= $ZTST_testdir/../Src/zsh -fis <<<'
- () {
-   typeset p=PS3
-   typeset -n p
-   p=zz
- }
- typeset -p PS3
+   () {
+     typeset p=PS3
+     typeset -n p
+     p=zz
+   }
+   typeset -p PS3
  '
 0:regression - converting a string into a named reference
 >typeset PS3=zz
diff --git a/Test/W01history.ztst b/Test/W01history.ztst
index 06a8556b9..665a37f2c 100644
--- a/Test/W01history.ztst
+++ b/Test/W01history.ztst
@@ -7,10 +7,10 @@
 %test
 
   PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-  print one two three four five six seven eight nine ten
-  print !:$ !:10 !:9 !:1 !:0
-  print one two three four five six seven eight nine ten
-  print !:0-$ !:1-2
+    print one two three four five six seven eight nine ten
+    print !:$ !:10 !:9 !:1 !:0
+    print one two three four five six seven eight nine ten
+    print !:0-$ !:1-2
   '
 0:History word references
 >one two three four five six seven eight nine ten
@@ -19,12 +19,12 @@
 >print one two three four five six seven eight nine ten one two
 
   PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-  print line one of an arbitrary series
-  print issue two for some mystery sequence
-  print !-1:5-$
-  print !1:2
-  print !2:2
-  print !-3:1-$
+    print line one of an arbitrary series
+    print issue two for some mystery sequence
+    print !-1:5-$
+    print !1:2
+    print !2:2
+    print !-3:1-$
   '
 0:History line numbering
 >line one of an arbitrary series
@@ -35,10 +35,10 @@
 >mystery sequence
 
   PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-  print All metaphor, Malachi, stilts and all
-  print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
-  print !1:2:&
-  print -l !1:2-3:gs/a/o/
+    print All metaphor, Malachi, stilts and all
+    print !1:2:s/,/\\\\?/ !1:2:s/m/shm/:s/,/\!/
+    print !1:2:&
+    print -l !1:2-3:gs/a/o/
   '
 0:History substitution
 >All metaphor, Malachi, stilts and all
@@ -48,9 +48,10 @@
 >Molochi,
 
   PS1= $ZTST_testdir/../Src/zsh -fis <<<'
-  echo foo bar
-  echo $(!!) again
-  echo more $( !! )'
+    echo foo bar
+    echo $(!!) again
+    echo more $( !! )
+  '
 0:Regression test for history references in command substitution
 >foo bar
 >foo bar again
@@ -60,16 +61,17 @@ F:Check that a history bug introduced by workers/34160 is working again.
 # Discarded line of error output consumes prompts printed by "zsh -i".
 
  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
- echo /my/path/for/testing
- echo !1:1:h10
- echo !1:1:h3
- echo !1:1:h2
- echo !1:1:h1
- echo !1:1:t10
- echo !1:1:t3
- echo !1:1:t2
- echo !1:1:t1
- echo !1:1:t3:h2'
+   echo /my/path/for/testing
+   echo !1:1:h10
+   echo !1:1:h3
+   echo !1:1:h2
+   echo !1:1:h1
+   echo !1:1:t10
+   echo !1:1:t3
+   echo !1:1:t2
+   echo !1:1:t1
+   echo !1:1:t3:h2
+ '
 0:Modifiers :h and :t with arguments
 >/my/path/for/testing
 >/my/path/for/testing
@@ -83,25 +85,27 @@ F:Check that a history bug introduced by workers/34160 is working again.
 >path/for
 
  PS1= $ZTST_testdir/../Src/zsh -fis <<<'
- echo /my/path/for/testing
- echo !1:1:P'
+   echo /my/path/for/testing
+   echo !1:1:P
+ '
 0:Modifier :P
 >/my/path/for/testing
 >/my/path/for/testing
 
  PS1= $ZTST_testdir/../Src/zsh -fgis <<<'
- SAVEHIST=7
- print -rs "one\\"
- print -rs "two\\\\"
- print -rs "three\\\\\\"
- print -rs "four\\\\\\\\"
- print -rs "five\\\\\\\\\\"
- print -s  "while false\ndo\ntrue\\\\\n && break\ndone"
- print -s  "echo one\\\\\ntwo"
- fc -W hist
- fc -p -R hist
- fc -l
- rm hist'
+   SAVEHIST=7
+   print -rs "one\\"
+   print -rs "two\\\\"
+   print -rs "three\\\\\\"
+   print -rs "four\\\\\\\\"
+   print -rs "five\\\\\\\\\\"
+   print -s  "while false\ndo\ntrue\\\\\n && break\ndone"
+   print -s  "echo one\\\\\ntwo"
+   fc -W hist
+   fc -p -R hist
+   fc -l
+   rm hist
+ '
 0:Lines ending in backslash saved and restored to history
 >    1  one\
 >    2  two\\


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