commit: 9d57b86ff0ef56e96ec33916ae8cfbcec9871ad5
parent 72625f923bf81fb977264cecb90ac8c0c86d8a94
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Tue, 30 Jul 2024 07:22:30 +0200
test-cmd/tty: Change from ATF to tap.sh
Diffstat:
3 files changed, 16 insertions(+), 44 deletions(-)
diff --git a/test-cmd/Kyuafile b/test-cmd/Kyuafile
@@ -11,7 +11,6 @@ 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}
-atf_test_program{name="tty", required_files=basedir.."/cmd/tty", timeout=1}
tap_test_program{name="arch.sh", required_files=basedir.."/cmd/arch", timeout=1}
tap_test_program{name="base64.sh", required_files=basedir.."/cmd/base64", timeout=1}
tap_test_program{name="basename.sh", required_files=basedir.."/cmd/basename", timeout=1}
@@ -29,5 +28,6 @@ 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}
tap_test_program{name="true.sh", required_files=basedir.."/cmd/true", timeout=1}
+tap_test_program{name="tty.sh", required_files=basedir.."/cmd/tty", timeout=1}
tap_test_program{name="uname.sh", required_files=basedir.."/cmd/uname", timeout=1}
tap_test_program{name="unlink.sh", required_files=basedir.."/cmd/unlink", timeout=1}
diff --git a/test-cmd/tty b/test-cmd/tty
@@ -1,43 +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 basic
-basic_body() {
- tty >/dev/null || atf_expect_fail "test environment not in a tty"
-
- atf_check -o 'not-inline:not a tty\n' ../cmd/tty
-
-}
-
-atf_test_case in_devnull
-in_devnull_body() {
- atf_check -s 'exit:1' -o 'inline:not a tty\n' ../cmd/tty </dev/null
-}
-
-atf_test_case out_devnull
-out_devnull_body() {
- tty >/dev/null || atf_expect_fail "test environment not in a tty"
-
- atf_check -o 'not-inline:not a tty\n' sh -c '../cmd/tty >/dev/null'
-}
-
-atf_test_case out_devfull
-out_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:2" sh -c '../cmd/tty >/dev/full'
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
-
- . ../test_functions.sh
-
- atf_add_test_case basic
- atf_add_test_case in_devnull
- atf_add_test_case out_devnull
- atf_add_test_case out_devfull
-}
diff --git a/test-cmd/tty.sh b/test-cmd/tty.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/tty"
+plans=1
+. "$(dirname "$0")/tap.sh"
+
+if tty >/dev/null 2>/dev/null; then
+ t noargs '' "$(tty)
+"
+else
+ t --exit=1 noargs '' 'not a tty
+'
+fi