>From 8f9ea959cc1c04f970d003bb22ccb70aaa69b8af Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C3=A1draig=20Brady?=
Date: Thu, 31 Aug 2017 23:52:59 -0700
Subject: [PATCH] tests: fix false failures in recent ls --hyperlink test
* 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 | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/tests/ls/hyperlink.sh b/tests/ls/hyperlink.sh
index bc13311..8165371 100755
--- a/tests/ls/hyperlink.sh
+++ b/tests/ls/hyperlink.sh
@@ -17,9 +17,7 @@
# along with this program. If not, see .
. "${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 || 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 || framework_failure_
+grep "file:///probably_missing" out || fail=1
Exit $fail
--
2.9.3