From: Pádraig Brady
Date: Fri, 1 Sep 2017 06:52:59 +0000 (-0700)
Subject: tests: fix false failure in recent ls --hyperlink test
X-Git-Tag: v8.28~1
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38c2b405ddd8120da43e4d08d3bd882e8fb822af;p=thirdparty%2Fcoreutils.git
tests: fix false failure 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.
---
diff --git a/tests/ls/hyperlink.sh b/tests/ls/hyperlink.sh
index bc1331147d..eaedd0876b 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