]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: fix false failure in recent ls --hyperlink test
authorPádraig Brady <P@draigBrady.com>
Fri, 1 Sep 2017 06:52:59 +0000 (23:52 -0700)
committerPádraig Brady <P@draigBrady.com>
Fri, 1 Sep 2017 07:03:08 +0000 (00:03 -0700)
* tests/ls/hyperlink.sh: If the hostname or any part of
the absolute path would be changed due to URL encoding,
the test would fail.  Therefore simplify to remove
these components of the URL from consideration.

tests/ls/hyperlink.sh

index bc1331147d226bfc8a3bc0c57c23554c2b5fc720..eaedd0876bbffc83be91c994309db3bfabe5e144 100755 (executable)
@@ -17,9 +17,7 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
-print_ver_ ls realpath
-
-hostname=$(hostname) || skip_ 'unable to determine hostname'
+print_ver_ ls
 
 # lookup based on first letter
 encode() {
@@ -32,30 +30,34 @@ encode() {
 ls_encoded() {
   ef=$(encode "$1")
   echo "$ef" | grep -q 'dir$' && dir=: || dir=''
-  printf '\033]8;;file://%s%s/%s\a%s\033]8;;\a%s\n' \
-    $hostname $basepath $ef "$1" "$dir"
+  printf '\033]8;;file:///%s\a%s\033]8;;\a%s\n' \
+    "$ef" "$1" "$dir"
+}
+
+# These could be encoded, so remove from consideration
+strip_host_and_path() {
+  sed 's|file://.*/|file:///|'
 }
 
 mkdir testdir || framework_failure_
-basepath=$(realpath -m .) || framework_failure_
 (
 cd testdir
 ls_encoded "testdir" > ../exp.t || framework_failure_
-basepath="$basepath/testdir"
 for f in 'back\slash' 'encoded%3Fquestion' 'ques?tion' 'sp ace'; do
   touch "$f" || framework_failure_
   ls_encoded "$f" >> ../exp.t || framework_failure_
 done
 )
 ln -s testdir testdirl || framework_failure_
-(cat exp.t && echo && sed 's/[^\/]testdir/&l/' exp.t) > exp \
+(cat exp.t && printf '\n' && sed 's/[^\/]testdir/&l/' exp.t) > exp \
   || framework_failure_
-ls --hyper testdir testdirl >out || fail=1
+ls --hyper testdir testdirl >out.t || fail=1
+strip_host_and_path <out.t >out || framework_failure_
 compare exp out || fail=1
 
-ln -s '/probably/missing' testlink || framework_failure_
-target=$(realpath -m testlink) || framework_failure_
-ls -l --hyper testlink > out || fail=1
-grep "file://.*$target" out || fail=1
+ln -s '/probably_missing' testlink || framework_failure_
+ls -l --hyper testlink > out.t || fail=1
+strip_host_and_path <out.t >out || framework_failure_
+grep 'file:///probably_missing' out || fail=1
 
 Exit $fail