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.
This commit is contained in:
William Hubbs
2022-04-16 15:13:08 -05:00
committed by GitHub
parent 0b3f8750e7
commit fdfa6dbb0e
15 changed files with 143 additions and 114 deletions

View File

@@ -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" "$@"
"$@"
}

View File

@@ -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

5
test/units/meson.build Normal file
View File

@@ -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)