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