diff options
author | Petr Viktorin <pviktori@redhat.com> | 2015-03-10 18:19:14 +0100 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2015-05-19 19:28:19 +0200 |
commit | 91b407fc94fcd0015fe91b84619f3a6d1d3595f2 (patch) | |
tree | 633eff65c3b69f709d06a3f437609aaa05474312 /buildtools | |
parent | 6f490000c6b233f275598a4680b2c49fcb69d35a (diff) | |
download | samba-91b407fc94fcd0015fe91b84619f3a6d1d3595f2.tar.gz |
buildtools: Add a helper for running Python tests
Add the function samba_utils.RUN_PYTHON_TESTS for running a Python
test. When building for multiple Python versions, all are tested.
Also, add the list of configured Python interpreters to build config.
Signed-off-by: Petr Viktorin <pviktori@redhat.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jelmer Vernooij <jelmer@samba.org>
Diffstat (limited to 'buildtools')
-rw-r--r-- | buildtools/wafsamba/samba_python.py | 6 | ||||
-rw-r--r-- | buildtools/wafsamba/samba_utils.py | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/buildtools/wafsamba/samba_python.py b/buildtools/wafsamba/samba_python.py index a0e0ffa9f6b..8b20066c9de 100644 --- a/buildtools/wafsamba/samba_python.py +++ b/buildtools/wafsamba/samba_python.py @@ -9,6 +9,8 @@ from Configure import conf @conf def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): # enable tool to build python extensions + interpreters = [] + if conf.env['EXTRA_PYTHON']: conf.all_envs['extrapython'] = conf.env.copy() conf.setenv('extrapython') @@ -21,6 +23,7 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): except Exception: warn('extra-python needs to be Python 3.3 or later') raise + interpreters.append(conf.env['PYTHON']) conf.setenv('default') conf.find_program('python', var='PYTHON', mandatory=mandatory) @@ -29,6 +32,9 @@ def SAMBA_CHECK_PYTHON(conf, mandatory=True, version=(2,4,2)): conf.env.PYTHON_SPECIFIED = (conf.env.PYTHON != path_python) conf.check_python_version(version) + interpreters.append(conf.env['PYTHON']) + conf.env.python_interpreters = interpreters + @conf def SAMBA_CHECK_PYTHON_HEADERS(conf, mandatory=True): diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py index e8bc0f38bc2..540fe447942 100644 --- a/buildtools/wafsamba/samba_utils.py +++ b/buildtools/wafsamba/samba_utils.py @@ -386,6 +386,22 @@ def RUN_COMMAND(cmd, return -1 +def RUN_PYTHON_TESTS(testfiles, pythonpath=None): + env = LOAD_ENVIRONMENT() + if pythonpath is None: + pythonpath = os.path.join(Utils.g_module.blddir, 'python') + result = 0 + for interp in env.python_interpreters: + for testfile in testfiles: + cmd = "PYTHONPATH=%s %s %s" % (pythonpath, interp, testfile) + print('Running Python test with %s: %s' % (interp, testfile)) + ret = RUN_COMMAND(cmd) + if ret: + print('Python test failed: %s' % cmd) + result = ret + return result + + # make sure we have md5. some systems don't have it try: from hashlib import md5 |