Make sure the PWD environment variable points to the t directory.
authorAndy Dougherty <doughera@lafayette.edu>
Thu, 13 Mar 2014 20:16:22 +0000 (16:16 -0400)
committerAndy Dougherty <doughera@lafayette.edu>
Tue, 18 Mar 2014 11:15:37 +0000 (07:15 -0400)
runtests is typically run under /bin/sh.  If the user uses a different
interactive shell (such as /bin/ksh) that maintains the PWD environment
variable, but /bin/sh does not, then the 'cd t' line in runtests ends
up changing the working directory without updating $PWD.  Several tests
in t/io/fs.t rely on being able to change directories and then get back
to the original.  The tests assume that if $PWD is set at all, then
it is set correctly.  This fix changes runtests to ensure it is so.

runtests.SH

index 481a237..78c879b 100755 (executable)
@@ -61,6 +61,15 @@ fi
 
 cd t
 
+# If this is run under an old shell that doesn't automatically 
+# update PWD, then we must update it.  Otherwise, t/io/fs.t gets 
+# mixed up about what directory we are in.
+case "$PWD" in
+    '')  ;; # Do nothing if it isn't set at all.
+    */t) ;; # Leave it alone if it's properly updated.
+    *) PWD=${PWD}/t; export PWD ;;  # Otherwise, fix it.
+esac
+
 !NO!SUBS!
 
 ## In the following, dollars and backticks do need the extra backslash.