commit: 1f86f772e1d80d29310e6653cd496a732b8bc8b6
parent 8bd3564a02f6a33bc9bd650c7b6490c9e9ec39e7
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2024 12:55:42 +0200
test-cmd/dirname*: Change from ATF to tap.sh
Diffstat:
3 files changed, 23 insertions(+), 39 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -10,7 +10,6 @@ basedir = fs.dirname(fs.dirname(current_kyuafile()))
atf_test_program{name="base64", required_files=basedir.."/cmd/base64", timeout=1}
atf_test_program{name="cat", required_files=basedir.."/cmd/cat", timeout=1}
atf_test_program{name="df", required_files=basedir.."/cmd/df", timeout=1}
-atf_test_program{name="dirname", required_files=basedir.."/cmd/dirname", timeout=1}
atf_test_program{name="echo", required_files=basedir.."/cmd/echo", timeout=1}
atf_test_program{name="env", required_files=basedir.."/cmd/env", timeout=1}
atf_test_program{name="false", required_files=basedir.."/cmd/false", timeout=1}
@@ -28,6 +27,7 @@ tap_test_program{name="arch.sh", required_files=basedir.."/cmd/arch", timeout=1}
tap_test_program{name="basename.sh", required_files=basedir.."/cmd/basename", timeout=1}
tap_test_program{name="chmod.sh", required_files=basedir.."/cmd/chmod", timeout=1}
tap_test_program{name="date.sh", required_files=basedir.."/cmd/date", timeout=1}
+tap_test_program{name="dirname.sh", required_files=basedir.."/cmd/dirname", timeout=1}
tap_test_program{name="seq.sh", required_files=basedir.."/cmd/seq", timeout=1}
tap_test_program{name="test.sh", required_files=basedir.."/cmd/test", timeout=2}
tap_test_program{name="uname.sh", required_files=basedir.."/cmd/uname", timeout=1}
diff --git a/test-cmd/dirname b/test-cmd/dirname
@@ -1,38 +0,0 @@
-#!/usr/bin/env atf-sh
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
-
-atf_test_case noargs
-noargs_body() {
- atf_check -e "inline:usage: dirname string\n" -s exit:1 ../cmd/dirname
-}
-
-atf_test_case one_slash
-one_slash_body() {
- atf_check -o "inline:/usr\n" ../cmd/dirname "/usr/bin"
-}
-
-atf_test_case two_slash
-two_slash_body() {
- atf_check -o "inline:/usr\n" ../cmd/dirname "/usr//bin"
-}
-
-atf_test_case two_dash
-two_dash_body() {
- atf_check -o "inline:/usr\n" ../cmd/dirname -- "/usr//bin"
-}
-
-atf_test_case badarg
-badarg_body() {
- atf_check -s exit:1 -e "inline:usage: dirname string\n" ../cmd/dirname -a "/usr//bin"
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- atf_add_test_case noargs
- atf_add_test_case badarg
- atf_add_test_case one_slash
- atf_add_test_case two_slash
- atf_add_test_case two_dash
-}
diff --git a/test-cmd/dirname.sh b/test-cmd/dirname.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/dirname"
+plans=10
+. "$(dirname "$0")/tap.sh"
+
+# atf_check -e "inline:usage: dirname string\n" -s exit:1 ../cmd/dirname
+
+t '/usr/bin' '/usr/bin' $'/usr\n'
+t '/usr//bin' '/usr//bin' $'/usr\n'
+t '-- /usr//bin' '/usr//bin' $'/usr\n'
+t '.' '.' $'.\n'
+t '-' '-' $'.\n'
+t '/' '/' $'/\n'
+t '///' '///' $'/\n'
+t '---' '---' $'.\n'
+t '--foo' '--foo' $'.\n'
+t './foobar' './foobar' $'.\n'
+
+# atf_check -s exit:1 -e "inline:usage: dirname string\n" ../cmd/dirname -a "/usr//bin"