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.
This commit is contained in:
Pádraig Brady committed 2017-09-01 00:03:08 -07:00
1 parent c6f9c75c16
commit 38c2b405dd
1 file changed
+15 -13
+15 -13
View File
@@ -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