Raphael Hertzog [2010-05-19 18:30 +0200]: > Attached is an untested patch. I'm just not sure whether the check > of pifp->valid was important. Works like charm, thanks! I'm now running dpkg git head + my filter patch + your int->bool patch, in current sid, with the current git head testsuite plus attached testsuite patch for the filtering options. The previous test case patch doesn't work since git seems to silently ignore empty directories (not just in format-patch, also in the real commit). The empty files seem to work fine (that's deliberate, they don't really need contents for the test). So please use this one for the test suite instead of the old one. The difference to the previous one is that this expects the test deb to have 14 lines in dpkg -L instead of 15 (i. e. minus the "empty/" directory). Thanks, Martin -- Martin Pitt | http://www.piware.de Ubuntu Developer (www.ubuntu.com) | Debian Developer (www.debian.org)
From 39ef93667037fcb18524b35329224bca4d5ea6ff Mon Sep 17 00:00:00 2001 From: Martin Pitt <martin.pitt@ubuntu.com> Date: Mon, 17 May 2010 19:30:55 +0200 Subject: [PATCH] Add filtering test cases. This checks the --include and --exclude options for package installation. --- t-filtering/Makefile | 101 ++++++++++++++++++++ t-filtering/pkg-somefiles/DEBIAN/control | 8 ++ 2 files changed, 109 insertions(+), 0 deletions(-) create mode 100644 t-filtering/Makefile create mode 100644 t-filtering/pkg-somefiles/DEBIAN/control create mode 100644 t-filtering/pkg-somefiles/usr/lib/pkg-somefiles/run create mode 100644 t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/README create mode 100644 t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/copyright create mode 100644 t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/html/index.html create mode 100644 t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/html/topic1/1.html diff --git a/t-filtering/Makefile b/t-filtering/Makefile new file mode 100644 index 0000000..e6c7740 --- /dev/null +++ b/t-filtering/Makefile @@ -0,0 +1,101 @@ +TESTS_DEB := pkg-somefiles + +include ../Test.mk + +test-case: test-no-filter test-no-doc-sub test-no-doc-all test-no-doc-except-copyright \ + test-no-doc-except-copyright-subdir test-no-doc-except-copyright-and-readme \ + test-include-only test-same-include-exclude test-upgrade test-help + +test-clean: + $(DPKG_PURGE) pkg-somefiles + +# no filter, should have all files +test-no-filter: + $(DPKG_INSTALL) pkg-somefiles.deb + test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = 14 + $(DPKG_PURGE) pkg-somefiles + +# filter out /usr/share/doc/*/*; this keeps the actual +# /usr/share/doc/pkg-somefiles dir around +test-no-doc-sub: + $(DPKG_INSTALL) --exclude '/usr/share/doc/*/*' pkg-somefiles.deb + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles. + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/lib/pkg-somefiles/run + $(DPKG_PURGE) pkg-somefiles + +# filter out /usr/share/doc/* +test-no-doc-all: + $(DPKG_INSTALL) --exclude '/usr/share/doc/*' pkg-somefiles.deb + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/lib/pkg-somefiles/run + $(DPKG_PURGE) pkg-somefiles + +# filter out /usr/share/doc/*/* except copyright +test-no-doc-except-copyright: + $(DPKG_INSTALL) --exclude '/usr/share/doc/*/*' --include '/usr/share/doc/*/copyright' pkg-somefiles.deb + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/copyright + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/html/index.html + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/README + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/lib/pkg-somefiles/run + $(DPKG_PURGE) pkg-somefiles + +# prune the entire doc dir; this triggers the special case that +# /usr/share/doc/pkg-somefiles is matched by the exclude, but still needs to be +# created due to the following include +test-no-doc-except-copyright-subdir: + $(DPKG_INSTALL) --exclude '/usr/share/doc/*' --include '/usr/share/doc/*/copyright' pkg-somefiles.deb + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/copyright + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/html/index.html + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/README + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/lib/pkg-somefiles/run + $(DPKG_PURGE) pkg-somefiles + +# two includes which revert an exclude, second of which matches several subdirs +# with one * +test-no-doc-except-copyright-and-readme: + $(DPKG_INSTALL) --exclude '/usr/share/doc/*' --include '/usr/share/doc/*/copyright' --include '/usr*/READ*' pkg-somefiles.deb + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/copyright + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/html/index.html + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/README + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/lib/pkg-somefiles/run + $(DPKG_PURGE) pkg-somefiles + +# only includes, should be a no-op and have all files +test-include-only: + $(DPKG_INSTALL) --include '/usr/*' --include '/usr/share/doc' --include '/usr/lib/*/*' pkg-somefiles.deb + test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = 14 + $(DPKG_PURGE) pkg-somefiles + +# include the same things than exclude, should be a no-op and have all files +test-same-include-exclude: + $(DPKG_INSTALL) --exclude '/usr/share/*' --include '/usr/share/*' pkg-somefiles.deb + test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = 14 + $(DPKG_PURGE) pkg-somefiles + + # now doubly so + $(DPKG_INSTALL) --exclude '/usr/share/*' --include '/usr/share/*' --exclude '/usr/share/*' --include '/usr/share/*' pkg-somefiles.deb + test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = 14 + $(DPKG_PURGE) pkg-somefiles + +# files are removed/re-added on upgrades +test-upgrade: + $(DPKG_INSTALL) pkg-somefiles.deb + test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = 14 + + $(DPKG_INSTALL) --exclude '/usr/share/doc/*' pkg-somefiles.deb + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles + + $(DPKG_INSTALL) --exclude '/usr/share/doc/*' --include '/usr/share/doc/*/copyright' pkg-somefiles.deb + $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/copyright + ! $(DPKG_QUERY) -L pkg-somefiles | grep -q /usr/share/doc/pkg-somefiles/README + + $(DPKG_INSTALL) pkg-somefiles.deb + test "`$(DPKG_QUERY) -L pkg-somefiles | wc -l`" = 14 + $(DPKG_PURGE) pkg-somefiles + + +# --help output explains the options +test-help: + $(DPKG) --help | grep -q -- --include + $(DPKG) --help | grep -q -- --exclude diff --git a/t-filtering/pkg-somefiles/DEBIAN/control b/t-filtering/pkg-somefiles/DEBIAN/control new file mode 100644 index 0000000..2b24276 --- /dev/null +++ b/t-filtering/pkg-somefiles/DEBIAN/control @@ -0,0 +1,8 @@ +Package: pkg-somefiles +Version: 0 +Section: test +Priority: extra +Maintainer: Guillem Jover <guillem@debian.org> +Architecture: all +Description: test package - provide some files + diff --git a/t-filtering/pkg-somefiles/usr/lib/pkg-somefiles/run b/t-filtering/pkg-somefiles/usr/lib/pkg-somefiles/run new file mode 100644 index 0000000..e69de29 diff --git a/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/README b/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/README new file mode 100644 index 0000000..e69de29 diff --git a/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/copyright b/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/copyright new file mode 100644 index 0000000..e69de29 diff --git a/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/html/index.html b/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/html/index.html new file mode 100644 index 0000000..e69de29 diff --git a/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/html/topic1/1.html b/t-filtering/pkg-somefiles/usr/share/doc/pkg-somefiles/html/topic1/1.html new file mode 100644 index 0000000..e69de29 -- 1.7.0.4
Attachment:
signature.asc
Description: Digital signature