summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2018-12-23 17:00:21 (EST)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2018-12-23 17:00:21 (EST)
commitc25e8d5a97b796e9d59e1c9e56405fa2469a0a68 (patch)
treec40cd3be5d6936de0d104a3ed271b53cb3f060ad
parent95594b590e0230b4d826a7ca563b8d1a4e98a9c1 (diff)
tests/ob_match_arch.sh: Convert to TAP
-rw-r--r--tests/local.mk4
-rw-r--r--tests/ob_match_arch.rc49
-rwxr-xr-x[-rw-r--r--]tests/ob_match_arch.sh108
3 files changed, 47 insertions, 114 deletions
diff --git a/tests/local.mk b/tests/local.mk
index 92c1e5e..dc1dd19 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -1,5 +1,5 @@
-TESTS =
-# %reldir%/ob_match_arch.sh \
+TESTS = \
+ %reldir%/ob_match_arch.sh
# %reldir%/ob_parse_dep.sh \
# %reldir%/ob_reduce_deps.sh \
# %reldir%/ob_arch_is_concerned.sh \
diff --git a/tests/ob_match_arch.rc b/tests/ob_match_arch.rc
deleted file mode 100644
index 10135d7..0000000
--- a/tests/ob_match_arch.rc
+++ /dev/null
@@ -1,49 +0,0 @@
-set arch all
-set arch_field all
-set result true
-test
-
-set arch foo-bar-baz
-set arch_field any
-set result true
-test
-
-set arch foo-bar-baz
-set arch_field any all
-set result true
-test
-
-set arch all
-set arch_field any all
-set result true
-test
-
-set arch foo-bar-baz
-set arch_field foo-any-any
-set result true
-test
-
-set arch foo-bar-baz
-set arch_field foo-bar-qux
-set result false
-test
-
-set arch foo-bar-baz
-set arch_field any-qux-any any-bar-any
-set result true
-test
-
-set arch foo-bar-baz
-set arch_field any-qux-any any-quux-any
-set result false
-test
-
-set arch all
-set arch_field any
-set result false
-test
-
-set arch all
-set arch_field foo-any-any
-set result false
-test
diff --git a/tests/ob_match_arch.sh b/tests/ob_match_arch.sh
index 545b2af..589a912 100644..100755
--- a/tests/ob_match_arch.sh
+++ b/tests/ob_match_arch.sh
@@ -17,78 +17,60 @@
# 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
-arch=
-arch_field=
-result=
+. "${srcdir}/aux/tap-functions.sh"
+. "${top_builddir}/lib/libopkbuild.shso.1"
-main()
-{
- while read line; do
+plan_ 10
- line=${line%#*}
- line=$(echo ${line})
- [ -z "${line}" ] && continue
+command_ok_ 'all IN [all]' -- \
+ ob_match_arch \
+ 'all' \
+ 'all'
- eval set -- ${line}
+command_ok_ 'foo-bar-baz IN [any]' -- \
+ ob_match_arch \
+ 'foo-bar-baz' \
+ 'any'
- cmd="${1}"
- shift
- if echo ' set test ' | grep " ${cmd} " >/dev/null 2>&1; then
- "cmd_${cmd}" "${@}"
- else
- ob_error 'Invalid command in ob_match_arch.rc!'
- fi
+command_ok_ 'foo-bar-baz IN [any all]' -- \
+ ob_match_arch \
+ 'foo-bar-baz' \
+ 'any all'
- done <'ob_match_arch.rc'
+command_ok_ 'all IN [any all]' -- \
+ ob_match_arch \
+ 'all' \
+ 'any all'
- exit ${ret}
-}
+command_ok_ 'foo-bar-baz IN [foo-bar-any]' -- \
+ ob_match_arch \
+ 'foo-bar-baz' \
+ 'foo-bar-any'
-cmd_set()
-{
- if [ ${#} -lt 2 ]; then
- ob_error 'Invalid arguments to command "set" in ob_match_arch.rc!'
- fi
+command_ok_ 'foo-bar-baz NOT IN [foo-bar-qux]' -- \
+ not ob_match_arch \
+ 'foo-bar-baz' \
+ 'foo-bar-qux'
- name="${1}"
- shift
- value="${@}"
+command_ok_ 'foo-bar-baz IN [any-qux-any any-bar-any]' -- \
+ ob_match_arch \
+ 'foo-bar-baz' \
+ 'any-qux-any any-bar-any'
- case "${name}" in
- arch)
- arch="${value}"
- ;;
- arch_field)
- arch_field="${value}"
- ;;
- result)
- result="${value}"
- ;;
- *)
- ob_error \
- 'Invalid name argument to command "set" in ob_match_arch.rc!'
- ;;
- esac
-}
+command_ok_ 'foo-bar-baz NOT IN [any-qux-any any-quux-any]' -- \
+ not ob_match_arch \
+ 'foo-bar-baz' \
+ 'any-qux-any any-quux-any'
-cmd_test()
-{
- if ob_match_arch "${arch}" "${arch_field}"; then
- if [ "${result}" = 'false' ]; then
- printf 'False positive:\n arch: %s\n arch_field: %s\n' \
- "${arch}" "${arch_field}" >&2
- ret=1
- fi
- else
- if [ "${result}" = 'true' ]; then
- printf 'False negative:\n arch: %s\n arch_field: %s\n' \
- "${arch}" "${arch_field}" >&2
- ret=1
- fi
- fi
-}
+command_ok_ 'all NOT IN [any]' -- \
+ not ob_match_arch \
+ 'all' \
+ 'any'
-main "${@}"
+command_ok_ 'all NOT IN [foo-any-any]' -- \
+ not ob_match_arch \
+ 'all' \
+ 'foo-any-any'