zsh-workers
 help / color / mirror / code / Atom feed
* pwd -r vs. pwd test failure
@ 2020-03-26 12:22 Vin Shelton
  2020-03-26 22:02 ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: Vin Shelton @ 2020-03-26 12:22 UTC (permalink / raw)
  To: Zsh Hackers' List

[-- Attachment #1: Type: text/plain, Size: 2243 bytes --]

I got a test failure in B13 today:

Running test: whence symlink resolution
ZTST_test: expecting status: 0
Input: /tmp/zsh.ztst.360386/ztst.in, output: /tmp/zsh.ztst.360386/ztst.out,
error: /tmp/zsh.ztst.360386/ztst.terr
ZTST_execchunk: status 0
ZTST_test: test produced standard output:
/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 -> /SSD-2/opt/
build/zsh-2020-03-26/Test/whence.tmp/step2 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/step3 -> /SSD-2/opt/build
/zsh-2020-03-26/Test/whence.tmp/real
/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/real
ZTST_test: and standard error:

--- /tmp/zsh.ztst.360386/ztst.out       2020-03-26 08:04:38.543366746 -0400
+++ /tmp/zsh.ztst.360386/ztst.tout      2020-03-26 08:04:38.543366746 -0400
@@ -1,2 +1,2 @@
-/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/opt/build/zsh-2020-03-26/Test/whence.tmp/step2 ->
/opt/build/zsh-2020-03-26/Test/whence.tmp/step3 ->
/opt/build/zsh-2020-03-26/Test/whence.tmp/real
-/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/opt/build/zsh-2020-03-26/Test/whence.tmp/real
+/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/step2 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/step3 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/real
+/opt/build/zsh-2020-03-26/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-26/Test/whence.tmp/real
Test ../../../src/zsh-2020-03-26/Test/B13whence.ztst failed: output differs
from expected as shown above for:
  (
    path=( $PWD/whence.tmp $path )
    whence -S step1
    whence -s step1
  )
Was testing: whence symlink resolution
../../../src/zsh-2020-03-26/Test/B13whence.ztst: test failed.

Looking at the diff, I realized that my build directory is under a symlink;
/opt -> /SSD-2/opt. The test uses $PWD, which resolves to
/opt/build/zsh-2020-03-26, but pwd -r correct identifies the path as
/SSD-2/opt/build/zsh-2020-03-26; sure enough, if I run the test from
/SSD-2/opt/build/zsh-2020-03-26, the test passes. Is the right thing to fix
the test, or should $PWD track realpath?

  - Vin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pwd -r vs. pwd test failure
  2020-03-26 12:22 pwd -r vs. pwd test failure Vin Shelton
@ 2020-03-26 22:02 ` Daniel Shahaf
  2020-03-27 11:56   ` Vin Shelton
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Shahaf @ 2020-03-26 22:02 UTC (permalink / raw)
  To: Vin Shelton; +Cc: Zsh Hackers' List

Vin Shelton wrote on Thu, 26 Mar 2020 08:22 -0400:
> I got a test failure in B13 today:
> 

Thanks for the report.

> Test ../../../src/zsh-2020-03-26/Test/B13whence.ztst failed: output differs
> from expected as shown above for:
>   (
>     path=( $PWD/whence.tmp $path )
>     whence -S step1
>     whence -s step1
>   )
> Was testing: whence symlink resolution
> ../../../src/zsh-2020-03-26/Test/B13whence.ztst: test failed.
> 
> Looking at the diff, I realized that my build directory is under a symlink;
> /opt -> /SSD-2/opt. The test uses $PWD, which resolves to
> /opt/build/zsh-2020-03-26, but pwd -r correct identifies the path as
> /SSD-2/opt/build/zsh-2020-03-26; sure enough, if I run the test from
> /SSD-2/opt/build/zsh-2020-03-26, the test passes. Is the right thing to fix
> the test, or should $PWD track realpath?

I don't see any reason to change the semantics of $PWD, so let's fix
the test:

8<--
From a3c664f6bede4c33eb57a7a76134c1121069970b Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Thu, 26 Mar 2020 21:41:49 +0000
Subject: [PATCH] Fix new test when ${PWD}'s value contains symlinks.

---
 Test/B13whence.ztst | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/Test/B13whence.ztst b/Test/B13whence.ztst
index ea0a4dae5..5993c2247 100644
--- a/Test/B13whence.ztst
+++ b/Test/B13whence.ztst
@@ -1,7 +1,10 @@
 %prep
 
   mkdir whence.tmp
-  pushd whence.tmp
+  ln -s . whence.tmp/cwd
+  # cd through the symlink in order to test the case that ${prefix} and
+  # ${prefix:P} are different
+  pushd whence.tmp/cwd
   ln -s real step3
   ln -s step3 step2
   ln -s step2 step1
@@ -21,8 +24,8 @@
     whence -s step1
   )
 0q:whence symlink resolution
