Skip to content

Commit d3e6807

Browse files
committed
tests: add test for installing an already installed package by its provides
1 parent 03dba73 commit d3e6807

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

tests/xbps/libxbps/shell/install_test.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,53 @@ install_and_update_revdeps_body() {
336336
atf_check_equal $(xbps-query -r root -p pkgver D) D-1.0_1
337337
}
338338

339+
atf_test_case install_virtual_already_installed
340+
341+
install_virtual_already_installed_head() {
342+
atf_set "descr" "Tests for pkg install: do not reinstall an already installed virtual package"
343+
}
344+
345+
install_virtual_already_installed_body() {
346+
mkdir -p repo1 repo1-dbg repo2 pkg/usr/bin
347+
348+
cd repo1
349+
touch ../pkg/usr/bin/A
350+
atf_check -o ignore -e ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" --provides "cmd:A-1.0_1" ../pkg
351+
atf_check -o ignore -- xbps-rindex -a $PWD/*.xbps
352+
cd ..
353+
354+
atf_check -o match:'A-1\.0_1: installed successfully\.' -- \
355+
xbps-install -r root -R repo1 -yv A
356+
357+
atf_check -o not-match:'A-1\.0_1: installed successfully\.' \
358+
-e inline:"ERROR: Package \`cmd:A' already installed.\n" -- \
359+
xbps-install -r root -R repo1 -yv cmd:A
360+
}
361+
362+
atf_test_case install_virtual_already_installed_as_dep
363+
364+
install_virtual_already_installed_as_dep_head() {
365+
atf_set "descr" "Tests for pkg install: do not reinstall an already installed virtual package as dependency"
366+
}
367+
368+
install_virtual_already_installed_as_dep_body() {
369+
mkdir -p repo1 pkg_A/usr/bin pkg_B/usr/bin
370+
371+
cd repo1
372+
touch ../pkg_A/usr/bin/A
373+
touch ../pkg_B/usr/bin/B
374+
atf_check -o ignore -e ignore -- xbps-create -A noarch -n A-1.0_1 -s "A pkg" --provides "cmd:A-1.0_1" ../pkg_A
375+
atf_check -o ignore -e ignore -- xbps-create -A noarch -n B-1.0_1 -s "B pkg" --dependencies "cmd:A-1.0_1" ../pkg_B
376+
atf_check -o ignore -- xbps-rindex -a $PWD/*.xbps
377+
cd ..
378+
379+
atf_check -o match:'A-1\.0_1: installed successfully\.' -- \
380+
xbps-install -r root -R repo1 -yv A
381+
382+
atf_check -o not-match:'A-1\.0_1: installed successfully\.' -- \
383+
xbps-install -r root -R repo1 -yv B
384+
}
385+
339386
atf_test_case update_file_timestamps
340387

341388
update_file_timestamps_head() {
@@ -735,6 +782,8 @@ atf_init_test_cases() {
735782
atf_add_test_case install_bestmatch_deps
736783
atf_add_test_case install_bestmatch_disabled
737784
atf_add_test_case install_and_update_revdeps
785+
atf_add_test_case install_virtual_already_installed
786+
atf_add_test_case install_virtual_already_installed_as_dep
738787
atf_add_test_case update_and_install
739788
atf_add_test_case update_if_installed
740789
atf_add_test_case update_to_empty_pkg

0 commit comments

Comments
 (0)