From aa0132c11cd852d86b4311faecdf36e7c97d2786 Mon Sep 17 00:00:00 2001 From: Duncan Overbruck Date: Sun, 17 Sep 2023 20:02:11 +0200 Subject: [PATCH] tests: add tests for install and remove messages --- tests/xbps/xbps-install/behaviour_tests.sh | 56 ++++++++++++++++++++++ tests/xbps/xbps-remove/basic_test.sh | 29 +++++++++++ 2 files changed, 85 insertions(+) diff --git a/tests/xbps/xbps-install/behaviour_tests.sh b/tests/xbps/xbps-install/behaviour_tests.sh index f4f8a4d99..b1a8a4bd5 100644 --- a/tests/xbps/xbps-install/behaviour_tests.sh +++ b/tests/xbps/xbps-install/behaviour_tests.sh @@ -175,6 +175,61 @@ reproducible_body() { atf_check_equal $? 1 } +atf_test_case install_msg + +install_msg_head() { + atf_set "descr" "xbps-install(1): show install message" +} + +install_msg_body() { + mkdir -p some_repo pkg_A + + # install will now show the message + cat <<-EOF >pkg_A/INSTALL.msg + foobar-install-msg + EOF + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + atf_check -s exit:0 \ + -o 'match:foobar-install-msg' \ + -e ignore \ + -- xbps-install -r root -C empty.conf --repository=$PWD/some_repo -y A + + # update with the same message will not show the message + cd some_repo + xbps-create -A noarch -n A-1.0_2 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + atf_check -s exit:0 \ + -o 'not-match:foobar-install-msg' \ + -e ignore \ + -- xbps-install -r root -C empty.conf --repository=$PWD/some_repo -yu + + # update with new message will show the message + cat <<-EOF >pkg_A/INSTALL.msg + fizzbuzz-install-msg + EOF + cd some_repo + xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + atf_check -s exit:0 \ + -o 'match:fizzbuzz-install-msg' \ + -e ignore \ + -- xbps-install -r root -C empty.conf --repository=$PWD/some_repo -yu +} + atf_init_test_cases() { atf_add_test_case install_existent atf_add_test_case update_existent @@ -182,4 +237,5 @@ atf_init_test_cases() { atf_add_test_case unpacked_dep atf_add_test_case reinstall_unpacked_unpack_only atf_add_test_case reproducible + atf_add_test_case install_msg } diff --git a/tests/xbps/xbps-remove/basic_test.sh b/tests/xbps/xbps-remove/basic_test.sh index 716fb4ebe..9abcf0924 100755 --- a/tests/xbps/xbps-remove/basic_test.sh +++ b/tests/xbps/xbps-remove/basic_test.sh @@ -176,6 +176,34 @@ clean_cache_uninstalled_body() { atf_check_equal $? 0 } +atf_test_case remove_msg + +remove_msg_head() { + atf_set "descr" "xbps-rmeove(1): show remove message" +} + +remove_msg_body() { + mkdir -p some_repo pkg_A + + cat <<-EOF >pkg_A/REMOVE.msg + foobar-remove-msg + EOF + cd some_repo + xbps-create -A noarch -n A-1.0_1 -s "A pkg" ../pkg_A + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root -C empty.conf -R some_repo -dvy A + atf_check_equal $? 0 + + atf_check -s exit:0 \ + -o 'match:foobar-remove-msg' \ + -e ignore \ + -- xbps-remove -r root -C empty.conf -y A +} + atf_init_test_cases() { atf_add_test_case remove_directory atf_add_test_case remove_orphans @@ -183,4 +211,5 @@ atf_init_test_cases() { atf_add_test_case clean_cache_dry_run atf_add_test_case clean_cache_dry_run_perm atf_add_test_case clean_cache_uninstalled + atf_add_test_case remove_msg }