[reprotest] 02/02: hey dawg i herd u liek tests so i put some tests in ur tests so u can test while u test

Ximin Luo infinity0 at debian.org
Fri Sep 23 10:02:39 UTC 2016


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository reprotest.

commit 28937c1e6d7482c81a329e8fb6f195bd761e1773
Author: Ximin Luo <infinity0 at debian.org>
Date:   Fri Sep 23 11:57:42 2016 +0200

    hey dawg i herd u liek tests so i put some tests in ur tests so u can test while u test
---
 debian/control        |  9 ++++++++-
 debian/rules          |  5 +++++
 reprotest/__init__.py | 18 +++++++++++-------
 tests/tests.py        | 25 +++++++++++++++++--------
 tox.ini               |  1 +
 5 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/debian/control b/debian/control
index 39cb1c3..9e1b126 100644
--- a/debian/control
+++ b/debian/control
@@ -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
diff --git a/debian/rules b/debian/rules
index e584856..dbd3719 100755
--- a/debian/rules
+++ b/debian/rules
@@ -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
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index c81a580..a712f44 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -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([
diff --git a/tests/tests.py b/tests/tests.py
index f8d85ca..bde054f 100755
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -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)
 
- at pytest.fixture(scope='module', params=['null' , 'qemu', 'schroot'])
+REPROTEST_TEST_SERVERS = os.getenv("REPROTEST_TEST_SERVERS", "null,qemu,schroot").split(",")
+ at 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")])))
diff --git a/tox.ini b/tox.ini
index 340b8fa..d8e2356 100644
--- a/tox.ini
+++ b/tox.ini
@@ -15,6 +15,7 @@ commands =
   coverage html
 
 [testenv]
+passenv = REPROTEST_TEST_SERVERS
 # usedevelop = True
 deps =
   coverage

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/reprotest.git



More information about the Reproducible-commits mailing list