commit: e03867c4144bffa78f26924e35f93a127521c411
parent d89f3ff6ceb7eb3d7665c0237c0acc3a01a23b0c
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Thu, 13 Jun 2024 14:32:45 +0200
test-cmd/env*: Change from ATF to tap.sh
Diffstat:
3 files changed, 29 insertions(+), 77 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="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}
atf_test_program{name="link", required_files=basedir.."/cmd/link", timeout=1}
@@ -28,6 +27,7 @@ tap_test_program{name="chmod.sh", required_files=basedir.."/cmd/chmod", timeout=
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="env.sh", required_files=basedir.."/cmd/env", 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/env b/test-cmd/env
@@ -1,76 +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() {
- gentoo_sandbox && atf_skip "sandbox (gentoo) interferes with the environment"
-
- atf_check -o "inline:FOO=BAR\n" env -i FOO=BAR ../cmd/env
-}
-
-atf_test_case badarg
-badarg_body() {
- atf_check -s not-exit:0 -e "inline:env: Error: Unrecognised option: '-f'\nenv [-i] [-u key | --unset=key] [key=value ...] [command [args]]\n" ../cmd/env -f
-}
-
-atf_test_case iflag
-iflag_body() {
- gentoo_sandbox && atf_skip "sandbox (gentoo) interferes with the environment"
-
- atf_check -o "inline:FOO=BAR\n" ../cmd/env -i FOO=BAR ../cmd/env
- atf_check -o "inline:FOO=BAR\n" ../cmd/env -i FOO=BAR
- atf_check -o "not-inline:FOO=BAR\n" ../cmd/env FOO=BAR ../cmd/env
- atf_check -o "not-inline:FOO=BAR\n" ../cmd/env FOO=BAR
-}
-
-atf_test_case uflag
-uflag_body() {
- gentoo_sandbox && atf_skip "sandbox (gentoo) interferes with the environment"
-
- atf_check -o "inline:FOO=BAR\n" ../cmd/env -i FOO=BAR BAR=FOO ../cmd/env -u BAR
-
- atf_check -s not-exit:0 -e "inline:env: Error: Missing operand for option: '-u'\nenv [-i] [-u key | --unset=key] [key=value ...] [command [args]]\n" ../cmd/env -u
-}
-
-atf_test_case unsetflag
-unsetflag_body() {
- gentoo_sandbox && atf_skip "sandbox (gentoo) interferes with the environment"
-
- atf_check -o "inline:FOO=BAR\n" ../cmd/env -i FOO=BAR BAR=FOO ../cmd/env --unset=BAR
-
- atf_check -s not-exit:0 -e "inline:env: Error: Missing operand for option: '-u'\nenv [-i] [-u key | --unset=key] [key=value ...] [command [args]]\n" ../cmd/env -u
-}
-
-atf_test_case devfull
-devfull_body() {
- [ "$(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 -e 'inline:env: puts(environ[i]): No space left on device\n' sh -c '../cmd/env >/dev/full'
-}
-
-atf_test_case noutil
-noutil_body() {
- atf_check -s exit:127 -e 'inline:env: execvp("/var/empty/e/no/ent", ...): No such file or directory\n' ../cmd/env /var/empty/e/no/ent
-}
-
-atf_test_case false
-false_body() {
- atf_check -s exit:1 ../cmd/env false
-}
-
-atf_init_test_cases() {
- cd "$(atf_get_srcdir)" || exit 1
-
- . ../test_functions.sh
-
- atf_add_test_case noargs
- atf_add_test_case badarg
- atf_add_test_case iflag
- atf_add_test_case uflag
- atf_add_test_case unsetflag
- atf_add_test_case devfull
- atf_add_test_case noutil
- atf_add_test_case false
-}
diff --git a/test-cmd/env.sh b/test-cmd/env.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+. "$(dirname "$0")/../test_functions.sh"
+
+if gentoo_sandbox
+then
+ echo '1..1'
+ echo '# Gentoo sandbox(1) detected, all checks of env(1) skipped due to environ interference'
+ exit 0
+fi
+
+target="$(dirname "$0")/../cmd/env"
+plans=6
+. "$(dirname "$0")/tap.sh"
+
+t reset '-i FOO=BAR' $'FOO=BAR\n'
+t reset_chain "-i FOO=BAR $target" $'FOO=BAR\n'
+t uflag "-i FOOZ=BARZ $target -u FOOZ FOO=BAR" $'FOO=BAR\n'
+t unsetflag "-i FOOZ=BARZ $target --unset=FOOZ FOO=BAR" $'FOO=BAR\n'
+t exec_true 'true' ''
+t exec_echo 'echo' $'\n'
+
+# atf_check -s not-exit:0 -e "inline:env: Error: Unrecognised option: '-f'\nenv [-i] [-u key | --unset=key] [key=value ...] [command [args]]\n" ../cmd/env -f
+# atf_check -s exit:127 -e 'inline:env: execvp("/var/empty/e/no/ent", ...): No such file or directory\n' ../cmd/env /var/empty/e/no/ent
+
+# atf_check -s exit:1 ../cmd/env false