From e12e99c4fea06eaa13e4d08f4d9001b7f815fe2b Mon Sep 17 00:00:00 2001
From: Patrick McDermott <patrick.mcdermott@libiquity.com>
Date: Sun, 17 Mar 2019 01:23:28 -0400
Subject: tests/*.sh: Move to tests/lib/

---
(limited to 'tests/lib')

diff --git a/tests/lib/ob_arch_is_concerned.sh b/tests/lib/ob_arch_is_concerned.sh
new file mode 100755
index 0000000..4f2ebdf
--- /dev/null
+++ b/tests/lib/ob_arch_is_concerned.sh
@@ -0,0 +1,147 @@
+# Tests for ob_arch_is_concerned()
+#
+# Copyright (C) 2012, 2014, 2018, 2019 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
+
+plan_ 18
+
+# Architecture: all
+
+command_ok_ \
+	'HOST "amd64-linux-glibc" DOES NOT MATCH ARCH "all"' -- \
+	not ob_arch_is_concerned \
+	'amd64-linux-glibc' \
+	'all'
+
+command_ok_ \
+	'HOST "i686-linux-glibc" DOES NOT MATCH ARCH "all"' -- \
+	not ob_arch_is_concerned \
+	'i686-linux-glibc' \
+	'all'
+
+command_ok_ \
+	'HOST "all" DOES MATCH ARCH "all"' -- \
+	ob_arch_is_concerned \
+	'all' \
+	'all'
+
+# Architecture: any
+
+command_ok_ \
+	'HOST "amd64-linux-glibc" DOES MATCH ARCH "any"' -- \
+	ob_arch_is_concerned \
+	'amd64-linux-glibc' \
+	'any'
+
+command_ok_ \
+	'HOST "i686-linux-glibc" DOES MATCH ARCH "any"' -- \
+	ob_arch_is_concerned \
+	'i686-linux-glibc' \
+	'any'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH ARCH "any"' -- \
+	not ob_arch_is_concerned \
+	'all' \
+	'any'
+
+# Architecture: amd64-linux-glibc
+
+command_ok_ \
+	'HOST "amd64-linux-glibc" DOES MATCH ARCH "amd64-linux-glibc"' -- \
+	ob_arch_is_concerned \
+	'amd64-linux-glibc' \
+	'amd64-linux-glibc'
+
+command_ok_ \
+	'HOST "i686-linux-glibc" DOES NOT MATCH ARCH "amd64-linux-glibc"' -- \
+	not ob_arch_is_concerned \
+	'i686-linux-glibc' \
+	'amd64-linux-glibc'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH ARCH "amd64-linux-glibc"' -- \
+	not ob_arch_is_concerned \
+	'all' \
+	'amd64-linux-glibc'
+
+# Architecture: !amd64-linux-glibc
+
+command_ok_ \
+	'HOST "amd64-linux-glibc" DOES NOT MATCH ARCH "!amd64-linux-glibc"' -- \
+	not ob_arch_is_concerned \
+	'amd64-linux-glibc' \
+	'!amd64-linux-glibc'
+
+command_ok_ \
+	'HOST "i686-linux-glibc" DOES MATCH ARCH "!amd64-linux-glibc"' -- \
+	ob_arch_is_concerned \
+	'i686-linux-glibc' \
+	'!amd64-linux-glibc'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH ARCH "!amd64-linux-glibc"' -- \
+	not ob_arch_is_concerned \
+	'all' \
+	'!amd64-linux-glibc'
+
+# Architecture: amd64-any-any
+
+command_ok_ \
+	'HOST "amd64-linux-glibc" DOES NOT MATCH ARCH "amd64-any-any"' -- \
+	ob_arch_is_concerned \
+	'amd64-linux-glibc' \
+	'amd64-any-any'
+
+command_ok_ \
+	'HOST "i686-linux-glibc" DOES MATCH ARCH "amd64-any-any"' -- \
+	not ob_arch_is_concerned \
+	'i686-linux-glibc' \
+	'amd64-any-any'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH ARCH "amd64-any-any"' -- \
+	not ob_arch_is_concerned \
+	'all' \
+	'amd64-any-any'
+
+# Architecture: cortexa8-any-any i686-any-any
+
+command_ok_ \
+	'HOST "amd64-linux-glibc" DOES NOT MATCH ARCH '$(: \
+		)'"cortexa8-any-any i686-any-any"' -- \
+	not ob_arch_is_concerned \
+	'amd64-linux-glibc' \
+	'cortexa8-any-any i686-any-any'
+
+command_ok_ \
+	'HOST "i686-linux-glibc" DOES MATCH ARCH '$(: \
+		)'"cortexa8-any-any i686-any-any"' -- \
+	ob_arch_is_concerned \
+	'i686-linux-glibc' \
+	'cortexa8-any-any i686-any-any'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH ARCH "cortexa8-any-any i686-any-any"' -- \
+	not ob_arch_is_concerned \
+	'all' \
+	'cortexa8-any-any i686-any-any'
diff --git a/tests/lib/ob_parse_changelog.sh b/tests/lib/ob_parse_changelog.sh
new file mode 100755
index 0000000..15be4e1
--- /dev/null
+++ b/tests/lib/ob_parse_changelog.sh
@@ -0,0 +1,165 @@
+# Tests for ob_parse_changelog()
+#
+# Copyright (C) 2018, 2019 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
+
+CHANGELOG='\
+bar (4) dev
+
+  * Non-maintainer upload.  Rename package and upload elsewhere.
+
+ -- "K. Random Hacker" <krandom@example.com>  Sun, 04 Jan 1970 00:00:00  +0000
+
+foo (3) trunk
+
+
+  * Frobnicate foos.
+  * Break all the things.
+
+
+ -- "J. Random Hacker" <jrandom@example.com>  Sat, 03 Jan 1970 00:00:00  +0000
+
+
+foo (2) trunk
+  * Reticulated splines.
+ -- "J. Random Hacker" <jrandom@example.com>  Fri, 02 Jan 1970 00:00:00  +0000
+foo (1) trunk
+  * Initial release.
+ -- "J. Random Hacker" <jrandom@example.com>  Thu, 01 Jan 1970 00:00:00  +0000
+'
+
+plan_ 19
+
+entry=0
+
+is()
+{
+	local description="${1}"
+	local got="${2}"
+	local expected="${3}"
+	shift 3
+
+	if [ "x${got}" = "x${expected}" ]; then
+		ok_ -- "${description}"
+	else
+		not_ok_ -- "${description}"
+		diag_ " Failed test '${description}'"
+		diag_ "         got: '${got}'"
+		diag_ "    expected: '${expected}'"
+	fi
+}
+
+entry_1()
+{
+	local source="${1}"
+	local version="${2}"
+	local distribution="${3}"
+	local changes="${4}"
+	local maintainer="${5}"
+	local date="${6}"
+	shift 6
+
+	is 'source' "${source}" 'bar'
+	is 'version' "${version}" '4'
+	is 'distribution' "${distribution}" 'dev'
+	is 'changes' "${changes}" "$(cat <<-EOF
+		bar (4) dev
+
+		  * Non-maintainer upload.  Rename package and upload elsewhere.
+		EOF
+		)"
+	is 'maintainer' "${maintainer}" \
+		'"K. Random Hacker" <krandom@example.com>'
+	is 'date' "${date}" 'Sun, 04 Jan 1970 00:00:00  +0000'
+
+	return 0
+}
+
+entry_2()
+{
+	local source="${1}"
+	local version="${2}"
+	local distribution="${3}"
+	local changes="${4}"
+	local maintainer="${5}"
+	local date="${6}"
+	shift 6
+
+	is 'source' "${source}" 'foo'
+	is 'version' "${version}" '3'
+	is 'distribution' "${distribution}" 'trunk'
+	is 'changes' "${changes}" "$(cat <<-EOF
+		foo (3) trunk
+		
+		
+		  * Frobnicate foos.
+		  * Break all the things.
+		EOF
+		)"
+	is 'maintainer' "${maintainer}" \
+		'"J. Random Hacker" <jrandom@example.com>'
+	is 'date' "${date}" 'Sat, 03 Jan 1970 00:00:00  +0000'
+
+	return 0
+}
+
+entry_3()
+{
+	local source="${1}"
+	local version="${2}"
+	local distribution="${3}"
+	local changes="${4}"
+	local maintainer="${5}"
+	local date="${6}"
+	shift 6
+
+	is 'source' "${source}" 'foo'
+	is 'version' "${version}" '2'
+	is 'distribution' "${distribution}" 'trunk'
+	is 'changes' "${changes}" "$(cat <<-EOF
+		foo (2) trunk
+		  * Reticulated splines.
+		EOF
+		)"
+	is 'maintainer' "${maintainer}" \
+		'"J. Random Hacker" <jrandom@example.com>'
+	is 'date' "${date}" 'Fri, 02 Jan 1970 00:00:00  +0000'
+
+	return 1
+}
+
+entry_4()
+{
+	: This should not be reached.
+}
+
+entry_cb()
+{
+	entry=$((${entry} + 1))
+	"entry_${entry}" "${@}"
+}
+
+ob_parse_changelog - entry_cb <<-EOF
+	${CHANGELOG}
+	EOF
+
+is 'number of parsed entries' "${entry}" 3
diff --git a/tests/lib/ob_parse_control.sh b/tests/lib/ob_parse_control.sh
new file mode 100755
index 0000000..921d99e
--- /dev/null
+++ b/tests/lib/ob_parse_control.sh
@@ -0,0 +1,113 @@
+# Tests for ob_parse_control()
+#
+# Copyright (C) 2018, 2019 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
+
+LF='
+'
+CONTROL="$(cat <<-'EOF'
+	Maintainer: "J. Random Hacker" <jrandom@example.com>
+	Build-Depends: opkhelper-3.0,
+	 libfoo-dev,
+	  libbar-dev,
+	Homepage: http://www.example.com/
+	EOF
+	)"
+
+plan_ 7
+
+field=0
+
+is()
+{
+	local description="${1}"
+	local got="${2}"
+	local expected="${3}"
+	shift 3
+
+	if [ "x${got}" = "x${expected}" ]; then
+		ok_ -- "${description}"
+	else
+		not_ok_ -- "${description}"
+		diag_ " Failed test '${description}'"
+		diag_ "         got: '${got}'"
+		diag_ "    expected: '${expected}'"
+	fi
+}
+
+field_1()
+{
+	local name="${1}"
+	local value="${2}"
+	local user_data="${3}"
+	shift 3
+
+	is 'maintainer field name' "${name}" 'Maintainer'
+	is 'maintainer field value' "${value}" \
+		'"J. Random Hacker" <jrandom@example.com>'
+
+	return 0
+}
+
+field_2()
+{
+	local name="${1}"
+	local value="${2}"
+	local user_data="${3}"
+	shift 3
+
+	is 'build-depends field name' "${name}" 'Build-Depends'
+	is 'build-depends field value' "${value}" \
+		"opkhelper-3.0,${LF}libfoo-dev,${LF} libbar-dev,"
+
+	return 0
+}
+
+field_3()
+{
+	local name="${1}"
+	local value="${2}"
+	local user_data="${3}"
+	shift 3
+
+	is 'homepage field name' "${name}" 'Homepage'
+	is 'homepage field value' "${value}" 'http://www.example.com/'
+
+	return 0
+}
+
+field_4()
+{
+	: This should not be reached.
+}
+
+field_cb()
+{
+	field=$((${field} + 1))
+	"field_${field}" "${@}"
+}
+
+ob_parse_control - field_cb '' 'Maintainer' 'Build-Depends Homepage' <<-EOF
+	${CONTROL}
+	EOF
+
+is 'number of parsed fields' "${field}" 3
diff --git a/tests/lib/ob_parse_dep.sh b/tests/lib/ob_parse_dep.sh
new file mode 100755
index 0000000..37dabd3
--- /dev/null
+++ b/tests/lib/ob_parse_dep.sh
@@ -0,0 +1,151 @@
+# Tests for ob_parse_dep()
+#
+# Copyright (C) 2012, 2018 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
+
+testcase()
+{
+	local dep="${1}"
+	local pkg="${2}"
+	local archqual="${3}"
+	local rel="${4}"
+	local ver="${5}"
+	local arches="${6}"
+	shift 6
+	local result=
+
+	ob_parse_dep -P test_pkg -q test_archqual -r test_rel -v test_ver \
+		-A test_arches "${dep}" >/dev/null
+
+	result='ok_'
+	for comp in pkg archqual rel ver arches; do
+		test_comp="$(eval "printf '%s' \"\${test_${comp}}\"")"
+		good_comp="$(eval "printf '%s' \"\${${comp}}\"")"
+		if [ x"${test_comp}" != x"${good_comp}" ]; then
+			diag_ "$(printf 'Dependency "%s", component "%s":' \
+				"${dep}" "${comp}")"
+			diag_ "$(printf '  "%s" != "%s"\n' \
+				"${test_comp}" "${good_comp}")"
+			result='not_ok_'
+		fi
+	done
+
+	"${result}" -- "PARSE DEPENDENCY \"${dep}\""
+}
+
+plan_ 12
+
+testcase \
+	'foo' \
+	'foo' \
+	'' \
+	'' \
+	'' \
+	''
+
+testcase \
+	'foo:amd64-linux-glibc' \
+	'foo' \
+	'amd64-linux-glibc' \
+	'' \
+	'' \
+	''
+
+testcase \
+	'foo (>= 1.0)' \
+	'foo' \
+	'' \
+	'>=' \
+	'1.0' \
+	''
+
+testcase \
+	'foo(>=1.0)' \
+	'foo' \
+	'' \
+	'>=' \
+	'1.0' \
+	''
+
+testcase \
+	'foo   (>=   1.0)' \
+	'foo' \
+	'' \
+	'>=' \
+	'1.0' \
+	''
+
+testcase \
+	'foo [amd64-linux-glibc]' \
+	'foo' \
+	'' \
+	'' \
+	'' \
+	'amd64-linux-glibc'
+
+testcase \
+	'foo[amd64-linux-glibc]' \
+	'foo' \
+	'' \
+	'' \
+	'' \
+	'amd64-linux-glibc'
+
+testcase \
+	'foo   [amd64-linux-glibc]' \
+	'foo' \
+	'' \
+	'' \
+	'' \
+	'amd64-linux-glibc'
+
+testcase \
+	'foo:amd64-linux-glibc (>= 1.0) [amd64-linux-glibc]' \
+	'foo' \
+	'amd64-linux-glibc' \
+	'>=' \
+	'1.0' \
+	'amd64-linux-glibc'
+
+testcase \
+	'foo:amd64-linux-glibc(>=1.0)[amd64-linux-glibc]' \
+	'foo' \
+	'amd64-linux-glibc' \
+	'>=' \
+	'1.0' \
+	'amd64-linux-glibc'
+
+testcase \
+	'foo:amd64-linux-glibc   (>=   1.0)   [amd64-linux-glibc]' \
+	'foo' \
+	'amd64-linux-glibc' \
+	'>=' \
+	'1.0' \
+	'amd64-linux-glibc'
+
+testcase \
+	'busybox (<< 1.21.1.12)' \
+	'busybox' \
+	'' \
+	'<<' \
+	'1.21.1.12' \
+	''
diff --git a/tests/lib/ob_plat_is_concerned.sh b/tests/lib/ob_plat_is_concerned.sh
new file mode 100755
index 0000000..4ba5787
--- /dev/null
+++ b/tests/lib/ob_plat_is_concerned.sh
@@ -0,0 +1,105 @@
+# Tests for ob_plat_is_concerned()
+#
+# Copyright (C) 2012, 2014, 2018 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
+
+plan_ 12
+
+# Platform: all
+
+command_ok_ \
+	'HOST "dev" DOES NOT MATCH PLAT "all"' -- \
+	not ob_plat_is_concerned \
+	'dev' \
+	'all'
+
+command_ok_ \
+	'HOST "ao751h" DOES NOT MATCH PLAT "all"' -- \
+	not ob_plat_is_concerned \
+	'ao751h' \
+	'all'
+
+command_ok_ \
+	'HOST "all" DOES MATCH PLAT "all"' -- \
+	ob_plat_is_concerned \
+	'all' \
+	'all'
+
+# Platform: any
+
+command_ok_ \
+	'HOST "dev" DOES MATCH PLAT "any"' -- \
+	ob_plat_is_concerned \
+	'dev' \
+	'any'
+
+command_ok_ \
+	'HOST "ao751h" DOES MATCH PLAT "any"' -- \
+	ob_plat_is_concerned \
+	'ao751h' \
+	'any'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH PLAT "any"' -- \
+	not ob_plat_is_concerned \
+	'all' \
+	'any'
+
+# Platform: dev
+
+command_ok_ \
+	'HOST "dev" DOES MATCH PLAT "dev"' -- \
+	ob_plat_is_concerned \
+	'dev' \
+	'dev'
+
+command_ok_ \
+	'HOST "ao751h" DOES NOT MATCH PLAT "dev"' -- \
+	not ob_plat_is_concerned \
+	'ao751h' \
+	'dev'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH PLAT "dev"' -- \
+	not ob_plat_is_concerned \
+	'all' \
+	'dev'
+
+# Platform: !dev
+
+command_ok_ \
+	'HOST "dev" DOES NOT MATCH PLAT "!dev"' -- \
+	not ob_plat_is_concerned \
+	'dev' \
+	'!dev'
+
+command_ok_ \
+	'HOST "ao751h" DOES MATCH PLAT "!dev"' -- \
+	ob_plat_is_concerned \
+	'ao751h' \
+	'!dev'
+
+command_ok_ \
+	'HOST "all" DOES NOT MATCH PLAT "!dev"' -- \
+	not ob_plat_is_concerned \
+	'all' \
+	'!dev'
diff --git a/tests/lib/ob_reduce_deps.sh b/tests/lib/ob_reduce_deps.sh
new file mode 100755
index 0000000..b1e8609
--- /dev/null
+++ b/tests/lib/ob_reduce_deps.sh
@@ -0,0 +1,134 @@
+# Tests for ob_reduce_deps()
+#
+# Copyright (C) 2012, 2018 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild.  If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_BUILDDIR}/lib/libopkbuild.${SHSOEXT}.${LIBOPKBUILD_SHSOVERSION}"
+
+plan_ 11
+
+# Normal and union AND-lists.
+
+command_ok_ \
+	'NORMAL LIST "foo, bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo, bar' \
+	)" = \
+		x'foo, bar' \
+	]
+
+command_ok_ \
+	'NORMAL LIST "foo,bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo,bar' \
+	)" = \
+		x'foo, bar' \
+	]
+
+command_ok_ \
+	'NORMAL LIST "foo,   bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo,   bar' \
+	)" = \
+		x'foo, bar' \
+	]
+
+command_ok_ \
+	'UNION LIST "foo, bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-u \
+		-a 'amd64-linux-glibc' \
+		'foo, bar' \
+	)" = \
+		x'foo, bar' \
+	]
+
+command_ok_ \
+	'UNION LIST "foo,bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-u \
+		-a 'amd64-linux-glibc' \
+		'foo,bar' \
+	)" = \
+		x'foo, bar' \
+	]
+
+command_ok_ \
+	'UNION LIST "foo,   bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-u \
+		-a 'amd64-linux-glibc' \
+		'foo,   bar' \
+	)" = \
+		x'foo, bar' \
+	]
+
+# Normal OR-lists.
+
+command_ok_ \
+	'NORMAL LIST "foo | bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo | bar' \
+	)" = \
+		x'foo | bar' \
+	]
+
+command_ok_ \
+	'NORMAL LIST "foo|bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo|bar' \
+	)" = \
+		x'foo | bar' \
+	]
+
+command_ok_ \
+	'NORMAL LIST "foo   |   bar"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo   |   bar' \
+	)" = \
+		x'foo | bar' \
+	]
+
+# Normal and union AND-lists with arch specs.
+
+command_ok_ \
+	'NORMAL LIST "foo [amd64-linux-glibc], bar [!amd64-linux-glibc]"' -- \
+	[ x"$(ob_reduce_deps \
+		-a 'amd64-linux-glibc' \
+		'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' \
+	)" = \
+		x'foo' \
+	]
+
+command_ok_ \
+	'UNION LIST "foo [amd64-linux-glibc], bar [!amd64-linux-glibc]"' -- \
+	[ x"$(ob_reduce_deps \
+		-u \
+		-a 'amd64-linux-glibc' \
+		'foo [amd64-linux-glibc], bar [!amd64-linux-glibc]' \
+	)" = \
+		x'foo' \
+	]
--
cgit v0.9.1