aboutsummaryrefslogtreecommitdiff
path: root/test/units
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2022-04-16 15:13:08 -0500
committerGitHub <noreply@github.com>2022-04-16 15:13:08 -0500
commitfdfa6dbb0e69742029d53f0e163b8e7e7e6860f5 (patch)
tree6a300ef3e1b25e22224b042cc8a8c07b43709950 /test/units
parent0b3f8750e7d307987eef9e63e327488a81c29a71 (diff)
rewrite tests (#515)
* rewrite tests to work with meson This ports our tests to meson and makes them able to be run in parallel. * add tests to ci * rewrite test/check-trailing-newlines in bash This test was using a GNU sed command which does not work on Alpine Linux.
Diffstat (limited to 'test/units')
-rwxr-xr-xtest/units/check-is-older-than.sh (renamed from test/units/is_older_than)13
-rwxr-xr-xtest/units/check-sh-yesno.sh (renamed from test/units/sh_yesno)2
-rw-r--r--test/units/meson.build5
3 files changed, 16 insertions, 4 deletions
diff --git a/test/units/is_older_than b/test/units/check-is-older-than.sh
index 47a62d78..8987fcd2 100755
--- a/test/units/is_older_than
+++ b/test/units/check-is-older-than.sh
@@ -2,7 +2,13 @@
# unit test for is_older_than code of baselayout (2008/06/19)
# Author: Matthias Schwarzott <zzam@gentoo.org>
-TMPDIR=tmp-"$(basename "$0")"
+if [ -z "${BUILD_ROOT}" ]; then
+ printf "%s\n" "BUILD_ROOT must be defined" >&2
+ exit 1
+fi
+PATH="${BUILD_ROOT}"/src/is_older_than:${PATH}
+
+TMPDIR="${BUILD_ROOT}"/tmp-"$(basename "$0")"
# Please note that we added this unit test because the function
# should really be called is_newer_than as it's what it's really testing.
@@ -37,13 +43,14 @@ do_test()
is_older_than "$@"
r2=$?
- [ -n "${VERBOSE}" ] && echo "reference = $r1 | OpenRC = $r2"
+ [ -n "${VERBOSE}" ] &&
+ printf "reference = %s | OpenRC = %s\n" "$r1" "$r2"
[ $r1 = $r2 ]
}
echo_cmd()
{
- [ -n "${VERBOSE}" ] && echo "$@"
+ [ -n "${VERBOSE}" ] && printf "%s\n" "$@"
"$@"
}
diff --git a/test/units/sh_yesno b/test/units/check-sh-yesno.sh
index 380864ee..ecc2f6dd 100755
--- a/test/units/sh_yesno
+++ b/test/units/check-sh-yesno.sh
@@ -9,7 +9,7 @@
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
-: ${top_srcdir:=..}
+top_srcdir=${SOURCE_ROOT:-..}
. $top_srcdir/test/setup_env.sh
ret=0
diff --git a/test/units/meson.build b/test/units/meson.build
new file mode 100644
index 00000000..23c2758a
--- /dev/null
+++ b/test/units/meson.build
@@ -0,0 +1,5 @@
+is_older_than = find_program('check-is-older-than.sh')
+sh_yesno = find_program('check-sh-yesno.sh')
+
+test('is_older_than', is_older_than, env : test_env)
+test('sh_yesno', sh_yesno, env : test_env)