From aefa87d9e5d3d4daf4544dddb6dfc16796c953d5 Mon Sep 17 00:00:00 2001 From: emma Date: Wed, 24 Apr 2024 15:22:07 -0600 Subject: [PATCH] tests: fixed aliasing and created mm.sh --- tests/bonsai/aliases | 3 +++ tests/bonsai/dj.sh | 2 ++ tests/bonsai/false.sh | 2 ++ tests/bonsai/intcmp.sh | 2 ++ tests/bonsai/mm.sh | 20 ++++++++++++++++++++ tests/bonsai/strcmp.sh | 2 ++ tests/bonsai/true.sh | 2 ++ tests/test.sh | 2 -- 8 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/bonsai/aliases create mode 100755 tests/bonsai/mm.sh diff --git a/tests/bonsai/aliases b/tests/bonsai/aliases new file mode 100644 index 0000000..f7dfb28 --- /dev/null +++ b/tests/bonsai/aliases @@ -0,0 +1,3 @@ +#!/bin/sh + +alias "$UTIL=$BIN/$UTIL" diff --git a/tests/bonsai/dj.sh b/tests/bonsai/dj.sh index be5ca49..eaefaa9 100755 --- a/tests/bonsai/dj.sh +++ b/tests/bonsai/dj.sh @@ -7,6 +7,8 @@ # permitted in any medium without royalty provided the copyright notice and this # notice are preserved. This file is offered as-is, without any warranty. +. tests/bonsai/aliases + ! dj -h # This test is theoretically Linux-dependent; write(2) should return -1 on diff --git a/tests/bonsai/false.sh b/tests/bonsai/false.sh index 670feba..6098b4f 100755 --- a/tests/bonsai/false.sh +++ b/tests/bonsai/false.sh @@ -7,5 +7,7 @@ # permitted in any medium without royalty provided the copyright notice and this # notice are preserved. This file is offered as-is, without any warranty. +. tests/bonsai/aliases + ! false ! false -h diff --git a/tests/bonsai/intcmp.sh b/tests/bonsai/intcmp.sh index 7acb28a..c566877 100755 --- a/tests/bonsai/intcmp.sh +++ b/tests/bonsai/intcmp.sh @@ -7,6 +7,8 @@ # permitted in any medium without royalty provided the copyright notice and this # notice are preserved. This file is offered as-is, without any warranty. +. tests/bonsai/aliases + intcmp -e 3 3 3 intcmp -g 3 2 1 intcmp -l 1 2 3 diff --git a/tests/bonsai/mm.sh b/tests/bonsai/mm.sh new file mode 100755 index 0000000..3ef1f99 --- /dev/null +++ b/tests/bonsai/mm.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# Copyright (c) 2024 DTB +# Copyright (c) 2024 Emma Tebibyte +# SPDX-License-Identifier: FSFAP +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice and this +# notice are preserved. This file is offered as-is, without any warranty. + +. tests/bonsai/aliases + +exec 3>&1 + +! mm -h + +# mm(1) will error if positional arguments are given without -i or -o +! mm argument + +# check if stderr is empty upon specifying -e +! "$BIN/strcmp" "$(printf 'test\n' | mm -i - -e 2>&1 1>&3)" '' diff --git a/tests/bonsai/strcmp.sh b/tests/bonsai/strcmp.sh index 82f2781..9c7ceb0 100755 --- a/tests/bonsai/strcmp.sh +++ b/tests/bonsai/strcmp.sh @@ -7,6 +7,8 @@ # permitted in any medium without royalty provided the copyright notice and this # notice are preserved. This file is offered as-is, without any warranty. +. tests/bonsai/aliases + strcmp equals equals ! strcmp inequals equals strcmp - - diff --git a/tests/bonsai/true.sh b/tests/bonsai/true.sh index e8ed913..39d3d53 100755 --- a/tests/bonsai/true.sh +++ b/tests/bonsai/true.sh @@ -7,5 +7,7 @@ # permitted in any medium without royalty provided the copyright notice and this # notice are preserved. This file is offered as-is, without any warranty. +. tests/bonsai/aliases + true true -h diff --git a/tests/test.sh b/tests/test.sh index faaae5e..b439464 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -23,8 +23,6 @@ for script in tests/bonsai/*.sh; do export UTIL="$(printf '%s\n' "$script" \ | sed -e 's/\.sh//g' -e 's;tests\/bonsai\/;;g')" - alias "$UTIL"="$BIN/$UTIL" - printf '%s: %s: Testing utility.\n' "$0" "$UTIL" "$script" printf '\n'