[Reproducible-commits] [reprotest] 01/01: Add tests that run reprotest on itself

Ceridwen ceridwen-guest at moszumanska.debian.org
Sun Jun 12 04:00:38 UTC 2016


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

ceridwen-guest pushed a commit to branch master
in repository reprotest.

commit 1008ce063e8119c55f1691ac926e4445faaf0128
Author: Ceridwen <ceridwenv at gmail.com>
Date:   Sun Jun 12 00:00:28 2016 -0400

    Add tests that run reprotest on itself
---
 debian/changelog      |  6 ++++--
 debian/control        |  4 +++-
 reprotest/__init__.py | 37 +++++++++++++++++++++++++------------
 tests/tests.py        |  5 +++++
 tox.ini               |  2 +-
 5 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 856726e..0bd3795 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,5 @@
-reprotest (0.1) wily; urgency=low
+reprotest (0.1) wily; urgency=medium
+
   * Initial release.
-  -- Ceridwen <ceridwenv at gmail.com>  Sat, 11 Jun 2016 17:16:20 -0400
+
+ -- Ceridwen <ceridwenv at gmail.com>  Sat, 11 Jun 2016 18:05:05 -0400
diff --git a/debian/control b/debian/control
index a6cb2fa..a45ee85 100644
--- a/debian/control
+++ b/debian/control
@@ -14,12 +14,14 @@ X-Python3-Version: >= 3.3
 
 Package: reprotest
 Architecture: all
-Depends: python3,
+Depends: ${python3:Depends},
  python3-debian,
  apt-utils,
  libdpkg-perl,
  procps,
+ diffoscope,
  ${misc:Depends}
 Recommends: autodep8
 Suggests: schroot, lxc, lxd-client, qemu-system, qemu-utils
 Description: Build packages and check them for reproducibility.
+ Nothing to see here.
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index c8f5409..9dce97a 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -44,8 +44,10 @@ def fileordering(command1, command2, env1, env2, tree1, tree2):
     disorderfs.mkdir()
     subprocess.check_call(['disorderfs', '--shuffle-dirents=yes',
                            str(tree2), str(disorderfs)])
-    yield command1, command2, env1, env2, tree1, disorderfs
-    subprocess.check_call(['fusermount', '-u', str(disorderfs)])
+    try:
+        yield command1, command2, env1, env2, tree1, disorderfs
+    finally:
+        subprocess.check_call(['fusermount', '-u', str(disorderfs)])
 
 @contextlib.contextmanager
 def home(command1, command2, env1, env2, tree1, tree2):
@@ -131,6 +133,12 @@ VARIATIONS = collections.OrderedDict([
 ])
 
 def build(command, source_root, built_artifact, artifact_store, **kws):
+    # print(command)
+    # print(source_root)
+    # print(list(pathlib.Path(source_root).glob('*')))
+    # print(kws)
+    # print(subprocess.check_output(['ls'], cwd=source_root, **kws).decode('ascii'))
+    # print(subprocess.check_output('python --version', cwd=source_root, **kws))
     subprocess.check_call(command, cwd=source_root, **kws)
     with open(built_artifact, 'rb') as artifact:
         artifact_store.write(artifact.read())
@@ -144,20 +152,22 @@ def check(build_command, artifact_name, source_root, variations=VARIATIONS):
         env2 = env1.copy()
         tree1 = pathlib.Path(shutil.copytree(str(source_root), temp + '/tree1'))
         tree2 = pathlib.Path(shutil.copytree(str(source_root), temp + '/tree2'))
-        # print(build_command)
-        with contextlib.ExitStack() as stack:
-            try:
-                for variation in variations:
-                    # print(variation)
-                    command1, command2, env1, env2, tree1, tree2 = stack.enter_context(VARIATIONS[variation](command1, command2, env1, env2, tree1, tree2))
+        # print(' '.join(command1))
+        # print(pathlib.Path.cwd())
+        # print(source_root)
+        try:
+            with contextlib.ExitStack() as stack:
+                    for variation in variations:
+                        # print(variation)
+                        command1, command2, env1, env2, tree1, tree2 = stack.enter_context(VARIATIONS[variation](command1, command2, env1, env2, tree1, tree2))
                     build(' '.join(command1), str(tree1),
                           temp + '/tree1/' + artifact_name,
                           open(temp + '/artifact1', 'wb'), env=env1, shell=True)
                     build(' '.join(command2), str(tree2),
                           temp + '/tree2/' + artifact_name,
                           open(temp + '/artifact2', 'wb'), env=env2, shell=True)
-            except Exception:
-                sys.exit(2)
+        except:
+            sys.exit(2)
         sys.exit(subprocess.call(['diffoscope', temp + '/artifact1', temp + '/artifact2']))
 
 def main():
@@ -195,7 +205,7 @@ def main():
         'artifact', help='Build artifact to test for reproducibility.')
     # Reprotest will copy this tree and then run the build command.
     arg_parser.add_argument(
-        '--source-root', dest='--source_root', type=pathlib.Path,
+        '--source-root', dest='source_root', type=pathlib.Path,
         help='Root of the source tree, if not the '
         'current working directory.')
     arg_parser.add_argument(
@@ -203,15 +213,18 @@ def main():
         help='Build variations to test as a comma-separated list'
         ' (without spaces).  Default is to test all available variations.')
     arg_parser.add_argument(
-        '--dont-vary', dest='--dont_vary',
+        '--dont-vary', dest='dont_vary',
         type=lambda s: frozenset(s.split(',')),
         help='Build variations *not* to test as a comma-separated'
         ' list (without spaces).  Default is to test all available variations.')
     # Argparse exits with status code 2 if something goes wrong, which
     # is already the right status exit code for reprotest.
+
     args = arg_parser.parse_args()
+    # print(args)
     if args.build_command:
         build_command = args.build_command.split()
+        # print(build_command)
     if args.artifact:
         artifact = args.artifact
     if args.source_root:
diff --git a/tests/tests.py b/tests/tests.py
index f321f35..9780f84 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -1,6 +1,8 @@
 # Licensed under the GPL: https://www.gnu.org/licenses/gpl-3.0.en.html
 # For details: reprotest/debian/copyright
 
+import subprocess
+
 import reprotest
 
 def test_return_code(command, code):
@@ -20,3 +22,6 @@ if __name__ == '__main__':
     test_return_code(['python', 'build.py', 'path'], 1)
     test_return_code(['python', 'build.py', 'timezone'], 1)
     test_return_code(['python', 'build.py', 'umask'], 1)
+
+    assert(subprocess.call(['reprotest', 'python setup.py bdist', 'dist/reprotest-0.1.linux-x86_64.tar.gz']) == 1)
+    assert(subprocess.call(['reprotest', 'debuild --no-lintian -b -uc -us', '../reprotest_0.1_amd64.deb']) == 2)
diff --git a/tox.ini b/tox.ini
index 65d0867..339f0fb 100644
--- a/tox.ini
+++ b/tox.ini
@@ -17,4 +17,4 @@ commands =
 deps =
   coverage
   diffoscope
-commands = coverage run --parallel tests/test.py
+commands = coverage run --parallel tests/tests.py

-- 
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