diff --git a/tests/xbps/libxbps/issue18/issue18_test.sh b/tests/xbps/libxbps/issue18/issue18_test.sh old mode 100755 new mode 100644 diff --git a/tests/xbps/xbps-rindex/Makefile b/tests/xbps/xbps-rindex/Makefile index b66302ba..6e339243 100644 --- a/tests/xbps/xbps-rindex/Makefile +++ b/tests/xbps/xbps-rindex/Makefile @@ -1,5 +1,5 @@ -include ../../../config.mk -SUBDIRS = common issue19 +SUBDIRS = common clean include ../../../mk/subdir.mk diff --git a/tests/xbps/xbps-rindex/issue19/Makefile b/tests/xbps/xbps-rindex/clean/Makefile similarity index 84% rename from tests/xbps/xbps-rindex/issue19/Makefile rename to tests/xbps/xbps-rindex/clean/Makefile index f1842a9a..1b15b12c 100644 --- a/tests/xbps/xbps-rindex/issue19/Makefile +++ b/tests/xbps/xbps-rindex/clean/Makefile @@ -1,7 +1,7 @@ TOPDIR = ../../../.. -include $(TOPDIR)/config.mk -TEST = issue19_test +TEST = clean_test include ../Makefile.inc include $(TOPDIR)/mk/test-shell.mk diff --git a/tests/xbps/xbps-rindex/clean/clean_test.sh b/tests/xbps/xbps-rindex/clean/clean_test.sh new file mode 100644 index 00000000..c407350b --- /dev/null +++ b/tests/xbps/xbps-rindex/clean/clean_test.sh @@ -0,0 +1,97 @@ +#! /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 + +noremove_head() { + atf_set "descr" "xbps-rindex(8) -c: dont removing anything test" +} + +noremove_body() { + mkdir -p some_repo pkg_A + 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 + cd .. + xbps-rindex -c some_repo + atf_check_equal $? 0 + result=$(xbps-query --repository=some_repo -s foo|wc -l) + 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 + +filesclean_head() { + atf_set "descr" "xbps-rindex(8) -c: index-files clean test" +} + +filesclean_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 + rm *.xbps + cd .. + xbps-rindex -c some_repo + atf_check_equal $? 0 + result=$(xbps-query --repository=some_repo -o \*|wc -l) + atf_check_equal ${result} 1 +} + +filesclean_cleanup() { + common_cleanup +} + +# 3rd 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 + +issue19_head() { + atf_set "descr" "xbps issue #19 (https://github.com/xtraeme/xbps/issues/19)" +} + +issue19_body() { + mkdir -p some_repo + cd some_repo + xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" . + atf_check_equal $? 0 + xbps-rindex -a *.xbps + atf_check_equal $? 0 + cd .. + rm some_repo/*.xbps + xbps-rindex -c some_repo + atf_check_equal $? 0 + result=$(xbps-query --repository=some_repo -s foo) + test -z "${result}" + 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 issue19 +} diff --git a/tests/xbps/xbps-rindex/common/Kyuafile b/tests/xbps/xbps-rindex/common/Kyuafile index d8f4c50e..2cf4d6a0 100644 --- a/tests/xbps/xbps-rindex/common/Kyuafile +++ b/tests/xbps/xbps-rindex/common/Kyuafile @@ -1,4 +1,4 @@ syntax("kyuafile", 1) test_suite("xbps-rindex") -atf_test_program{name="issue19_test"} +atf_test_program{name="clean_test"} diff --git a/tests/xbps/xbps-rindex/issue19/issue19_test.sh b/tests/xbps/xbps-rindex/issue19/issue19_test.sh deleted file mode 100755 index 51f8c5f1..00000000 --- a/tests/xbps/xbps-rindex/issue19/issue19_test.sh +++ /dev/null @@ -1,38 +0,0 @@ -#! /usr/bin/env atf-sh - -# 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 - -issue19_head() { - atf_set "descr" "xbps issue #19 (https://github.com/xtraeme/xbps/issues/19)" -} - -issue19_body() { - mkdir -p some_repo - cd some_repo - xbps-create -A noarch -n foo-1.0_1 -s "foo pkg" . - atf_check_equal $? 0 - xbps-rindex -a *.xbps - atf_check_equal $? 0 - cd .. - rm some_repo/*.xbps - xbps-rindex -c some_repo - atf_check_equal $? 0 - result=$(xbps-query --repository=some_repo -s foo) - test -z "${result}" - atf_check_equal $? 0 -} - -issue19_cleanup() { - rm -rf some_repo -} - -atf_init_test_cases() { - atf_add_test_case issue19 -}