summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2024-01-03 13:53:09 +0000
committerDavid Kalnischkies <david@kalnischkies.de>2024-01-03 13:53:09 +0000
commitc82f96210eb62c92d31ded7073f4cf5371cc9485 (patch)
treeb0ba92b152c2dae076a8f0d811af287084878a89 /test
parentc555d8f1ae31d1f511bf811640423231b75a8e13 (diff)
Improve and test distclean implementation
The implementation as-is as various smaller/esoteric bugs and inconsistencies like apt-get not supporting them, the option -s being supported in code but not accepted on the command line, the regex not escaping the dot before the file extension and exposing more implementation details to public headers than we actually need. Also comes with a small test case to ensure it actually works. References: bd7c126e3fb1b94e76e0e632c657cea854586844
Diffstat (limited to 'test')
-rwxr-xr-xtest/integration/test-apt-get-clean40
1 files changed, 36 insertions, 4 deletions
diff --git a/test/integration/test-apt-get-clean b/test/integration/test-apt-get-clean
index d05073218..32dd3e852 100755
--- a/test/integration/test-apt-get-clean
+++ b/test/integration/test-apt-get-clean
@@ -13,13 +13,27 @@ insertpackage 'experimental' 'foo' 'all' '1:1'
insertinstalledpackage 'foo' 'all' '3'
setupaptarchive --no-update
+mkdir -p rootdir/var/lib/apt/lists/partial
+testsuccess test -d rootdir/var/lib/apt/lists/partial
+
+# nothing to do always works (part 1)
+for cmd in aptget apt; do
+ for sub in distclean dist-clean; do
+ testsuccess $cmd $sub
+ testsuccess $cmd $sub -s
+ done
+done
+testsuccess test -d rootdir/var/lib/apt/lists/partial
-mkdir -p rootdir/var/lib/apt/lists/lost+found
testsuccess apt update
-# nothing to do always works
-testsuccess aptget clean
-testsuccess aptget clean -s
+# nothing to do always works (part 2)
+for cmd in aptget apt; do
+ for sub in clean autoclean auto-clean; do
+ testsuccess $cmd $sub
+ testsuccess $cmd $sub -s
+ done
+done
# generate some dirt and clean it up
generatedirt() {
@@ -63,6 +77,23 @@ if [ "$(id -u)" != '0' ]; then
chmod 644 rootdir/var/cache/apt/archives/lock
fi
+msgmsg 'distclean'
+listcurrentlistsdirectory > aptdistclean.before
+testsuccessequal '3' grep -c -e 'Release$' aptdistclean.before
+testsuccess grep -e 'Packages$' -e 'Sources$' -e 'Translation-*$' aptdistclean.before
+testsuccess apt distclean
+listcurrentlistsdirectory > aptdistclean.after
+testfailure cmp aptdistclean.before aptdistclean.after
+testsuccessequal '3' grep -c -e 'Release$' aptdistclean.after
+testfailureequal '0' grep -c -e 'Packages$' -e 'Sources$' -e 'Translation-*$' aptdistclean.after
+for dirt in Packages.gz Sources.xz Release2gpg Release_Packages; do
+ touch "rootdir/var/lib/apt/lists/_foo_bar_$dirt"
+done
+listcurrentlistsdirectory > aptdistclean.before
+testsuccess apt distclean
+listcurrentlistsdirectory > aptdistclean.cleaned
+testsuccess cmp aptdistclean.after aptdistclean.cleaned
+
directorygone() {
rm -rf "$1"
testsuccess apt autoclean
@@ -86,3 +117,4 @@ directorygone 'rootdir/var/lib/apt/lists'
msgmsg 'apt directory missing'
directorygone 'rootdir/var/cache/apt'
directorygone 'rootdir/var/lib/apt'
+