->$prefix/step1 -> $prefix/step2 -> $prefix/step3 -> $prefix/real
->$prefix/step1 -> $prefix/real
+>${prefix:P}/step1 -> ${prefix:P}/step2 -> ${prefix:P}/step3 -> ${prefix:P}/real
+>${prefix:P}/step1 -> ${prefix:P}/real
 
   (
     path=( $PWD/whence.tmp $path )

Thanks again,

Daniel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pwd -r vs. pwd test failure
  2020-03-26 22:02 ` Daniel Shahaf
@ 2020-03-27 11:56   ` Vin Shelton
  2020-03-27 23:11     ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: Vin Shelton @ 2020-03-27 11:56 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh Hackers' List

[-- Attachment #1: Type: text/plain, Size: 3889 bytes --]

Almost, but not quite:

: build/zsh-2020-03-27 Fri 27 7:47; ZTST_verbose=2 make TESTNUM=B13 -e check
cd Test ; make check
make[1]: Entering directory '/SSD-2/opt/build/zsh-2020-03-27/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-2020-03-27/Test/B13*.ztst; \
           do echo $f; done`" \
 ZTST_srcdir="../../../src/zsh-2020-03-27/Test" \
 ZTST_exe=../Src/zsh \
 ../Src/zsh +Z -f ../../../src/zsh-2020-03-27/Test/$ZTST_handler; then \
 stat=0; \
else \
 stat=1; \
fi; \
sleep 1; \
rm -rf Modules .zcompdump; \
exit $stat
../../../src/zsh-2020-03-27/Test/B13whence.ztst: starting.
ZTST_getsect: read section name: prep
ZTST_getchunk: read code chunk:
  mkdir whence.tmp
  ln -s . whence.tmp/cwd
  # cd through the symlink in order to test the case that ${prefix} and
  # ${prefix:P} are different
  pushd whence.tmp/cwd
  ln -s real step3
  ln -s step3 step2
  ln -s step2 step1
  ln -s loop loop
  ln -s flip flop
  ln -s flop flip
  touch real
  chmod +x real
  prefix=$PWD
  popd
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:
  (
ZTST_getchunk: read code chunk:
  (
    path=( $PWD/whence.tmp $path )
    whence -S step1
    whence -s step1
  )
ZTST_test: examining line:
>${prefix:P}/step1 -> ${prefix:P}/step2 -> ${prefix:P}/step3 ->
${prefix:P}/real
ZTST_getredir: read redir for '>':
${prefix:P}/step1 -> ${prefix:P}/step2 -> ${prefix:P}/step3 ->
${prefix:P}/real
${prefix:P}/step1 -> ${prefix:P}/real
ZTST_test: examining line:

Running test: whence symlink resolution
ZTST_test: expecting status: 0
Input: /tmp/zsh.ztst.606947/ztst.in, output: /tmp/zsh.ztst.606947/ztst.out,
error: /tmp/zsh.ztst.606947/ztst.terr
ZTST_execchunk: status 0
ZTST_test: test produced standard output:
/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step2 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step3 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/real
/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/real
ZTST_test: and standard error:

--- /tmp/zsh.ztst.606947/ztst.out 2020-03-27 07:48:54.836700073 -0400
+++ /tmp/zsh.ztst.606947/ztst.tout 2020-03-27 07:48:54.833366739 -0400
@@ -1,2 +1,2 @@
-/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step2 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step3 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/real
-/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/real
+/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step2 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/step3 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/real
+/opt/build/zsh-2020-03-27/Test/whence.tmp/step1 ->
/SSD-2/opt/build/zsh-2020-03-27/Test/whence.tmp/real
Test ../../../src/zsh-2020-03-27/Test/B13whence.ztst failed: output differs
from expected as shown above for:
  (
    path=( $PWD/whence.tmp $path )
    whence -S step1
    whence -s step1
  )
Was testing: whence symlink resolution
../../../src/zsh-2020-03-27/Test/B13whence.ztst: test failed.
**************************************
0 successful test scripts, 1 failure, 0 skipped
**************************************
make[1]: *** [Makefile:190: check] Error 1
make[1]: Leaving directory '/SSD-2/opt/build/zsh-2020-03-27/Test'
make: *** [Makefile:263: check] Error 2

Thanks!

  - Vin

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pwd -r vs. pwd test failure
  2020-03-27 11:56   ` Vin Shelton
@ 2020-03-27 23:11     ` Daniel Shahaf
  2020-03-28  0:20       ` Vin Shelton
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Shahaf @ 2020-03-27 23:11 UTC (permalink / raw)
  To: Vin Shelton; +Cc: Zsh Hackers' List

Vin Shelton wrote on Fri, 27 Mar 2020 07:56 -0400:
> Almost, but not quite:

Does this work better?  I added another :P.  This catches the case that
the source directory isn't a realpath.  (The case that the _build_ directory
isn't a realpath worked since day one.)

8<--8<--
From 57818d5fde2334965dce508e239af754f1fa565f Mon Sep 17 00:00:00 2001
From: Daniel Shahaf <d.s@daniel.shahaf.name>
Date: Thu, 26 Mar 2020 21:41:49 +0000
Subject: [PATCH] Fix new test when ${PWD}'s value contains symlinks.

---
 Test/B13whence.ztst | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Test/B13whence.ztst b/Test/B13whence.ztst
index ea0a4dae5..3b35835fe 100644
--- a/Test/B13whence.ztst
+++ b/Test/B13whence.ztst
@@ -1,7 +1,10 @@
 %prep
 
   mkdir whence.tmp
-  pushd whence.tmp
+  ln -s . whence.tmp/cwd
+  # cd through the symlink in order to test the case that ${prefix} and
+  # ${prefix:P} are different
+  pushd whence.tmp/cwd
   ln -s real step3
   ln -s step3 step2
   ln -s step2 step1
@@ -16,13 +19,13 @@
 %test
 
   (
-    path=( $PWD/whence.tmp $path )
+    path=( ${PWD:P}/whence.tmp $path )
     whence -S step1
     whence -s step1
   )
 0q:whence symlink resolution
->$prefix/step1 -> $prefix/step2 -> $prefix/step3 -> $prefix/real
->$prefix/step1 -> $prefix/real
+>${prefix:P}/step1 -> ${prefix:P}/step2 -> ${prefix:P}/step3 -> ${prefix:P}/real
+>${prefix:P}/step1 -> ${prefix:P}/real
 
   (
     path=( $PWD/whence.tmp $path )

Cheers,

Daniel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pwd -r vs. pwd test failure
  2020-03-27 23:11     ` Daniel Shahaf
@ 2020-03-28  0:20       ` Vin Shelton
  2020-03-28  0:57         ` Daniel Shahaf
  0 siblings, 1 reply; 7+ messages in thread
From: Vin Shelton @ 2020-03-28  0:20 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh Hackers' List

[-- Attachment #1: Type: text/plain, Size: 5486 bytes --]

Yes!

That leaves only a V07 test failure:

ZTST_verbose=2 make TESTNUM=V07 -e check
cd Test ; make check
make[1]: Entering directory '/SSD-2/opt/build/zsh-2020-03-27/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-2020-03-27/Test/V07*.ztst; \
           do echo $f; done`" \
 ZTST_srcdir="../../../src/zsh-2020-03-27/Test" \
 ZTST_exe=../Src/zsh \
 ../Src/zsh +Z -f ../../../src/zsh-2020-03-27/Test/$ZTST_handler; then \
 stat=0; \
else \
 stat=1; \
fi; \
sleep 1; \
rm -rf Modules .zcompdump; \
exit $stat
../../../src/zsh-2020-03-27/Test/V07pcre.ztst: starting.
ZTST_getsect: read section name: prep
ZTST_getchunk: read code chunk:
  if ! zmodload zsh/pcre 2>/dev/null; then
  then
    ZTST_unimplemented="the zsh/pcre module was disabled by configure (see
config.modules)"
    return 0
  fi
  setopt rematch_pcre
  setopt multibyte
  unset -m LC_\*
  mb_ok=
  langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8
$(locale -a 2>/dev/null | egrep 'utf8|UTF-8'))
  for LANG in $langs; do
    if [[ é = ? ]]; then
      mb_ok=1
      break;
    fi
  done
  if [[ -z $mb_ok ]]; then
    ZTST_unimplemented="no UTF-8 locale or multibyte mode is not
implemented"
  else
    print -u $ZTST_fd Testing PCRE multibyte with locale $LANG
    mkdir multibyte.tmp && cd multibyte.tmp
  fi
(eval):3: parse error near `ZTST_unimplemented="...'
ZTST_execchunk: status 1
Test ../../../src/zsh-2020-03-27/Test/V07pcre.ztst failed: non-zero status
from preparation code:
  if ! zmodload zsh/pcre 2>/dev/null; then
  then
    ZTST_unimplemented="the zsh/pcre module was disabled by configure (see
config.modules)"
    return 0
  fi
  setopt rematch_pcre
  setopt multibyte
  unset -m LC_\*
  mb_ok=
  langs=(en_{US,GB}.{UTF-,utf}8 en.UTF-8
$(locale -a 2>/dev/null | egrep 'utf8|UTF-8'))
  for LANG in $langs; do
    if [[ é = ? ]]; then
      mb_ok=1
      break;
    fi
  done
  if [[ -z $mb_ok ]]; then
    ZTST_unimplemented="no UTF-8 locale or multibyte mode is not
implemented"
  else
    print -u $ZTST_fd Testing PCRE multibyte with locale $LANG
    mkdir multibyte.tmp && cd multibyte.tmp
  fi
../../../src/zsh-2020-03-27/Test/V07pcre.ztst: test failed.
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:
  [[ 'foo→bar' =~ .([^[:ascii:]]). ]]
ZTST_getchunk: read code chunk:
  [[ 'foo→bar' =~ .([^[:ascii:]]). ]]
  print $MATCH
  print $match[1]
ZTST_test: examining line:
>o→b
ZTST_getredir: read redir for '>':
o→b
→
ZTST_test: examining line:

Running test: Basic non-ASCII regexp matching
ZTST_test: expecting status: 0
Input: /tmp/zsh.ztst.39712/ztst.in, output: /tmp/zsh.ztst.39712/ztst.out,
error: /tmp/zsh.ztst.39712/ztst.terr
ZTST_execchunk: status 0
ZTST_test: test produced standard output:

0
ZTST_test: and standard error:
(eval):1: failed to compile regex: Invalid character class name
--- /tmp/zsh.ztst.39712/ztst.out 2020-03-27 20:14:42.843332930 -0400
+++ /tmp/zsh.ztst.39712/ztst.tout 2020-03-27 20:14:42.843332930 -0400
@@ -1,2 +1,2 @@
-o→b
-→
+
+0
Test ../../../src/zsh-2020-03-27/Test/V07pcre.ztst failed: output differs
from expected as shown above for:
  [[ 'foo→bar' =~ .([^[:ascii:]]). ]]
  print $MATCH
  print $match[1]
Error output:
(eval):1: failed to compile regex: Invalid character class name
Was testing: Basic non-ASCII regexp matching
../../../src/zsh-2020-03-27/Test/V07pcre.ztst: test failed.

  - Vin

On Fri, Mar 27, 2020 at 7:11 PM Daniel Shahaf <d.s@daniel.shahaf.name>
wrote:

> Vin Shelton wrote on Fri, 27 Mar 2020 07:56 -0400:
> > Almost, but not quite:
>
> Does this work better?  I added another :P.  This catches the case that
> the source directory isn't a realpath.  (The case that the _build_
> directory
> isn't a realpath worked since day one.)
>
> 8<--8<--
> From 57818d5fde2334965dce508e239af754f1fa565f Mon Sep 17 00:00:00 2001
> From: Daniel Shahaf <d.s@daniel.shahaf.name>
> Date: Thu, 26 Mar 2020 21:41:49 +0000
> Subject: [PATCH] Fix new test when ${PWD}'s value contains symlinks.
>
> ---
>  Test/B13whence.ztst | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/Test/B13whence.ztst b/Test/B13whence.ztst
> index ea0a4dae5..3b35835fe 100644
> --- a/Test/B13whence.ztst
> +++ b/Test/B13whence.ztst
> @@ -1,7 +1,10 @@
>  %prep
>
>    mkdir whence.tmp
> -  pushd whence.tmp
> +  ln -s . whence.tmp/cwd
> +  # cd through the symlink in order to test the case that ${prefix} and
> +  # ${prefix:P} are different
> +  pushd whence.tmp/cwd
>    ln -s real step3
>    ln -s step3 step2
>    ln -s step2 step1
> @@ -16,13 +19,13 @@
>  %test
>
>    (
> -    path=( $PWD/whence.tmp $path )
> +    path=( ${PWD:P}/whence.tmp $path )
>      whence -S step1
>      whence -s step1
>    )
>  0q:whence symlink resolution
> ->$prefix/step1 -> $prefix/step2 -> $prefix/step3 -> $prefix/real
> ->$prefix/step1 -> $prefix/real
> +>${prefix:P}/step1 -> ${prefix:P}/step2 -> ${prefix:P}/step3 ->
> ${prefix:P}/real
> +>${prefix:P}/step1 -> ${prefix:P}/real
>
>    (
>      path=( $PWD/whence.tmp $path )
>
> Cheers,
>
> Daniel
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pwd -r vs. pwd test failure
  2020-03-28  0:20       ` Vin Shelton
@ 2020-03-28  0:57         ` Daniel Shahaf
  2020-03-28  1:17           ` Vin Shelton
  0 siblings, 1 reply; 7+ messages in thread
From: Daniel Shahaf @ 2020-03-28  0:57 UTC (permalink / raw)
  To: Vin Shelton; +Cc: Zsh Hackers' List

Vin Shelton wrote on Fri, 27 Mar 2020 20:20 -0400:
> Yes!
> 

Pushed.

> That leaves only a V07 test failure:

Fixed in HEAD.  Sorry about the breakage.

Daniel

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: pwd -r vs. pwd test failure
  2020-03-28  0:57         ` Daniel Shahaf
@ 2020-03-28  1:17           ` Vin Shelton
  0 siblings, 0 replies; 7+ messages in thread
From: Vin Shelton @ 2020-03-28  1:17 UTC (permalink / raw)
  To: Daniel Shahaf; +Cc: Zsh Hackers' List

[-- Attachment #1: Type: text/plain, Size: 28 bytes --]

It's all good now.

  - Vin

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-03-28  1:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 12:22 pwd -r vs. pwd test failure Vin Shelton
2020-03-26 22:02 ` Daniel Shahaf
2020-03-27 11:56   ` Vin Shelton
2020-03-27 23:11     ` Daniel Shahaf
2020-03-28  0:20       ` Vin Shelton
2020-03-28  0:57         ` Daniel Shahaf
2020-03-28  1:17           ` Vin Shelton

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).