Only run tests under Python 3, fix random bitrot
This commit is contained in:
parent
a0e0776bec
commit
46774f6068
20 changed files with 115 additions and 97 deletions
|
@ -1,8 +1,7 @@
|
|||
repos:
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v1.2.3
|
||||
rev: v2.2.3
|
||||
hooks:
|
||||
- id: autopep8-wrapper
|
||||
- id: check-added-large-files
|
||||
- id: check-docstring-first
|
||||
- id: check-executables-have-shebangs
|
||||
|
@ -16,15 +15,28 @@ repos:
|
|||
- id: name-tests-test
|
||||
- id: requirements-txt-fixer
|
||||
- id: trailing-whitespace
|
||||
- id: fix-encoding-pragma
|
||||
args: ['--remove']
|
||||
- repo: https://github.com/pre-commit/mirrors-autopep8
|
||||
rev: v1.4.4
|
||||
hooks:
|
||||
- id: autopep8
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
rev: v1.0.1
|
||||
rev: v1.6.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
args: ['--py3-plus']
|
||||
- repo: https://github.com/Lucas-C/pre-commit-hooks
|
||||
rev: v1.1.5
|
||||
rev: v1.1.6
|
||||
hooks:
|
||||
- id: remove-tabs
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v1.11.3
|
||||
rev: v1.21.0
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: ['--py3-plus']
|
||||
- repo: https://github.com/asottile/add-trailing-comma
|
||||
rev: v1.4.1
|
||||
hooks:
|
||||
- id: add-trailing-comma
|
||||
args: ['--py36-plus']
|
||||
|
|
|
@ -4,16 +4,15 @@ services:
|
|||
|
||||
matrix:
|
||||
include:
|
||||
- env: ITEST_TARGET=itest_trusty
|
||||
- env: ITEST_TARGET=itest_xenial
|
||||
- env: ITEST_TARGET=itest_bionic
|
||||
- env: ITEST_TARGET=itest_stretch
|
||||
- env: ITEST_TARGET=itest_buster
|
||||
- env: ITEST_TARGET=itest_tox
|
||||
- os: linux-ppc64le
|
||||
env: ITEST_TARGET=itest_stretch
|
||||
env: ITEST_TARGET=itest_buster
|
||||
allow_failures:
|
||||
- os: linux-ppc64le
|
||||
env: ITEST_TARGET=itest_stretch
|
||||
env: ITEST_TARGET=itest_buster
|
||||
|
||||
|
||||
script:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
FROM debian:stretch
|
||||
FROM debian:buster
|
||||
|
||||
LABEL maintainer="Chris Kuehl <ckuehl@yelp.com>"
|
||||
|
||||
|
|
7
Makefile
7
Makefile
|
@ -69,18 +69,17 @@ test:
|
|||
install-hooks:
|
||||
tox -e pre-commit -- install -f --install-hooks
|
||||
|
||||
ITEST_TARGETS = itest_trusty itest_xenial itest_bionic itest_stretch
|
||||
ITEST_TARGETS = itest_xenial itest_bionic itest_buster
|
||||
|
||||
.PHONY: itest $(ITEST_TARGETS)
|
||||
itest: $(ITEST_TARGETS)
|
||||
|
||||
itest_trusty: _itest-ubuntu-trusty
|
||||
itest_xenial: _itest-ubuntu-xenial
|
||||
itest_bionic: _itest-ubuntu-bionic
|
||||
itest_stretch: _itest-debian-stretch
|
||||
itest_buster: _itest-debian-buster
|
||||
|
||||
itest_tox:
|
||||
$(DOCKER_RUN_TEST) ubuntu:bionic /mnt/ci/docker-tox-test
|
||||
$(DOCKER_RUN_TEST) debian:buster /mnt/ci/docker-tox-test
|
||||
|
||||
_itest-%: _itest_deb-% _itest_python-%
|
||||
@true
|
||||
|
|
|
@ -7,10 +7,10 @@ apt-get update
|
|||
apt-get install -y --no-install-recommends \
|
||||
build-essential \
|
||||
procps \
|
||||
python \
|
||||
python-dev \
|
||||
python-pip \
|
||||
python-setuptools
|
||||
python3 \
|
||||
python3-dev \
|
||||
python3-pip \
|
||||
python3-setuptools
|
||||
|
||||
cp -r /mnt/ /test
|
||||
cd /test
|
||||
|
|
|
@ -4,7 +4,7 @@ set -o pipefail
|
|||
. /mnt/ci/docker
|
||||
|
||||
dpkg -i dist/*.deb
|
||||
pip install -r requirements-dev.txt
|
||||
py.test tests/
|
||||
pip3 install -r requirements-dev.txt
|
||||
pytest tests/
|
||||
|
||||
exec dumb-init /mnt/tests/test-zombies
|
||||
|
|
|
@ -3,10 +3,10 @@ set -o pipefail
|
|||
|
||||
. /mnt/ci/docker
|
||||
|
||||
python setup.py clean
|
||||
python setup.py sdist
|
||||
pip install -vv dist/*.tar.gz
|
||||
pip install -r requirements-dev.txt
|
||||
py.test tests/
|
||||
python3 setup.py clean
|
||||
python3 setup.py sdist
|
||||
pip3 install -vv dist/*.tar.gz
|
||||
pip3 install -r requirements-dev.txt
|
||||
pytest tests/
|
||||
|
||||
exec dumb-init /mnt/tests/test-zombies \
|
||||
exec dumb-init /mnt/tests/test-zombies
|
||||
|
|
|
@ -6,8 +6,7 @@ set -o pipefail
|
|||
apt-get update
|
||||
apt-get install -y --no-install-recommends \
|
||||
git \
|
||||
python2.7-dev \
|
||||
python3.6-dev \
|
||||
python3.7-dev \
|
||||
tox
|
||||
|
||||
tox
|
||||
|
|
6
debian/control
vendored
6
debian/control
vendored
|
@ -2,16 +2,14 @@ Source: dumb-init
|
|||
Section: utils
|
||||
Priority: extra
|
||||
Maintainer: Chris Kuehl <ckuehl@yelp.com>
|
||||
Uploaders: Kent Wills <rkwills@yelp.com>
|
||||
Build-Depends:
|
||||
debhelper (>= 9),
|
||||
help2man,
|
||||
musl-tools,
|
||||
## Tests:
|
||||
procps,
|
||||
python,
|
||||
python-mock,
|
||||
python-pytest,
|
||||
python3,
|
||||
python3-pytest,
|
||||
Standards-Version: 3.9.7
|
||||
Homepage: https://github.com/Yelp/dumb-init
|
||||
Vcs-Browser: https://github.com/Yelp/dumb-init
|
||||
|
|
2
debian/rules
vendored
2
debian/rules
vendored
|
@ -31,4 +31,4 @@ override_dh_builddeb:
|
|||
override_dh_auto_test:
|
||||
find . -name '*.pyc' -delete
|
||||
find . -name '__pycache__' -delete
|
||||
PATH=.:$$PATH timeout --signal=KILL 60 py.test -vv tests/
|
||||
PATH=.:$$PATH timeout --signal=KILL 60 pytest-3 -vv tests/
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
mock
|
||||
pre-commit>=0.5.0
|
||||
pytest
|
||||
pytest-timeout
|
||||
|
|
3
setup.py
3
setup.py
|
@ -58,7 +58,8 @@ class install_cexe(Command):
|
|||
# this initializes attributes based on other commands' attributes
|
||||
self.set_undefined_options('build', ('build_scripts', 'build_dir'))
|
||||
self.set_undefined_options(
|
||||
'install', ('install_scripts', 'install_dir'))
|
||||
'install', ('install_scripts', 'install_dir'),
|
||||
)
|
||||
|
||||
def run(self):
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ SUSPEND_SIGNALS = frozenset([
|
|||
NORMAL_SIGNALS = frozenset(
|
||||
set(range(1, 32)) -
|
||||
{signal.SIGKILL, signal.SIGSTOP, signal.SIGCHLD} -
|
||||
SUSPEND_SIGNALS
|
||||
SUSPEND_SIGNALS,
|
||||
)
|
||||
|
||||
|
||||
|
@ -57,7 +57,7 @@ def child_pids(pid):
|
|||
ppid = int(m.group(1))
|
||||
if ppid == pid:
|
||||
children.add(int(p.basename))
|
||||
except IOError:
|
||||
except OSError:
|
||||
# Happens when the process exits after listing it, or between
|
||||
# opening stat and reading it.
|
||||
pass
|
||||
|
|
|
@ -13,7 +13,7 @@ import time
|
|||
|
||||
|
||||
CATCHABLE_SIGNALS = frozenset(
|
||||
set(range(1, 32)) - {signal.SIGKILL, signal.SIGSTOP, signal.SIGCHLD}
|
||||
set(range(1, 32)) - {signal.SIGKILL, signal.SIGSTOP, signal.SIGCHLD},
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ def spawn_and_kill_pipeline():
|
|||
proc = Popen((
|
||||
'dumb-init',
|
||||
'sh', '-c',
|
||||
"yes 'oh, hi' | tail & yes error | tail >&2"
|
||||
"yes 'oh, hi' | tail & yes error | tail >&2",
|
||||
))
|
||||
|
||||
def assert_living_pids():
|
||||
|
@ -129,12 +129,14 @@ def test_processes_dont_receive_term_on_exit_if_no_setsid():
|
|||
os.kill(child_pid, signal.SIGKILL)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('args', [
|
||||
('/doesnotexist',),
|
||||
('--', '/doesnotexist'),
|
||||
('-c', '/doesnotexist'),
|
||||
('--single-child', '--', '/doesnotexist'),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
'args', [
|
||||
('/doesnotexist',),
|
||||
('--', '/doesnotexist'),
|
||||
('-c', '/doesnotexist'),
|
||||
('--single-child', '--', '/doesnotexist'),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures('both_debug_modes', 'both_setsid_modes')
|
||||
def test_fails_nonzero_with_bad_exec(args):
|
||||
"""If dumb-init can't exec as requested, it should exit nonzero."""
|
||||
|
|
|
@ -120,18 +120,20 @@ def test_verbose_and_single_child(flag1, flag2):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('extra_args', [
|
||||
('-r',),
|
||||
('-r', ''),
|
||||
('-r', 'herp'),
|
||||
('-r', 'herp:derp'),
|
||||
('-r', '15'),
|
||||
('-r', '15::12'),
|
||||
('-r', '15:derp'),
|
||||
('-r', '15:12', '-r'),
|
||||
('-r', '15:12', '-r', '0'),
|
||||
('-r', '15:12', '-r', '1:32'),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
'extra_args', [
|
||||
('-r',),
|
||||
('-r', ''),
|
||||
('-r', 'herp'),
|
||||
('-r', 'herp:derp'),
|
||||
('-r', '15'),
|
||||
('-r', '15::12'),
|
||||
('-r', '15:derp'),
|
||||
('-r', '15:12', '-r'),
|
||||
('-r', '15:12', '-r', '0'),
|
||||
('-r', '15:12', '-r', '1:32'),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures('both_debug_modes', 'both_setsid_modes')
|
||||
def test_rewrite_errors(extra_args):
|
||||
proc = Popen(
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import os
|
||||
from unittest import mock
|
||||
|
||||
import mock
|
||||
import pytest
|
||||
|
||||
|
||||
|
|
|
@ -16,12 +16,14 @@ def test_exit_status_regular_exit(exit_status):
|
|||
assert proc.returncode == exit_status
|
||||
|
||||
|
||||
@pytest.mark.parametrize('signal', [
|
||||
signal.SIGTERM,
|
||||
signal.SIGHUP,
|
||||
signal.SIGQUIT,
|
||||
signal.SIGKILL,
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
'signal', [
|
||||
signal.SIGTERM,
|
||||
signal.SIGHUP,
|
||||
signal.SIGQUIT,
|
||||
signal.SIGKILL,
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures('both_debug_modes', 'both_setsid_modes')
|
||||
def test_exit_status_terminated_by_signal(signal):
|
||||
"""dumb-init should exit with status 128 + signal when the child process is
|
||||
|
@ -29,8 +31,10 @@ def test_exit_status_terminated_by_signal(signal):
|
|||
"""
|
||||
# We use Python because sh is "dash" on Debian and "bash" on others.
|
||||
# https://github.com/Yelp/dumb-init/issues/115
|
||||
proc = Popen(('dumb-init', sys.executable, '-c', 'import os; os.kill(os.getpid(), {})'.format(
|
||||
signal,
|
||||
)))
|
||||
proc = Popen((
|
||||
'dumb-init', sys.executable, '-c', 'import os; os.kill(os.getpid(), {})'.format(
|
||||
signal,
|
||||
),
|
||||
))
|
||||
proc.wait()
|
||||
assert proc.returncode == 128 + signal
|
||||
|
|
|
@ -24,36 +24,38 @@ def _rewrite_map_to_args(rewrite_map):
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.parametrize('rewrite_map,sequence,expected', [
|
||||
(
|
||||
{},
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
),
|
||||
@pytest.mark.parametrize(
|
||||
'rewrite_map,sequence,expected', [
|
||||
(
|
||||
{},
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
),
|
||||
|
||||
(
|
||||
{signal.SIGTERM: signal.SIGINT},
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
[signal.SIGINT, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
),
|
||||
(
|
||||
{signal.SIGTERM: signal.SIGINT},
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
[signal.SIGINT, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
),
|
||||
|
||||
(
|
||||
{
|
||||
signal.SIGTERM: signal.SIGINT,
|
||||
signal.SIGINT: signal.SIGTERM,
|
||||
signal.SIGQUIT: signal.SIGQUIT,
|
||||
},
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
[signal.SIGINT, signal.SIGQUIT, signal.SIGCONT, signal.SIGTERM],
|
||||
),
|
||||
(
|
||||
{
|
||||
signal.SIGTERM: signal.SIGINT,
|
||||
signal.SIGINT: signal.SIGTERM,
|
||||
signal.SIGQUIT: signal.SIGQUIT,
|
||||
},
|
||||
[signal.SIGTERM, signal.SIGQUIT, signal.SIGCONT, signal.SIGINT],
|
||||
[signal.SIGINT, signal.SIGQUIT, signal.SIGCONT, signal.SIGTERM],
|
||||
),
|
||||
|
||||
# Lowest possible and highest possible signals.
|
||||
(
|
||||
{1: 31, 31: 1},
|
||||
[1, 31],
|
||||
[31, 1],
|
||||
),
|
||||
])
|
||||
# Lowest possible and highest possible signals.
|
||||
(
|
||||
{1: 31, 31: 1},
|
||||
[1, 31],
|
||||
[31, 1],
|
||||
),
|
||||
],
|
||||
)
|
||||
@pytest.mark.usefixtures('both_debug_modes', 'both_setsid_modes')
|
||||
def test_proxies_signals_with_rewrite(rewrite_map, sequence, expected):
|
||||
"""Ensure dumb-init can rewrite signals."""
|
||||
|
|
7
tox.ini
7
tox.ini
|
@ -1,20 +1,21 @@
|
|||
[tox]
|
||||
envlist = py27,py36,gcov
|
||||
envlist = py37,gcov
|
||||
|
||||
[testenv]
|
||||
deps = -r{toxinidir}/requirements-dev.txt
|
||||
commands =
|
||||
python -m pytest
|
||||
pytest
|
||||
|
||||
[testenv:gcov]
|
||||
skip_install = True
|
||||
basepython = /usr/bin/python3.7
|
||||
commands =
|
||||
{toxinidir}/ci/gcov-build {envbindir}
|
||||
{[testenv]commands}
|
||||
{toxinidir}/ci/gcov-report
|
||||
|
||||
[testenv:pre-commit]
|
||||
basepython = /usr/bin/python3.6
|
||||
basepython = /usr/bin/python3.7
|
||||
commands = pre-commit {posargs:run --all-files}
|
||||
|
||||
[flake8]
|
||||
|
|
Loading…
Reference in a new issue