From ca5344ff4205e572f7acad6abf0af7f4b80d9b73 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sun, 21 Apr 2019 18:09:23 -0400 Subject: tests/reduce_deps.sh: Convert to TAP --- (limited to 'tests') diff --git a/tests/local.mk b/tests/local.mk index b63b962..ecb5847 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -39,7 +39,7 @@ CLEANFILES += $(tests_plat_is_concerned_LDADD) tests_reduce_deps_SOURCES = \ tests/reduce_deps.sh \ - tests/common.sh \ + tests/aux/tap-functions.sh \ src/deps.sh \ src/archplat.sh tests_reduce_deps_LDADD = $(tests_reduce_deps_SOURCES:.sh=.sho) diff --git a/tests/reduce_deps.sh b/tests/reduce_deps.sh index 386b609..41a4b58 100755 --- a/tests/reduce_deps.sh +++ b/tests/reduce_deps.sh @@ -1,6 +1,6 @@ # reduce_deps() tests # -# Copyright (C) 2014 Patrick "P. J." McDermott +# Copyright (C) 2014, 2018, 2019 Patrick McDermott # # This file is part of the ProteanOS Development Kit. # @@ -18,51 +18,125 @@ # along with the ProteanOS Development Kit. If not, see # . -do_test() -{ - local deps="${1}" - local union="${2}" - local host_arch="${3}" - local host_plat="${4}" - local result="${5}" - - deps="$(reduce_deps "${deps}" "${union}" "${host_arch}" "${host_plat}")" - - if [ "x${deps}" != "x${result}" ]; then - ${union} && printf 'Union' || printf 'Normal' - printf ' dependency list for ' - printf 'host arch "%s" and host plat "%s":\n' \ - "${host_arch}" "${host_plat}" - printf ' "%s" != "%s"\n' \ - "${deps}" "${result}" - tests_es=1 - fi -} - main() { + plan_ 13 + # Normal and union AND-lists. - do_test 'foo, bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' - do_test 'foo,bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' - do_test 'foo, bar' false 'amd64-linux-glibc' 'dev' 'foo, bar' - do_test 'foo, bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' - do_test 'foo,bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' - do_test 'foo, bar' true 'amd64-linux-glibc' 'dev' 'foo, bar' + command_ok_ \ + 'NORMAL LIST "foo, bar"' -- \ + [ x"$(reduce_deps \ + 'foo, bar' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo, bar' \ + ] + command_ok_ \ + 'NORMAL LIST "foo,bar"' -- \ + [ x"$(reduce_deps \ + 'foo,bar' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo, bar' \ + ] + command_ok_ \ + 'NORMAL LIST "foo, bar"' -- \ + [ x"$(reduce_deps \ + 'foo, bar' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo, bar' \ + ] + command_ok_ \ + 'UNION LIST "foo, bar"' -- \ + [ x"$(reduce_deps \ + 'foo, bar' true \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo, bar' \ + ] + command_ok_ \ + 'UNION LIST "foo,bar"' -- \ + [ x"$(reduce_deps \ + 'foo,bar' true \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo, bar' \ + ] + command_ok_ \ + 'UNION LIST "foo, bar"' -- \ + [ x"$(reduce_deps \ + 'foo, bar' true \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo, bar' \ + ] # Normal and union OR-lists. - do_test 'foo | bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' - do_test 'foo|bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' - do_test 'foo | bar' false 'amd64-linux-glibc' 'dev' 'foo | bar' + command_ok_ \ + 'NORMAL LIST "foo | bar"' -- \ + [ x"$(reduce_deps \ + 'foo | bar' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo | bar' \ + ] + command_ok_ \ + 'NORMAL LIST "foo|bar"' -- \ + [ x"$(reduce_deps \ + 'foo|bar' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo | bar' \ + ] + command_ok_ \ + 'NORMAL LIST "foo | bar"' -- \ + [ x"$(reduce_deps \ + 'foo | bar' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo | bar' \ + ] # Normal and union AND-lists with arch specs. - do_test 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' false \ - 'amd64-linux-glibc' 'dev' 'foo' - do_test 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' true \ - 'amd64-linux-glibc' 'dev' 'foo' + command_ok_ \ + 'NORMAL LIST "foo [amd64-linux-glibc], '$(: \ + )'bar [!amd64-linux-glibc]"' -- \ + [ x"$(reduce_deps \ + 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' \ + false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo' \ + ] + command_ok_ \ + 'UNION LIST "foo [amd64-linux-glibc], '$(: \ + )'bar [!amd64-linux-glibc]"' -- \ + [ x"$(reduce_deps \ + 'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' \ + true \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo' \ + ] # Normal and union AND-lists with plat specs. - do_test 'foo , bar ' false 'amd64-linux-glibc' 'dev' 'foo' - do_test 'foo , bar ' true 'amd64-linux-glibc' 'dev' 'foo' + command_ok_ \ + 'NORMAL LIST "foo , bar "' -- \ + [ x"$(reduce_deps \ + 'foo , bar ' false \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo' \ + ] + command_ok_ \ + 'UNION LIST "foo , bar "' -- \ + [ x"$(reduce_deps \ + 'foo , bar ' true \ + 'amd64-linux-glibc' 'dev' \ + )" = \ + x'foo' \ + ] return 0 } -- cgit v0.9.1