[Reproducible-commits] [reprotest] 04/06: Add arguments for virtualization support and fix accompanying tests
Ceridwen
ceridwen-guest at moszumanska.debian.org
Fri Jun 24 18:46:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
ceridwen-guest pushed a commit to branch virtualization
in repository reprotest.
commit e0c68f3a6a0fc0bdfae801f8ebae62c342716da7
Author: Ceridwen <ceridwenv at gmail.com>
Date: Wed Jun 22 00:05:50 2016 -0400
Add arguments for virtualization support and fix accompanying tests
---
reprotest/__init__.py | 44 +++++++++++++++++++++++++++++++++++++-------
tests/tests.py | 6 +++---
tox.ini | 6 +++---
3 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/reprotest/__init__.py b/reprotest/__init__.py
index 58b51af..b77fcf2 100644
--- a/reprotest/__init__.py
+++ b/reprotest/__init__.py
@@ -16,6 +16,8 @@ import time
import traceback
import types
+import pkg_resources
+
from reprotest.lib import adt_testbed
# time zone, locales, disorderfs, host name, user/group, shell, CPU
@@ -24,10 +26,26 @@ from reprotest.lib import adt_testbed
# chroot is the only form of OS virtualization that's available on
# most POSIX OSes. Linux containers (lxc) and namespaces are specific
-# to Linux. Some versions of BSD has jails (MacOS X?). There are a
+# to Linux. Some versions of BSD have jails (MacOS X?). There are a
# variety of other options including Docker etc that use different
# approaches.
+ at contextlib.contextmanager
+def virt_server_manager(server_type, args):
+ '''This is a simple wrapper around adt_testbed that automates the
+ clean up.'''
+ # Find the location of reprotest using setuptools and then get the
+ # path for the correct virt-server script.
+ server_path = pkg_resources.resource_filename(__name__, 'virt/' +
+ server_type)
+ virt_server = adt_testbed.Testbed((server_path,) + args, '/tmp/outdir', None)
+ virt_server.start()
+ virt_server.open()
+ try:
+ yield virt_server
+ finally:
+ virt_server.stop()
+
# TODO: relies on a pbuilder-specific command to parallelize
# def cpu(command1, command2, env1, env2, tree1, tree2):
# yield command1, command2, env1, env2, tree1, tree2
@@ -148,7 +166,9 @@ def build(command, source_root, built_artifact, artifact_store, **kws):
artifact_store.write(artifact.read())
artifact_store.flush()
-def check(build_command, artifact_name, source_root, variations=VARIATIONS):
+def check(build_command, artifact_name, virt_server_args, source_root,
+ variations=VARIATIONS):
+ # print(virt_server_args)
with tempfile.TemporaryDirectory() as temp:
command1 = build_command
command2 = build_command
@@ -188,6 +208,9 @@ COMMAND_LINE_OPTIONS = types.MappingProxyType(collections.OrderedDict([
('artifact', types.MappingProxyType({
'default': None, 'nargs': '?',
'help': 'Build artifact to test for reproducibility.'})),
+ ('virt_server_args', types.MappingProxyType({
+ 'default': None, 'nargs': '*',
+ 'help': 'Arguments to pass to the virt_server.'})),
('--source-root', types.MappingProxyType({
'dest': 'source_root', 'type': pathlib.Path,
'help': 'Root of the source tree, if not the '
@@ -207,8 +230,8 @@ COMMAND_LINE_OPTIONS = types.MappingProxyType(collections.OrderedDict([
'help': 'An integer. Control which messages are displayed.'}))
]))
-
-MULTIPLET_OPTIONS = frozenset(['build_command', 'dont_vary', 'variations'])
+MULTIPLET_OPTIONS = frozenset(['build_command', 'dont_vary',
+ 'variations', 'virt_server_args'])
CONFIG_OPTIONS = []
for option in COMMAND_LINE_OPTIONS.keys():
@@ -241,7 +264,7 @@ def command_line():
# print(args)
return types.MappingProxyType({k:v for k, v in vars(args).items() if v is not None})
-
+
def main():
config_options = config()
@@ -249,7 +272,7 @@ def main():
# Argparse exits with status code 2 if something goes wrong, which
# is already the right status exit code for reprotest.
command_line_options = command_line()
-
+
# Command-line arguments override config file settings.
build_command = command_line_options.get(
'build_command',
@@ -257,6 +280,9 @@ def main():
artifact = command_line_options.get(
'artifact',
config_options.get('artifact'))
+ virt_server_args = command_line_options.get(
+ 'virt_server_args',
+ config_options.get('virt_server_args'))
# Reprotest will copy this tree and then run the build command.
# If a source root isn't provided, assume it's the current working
# directory.
@@ -285,6 +311,10 @@ def main():
if not artifact:
print("No build artifact to test for differences provided.")
sys.exit(2)
+ if not virt_server_args:
+ print("No virt_server to run the build in specified.")
+ sys.exit(2)
logging.basicConfig(
format='%(message)s', level=30-10*verbosity, stream=sys.stdout)
- check(build_command, artifact, source_root, variations)
+ # print(build_command, artifact, virt_server_args)
+ check(build_command, artifact, virt_server_args, source_root, variations)
diff --git a/tests/tests.py b/tests/tests.py
index 28bd310..6e774c7 100755
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -8,7 +8,7 @@ import reprotest
def test_return_code(command, code):
try:
- reprotest.check(command, 'artifact', 'tests/')
+ reprotest.check(command, 'artifact', 'null', 'tests/')
except SystemExit as system_exit:
assert(system_exit.args[0] == code)
@@ -30,5 +30,5 @@ if __name__ == '__main__':
test_return_code(['python', 'mock_build.py', 'umask'], 1)
if args.test_build:
- assert(subprocess.call(['reprotest', 'python setup.py bdist', 'dist/reprotest-0.1.linux-x86_64.tar.gz']) == 1)
- assert(subprocess.call(['reprotest', 'debuild -b -uc -us', '../reprotest_0.1_all.deb']) == 1)
+ assert(subprocess.call(['reprotest', 'python setup.py bdist', 'dist/reprotest-0.1.linux-x86_64.tar.gz', 'null']) == 1)
+ assert(subprocess.call(['reprotest', 'debuild -b -uc -us', '../reprotest_0.1_all.deb', 'null']) == 1)
diff --git a/tox.ini b/tox.ini
index 7269f37..1f57280 100644
--- a/tox.ini
+++ b/tox.ini
@@ -11,13 +11,13 @@ commands = coverage erase
skip_install = True
commands =
coverage combine
- coverage report
- coverage html
+ coverage report --omit "*tox*"
+ coverage html --omit "*tox*"
[testenv]
deps =
coverage
- coverage_pth
+# coverage_pth
diffoscope
# pytest-cov
# commands = py.test --cov-report html --cov=reprotest 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