Skip to content
Snippets Groups Projects
Commit 0c17de77 authored by Frédéric Pierret's avatar Frédéric Pierret Committed by Holger Levsen
Browse files

test_reprotest: add spaces and regorganize functions


Signed-off-by: default avatarHolger Levsen <holger@layer-acht.org>
parent 4ac84ed5
No related branches found
No related tags found
No related merge requests found
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
import contextlib import contextlib
import logging import logging
import os import os
import pytest
import subprocess import subprocess
import sys import sys
import pytest
import reprotest import reprotest
from reprotest.build import VariationSpec, Variations, VARIATIONS from reprotest.build import VariationSpec, Variations, VARIATIONS
...@@ -20,6 +20,7 @@ if REPROTEST_TEST_DONTVARY: ...@@ -20,6 +20,7 @@ if REPROTEST_TEST_DONTVARY:
TEST_VARIATIONS = frozenset(VARIATIONS.keys()) - frozenset(REPROTEST_TEST_DONTVARY) TEST_VARIATIONS = frozenset(VARIATIONS.keys()) - frozenset(REPROTEST_TEST_DONTVARY)
def check_reproducibility(command, virtual_server, reproducible): def check_reproducibility(command, virtual_server, reproducible):
result = reprotest.check( result = reprotest.check(
reprotest.TestArgs.of(command, 'tests', 'artifact'), reprotest.TestArgs.of(command, 'tests', 'artifact'),
...@@ -27,6 +28,7 @@ def check_reproducibility(command, virtual_server, reproducible): ...@@ -27,6 +28,7 @@ def check_reproducibility(command, virtual_server, reproducible):
Variations.of(VariationSpec.default(TEST_VARIATIONS))) Variations.of(VariationSpec.default(TEST_VARIATIONS)))
assert result == reproducible assert result == reproducible
def check_command_line(command_line, code=None): def check_command_line(command_line, code=None):
try: try:
retcode = 0 retcode = 0
...@@ -41,6 +43,7 @@ def check_command_line(command_line, code=None): ...@@ -41,6 +43,7 @@ def check_command_line(command_line, code=None):
else: else:
assert(retcode in code) assert(retcode in code)
@pytest.fixture(scope='module', params=REPROTEST_TEST_SERVERS) @pytest.fixture(scope='module', params=REPROTEST_TEST_SERVERS)
def virtual_server(request): def virtual_server(request):
if request.param == 'null': if request.param == 'null':
...@@ -52,11 +55,6 @@ def virtual_server(request): ...@@ -52,11 +55,6 @@ def virtual_server(request):
else: else:
raise ValueError(request.param) raise ValueError(request.param)
def test_simple_builds(virtual_server):
check_reproducibility('python3 mock_build.py', virtual_server, True)
with pytest.raises(Exception):
check_reproducibility('python3 mock_failure.py', virtual_server)
check_reproducibility('python3 mock_build.py irreproducible', virtual_server, False)
@contextlib.contextmanager @contextlib.contextmanager
def setup_logging(debug): def setup_logging(debug):
...@@ -82,6 +80,14 @@ def setup_logging(debug): ...@@ -82,6 +80,14 @@ def setup_logging(debug):
logger.removeHandler(ch) logger.removeHandler(ch)
logger.setLevel(oldLevel) logger.setLevel(oldLevel)
def test_simple_builds(virtual_server):
check_reproducibility('python3 mock_build.py', virtual_server, True)
with pytest.raises(Exception):
check_reproducibility('python3 mock_failure.py', virtual_server)
check_reproducibility('python3 mock_build.py irreproducible', virtual_server, False)
# TODO: test all variations that we support # TODO: test all variations that we support
@pytest.mark.parametrize('captures', list(VARIATIONS.keys())) @pytest.mark.parametrize('captures', list(VARIATIONS.keys()))
def test_variations(virtual_server, captures): def test_variations(virtual_server, captures):
...@@ -89,6 +95,7 @@ def test_variations(virtual_server, captures): ...@@ -89,6 +95,7 @@ def test_variations(virtual_server, captures):
with setup_logging(False): with setup_logging(False):
check_reproducibility('python3 mock_build.py ' + captures, virtual_server, expected) check_reproducibility('python3 mock_build.py ' + captures, virtual_server, expected)
@pytest.mark.need_builddeps @pytest.mark.need_builddeps
def test_self_build(virtual_server): def test_self_build(virtual_server):
# at time of writing (2016-09-23) these are not expected to reproduce; # at time of writing (2016-09-23) these are not expected to reproduce;
...@@ -98,6 +105,7 @@ def test_self_build(virtual_server): ...@@ -98,6 +105,7 @@ def test_self_build(virtual_server):
assert(1 == subprocess.call(REPROTEST + ['python3 setup.py bdist', 'dist/*.tar.gz'] + virtual_server)) assert(1 == subprocess.call(REPROTEST + ['python3 setup.py bdist', 'dist/*.tar.gz'] + virtual_server))
assert(1 == subprocess.call(REPROTEST + ['python3 setup.py sdist', 'dist/*.tar.gz'] + virtual_server)) assert(1 == subprocess.call(REPROTEST + ['python3 setup.py sdist', 'dist/*.tar.gz'] + virtual_server))
def test_command_lines(): def test_command_lines():
test_args, _, _ = check_command_line(".".split(), 0) test_args, _, _ = check_command_line(".".split(), 0)
assert test_args.artifact_pattern is not None assert test_args.artifact_pattern is not None
...@@ -128,6 +136,7 @@ def test_command_lines(): ...@@ -128,6 +136,7 @@ def test_command_lines():
_, testbed_args, _ = check_command_line(". -- schroot unstable-amd64-sbuild".split(), 0) _, testbed_args, _ = check_command_line(". -- schroot unstable-amd64-sbuild".split(), 0)
assert testbed_args.virtual_server_args == ['schroot', 'unstable-amd64-sbuild'] assert testbed_args.virtual_server_args == ['schroot', 'unstable-amd64-sbuild']
# TODO: don't call it if we don't have debian/, e.g. for other distros # TODO: don't call it if we don't have debian/, e.g. for other distros
@pytest.mark.need_builddeps @pytest.mark.need_builddeps
def test_debian_build(virtual_server): def test_debian_build(virtual_server):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment