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

Re: pwd -r vs. pwd test failure



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@xxxxxxxxxxxxxxxxxx>
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



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