commit: ee20ad4bb26661b721d2c758aba535a2c6300ce0
parent 5b3a5784d836e01230e35a52bb103f0a7dbaf800
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 8 Jul 2024 04:37:52 +0200
test-cmd/pwd: Change from ATF to tap.sh
Diffstat:
3 files changed, 23 insertions(+), 50 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="df", required_files=basedir.."/cmd/df", timeout=1}
atf_test_program{name="id", required_files=basedir.."/cmd/id", timeout=1}
atf_test_program{name="link", required_files=basedir.."/cmd/link", timeout=1}
-atf_test_program{name="pwd", required_files=basedir.."/cmd/pwd", timeout=1}
atf_test_program{name="strings", required_files=basedir.."/cmd/strings", 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}
@@ -26,6 +25,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="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}
tap_test_program{name="test.sh", required_files=basedir.."/cmd/test", timeout=2}
tap_test_program{name="true.sh", required_files=basedir.."/cmd/true", timeout=1}
diff --git a/test-cmd/pwd b/test-cmd/pwd
@@ -1,49 +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 simple
-simple_body() {
- atf_check -o "inline:${PWD}\n" ../cmd/pwd
- atf_check -o "inline:$(atf_get_srcdir)\n" ../cmd/pwd
-}
-
-atf_test_case args
-args_body() {
- atf_check -s exit:1 -e "inline:usage: pwd\n" ../cmd/pwd -H
-}
-
-atf_test_case enoent cleanup
-enoent_body() {
- mkdir -p "$(atf_get_srcdir)/remove-me" || exit 1
- cd "$(atf_get_srcdir)/remove-me" || exit 1
-
- atf_check -o "inline:$(atf_get_srcdir)/remove-me\n" "$(atf_get_srcdir)/../cmd/pwd"
-
- rm -fr "$(atf_get_srcdir)/remove-me" || exit 1
-
- atf_check -s exit:1 -e 'inline:pwd: getcwd: No such file or directory\n' "$(atf_get_srcdir)/../cmd/pwd"
-}
-enoent_cleanup() {
- rm -fr "$(atf_get_srcdir)/remove-me"
-}
-
-atf_test_case devfull
-devfull_body() {
- has_glibc && atf_skip "glibc ignoring write errors for puts()"
- [ "$(uname -s)" = "NetBSD" ] && atf_skip "NetBSD ignoring write errors for puts()"
- [ "$(uname -s)" = "FreeBSD" ] && atf_skip "FreeBSD ignoring write errors for puts()"
-
- atf_check -s exit:1 sh -c '../cmd/pwd >/dev/full'
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
-
- . ../test_functions.sh
-
- atf_add_test_case simple
- atf_add_test_case args
- atf_add_test_case enoent
- atf_add_test_case devfull
-}
diff --git a/test-cmd/pwd.sh b/test-cmd/pwd.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+WD="$(dirname "$0")"
+target="$(realpath "$WD/../cmd/pwd")"
+plans=3
+. "$(dirname "$0")/tap.sh"
+
+t noargs '' "${PWD?}
+"
+
+t --exit=1 usage '-H' 'usage: pwd
+'
+
+tmpdir="$(mktemp -d)" || exit 1
+test -d "$tmpdir" || exit 1
+cd "$tmpdir" || exit 1
+rm -fr "$tmpdir" || exit 1
+t --exit=1 enoent '' 'pwd: getcwd: No such file or directory
+'
+cd ~-