summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/local.mk4
-rw-r--r--tests/ob_reduce_deps.rc71
-rwxr-xr-x[-rw-r--r--]tests/ob_reduce_deps.sh149
3 files changed, 118 insertions, 106 deletions
diff --git a/tests/local.mk b/tests/local.mk
index 91c2a63..ff5e3ba 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -1,6 +1,6 @@
TESTS = \
%reldir%/ob_match_arch.sh \
+ %reldir%/ob_reduce_deps.sh \
%reldir%/ob_arch_is_concerned.sh \
%reldir%/ob_plat_is_concerned.sh
-# %reldir%/ob_parse_dep.sh \
-# %reldir%/ob_reduce_deps.sh
+# %reldir%/ob_parse_dep.sh
diff --git a/tests/ob_reduce_deps.rc b/tests/ob_reduce_deps.rc
deleted file mode 100644
index ff1acfc..0000000
--- a/tests/ob_reduce_deps.rc
+++ /dev/null
@@ -1,71 +0,0 @@
-# Normal and union AND-lists.
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo, bar'
-result='foo, bar'
-testcase
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo,bar'
-result='foo, bar'
-testcase
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo, bar'
-result='foo, bar'
-testcase
-
-type='u'
-host_arch='core-linux-eglibc'
-deps='foo, bar'
-result='foo, bar'
-testcase
-
-type='u'
-host_arch='core-linux-eglibc'
-deps='foo,bar'
-result='foo, bar'
-testcase
-
-type='u'
-host_arch='core-linux-eglibc'
-deps='foo, bar'
-result='foo, bar'
-testcase
-
-# Normal and union OR-lists.
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo | bar'
-result='foo | bar'
-testcase
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo|bar'
-result='foo | bar'
-testcase
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo | bar'
-result='foo | bar'
-testcase
-
-# Normal and union AND-lists with arch specs.
-
-type='n'
-host_arch='core-linux-eglibc'
-deps='foo [core-linux-eglibc], bar [!core-linux-eglibc]'
-result='foo'
-testcase
-
-type='u'
-host_arch='core-linux-eglibc'
-deps='foo [core-linux-eglibc], bar [!core-linux-eglibc]'
-result='foo'
-testcase
diff --git a/tests/ob_reduce_deps.sh b/tests/ob_reduce_deps.sh
index 406db0b..fd1a810 100644..100755
--- a/tests/ob_reduce_deps.sh
+++ b/tests/ob_reduce_deps.sh
@@ -17,36 +17,119 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-. ./common.sh
-
-ret=0
-type=
-host_arch=
-deps=
-result=
-
-main()
-{
- . ./ob_reduce_deps.rc
-
- exit ${ret}
-}
-
-testcase()
-{
- if [ "${type}" != 'u' ]; then
- deps="$(ob_reduce_deps -a "${host_arch}" "${deps}")"
- else
- deps="$(ob_reduce_deps -u -a "${host_arch}" "${deps}")"
- fi
-
- if [ "${deps}" != "${result}" ]; then
- printf 'Dependency list of type "%s" for host arch "%s":\n' \
- "${type}" "${host_arch}"
- printf ' "%s" != "%s"\n' \
- "${deps}" "${result}"
- ret=1
- fi
-}
-
-main "${@}"
+srcdir="$(dirname "${0}")"
+top_builddir="${PWD}"
+
+. "${srcdir}/aux/tap-functions.sh"
+. "${top_builddir}/lib/libopkbuild.shso.1"
+
+plan_ 11
+
+# Normal and union AND-lists.
+
+command_ok_ \
+ 'NORMAL LIST "foo, bar"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo, bar' \
+ )" = \
+ 'foo, bar' \
+ ]
+
+command_ok_ \
+ 'NORMAL LIST "foo,bar"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo,bar' \
+ )" = \
+ 'foo, bar' \
+ ]
+
+command_ok_ \
+ 'NORMAL LIST "foo, bar"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo, bar' \
+ )" = \
+ 'foo, bar' \
+ ]
+
+command_ok_ \
+ 'UNION LIST "foo, bar"' -- \
+ [ "$(ob_reduce_deps \
+ -u \
+ -a 'core-linux-eglibc' \
+ 'foo, bar' \
+ )" = \
+ 'foo, bar' \
+ ]
+
+command_ok_ \
+ 'UNION LIST "foo,bar"' -- \
+ [ "$(ob_reduce_deps \
+ -u \
+ -a 'core-linux-eglibc' \
+ 'foo,bar' \
+ )" = \
+ 'foo, bar' \
+ ]
+
+command_ok_ \
+ 'UNION LIST "foo, bar"' -- \
+ [ "$(ob_reduce_deps \
+ -u \
+ -a 'core-linux-eglibc' \
+ 'foo, bar' \
+ )" = \
+ 'foo, bar' \
+ ]
+
+# Normal and union OR-lists.
+
+command_ok_ \
+ 'NORMAL LIST "foo | bar"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo | bar' \
+ )" = \
+ 'foo | bar' \
+ ]
+
+command_ok_ \
+ 'NORMAL LIST "foo|bar"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo|bar' \
+ )" = \
+ 'foo | bar' \
+ ]
+
+command_ok_ \
+ 'NORMAL LIST "foo | bar"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo | bar' \
+ )" = \
+ 'foo | bar' \
+ ]
+
+# Normal and union AND-lists with arch specs.
+
+command_ok_ \
+ 'NORMAL LIST "foo [core-linux-eglibc], bar [!core-linux-eglibc]"' -- \
+ [ "$(ob_reduce_deps \
+ -a 'core-linux-eglibc' \
+ 'foo [core-linux-eglibc], bar [!core-linux-eglibc]' \
+ )" = \
+ 'foo' \
+ ]
+
+command_ok_ \
+ 'UNION LIST "foo [core-linux-eglibc], bar [!core-linux-eglibc]"' -- \
+ [ "$(ob_reduce_deps \
+ -u \
+ -a 'core-linux-eglibc' \
+ 'foo [core-linux-eglibc], bar [!core-linux-eglibc]' \
+ )" = \
+ 'foo' \
+ ]