commit: 2892d28528a0820a3842b9b0289c48b2a2905e35
parent 9d57b86ff0ef56e96ec33916ae8cfbcec9871ad5
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 30 Jul 2024 07:50:41 +0200
test-cmd/link: Change from ATF to tap.sh
Diffstat:
3 files changed, 24 insertions(+), 36 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -8,7 +8,6 @@ basedir = fs.dirname(fs.dirname(current_kyuafile()))
-- 9,$|LC_ALL=C.UTF-8 sort
atf_test_program{name="df", required_files=basedir.."/cmd/df", timeout=1}
-atf_test_program{name="link", required_files=basedir.."/cmd/link", timeout=1}
atf_test_program{name="tee", required_files=basedir.."/cmd/tee", timeout=1}
atf_test_program{name="touch", required_files=basedir.."/cmd/touch", timeout=3}
tap_test_program{name="arch.sh", required_files=basedir.."/cmd/arch", timeout=1}
@@ -22,6 +21,7 @@ tap_test_program{name="echo.sh", required_files=basedir.."/cmd/echo", timeout=1}
tap_test_program{name="env.sh", required_files=basedir.."/cmd/env", timeout=1}
tap_test_program{name="false.sh", required_files=basedir.."/cmd/false", timeout=1}
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="seq.sh", required_files=basedir.."/cmd/seq", timeout=1}
diff --git a/test-cmd/link b/test-cmd/link
@@ -1,35 +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 empty
-empty_body() {
- atf_check -s exit:1 -e "inline:usage: link <reference> <destination>\n" ../cmd/link
-}
-
-atf_test_case basic cleanup
-basic_body() {
- touch foo
-
- atf_check ../cmd/link foo bar
- atf_check cmp foo bar
-
- echo hello >> foo
- atf_check cmp foo bar
-}
-basic_cleanup() {
- atf_check rm -f foo bar
-}
-
-atf_test_case enoent
-enoent_body() {
- atf_check -s exit:1 -e 'inline:link: No such file or directory\n' ../cmd/link /var/empty/e/no/ent enoent_foo
- atf_check -s exit:1 -e 'inline:link: No such file or directory\n' ../cmd/link enoent_bar /var/empty/e/no/ent
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- atf_add_test_case empty
- atf_add_test_case basic
- atf_add_test_case enoent
-}
diff --git a/test-cmd/link.sh b/test-cmd/link.sh
@@ -0,0 +1,23 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/link"
+plans=4
+. "$(dirname "$0")/tap.sh"
+
+t --exit=1 noargs '' 'usage: link <reference> <destination>
+'
+
+basic_foo=$(mktemp)
+t basic "${basic_foo} ${basic_foo}.bar" ''
+printf '%s\n' $RANDOM > "${basic_foo}" || exit 1
+cmp "${basic_foo}" "${basic_foo}.bar" || exit 1
+printf '%s\n' $RANDOM > "${basic_foo}.bar" || exit 1
+cmp "${basic_foo}" "${basic_foo}.bar" || exit 1
+rm "${basic_foo}" "${basic_foo}.bar" || exit 1
+
+t --exit=1 enoent1 '/var/empty/e/no/ent enoent_foo' 'link: No such file or directory
+'
+t --exit=1 enoent2 'enoent_foo /var/empty/e/no/ent' 'link: No such file or directory
+'