Commit 28937c1e authored by Ximin Luo's avatar Ximin Luo

hey dawg i herd u liek tests so i put some tests in ur tests so u can test while u test

parent 2ea325f2
......@@ -6,8 +6,15 @@ Priority: optional
Standards-Version: 3.9.8
Build-Depends: debhelper (>= 9),
dh-python,
python3-all,
python3-all,
python3-setuptools,
# tests.py uses debuild from devscripts
devscripts <!nocheck>,
# test this variation as well
disorderfs <!nocheck>,
python3-coverage <!nocheck>,
python3-pytest <!nocheck>,
tox <!nocheck>
Vcs-Git: https://anonscm.debian.org/git/reproducible/reprotest.git
Vcs-Browser: https://anonscm.debian.org/git/reproducible/reprotest.git
X-Python3-Version: >= 3.5
......
......@@ -5,3 +5,8 @@ export PYBUILD_NAME = reprotest
%:
dh $@ --with python3 --buildsystem=pybuild
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
REPROTEST_TEST_SERVERS=null tox -- -s
endif
......@@ -359,13 +359,17 @@ def check(build_command, artifact_pattern, virtual_server_args, source_root,
except Exception:
traceback.print_exc()
return 2
subprocess.check_call(['diffoscope', result.control, result.experiment])
print("=======================")
print("Reproduction successful")
print("=======================")
print("No differences in %s" % artifact_pattern)
subprocess.call(['find', '.', '-type', 'f', '-exec', 'sha256sum', '{}', ';'], cwd=result.control)
return 0
retcode = subprocess.call(['diffoscope', result.control, result.experiment])
if retcode == 0:
print("=======================")
print("Reproduction successful")
print("=======================")
print("No differences in %s" % artifact_pattern)
subprocess.call(['find', '.', '-type', 'f', '-exec', 'sha256sum', '{}', ';'], cwd=result.control)
else:
# a slight hack, to trigger no_clean_on_error
raise SystemExit(retcode)
return retcode
COMMAND_LINE_OPTIONS = types.MappingProxyType(collections.OrderedDict([
......
......@@ -13,11 +13,13 @@ VERSION = pkg_resources.require('reprotest')[0].version
def check_return_code(command, virtual_server, code):
try:
reprotest.check(command, 'artifact', virtual_server, 'tests')
retcode = reprotest.check(command, 'artifact', virtual_server, 'tests')
assert(code == retcode)
except SystemExit as system_exit:
assert(system_exit.args[0] == code)
@pytest.fixture(scope='module', params=['null' , 'qemu', 'schroot'])
REPROTEST_TEST_SERVERS = os.getenv("REPROTEST_TEST_SERVERS", "null,qemu,schroot").split(",")
@pytest.fixture(scope='module', params=REPROTEST_TEST_SERVERS)
def virtual_server(request):
if request.param == 'null':
return [request.param]
......@@ -39,9 +41,16 @@ def test_variations(virtual_server, variation):
def test_self_build(virtual_server):
assert(subprocess.call(['reprotest', 'python3 setup.py bdist', 'dist/reprotest-' + VERSION + '.linux-x86_64.tar.gz'] + virtual_server) == 1)
# setup.py complains there's no README.rst, README, or README.txt.
# Why that's hard-coded, I have no idea. This command eats the
# error so the build doesn't crash.
assert(subprocess.call(['reprotest', 'python3 setup.py sdist 2>/dev/null', 'dist/reprotest-' + VERSION + '.tar.gz'] + virtual_server) == 1)
assert(subprocess.call(['reprotest', 'python3 setup.py bdist_wheel', 'dist/reprotest-' + VERSION + '-py3-none-any.whl'] + virtual_server) == 1)
assert(subprocess.call(['reprotest', 'debuild -b -uc -us', '../reprotest_' + VERSION + '_all.deb'] + virtual_server) == 1)
# at time of writing (2016-09-23) these are not expected to reproduce;
# strip-nondeterminism normalises them for Debian
assert(1 == subprocess.call(['reprotest', 'python3 setup.py sdist 2>/dev/null', 'dist/*.tar.gz'] + virtual_server))
assert(1 == subprocess.call(['reprotest', 'python3 setup.py bdist_wheel', 'dist/*.whl'] + virtual_server))
# This is a bit dirty though it works - when building the debian package,
# debian/rules will call this, which will call debian/rules, so ../*.deb
# gets written twice and the second one is the "real" one, but since it
# should all be reproducible, this should be OK.
# TODO: don't call it if we don't have debian/, e.g. for other distros
assert(0 == subprocess.call(
['reprotest', 'debuild -b -uc -us', '../*.deb'] + virtual_server,
# "nocheck" to stop tests recursing into themselves
env=dict(list(os.environ.items()) + [("DEB_BUILD_OPTIONS", "nocheck")])))
......@@ -15,6 +15,7 @@ commands =
coverage html
[testenv]
passenv = REPROTEST_TEST_SERVERS
# usedevelop = True
deps =
coverage
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment