From 1635cd2e0431d948b03017444879540466ac1900 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Sun, 12 Nov 2017 08:43:23 -0500 Subject: [PATCH] Use the minimal Python interface for tests when others are not built If no full or minimal Python interface is being built, copy the minimal interface into the build directory and use the sys.executable to run it, so the tests that require CTML or CTI conversion can run. --- SConstruct | 16 ++++++++++++++++ test/SConscript | 9 +++++---- test_problems/SConscript | 10 ++++++---- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/SConstruct b/SConstruct index 6f2ee4077..03979a3dd 100644 --- a/SConstruct +++ b/SConstruct @@ -112,6 +112,7 @@ if 'clean' in COMMAND_LINE_TARGETS: if 'test-clean' in COMMAND_LINE_TARGETS: removeDirectory('build/test') removeDirectory('test/work') + removeDirectory('build/python_minimal') # ****************************************************** # *** Set system-dependent defaults for some options *** @@ -1789,6 +1790,21 @@ if any(target.startswith('test') for target in COMMAND_LINE_TARGETS): env['testNames'] = [] env['test_results'] = env.Command('test_results', [], testResults.printReport) + if env['python2_package'] == 'none' and env['python3_package'] == 'none': + # copy scripts from the full Cython module + test_py_int = env.Command('#build/python_minimal/cantera/__init__.py', + '#interfaces/python_minimal/cantera/__init__.py', + Copy('$TARGET', '$SOURCE')) + for script in ['ctml_writer', 'ck2cti']: + s = env.Command('#build/python_minimal/cantera/{}.py'.format(script), + '#interfaces/cython/cantera/{}.py'.format(script), + Copy('$TARGET', '$SOURCE')) + env.Depends(test_py_int, s) + + env.Depends(env['test_results'], test_py_int) + + env['python_cmd'] = sys.executable + # Tests written using the gtest framework, the Python unittest module, # or the Matlab xunit package. VariantDir('build/test', 'test', duplicate=0) diff --git a/test/SConscript b/test/SConscript index d63038faa..8aafcc98f 100644 --- a/test/SConscript +++ b/test/SConscript @@ -209,14 +209,15 @@ def addMatlabTest(script, testName, dependencies=None, env_vars=()): return run_program -if localenv['python_package'] in ('full', 'minimal'): +if localenv['python2_package'] in ('full', 'minimal'): python_env_vars = {'PYTHONPATH': localenv['pythonpath_build2'], - 'PYTHON_CMD': localenv.subst('$python_cmd')} -elif localenv['python3_package'] == 'y': + 'PYTHON_CMD': localenv.subst('$python2_cmd')} +elif localenv['python3_package'] in ('full', 'minimal'): python_env_vars = {'PYTHONPATH': localenv['pythonpath_build3'], 'PYTHON_CMD': localenv.subst('$python3_cmd')} else: - python_env_vars = {} # Tests calling ck2cti or ctml_writer will fail + python_env_vars = {'PYTHONPATH': '../../build/python_minimal', + 'PYTHON_CMD': localenv.subst('$python_cmd')} # Instantiate tests diff --git a/test_problems/SConscript b/test_problems/SConscript index 267247760..17ec0fdf4 100644 --- a/test_problems/SConscript +++ b/test_problems/SConscript @@ -19,16 +19,18 @@ if localenv['OS'] == 'Linux': else: cantera_libs = localenv['cantera_libs'] -if localenv['python_package'] in ('full', 'minimal'): +if localenv['python2_package'] in ('full', 'minimal'): localenv['ENV']['PYTHONPATH'] = localenv['pythonpath_build2'] - localenv['ENV']['PYTHON_CMD'] = localenv.subst('$python_cmd') + localenv['ENV']['PYTHON_CMD'] = localenv.subst('$python2_cmd') haveConverters = True -elif localenv['python3_package'] == 'y': +elif localenv['python3_package'] in ('full', 'minimal'): localenv['ENV']['PYTHONPATH'] = localenv['pythonpath_build3'] localenv['ENV']['PYTHON_CMD'] = localenv.subst('$python3_cmd') haveConverters = True else: - haveConverters = False + localenv['ENV']['PYTHONPATH'] = '../../build/python_minimal' + localenv['ENV']['PYTHON_CMD'] = localenv.subst('$python_cmd') + haveConverters = True localenv['ENV']['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'build', 'data')