From 397f2b86e157ed3c8867e062e2d8db2a442b7aef Mon Sep 17 00:00:00 2001 From: Juan RP Date: Fri, 7 Feb 2020 09:55:36 +0100 Subject: [PATCH] tests: new alternatives test case by @CameronNemo. The test case has been provided by @CameronNemo via #185. This is expected to fail currently. --- tests/xbps/xbps-alternatives/main_test.sh | 61 ++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/tests/xbps/xbps-alternatives/main_test.sh b/tests/xbps/xbps-alternatives/main_test.sh index da4a38cb..fcc3a1df 100644 --- a/tests/xbps/xbps-alternatives/main_test.sh +++ b/tests/xbps/xbps-alternatives/main_test.sh @@ -565,7 +565,7 @@ useless_switch_body() { echo "B lnk: $lnk" fi atf_check_equal $rv 0 - + ln -sf /dev/null root/usr/bin/file xbps-remove -r root -ydv B atf_check_equal $? 0 @@ -841,6 +841,64 @@ keep_provider_on_update_body() { atf_check_equal $link gtar } +atf_test_case replace_file_with_alternative + +replace_file_with_alternative_head() { + atf_set "descr" "xbps-alternatives: replace file with an alternative" +} +replace_file_with_alternative_body() { + atf_expect_fail "https://github.com/void-linux/xbps/pull/185" + + mkdir -p repo pkg_A_old/usr/bin pkg_A_new/usr/bin pkg_B_old/usr/bin \ + pkg_B_new/usr/bin + printf 'A' > pkg_A_old/usr/bin/pkg-a-file + printf 'Ap' > pkg_A_new/usr/bin/pkg-a-file + printf 'B' > pkg_B_old/usr/bin/file + printf 'Bp' > pkg_B_new/usr/bin/pkg-B-file + + cd repo + xbps-create -A noarch -n A-1.1_1 -s "A pkg" ../pkg_A_old + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=repo -ydv A + atf_check_equal $? 0 + + cd repo + xbps-create -A noarch -n B-1.1_1 -s "B pkg" ../pkg_B_old + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=repo -ydv B + atf_check_equal $? 0 + + cd repo + xbps-create -A noarch -n A-1.1_2 -s "A pkg" --alternatives "file:file:/usr/bin/pkg-a-file" ../pkg_A_new + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + cd repo + xbps-create -A noarch -n B-1.1_2 -s "B pkg" --alternatives "file:file:/usr/bin/pkg-b-file" ../pkg_B_new + atf_check_equal $? 0 + xbps-rindex -d -a $PWD/*.xbps + atf_check_equal $? 0 + cd .. + + xbps-install -r root --repository=repo -ydv -Su + atf_check_equal $? 0 + + test -L root/usr/bin/file + atf_check_equal $? 0 + test "$(readlink -f root/usr/bin/file)" = "pkg-b-file" + atf_check_equal $? 0 +} + atf_init_test_cases() { atf_add_test_case register_one atf_add_test_case register_one_dangling @@ -862,4 +920,5 @@ atf_init_test_cases() { atf_add_test_case prune_leftover_groups atf_add_test_case replace_alternative_with_symlink atf_add_test_case keep_provider_on_update + atf_add_test_case replace_file_with_alternative }