summaryrefslogtreecommitdiffstats
path: root/tests/reduce_deps.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/reduce_deps.sh')
-rwxr-xr-xtests/reduce_deps.sh148
1 files changed, 111 insertions, 37 deletions
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
# <http://www.gnu.org/licenses/>.
-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 <dev>, bar <!dev>' false 'amd64-linux-glibc' 'dev' 'foo'
- do_test 'foo <dev>, bar <!dev>' true 'amd64-linux-glibc' 'dev' 'foo'
+ command_ok_ \
+ 'NORMAL LIST "foo <dev>, bar <!dev>"' -- \
+ [ x"$(reduce_deps \
+ 'foo <dev>, bar <!dev>' false \
+ 'amd64-linux-glibc' 'dev' \
+ )" = \
+ x'foo' \
+ ]
+ command_ok_ \
+ 'UNION LIST "foo <dev>, bar <!dev>"' -- \
+ [ x"$(reduce_deps \
+ 'foo <dev>, bar <!dev>' true \
+ 'amd64-linux-glibc' 'dev' \
+ )" = \
+ x'foo' \
+ ]
return 0
}