commit: d89f3ff6ceb7eb3d7665c0237c0acc3a01a23b0c
parent 1f86f772e1d80d29310e6653cd496a732b8bc8b6
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2024 14:14:46 +0200
test-cmd/echo*: Change from ATF to tap.sh
Diffstat:
3 files changed, 17 insertions(+), 41 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="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}
atf_test_program{name="id", required_files=basedir.."/cmd/id", timeout=1}
@@ -28,6 +27,7 @@ tap_test_program{name="basename.sh", required_files=basedir.."/cmd/basename", ti
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="echo.sh", required_files=basedir.."/cmd/echo", 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/echo b/test-cmd/echo
@@ -1,40 +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 -o "inline:\n" ../cmd/echo
-}
-
-atf_test_case hello
-hello_body() {
- atf_check -o "inline:hello world\n" ../cmd/echo hello world
-}
-
-atf_test_case doubledash
-doubledash_body() {
- atf_check -o "inline:-- hello\n" ../cmd/echo -- hello
-}
-
-atf_test_case devfull
-devfull_body() {
- atf_check -s exit:1 -e 'inline:echo: Write error, write(1, buffer, 12) = -1: No space left on device\n' sh -c '../cmd/echo hello world >/dev/full'
-}
-
-atf_test_case opt_n
-opt_n_body() {
- atf_check -o "inline:" ../cmd/echo -n
- atf_check -o "inline:foo" ../cmd/echo -n foo
- atf_check -o "inline:foo bar" ../cmd/echo -n foo bar
- atf_check -o "inline:-- foo" ../cmd/echo -n -- foo
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
- atf_add_test_case empty
- atf_add_test_case hello
- atf_add_test_case doubledash
- atf_add_test_case devfull
- atf_add_test_case opt_n
-}
diff --git a/test-cmd/echo.sh b/test-cmd/echo.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+target="$(dirname "$0")/../cmd/echo"
+plans=7
+. "$(dirname "$0")/tap.sh"
+
+t 'empty' '' $'\n'
+t 'hello' 'hello' $'hello\n'
+t '-- hello' '-- hello' $'-- hello\n'
+
+t '-n' '-n' ''
+t '-n foo' '-n foo' 'foo'
+t '-n foo bar' '-n foo bar' 'foo bar'
+t '-n -- foo' '-n -- foo' '-- foo'