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.
This commit is contained in:
Bryan W. Weber 2017-11-12 08:43:23 -05:00 committed by Ray Speth
parent 136c86636e
commit 1635cd2e04
3 changed files with 27 additions and 8 deletions

View file

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

View file

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

View file

@ -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')