diff options
author | Bryan Drewery <bryan@shatow.net> | 2022-07-13 19:33:59 +0300 |
---|---|---|
committer | Bryan Drewery <bryan@shatow.net> | 2022-07-13 19:35:06 +0300 |
commit | d8590c6e8762bc27bd2c5641bacd43fc44ba4d8e (patch) | |
tree | bcc6edc7d1b51ad2ebdff7a3d2ebbaddc1d78a5c | |
parent | a787fc01682e3401f95f6a54a0ae582f82d72fc3 (diff) |
Add pkg_version tests.
One is currently failing which is fixed by #1004
-rw-r--r-- | test/Makefile.am | 1 | ||||
-rw-r--r-- | test/Makefile.in | 15 | ||||
-rw-r--r-- | test/common.sh | 10 | ||||
-rw-r--r-- | test/pkg_version.sh | 27 |
4 files changed, 49 insertions, 4 deletions
diff --git a/test/Makefile.am b/test/Makefile.am index 2415c53c..1711951f 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -24,6 +24,7 @@ TESTS=\ locked_mkdir_waiters_kill.sh \ locked_mkdir_waiters_all_lose.sh \ mapfile.sh \ + pkg_version.sh \ port_var_fetch.sh \ prefix_output.sh \ read_blocking.sh \ diff --git a/test/Makefile.in b/test/Makefile.in index ccdd74ce..7c9556ad 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -466,10 +466,10 @@ TESTS = builtins.sh cache.sh do_clone.sh encode_args.sh getpid.sh \ locks_critical_section.sh locks_critical_section_nested.sh \ locked_mkdir.sh locked_mkdir_waiters.sh \ locked_mkdir_waiters_kill.sh locked_mkdir_waiters_all_lose.sh \ - mapfile.sh port_var_fetch.sh prefix_output.sh read_blocking.sh \ - read_file.sh relpath.sh relpath_common.sh shash_basic.sh \ - stripansi.sh timespec.sh timestamp.sh trap_save.sh \ - $(JAIL_TESTS) prep.sh + mapfile.sh pkg_version.sh port_var_fetch.sh prefix_output.sh \ + read_blocking.sh read_file.sh relpath.sh relpath_common.sh \ + shash_basic.sh stripansi.sh timespec.sh timestamp.sh \ + trap_save.sh $(JAIL_TESTS) prep.sh JAIL_TESTS = \ bulk-bad-DEPENDS_ARGS.sh \ bulk-ignore-listed.sh \ @@ -829,6 +829,13 @@ mapfile.sh.log: mapfile.sh --log-file $$b.log --trs-file $$b.trs \ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ "$$tst" $(AM_TESTS_FD_REDIRECT) +pkg_version.sh.log: pkg_version.sh + @p='pkg_version.sh'; \ + b='pkg_version.sh'; \ + $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) port_var_fetch.sh.log: port_var_fetch.sh @p='port_var_fetch.sh'; \ b='port_var_fetch.sh'; \ diff --git a/test/common.sh b/test/common.sh index 8fdf0978..475d26ee 100644 --- a/test/common.sh +++ b/test/common.sh @@ -137,6 +137,16 @@ _assert_ret() { } alias assert_ret='_assert_ret "$0:$LINENO"' +_assert_out() { + local lineinfo="$1" + local expected="$2" + shift 2 + local out + + _assert "${lineinfo}" "${expected}" "$("$@")" "Bad output: $@" +} +alias assert_out='_assert_out "$0:$LINENO"' + aecho() { local -; set +x [ $# -ge 2 ] || eargs aecho result lineinfo expected actual msg diff --git a/test/pkg_version.sh b/test/pkg_version.sh new file mode 100644 index 00000000..a1d511a5 --- /dev/null +++ b/test/pkg_version.sh @@ -0,0 +1,27 @@ +set -e +. common.sh +. ${SCRIPTPREFIX}/common.sh +set +e + + +assert_out "<" pkg_version -t 1 2 +assert_out ">" pkg_version -t 2 1 +assert_out "=" pkg_version -t 2 2 +assert_out "<" pkg_version -t 2 1,1 +assert_out "<" pkg_version -t 1.17.5_1 1.18.3 +assert_out "=" pkg_version -t 1.17.5_1,0 1.17.5_1,0 +assert_out "=" pkg_version -t 1.17.5_1,0 1.17.5_1 +assert_out ">" pkg_version -t 1.17.5_1,1 1.18.3 + +if false; then +# Test cases taken from pkg/tests/frontend/version.sh +# Special prefixes +assert_out "<" pkg_version -t 1.pl1 1.alpha1 +assert_out "<" pkg_version -t 1.alpha1 1.beta1 +assert_out "<" pkg_version -t 1.beta1 1.pre1 +assert_out "<" pkg_version -t 1.pre1 1.rc1 +assert_out "<" pkg_version -t 1.rc1 1 + +assert_out "<" pkg_version -t 1.pl1 1.snap1 +assert_out "<" pkg_version -t 1.snap1 1.alpha1 +fi |