summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/local.mk2
-rw-r--r--tests/ob_parse_dep.rc95
-rwxr-xr-x[-rw-r--r--]tests/ob_parse_dep.sh137
3 files changed, 119 insertions, 115 deletions
diff --git a/tests/local.mk b/tests/local.mk
index ff5e3ba..39b5669 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -1,6 +1,6 @@
TESTS = \
%reldir%/ob_match_arch.sh \
+ %reldir%/ob_parse_dep.sh \
%reldir%/ob_reduce_deps.sh \
%reldir%/ob_arch_is_concerned.sh \
%reldir%/ob_plat_is_concerned.sh
-# %reldir%/ob_parse_dep.sh
diff --git a/tests/ob_parse_dep.rc b/tests/ob_parse_dep.rc
deleted file mode 100644
index 3a8c81d..0000000
--- a/tests/ob_parse_dep.rc
+++ /dev/null
@@ -1,95 +0,0 @@
-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
-
-dep='busybox (<< 1.21.1.12)'
-pkg='busybox'
-archqual=''
-rel='<<'
-ver='1.21.1.12'
-arches=''
-testcase
diff --git a/tests/ob_parse_dep.sh b/tests/ob_parse_dep.sh
index 2b4a074..1278533 100644..100755
--- a/tests/ob_parse_dep.sh
+++ b/tests/ob_parse_dep.sh
@@ -17,37 +17,136 @@
# 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
+srcdir="$(dirname "${0}")"
+top_builddir="${PWD}"
-ret=0
-dep=
-pkg=
-archqual=
-rel=
-ver=
-arches=
-
-main()
-{
- . ./ob_parse_dep.rc
-
- exit ${ret}
-}
+. "${srcdir}/aux/tap-functions.sh"
+. "${top_builddir}/lib/libopkbuild.shso.1"
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 echo \"\$\{test_${comp}\}\")"
good_comp="$(eval echo \"\$\{${comp}\}\")"
if [ "${test_comp}" != "${good_comp}" ]; then
- printf 'Dependency "%s", component "%s":\n "%s" != "%s"\n' \
- "${dep}" "${comp}" "${test_comp}" "${good_comp}" >&2
- ret=1
+ 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}\""
}
-main "${@}"
+plan_ 12
+
+testcase \
+ 'foo' \
+ 'foo' \
+ '' \
+ '' \
+ '' \
+ ''
+
+testcase \
+ 'foo:core-linux-eglibc' \
+ 'foo' \
+ 'core-linux-eglibc' \
+ '' \
+ '' \
+ ''
+
+testcase \
+ 'foo (>= 1.0)' \
+ 'foo' \
+ '' \
+ '>=' \
+ '1.0' \
+ ''
+
+testcase \
+ 'foo(>=1.0)' \
+ 'foo' \
+ '' \
+ '>=' \
+ '1.0' \
+ ''
+
+testcase \
+ 'foo (>= 1.0)' \
+ 'foo' \
+ '' \
+ '>=' \
+ '1.0' \
+ ''
+
+testcase \
+ 'foo [core-linux-eglibc]' \
+ 'foo' \
+ '' \
+ '' \
+ '' \
+ 'core-linux-eglibc'
+
+testcase \
+ 'foo[core-linux-eglibc]' \
+ 'foo' \
+ '' \
+ '' \
+ '' \
+ 'core-linux-eglibc'
+
+testcase \
+ 'foo [core-linux-eglibc]' \
+ 'foo' \
+ '' \
+ '' \
+ '' \
+ 'core-linux-eglibc'
+
+testcase \
+ 'foo:core-linux-eglibc (>= 1.0) [core-linux-eglibc]' \
+ 'foo' \
+ 'core-linux-eglibc' \
+ '>=' \
+ '1.0' \
+ 'core-linux-eglibc'
+
+testcase \
+ 'foo:core-linux-eglibc(>=1.0)[core-linux-eglibc]' \
+ 'foo' \
+ 'core-linux-eglibc' \
+ '>=' \
+ '1.0' \
+ 'core-linux-eglibc'
+
+testcase \
+ 'foo:core-linux-eglibc (>= 1.0) [core-linux-eglibc]' \
+ 'foo' \
+ 'core-linux-eglibc' \
+ '>=' \
+ '1.0' \
+ 'core-linux-eglibc'
+
+testcase \
+ 'busybox (<< 1.21.1.12)' \
+ 'busybox' \
+ '' \
+ '<<' \
+ '1.21.1.12' \
+ ''