This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=395c655fc1765a31fb828ef3c085f51ae4592e36

commit 395c655fc1765a31fb828ef3c085f51ae4592e36
Author: Guillem Jover <guil...@debian.org>
AuthorDate: Thu May 11 00:29:22 2023 +0200

    test: Add cases for disappearing with diversions
---
 tests/Makefile                                     |  1 +
 tests/t-disappear-diverted/Makefile                | 58 ++++++++++++++++++++++
 .../pkg-disappear/DEBIAN/control                   |  0
 .../pkg-disappear/test-dir/test-normal             |  0
 .../pkg-divert}/DEBIAN/control                     |  5 +-
 .../t-disappear-diverted/pkg-divert/DEBIAN/postrm  |  8 +++
 .../t-disappear-diverted/pkg-divert/DEBIAN/preinst |  8 +++
 .../pkg-divert}/test-dir/test-normal               |  0
 .../pkg-normal/DEBIAN/control                      |  0
 .../pkg-normal}/test-dir/test-normal               |  0
 10 files changed, 77 insertions(+), 3 deletions(-)

diff --git a/tests/Makefile b/tests/Makefile
index 949baa62c..3240e8c87 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -47,6 +47,7 @@ TESTS_PASS += t-dir-leftover-parents
 TESTS_PASS += t-dir-leftover-conffile
 TESTS_PASS += t-disappear
 TESTS_PASS += t-disappear-depended
+TESTS_PASS += t-disappear-diverted
 TESTS_PASS += t-disappear-empty
 TESTS_PASS += t-provides
 TESTS_PASS += t-provides-self
diff --git a/tests/t-disappear-diverted/Makefile 
b/tests/t-disappear-diverted/Makefile
new file mode 100644
index 000000000..9fd88ea8e
--- /dev/null
+++ b/tests/t-disappear-diverted/Makefile
@@ -0,0 +1,58 @@
+TESTS_DEB := pkg-normal pkg-divert pkg-disappear
+
+include ../Test.mk
+
+test-case:
+       # Test not disappearing diverted package.
+       $(DPKG_INSTALL) pkg-disappear.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_INSTALL) pkg-divert.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       # Should not disappear while it's being diverted.
+       $(call pkg_is_installed,pkg-disappear)
+       $(DPKG_PURGE) pkg-divert
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_PURGE) pkg-disappear
+       :
+       # Test disappearing package not being diverted.
+       $(DPKG_INSTALL) pkg-disappear.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_INSTALL) pkg-normal.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       # Should have been disappered now.
+       $(call pkg_is_not_installed,pkg-disappear)
+       $(DPKG_PURGE) pkg-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_PURGE) pkg-disappear
+       :
+       # Test disappearing package diverted but replaced by a 3rd package.
+       $(DPKG_INSTALL) pkg-disappear.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_INSTALL) pkg-divert.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_INSTALL) pkg-normal.deb
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       # Should have been disappered now, as it is diverted by a 3rd package.
+       $(call pkg_is_not_installed,pkg-disappear)
+       $(DPKG_PURGE) pkg-normal
+       test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_PURGE) pkg-divert
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal
+       ! test -e $(DPKG_INSTDIR)/test-dir/test-normal.distrib
+       $(DPKG_PURGE) pkg-disappear
+
+test-clean:
+       $(DPKG_PURGE) pkg-divert
+       $(DPKG_PURGE) pkg-disappear
+       $(DPKG_PURGE) pkg-normal
+
diff --git a/tests/t-disappear-depended/pkg-disappear/DEBIAN/control 
b/tests/t-disappear-diverted/pkg-disappear/DEBIAN/control
similarity index 100%
copy from tests/t-disappear-depended/pkg-disappear/DEBIAN/control
copy to tests/t-disappear-diverted/pkg-disappear/DEBIAN/control
diff --git a/tests/t-disappear-depended/pkg-disappear/test-dir/test-normal 
b/tests/t-disappear-diverted/pkg-disappear/test-dir/test-normal
similarity index 100%
copy from tests/t-disappear-depended/pkg-disappear/test-dir/test-normal
copy to tests/t-disappear-diverted/pkg-disappear/test-dir/test-normal
diff --git a/tests/t-disappear-empty/pkg-normal/DEBIAN/control 
b/tests/t-disappear-diverted/pkg-divert/DEBIAN/control
similarity index 65%
copy from tests/t-disappear-empty/pkg-normal/DEBIAN/control
copy to tests/t-disappear-diverted/pkg-divert/DEBIAN/control
index 4e2f9a3cc..42515eb7b 100644
--- a/tests/t-disappear-empty/pkg-normal/DEBIAN/control
+++ b/tests/t-disappear-diverted/pkg-divert/DEBIAN/control
@@ -1,10 +1,9 @@
-Package: pkg-normal
+Package: pkg-divert
 Version: 0.0-1
 Section: test
 Priority: extra
 Maintainer: Dpkg Developers <debian-d...@lists.debian.org>
 Architecture: all
 Replaces: pkg-disappear
-Provides: pkg-disappear
-Description: test package - normal
+Description: test package - divert on disappearing package
 
diff --git a/tests/t-disappear-diverted/pkg-divert/DEBIAN/postrm 
b/tests/t-disappear-diverted/pkg-divert/DEBIAN/postrm
new file mode 100755
index 000000000..3787c6627
--- /dev/null
+++ b/tests/t-disappear-diverted/pkg-divert/DEBIAN/postrm
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "purge" ] || [ "$1" = "disappear" ]; then
+  dpkg-divert --rename --remove /test-dir/test-normal
+fi
+
diff --git a/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst 
b/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst
new file mode 100755
index 000000000..898c3c50c
--- /dev/null
+++ b/tests/t-disappear-diverted/pkg-divert/DEBIAN/preinst
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+set -e
+
+if [ "$1" = "install" ] || [ "$1" = "upgrade" ]; then
+  dpkg-divert --rename --add /test-dir/test-normal
+fi
+
diff --git a/tests/t-disappear-depended/pkg-disappear/test-dir/test-normal 
b/tests/t-disappear-diverted/pkg-divert/test-dir/test-normal
similarity index 100%
copy from tests/t-disappear-depended/pkg-disappear/test-dir/test-normal
copy to tests/t-disappear-diverted/pkg-divert/test-dir/test-normal
diff --git a/tests/t-disappear-depended/pkg-normal/DEBIAN/control 
b/tests/t-disappear-diverted/pkg-normal/DEBIAN/control
similarity index 100%
copy from tests/t-disappear-depended/pkg-normal/DEBIAN/control
copy to tests/t-disappear-diverted/pkg-normal/DEBIAN/control
diff --git a/tests/t-disappear-depended/pkg-disappear/test-dir/test-normal 
b/tests/t-disappear-diverted/pkg-normal/test-dir/test-normal
similarity index 100%
copy from tests/t-disappear-depended/pkg-disappear/test-dir/test-normal
copy to tests/t-disappear-diverted/pkg-normal/test-dir/test-normal

-- 
Dpkg.Org's dpkg

Reply via email to