[Piuparts-devel] [Git][debian/piuparts][develop] 6 commits: Run autopkgtest on all supported Python versions
Nicolas Dandrimont (@olasd)
gitlab at salsa.debian.org
Tue May 14 13:17:19 BST 2024
Nicolas Dandrimont pushed to branch develop at Debian / piuparts
Commits:
160354cc by Nicolas Dandrimont at 2024-05-14T13:21:38+02:00
Run autopkgtest on all supported Python versions
- - - - -
f6216a2f by Nicolas Dandrimont at 2024-05-14T13:24:42+02:00
Add more tar ignore patterns to debian/source/options
- - - - -
958c35ab by Nicolas Dandrimont at 2024-05-14T13:24:58+02:00
Remove use of deprecated configparser.SafeConfigParser
This was deprecated back in 3.2 and finally got removed in 3.12.
Closes: #1067938
- - - - -
38f61053 by Nicolas Dandrimont at 2024-05-14T13:24:58+02:00
d/t/all-python-versions: turn on the CPython dev mode
This should enable all warnings
- - - - -
663e4c40 by Nicolas Dandrimont at 2024-05-14T13:24:58+02:00
run(): ensure that fds are properly closed under all circumstances
This removes a ResourceWarning in dev mode
- - - - -
36cca1b2 by Nicolas Dandrimont at 2024-05-14T12:16:41+00:00
Merge branch 'mr/python3.12' into 'develop'
python 3.12 support
See merge request debian/piuparts!59
- - - - -
7 changed files:
- debian/source/options
- + debian/tests/all-python-versions
- + debian/tests/common.sh
- debian/tests/control
- debian/tests/smoke-test
- piuparts.py
- piupartslib/conf.py
Changes:
=====================================
debian/source/options
=====================================
@@ -1 +1 @@
-tar-ignore = .git
+tar-ignore = .git,.tox,.mypy_cache,__pycache__
=====================================
debian/tests/all-python-versions
=====================================
@@ -0,0 +1,19 @@
+#!/bin/sh
+
+set -eu
+
+. "$(dirname "$0")/common.sh"
+
+echo running "$0"
+
+test_this piuparts --version
+
+cd "$AUTOPKGTEST_TMP"
+
+create_packages
+
+for pyvers in $(py3versions -vi); do
+ test_this "python$pyvers" -X dev /usr/sbin/piuparts t.deb
+done
+
+exit 0
=====================================
debian/tests/common.sh
=====================================
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+set -e
+
+test_this() {
+ echo
+ echo "running $@"
+ $@
+}
+
+create_packages () {
+ # set up a very simple test package
+
+ mkdir -p t/DEBIAN t/usr t/etc
+ cat >t/DEBIAN/control <<EOF
+Package: t
+Version: 4
+Maintainer: Piu Parts <piuparts-devel at alioth-lists.debian.net>
+Priority: optional
+Architecture: all
+Installed-Size: 0
+Description: Auto Package Test Dummy
+ Extremely simple binary package for piuparts testing
+EOF
+
+ dpkg-deb -b t
+
+ rm -r t/
+
+ # another simple package, but set up for failure
+
+ mkdir -p f/DEBIAN f/usr f/etc
+ cat >f/DEBIAN/control <<EOF
+Package: f
+Version: 4
+Maintainer: Piu Parts <piuparts-devel at alioth-lists.debian.net>
+Priority: optional
+Architecture: all
+Installed-Size: 0
+Description: Auto Package Test Fail Dummy
+ Extremely simple binary package for piuparts testing - fail version
+EOF
+
+ cat >f/DEBIAN/postinst <<EOF
+#! /bin/sh
+mkdir -p /etc/f/
+touch /etc/f/ailure
+EOF
+
+ chmod +x f/DEBIAN/postinst
+
+ dpkg-deb -b f
+
+ rm -r f/
+}
=====================================
debian/tests/control
=====================================
@@ -1,3 +1,7 @@
Tests: smoke-test
-Depends: @
+Depends: piuparts
+Restrictions: needs-root
+
+Tests: all-python-versions
+Depends: piuparts, python3-all
Restrictions: needs-root
=====================================
debian/tests/smoke-test
=====================================
@@ -1,66 +1,20 @@
#!/bin/sh
-set -e
+set -eu
-echo running $0
+. "$(dirname "$0")/common.sh"
-test_this() {
- echo
- echo "running $@"
- $@
-}
+echo running "$0"
test_this piuparts --version
-WORKDIR=$(mktemp -d)
-trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
-cd $WORKDIR
+cd "$AUTOPKGTEST_TMP"
-
-# set up a very simple test package
-
-mkdir -p t/DEBIAN t/usr t/etc
-cat >t/DEBIAN/control <<EOF
-Package: t
-Version: 4
-Maintainer: Piu Parts <piuparts-devel at alioth-lists.debian.net>
-Priority: optional
-Architecture: all
-Installed-Size: 0
-Description: Auto Package Test Dummy
- Extremely simple binary package for piuparts testing
-EOF
-
-dpkg-deb -b t
+create_packages
# this should always succeed
test_this piuparts t.deb
-
-# another simple package, but set up for failure
-
-mkdir -p f/DEBIAN f/usr f/etc
-cat >f/DEBIAN/control <<EOF
-Package: f
-Version: 4
-Maintainer: Piu Parts <piuparts-devel at alioth-lists.debian.net>
-Priority: optional
-Architecture: all
-Installed-Size: 0
-Description: Auto Package Test Fail Dummy
- Extremely simple binary package for piuparts testing - fail version
-EOF
-
-cat >f/DEBIAN/postinst <<EOF
-#! /bin/sh
-mkdir -p /etc/f/
-touch /etc/f/ailure
-EOF
-
-chmod +x f/DEBIAN/postinst
-
-dpkg-deb -b f
-
# it is an error if this succeeds
test_this piuparts f.deb && false
=====================================
piuparts.py
=====================================
@@ -49,6 +49,7 @@ import time
import traceback
import uuid
from collections import namedtuple
+from contextlib import ExitStack
from signal import SIGALRM, SIGKILL, SIGTERM, alarm, signal
from typing import Dict
@@ -549,59 +550,62 @@ def run(command, ignore_errors=False, timeout=0):
p.kill()
p.wait()
- assert isinstance(command, type([]))
+ assert isinstance(command, list)
logging.debug("Starting command: %s" % command)
env = get_clean_environment()
- devnull = open("/dev/null", "r")
- p = subprocess.Popen(
- command,
- env=env,
- stdin=devnull,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT,
- universal_newlines=True,
- errors="backslashreplace",
- )
- output = ""
- excessive_output = False
- if timeout > 0:
- signal(SIGALRM, alarm_handler)
- alarm(timeout)
- try:
- while p.poll() is None:
- """Read 64 KB chunks, but depending on the output buffering behavior
- of the command we may get less even if more output is coming later.
- Abort after reading max_command_output_size bytes."""
- output += p.stdout.read(1 << 16)
- if len(output) > settings.max_command_output_size:
- excessive_output = True
- ignore_errors = False
- alarm(0)
- kill_subprocess(p, "excessive output")
- output += "\n\n***** Command was terminated after exceeding output limit (%.2f MB) *****\n" % (
- settings.max_command_output_size / 1024.0 / 1024.0
- )
- break
- if not excessive_output:
- output += p.stdout.read(settings.max_command_output_size)
- alarm(0)
- except Alarm:
- ignore_errors = False
- kill_subprocess(p, "excessive runtime")
- output += "\n\n***** Command was terminated after exceeding runtime limit (%s s) *****\n" % timeout
- devnull.close()
-
- if output:
- dump("\n" + indent_string(output.rstrip("\n")))
-
- if p.returncode == 0:
- logging.debug("Command ok: %s" % repr(command))
- elif ignore_errors:
- logging.debug("Command failed (status=%d), but ignoring error: %s" % (p.returncode, repr(command)))
- else:
- logging.error("Command failed (status=%d): %s\n%s" % (p.returncode, repr(command), indent_string(output)))
- panic()
- return p.returncode, output
+ with ExitStack() as s:
+ devnull = s.enter_context(open("/dev/null", "r"))
+
+ p = s.enter_context(
+ subprocess.Popen(
+ command,
+ env=env,
+ stdin=devnull,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.STDOUT,
+ universal_newlines=True,
+ errors="backslashreplace",
+ )
+ )
+ output = ""
+ excessive_output = False
+ if timeout > 0:
+ signal(SIGALRM, alarm_handler)
+ alarm(timeout)
+ try:
+ while p.poll() is None:
+ """Read 64 KB chunks, but depending on the output buffering behavior
+ of the command we may get less even if more output is coming later.
+ Abort after reading max_command_output_size bytes."""
+ output += p.stdout.read(1 << 16)
+ if len(output) > settings.max_command_output_size:
+ excessive_output = True
+ ignore_errors = False
+ alarm(0)
+ kill_subprocess(p, "excessive output")
+ output += "\n\n***** Command was terminated after exceeding output limit (%.2f MB) *****\n" % (
+ settings.max_command_output_size / 1024.0 / 1024.0
+ )
+ break
+ if not excessive_output:
+ output += p.stdout.read(settings.max_command_output_size)
+ alarm(0)
+ except Alarm:
+ ignore_errors = False
+ kill_subprocess(p, "excessive runtime")
+ output += "\n\n***** Command was terminated after exceeding runtime limit (%s s) *****\n" % timeout
+
+ if output:
+ dump("\n" + indent_string(output.rstrip("\n")))
+
+ if p.returncode == 0:
+ logging.debug("Command ok: %s" % repr(command))
+ elif ignore_errors:
+ logging.debug("Command failed (status=%d), but ignoring error: %s" % (p.returncode, repr(command)))
+ else:
+ logging.error("Command failed (status=%d): %s\n%s" % (p.returncode, repr(command), indent_string(output)))
+ panic()
+ return p.returncode, output
def create_temp_file():
=====================================
piupartslib/conf.py
=====================================
@@ -156,7 +156,7 @@ class DistroConfig(UserDict):
"depends": None,
"candidates": None,
}
- cp = configparser.SafeConfigParser()
+ cp = configparser.ConfigParser()
cp.read(filename)
for section in cp.sections():
self[section] = dict(self._defaults)
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/e41cb827c25fe366a26cea286787c748c23fec1a...36cca1b20e1a11f29ea7125fd6ad5d48395728e1
--
View it on GitLab: https://salsa.debian.org/debian/piuparts/-/compare/e41cb827c25fe366a26cea286787c748c23fec1a...36cca1b20e1a11f29ea7125fd6ad5d48395728e1
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/piuparts-devel/attachments/20240514/16d192f9/attachment-0001.htm>
More information about the Piuparts-devel
mailing list