Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/freebsd/poudriere.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Drewery <bryan@shatow.net>2022-09-09 22:57:54 +0300
committerBryan Drewery <bryan@shatow.net>2022-11-05 18:47:57 +0300
commiteab6c4c5162f9c45469700002ee638155d315b80 (patch)
treef3a10bda5c40c007e6676e09d514aef7282767ec
parentcc14f49acd7852c468bc07ea618cfcac602fedcd (diff)
Add display() tests
-rw-r--r--test/Makefile.am1
-rw-r--r--test/Makefile.in26
-rw-r--r--test/display.sh51
3 files changed, 69 insertions, 9 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index bee11dd9..ecb680b9 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -8,6 +8,7 @@ EXTRA_DIST= $(TESTS) \
TESTS=\
builtins.sh \
cache.sh \
+ display.sh \
do_clone.sh \
encode_args.sh \
getpid.sh \
diff --git a/test/Makefile.in b/test/Makefile.in
index 42daf32f..5e44655f 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -461,15 +461,16 @@ EXTRA_DIST = $(TESTS) \
# Depend bulk tests on jail setup
-TESTS = builtins.sh cache.sh do_clone.sh encode_args.sh getpid.sh \
- getvar.sh gsub.sh globmatch.sh hash_basic.sh list.sh locks.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 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
+TESTS = builtins.sh cache.sh display.sh do_clone.sh encode_args.sh \
+ getpid.sh getvar.sh gsub.sh globmatch.sh hash_basic.sh list.sh \
+ locks.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 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-build-self-immutable-base-nullfs.sh \
@@ -722,6 +723,13 @@ cache.sh.log: cache.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)
+display.sh.log: display.sh
+ @p='display.sh'; \
+ b='display.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)
do_clone.sh.log: do_clone.sh
@p='do_clone.sh'; \
b='do_clone.sh'; \
diff --git a/test/display.sh b/test/display.sh
new file mode 100644
index 00000000..e9a4281c
--- /dev/null
+++ b/test/display.sh
@@ -0,0 +1,51 @@
+. common.sh
+. ${SCRIPTPREFIX}/include/util.sh
+. ${SCRIPTPREFIX}/include/hash.sh
+. ${SCRIPTPREFIX}/include/display.sh
+
+_assert_file() {
+ local lineinfo="$1"
+ local expected="$2"
+ local have="$3"
+ local reason="$4"
+ local ret=0
+
+ cmp -s "${have}" "${expected}" || ret=$?
+
+ reason="${reason:+${reason} -}
+HAVE:
+$(cat -vet "${have}")
+EXPECTED:
+$(cat -vet "${expected}")"
+ rm -f "${have}" "${expected}"
+ _assert "${lineinfo}" 0 "${ret}" "${reason}"
+}
+alias assert_file='_assert_file "$0:$LINENO"'
+
+display_setup "%%-%ds %%-%ds" "-k2,2V -k1,1d"
+display_add "Name" "Release"
+display_add "blah" "11.2-RELEASE-p1"
+display_add "blah" "10.0-RELEASE"
+display_add "blah" "10.2-RELEASE"
+display_add "blah" "10.2-RELEASE-p10"
+display_add "blah2" "10.2-RELEASE-p1"
+display_add "blah" "10.2-RELEASE-p1"
+display_add "blah" "9.3-RELEASE-p10"
+display_add "blah" "9.3-RELEASE-p1"
+display_add "blah" "8.2-RELEASE-p1"
+outfile=$(mktemp -t outfile)
+display_output > "${outfile}"
+expected=$(mktemp -t expected)
+cat > "${expected}" <<-EOF
+Name Release
+blah 8.2-RELEASE-p1
+blah 9.3-RELEASE-p1
+blah 9.3-RELEASE-p10
+blah 10.0-RELEASE
+blah 10.2-RELEASE
+blah 10.2-RELEASE-p1
+blah2 10.2-RELEASE-p1
+blah 10.2-RELEASE-p10
+blah 11.2-RELEASE-p1
+EOF
+assert_file "${expected}" "${outfile}"