xbps-rindex: fix clean mode while removing obsolete entries on index-files with updates.
This commit is contained in:
@@ -1,12 +1,8 @@
|
||||
#! /usr/bin/env atf-sh
|
||||
# Test that xbps-rindex(8) -c (clean mode) works as expected.
|
||||
|
||||
common_cleanup() {
|
||||
rm -rf some_repo
|
||||
}
|
||||
|
||||
# 1st test: make sure that nothing is removed if there are no changes.
|
||||
atf_test_case noremove cleanup
|
||||
atf_test_case noremove
|
||||
|
||||
noremove_head() {
|
||||
atf_set "descr" "xbps-rindex(8) -c: dont removing anything test"
|
||||
@@ -26,12 +22,8 @@ noremove_body() {
|
||||
atf_check_equal ${result} 1
|
||||
}
|
||||
|
||||
noremove_cleanup() {
|
||||
common_cleanup
|
||||
}
|
||||
|
||||
# 2nd test: make sure that entries are also removed from index-files.
|
||||
atf_test_case filesclean cleanup
|
||||
atf_test_case filesclean
|
||||
|
||||
filesclean_head() {
|
||||
atf_set "descr" "xbps-rindex(8) -c: index-files clean test"
|
||||
@@ -54,18 +46,46 @@ filesclean_body() {
|
||||
atf_check_equal $? 0
|
||||
}
|
||||
|
||||
filesclean_cleanup() {
|
||||
common_cleanup
|
||||
# 3nd test: make sure that entries are removed from index-files on updates.
|
||||
atf_test_case filesclean2
|
||||
|
||||
filesclean2_head() {
|
||||
atf_set "descr" "xbps-rindex(8) -c: index-files clean test on updates"
|
||||
}
|
||||
|
||||
# 3rd test: xbps issue #19.
|
||||
filesclean2_body() {
|
||||
mkdir -p some_repo pkg_A
|
||||
touch -f pkg_A/file00
|
||||
cd some_repo
|
||||
xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -a *.xbps
|
||||
atf_check_equal $? 0
|
||||
xbps-create -A noarch -n foo-1.1_1 -s "foo pkg" ../pkg_A
|
||||
atf_check_equal $? 0
|
||||
xbps-rindex -a *.xbps
|
||||
atf_check_equal $? 0
|
||||
cd ..
|
||||
xbps-rindex -c some_repo
|
||||
atf_check_equal $? 0
|
||||
result="$(xbps-query --repository=some_repo -o \*)"
|
||||
expected="foo-1.1_1: /file00 (some_repo)"
|
||||
rv=0
|
||||
if [ "$result" != "$expected" ]; then
|
||||
rv=1
|
||||
fi
|
||||
atf_check_equal $rv 0
|
||||
|
||||
}
|
||||
|
||||
# 4th test: xbps issue #19.
|
||||
# How to reproduce it:
|
||||
# Generate pkg foo-1.0_1.
|
||||
# Add it to the index of a local repo.
|
||||
# Remove the pkg file from the repo.
|
||||
# Run xbps-rindex -c on the repo.
|
||||
|
||||
atf_test_case issue19 cleanup
|
||||
atf_test_case issue19
|
||||
|
||||
issue19_head() {
|
||||
atf_set "descr" "xbps issue #19 (https://github.com/xtraeme/xbps/issues/19)"
|
||||
@@ -87,12 +107,9 @@ issue19_body() {
|
||||
atf_check_equal $? 0
|
||||
}
|
||||
|
||||
issue19_cleanup() {
|
||||
common_cleanup
|
||||
}
|
||||
|
||||
atf_init_test_cases() {
|
||||
atf_add_test_case noremove
|
||||
atf_add_test_case filesclean
|
||||
atf_add_test_case filesclean2
|
||||
atf_add_test_case issue19
|
||||
}
|
||||
|
Reference in New Issue
Block a user