summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/ob_parse_dep.data16
-rw-r--r--tests/ob_parse_dep.rc87
-rw-r--r--tests/ob_parse_dep.sh41
3 files changed, 108 insertions, 36 deletions
diff --git a/tests/ob_parse_dep.data b/tests/ob_parse_dep.data
deleted file mode 100644
index 5d19a4b..0000000
--- a/tests/ob_parse_dep.data
+++ /dev/null
@@ -1,16 +0,0 @@
-# dependency ; pkg ; archqual ; rel ; ver ; arches
-
-foo ;foo
-foo:core-linux-eglibc ;foo;core-linux-eglibc
-foo (>= 1.0) ;foo;;>=;1.0
-foo(>=1.0) ;foo;;>=;1.0
-foo (>= 1.0) ;foo;;>=;1.0
-foo [core-linux-eglibc] ;foo;;;;core-linux-eglibc
-foo[core-linux-eglibc] ;foo;;;;core-linux-eglibc
-foo [core-linux-eglibc] ;foo;;;;core-linux-eglibc
-foo:core-linux-eglibc (>= 1.0) [core-linux-eglibc] \
- ;foo;core-linux-eglibc;>=;1.0;core-linux-eglibc
-foo:core-linux-eglibc(>=1.0)[core-linux-eglibc] \
- ;foo;core-linux-eglibc;>=;1.0;core-linux-eglibc
-foo:core-linux-eglibc (>= 1.0) [core-linux-eglibc] \
- ;foo;core-linux-eglibc;>=;1.0;core-linux-eglibc
diff --git a/tests/ob_parse_dep.rc b/tests/ob_parse_dep.rc
new file mode 100644
index 0000000..fd0a8ed
--- /dev/null
+++ b/tests/ob_parse_dep.rc
@@ -0,0 +1,87 @@
+dep='foo'
+pkg='foo'
+archqual=''
+rel=''
+ver=''
+arches=''
+testcase
+
+dep='foo:core-linux-eglibc'
+pkg='foo'
+archqual='core-linux-eglibc'
+rel=''
+ver=''
+arches=''
+testcase
+
+dep='foo (>= 1.0)'
+pkg='foo'
+archqual=''
+rel='>='
+ver='1.0'
+arches=''
+testcase
+
+dep='foo(>=1.0)'
+pkg='foo'
+archqual=''
+rel='>='
+ver='1.0'
+arches=''
+testcase
+
+dep='foo (>= 1.0)'
+pkg='foo'
+archqual=''
+rel='>='
+ver='1.0'
+arches=''
+testcase
+
+dep='foo [core-linux-eglibc]'
+pkg='foo'
+archqual=''
+rel=''
+ver=''
+arches='core-linux-eglibc'
+testcase
+
+dep='foo[core-linux-eglibc]'
+pkg='foo'
+archqual=''
+rel=''
+ver=''
+arches='core-linux-eglibc'
+testcase
+
+dep='foo [core-linux-eglibc]'
+pkg='foo'
+archqual=''
+rel=''
+ver=''
+arches='core-linux-eglibc'
+testcase
+
+dep='foo:core-linux-eglibc (>= 1.0) [core-linux-eglibc]'
+pkg='foo'
+archqual='core-linux-eglibc'
+rel='>='
+ver='1.0'
+arches='core-linux-eglibc'
+testcase
+
+dep='foo:core-linux-eglibc(>=1.0)[core-linux-eglibc]'
+pkg='foo'
+archqual='core-linux-eglibc'
+rel='>='
+ver='1.0'
+arches='core-linux-eglibc'
+testcase
+
+dep='foo:core-linux-eglibc (>= 1.0) [core-linux-eglibc]'
+pkg='foo'
+archqual='core-linux-eglibc'
+rel='>='
+ver='1.0'
+arches='core-linux-eglibc'
+testcase
diff --git a/tests/ob_parse_dep.sh b/tests/ob_parse_dep.sh
index ccc8c4d..7a113a9 100644
--- a/tests/ob_parse_dep.sh
+++ b/tests/ob_parse_dep.sh
@@ -22,33 +22,34 @@
ob_use deps
ret=0
-
-while read line; do
-
- line="${line%%#*}"
- [ -z "${line}" ] && continue
-
- IFS=';' read -r test_dep good_pkg good_archqual good_rel good_ver good_arches \
- <<EOF
-${line}
-EOF
-
- test_dep="$(echo "${test_dep}" | sed 's/^ *//;s/ *$//')"
-
+dep=
+pkg=
+archqual=
+rel=
+ver=
+arches=
+
+main()
+{
+ . ./ob_parse_dep.rc
+
+ exit ${ret}
+}
+
+testcase()
+{
ob_parse_dep -p test_pkg -q test_archqual -r test_rel -v test_ver \
- -A test_arches "${test_dep}" >/dev/null
+ -A test_arches "${dep}" >/dev/null
for comp in pkg archqual rel ver arches; do
- comp="$(echo "${comp}" | sed 's/^ *//;s/ *$//')"
test_comp="$(eval echo \"\$\{test_${comp}\}\")"
- good_comp="$(eval echo \"\$\{good_${comp}\}\")"
+ good_comp="$(eval echo \"\$\{${comp}\}\")"
if [ "${test_comp}" != "${good_comp}" ]; then
printf 'Dependency "%s", component "%s":\n "%s" != "%s"\n' \
- "${test_dep}" "${comp}" "${test_comp}" "${good_comp}" >&2
+ "${dep}" "${comp}" "${test_comp}" "${good_comp}" >&2
ret=1
fi
done
+}
-done <'ob_parse_dep.data'
-
-exit ${ret}
+main "${@}"