commit: 5bf8c96e260bdd43b036d4e90f235f41f4d55d6d
parent 48543f627400bf374a43532873174e2ff8fcc61b
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 30 Jul 2024 09:39:04 +0200
test-cmd/realpath: Change from cram to tap.sh
Diffstat:
3 files changed, 85 insertions(+), 128 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -26,6 +26,7 @@ tap_test_program{name="id.sh", required_files=basedir.."/cmd/id", timeout=1}
tap_test_program{name="link.sh", required_files=basedir.."/cmd/link", timeout=1}
tap_test_program{name="logname.sh", required_files=basedir.."/cmd/logname", timeout=1}
tap_test_program{name="pwd.sh", required_files=basedir.."/cmd/pwd", timeout=1}
+tap_test_program{name="realpath.sh", required_files=basedir.."/cmd/realpath", timeout=1}
tap_test_program{name="seq.sh", required_files=basedir.."/cmd/seq", timeout=1}
tap_test_program{name="strings.sh", required_files=basedir.."/cmd/strings", timeout=1}
tap_test_program{name="test.sh", required_files=basedir.."/cmd/test", timeout=2}
diff --git a/test-cmd/realpath.sh b/test-cmd/realpath.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/realpath"
+plans=30
+. "$(dirname "$0")/tap.sh"
+
+t . '.' "${PWD}
+"
+
+t / / '/
+'
+t /var /var '/var
+'
+t /var/empty /var/empty '/var/empty
+'
+t /var/empty/foo /var/empty/foo '/var/empty/foo
+'
+t /var/empty/foo/ /var/empty/foo/ '/var/empty/foo
+'
+t /var/empty/foo// /var/empty/foo// '/var/empty/foo
+'
+
+t --exit=1 /var/empty/foo/bar /var/empty/foo/bar 'realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
+'
+t --exit=1 /var/empty/foo/bar/ /var/empty/foo/bar/ 'realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
+'
+t --exit=1 /var/empty/foo/bar// /var/empty/foo/bar// 'realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
+'
+
+t e:/ '-e /' '/
+'
+t e:/var '-e /var' '/var
+'
+t e:/var/empty '-e /var/empty' '/var/empty
+'
+t --exit=1 e:/var/empty/foo '-e /var/empty/foo' 'realpath: Failed canonilizing "/var/empty/foo": No such file or directory
+'
+t --exit=1 e:/var/empty/foo/ '-e /var/empty/foo/' 'realpath: Failed canonilizing "/var/empty/foo/": No such file or directory
+'
+t --exit=1 e:/var/empty/foo// '-e /var/empty/foo//' 'realpath: Failed canonilizing "/var/empty/foo//": No such file or directory
+'
+t --exit=1 e:/var/empty/foo/bar '-e /var/empty/foo/bar' 'realpath: Failed canonilizing "/var/empty/foo/bar": No such file or directory
+'
+t --exit=1 e:/var/empty/foo/bar/ '-e /var/empty/foo/bar/' 'realpath: Failed canonilizing "/var/empty/foo/bar/": No such file or directory
+'
+t --exit=1 e:/var/empty/foo/bar// '-e /var/empty/foo/bar//' 'realpath: Failed canonilizing "/var/empty/foo/bar//": No such file or directory
+'
+
+# Non-directory
+
+t /dev/null /dev/null '/dev/null
+'
+t e:/dev/null '-e /dev/null' '/dev/null
+'
+t E:/dev/null '-E /dev/null' '/dev/null
+'
+
+t --exit=1 /dev/null/ /dev/null/ 'realpath: Failed canonilizing "/dev/null/": Not a directory
+'
+t --exit=1 e:/dev/null/ '-e /dev/null/' 'realpath: Failed canonilizing "/dev/null/": Not a directory
+'
+t --exit=1 E:/dev/null/ '-E /dev/null/' 'realpath: Failed canonilizing "/dev/null/": Not a directory
+'
+
+t --exit=1 /dev/null/.. /dev/null/.. 'realpath: Failed canonilizing "/dev/null/..": Not a directory
+'
+t --exit=1 e:/dev/null/.. '-e /dev/null/..' 'realpath: Failed canonilizing "/dev/null/..": Not a directory
+'
+t --exit=1 E:/dev/null/.. '-E /dev/null/..' 'realpath: Failed canonilizing "/dev/null/..": Not a directory
+'
+
+# Zero-separation
+
+# t z:/dev/null_/var/empty '-z /dev/null /var/empty' $'/dev/null\0/var/empty\0'
+
+# No final newline
+t n:/dev/null_/var/empty '-n /dev/null /var/empty' '/dev/null
+/var/empty'
+
+# As required by POSIX.1-2024 -E and -e aren't errorneous
+t Ee:/dev/null '-E -e /dev/null' '/dev/null
+'
diff --git a/test-cmd/realpath.t b/test-cmd/realpath.t
@@ -1,128 +0,0 @@
-#!/usr/bin/env cram
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
- $ export path="$TESTDIR/../cmd"
-
-
- $ test "$($path/realpath .)" = "$(pwd)"
- $ $path/realpath /
- /
- $ $path/realpath /var
- /var
- $ $path/realpath /var/
- /var
- $ $path/realpath /var/empty
- /var/empty
- $ $path/realpath /var/empty/foo
- /var/empty/foo
- $ $path/realpath /var/empty/foo/
- /var/empty/foo
- $ $path/realpath /var/empty/foo//
- /var/empty/foo
- $ $path/realpath /var/empty/foo/bar
- realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
- [1]
- $ $path/realpath /var/empty/foo/bar/
- realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
- [1]
- $ $path/realpath /var/empty/foo/bar//
- realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
- [1]
-
- $ test "$($path/realpath .)" = "$(pwd)"
- $ $path/realpath /
- /
- $ $path/realpath /var
- /var
- $ $path/realpath /var/
- /var
- $ $path/realpath /var/empty
- /var/empty
- $ $path/realpath /var/empty/foo
- /var/empty/foo
- $ $path/realpath /var/empty/foo/
- /var/empty/foo
- $ $path/realpath /var/empty/foo//
- /var/empty/foo
- $ $path/realpath /var/empty/foo/bar
- realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
- [1]
- $ $path/realpath /var/empty/foo/bar/
- realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
- [1]
- $ $path/realpath /var/empty/foo/bar//
- realpath: Failed canonilizing parent of full path "/var/empty/foo/bar": No such file or directory
- [1]
-
-
- $ test "$($path/realpath -e .)" = "$(pwd)"
- $ $path/realpath -e /
- /
- $ $path/realpath -e /var
- /var
- $ $path/realpath -e /var/
- /var
- $ $path/realpath -e /var/empty
- /var/empty
- $ $path/realpath -e /var/empty/foo
- realpath: Failed canonilizing "/var/empty/foo": No such file or directory
- [1]
- $ $path/realpath -e /var/empty/foo/
- realpath: Failed canonilizing "/var/empty/foo/": No such file or directory
- [1]
- $ $path/realpath -e /var/empty/foo//
- realpath: Failed canonilizing "/var/empty/foo//": No such file or directory
- [1]
- $ $path/realpath -e /var/empty/foo/bar
- realpath: Failed canonilizing "/var/empty/foo/bar": No such file or directory
- [1]
- $ $path/realpath -e /var/empty/foo/bar/
- realpath: Failed canonilizing "/var/empty/foo/bar/": No such file or directory
- [1]
- $ $path/realpath -e /var/empty/foo/bar//
- realpath: Failed canonilizing "/var/empty/foo/bar//": No such file or directory
- [1]
-
-Non-directory
-
- $ $path/realpath /dev/null
- /dev/null
- $ $path/realpath -e /dev/null
- /dev/null
- $ $path/realpath -E /dev/null
- /dev/null
-
- $ $path/realpath /dev/null/
- realpath: Failed canonilizing "/dev/null/": Not a directory
- [1]
- $ $path/realpath -e /dev/null/
- realpath: Failed canonilizing "/dev/null/": Not a directory
- [1]
- $ $path/realpath -E /dev/null/
- realpath: Failed canonilizing "/dev/null/": Not a directory
- [1]
-
- $ $path/realpath /dev/null/..
- realpath: Failed canonilizing "/dev/null/..": Not a directory
- [1]
- $ $path/realpath -e /dev/null/..
- realpath: Failed canonilizing "/dev/null/..": Not a directory
- [1]
- $ $path/realpath -E /dev/null/..
- realpath: Failed canonilizing "/dev/null/..": Not a directory
- [1]
-
-Zero-separation
- $ $path/realpath -z /dev/null /var/empty
- /dev/null\x00/var/empty\x00 (no-eol) (esc)
-
-No final newline
- $ $path/realpath -n /dev/null /var/empty
- /dev/null
- /var/empty (no-eol)
-
-As required by "IEEE P1003.1™-202x/D4" -E and -e aren't errorneous
-
- $ $path/realpath -E -e /dev/null
- /dev/null