[Piuparts-commits] [piuparts] 06/08: p: is_installable_* may skip&fail a test

Holger Levsen holger at layer-acht.org
Sat Aug 5 17:55:28 UTC 2017


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

holger pushed a commit to branch develop
in repository piuparts.

commit df2adf7a46a9300c61c315ca749e41e63daf0d71
Author: Andreas Beckmann <anbe at debian.org>
Date:   Sat Aug 5 04:54:51 2017 +0200

    p: is_installable_* may skip&fail a test
    
    Signed-off-by: Andreas Beckmann <anbe at debian.org>
    Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
 README.txt                                       |  7 +++++--
 custom-scripts/scripts/is_testable_uninstallable |  6 ++++++
 debian/changelog                                 |  6 +++++-
 piuparts.py                                      | 22 +++++++++++++++++-----
 4 files changed, 33 insertions(+), 8 deletions(-)

diff --git a/README.txt b/README.txt
index 225a66d..fa6dc47 100644
--- a/README.txt
+++ b/README.txt
@@ -224,11 +224,14 @@ the chroot was recorded for later comparison.
 
 'is_testable_' - before *installing* your package. If this script
 returns a non-zero return value, the installation of the package
-will be skipped, but the test will be reported as successful.
+will be skipped. With a return value of 1 the test will be reported
+as successful, but with a return value if 2 it will be reported as
+failed.
 Use this to flag packages that cannot be be tested with piuparts
 by design (e.g. usrmerge), require not publicly available external
 ressources (e.g. some downloader packages) or are broken beyond
-repair (e.g. buggy packages in archived releases).
+repair (e.g. buggy packages in archived releases). Use the return
+value of 2 for seriously broken packages that can break piuparts.
 
 'pre_install_' - before *installing* your package. Depending on
 the test, this may be run multiple times. The PIUPARTS_TEST and
diff --git a/custom-scripts/scripts/is_testable_uninstallable b/custom-scripts/scripts/is_testable_uninstallable
index 42db116..191d451 100755
--- a/custom-scripts/scripts/is_testable_uninstallable
+++ b/custom-scripts/scripts/is_testable_uninstallable
@@ -16,6 +16,12 @@ skip_test()
 	exit 1
 }
 
+fail_test()
+{
+	echo "Failing piuparts test: $*"
+	exit 2
+}
+
 skip_always()
 {
 	skip_test "$@"
diff --git a/debian/changelog b/debian/changelog
index 1c110ba..8ef41d7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,10 @@ piuparts (0.79) UNRELEASED; urgency=medium
     - Do not ignore errors while purging packages.
     - Add post_test_* custom scripts. These are run exactly once at the end
       of each test (before comparing with the reference chroot state).
+    - is_testable_* custom scripts can use return value '2' to make a test
+      fail without actually installing the package. Use for (unfixable)
+      packages that would fail anyway, but are resource hogs or otherwise
+      break piuparts.
     - Silence diff_meta_data() for "others" for --warn-on-others.
   * piuparts.conf:
     - Use relative expiration ages.
@@ -330,7 +334,7 @@ piuparts (0.74) unstable; urgency=medium
   * piuparts.py:
     - Add to ignored_files:
       + /etc/modprobe.d/
-    - Add new class of is_testable_* custom scripts: A non-zero return value
+    - Add new class of is_testable_* custom scripts: A return value of '1'
       makes the test succeed without actually installing the package. Use for
       packages that cannot be tested with piuparts by design or are broken in
       an unfixable way.  (Closes: #682739)
diff --git a/piuparts.py b/piuparts.py
index b6f3240..21a5d7d 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -2744,10 +2744,17 @@ def install_and_upgrade_between_distros(package_files, packages_qualified):
 
     chroot.check_for_no_processes(fail=True)
 
-    if chroot.run_scripts("is_testable", ignore_errors=True) != 0:
-        logging.info("SKIP: All tests. Package cannot be tested with piuparts: %s.", " ".join(packages))
+    cannot_test = chroot.run_scripts("is_testable", ignore_errors=True)
+    if cannot_test != 0:
+        if cannot_test & 2:
+            logging.info("FAIL: All tests. Package cannot be tested with piuparts: %s.", " ".join(packages))
+            retval = False
+        else:
+            logging.info("SKIP: All tests. Package cannot be tested with piuparts: %s.", " ".join(packages))
+            retval = True
+        testable = False
         chroot.remove()
-        return True
+        return retval
 
     if settings.shell_on_error:
         panic_handler_id = do_on_panic(lambda: chroot.interactive_shell())
@@ -3324,9 +3331,14 @@ def process_packages(package_list):
         chroot_state = chroot.get_state_meta_data()
 
         testable = True
-        if chroot.run_scripts("is_testable", ignore_errors=True) != 0:
-            logging.info("SKIP: All tests. Package cannot be tested with piuparts: %s.", " ".join(packages))
+        cannot_test = chroot.run_scripts("is_testable", ignore_errors=True)
+        if cannot_test != 0:
             testable = False
+            if cannot_test & 2:
+                logging.info("FAIL: All tests. Package cannot be tested with piuparts: %s.", " ".join(packages))
+                panic()
+            else:
+                logging.info("SKIP: All tests. Package cannot be tested with piuparts: %s.", " ".join(packages))
 
         if testable and not settings.no_install_purge_test:
             extra_packages = chroot.get_known_packages(settings.extra_old_packages)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/piuparts/piuparts.git



More information about the Piuparts-commits mailing list