Python tests now have SCons dependency on the Python extension

This means that running a Python test will cause the Python extension
to be built, and that changes in the source will cause the Python tests
to rerun.
This commit is contained in:
Ray Speth 2012-03-09 22:59:04 +00:00
parent 950ebbb2ca
commit b5fdb92146
3 changed files with 21 additions and 10 deletions

View file

@ -61,6 +61,7 @@ if localenv['python_package'] == 'full':
dest = pjoin('interfaces', 'python', 'Cantera', file.name)
localenv.AddPreAction(pymodule,Copy(dest, file))
env['python_module'] = pymodule
elif localenv['python_package'] == 'minimal':
pymodule = make_setup

View file

@ -62,7 +62,9 @@ def addTestScript(subdir, script, interpreter, dependencies):
passedFile = File(pjoin(subdir, '%s.passed' % (script)))
run_program = testenv.Command(passedFile, pjoin(subdir, script), scriptRunner)
for dep in dependencies:
testenv.Depends(run_program, File(pjoin(subdir, dep)))
if isinstance(dep, str):
dep = File(pjoin(subdir, dep))
testenv.Depends(run_program, dep)
Alias('newtest', run_program)
if os.path.exists(passedFile.abspath):
Alias('newtest-reset', testenv.Command('reset-%s%s' % (subdir, script),
@ -72,4 +74,4 @@ def addTestScript(subdir, script, interpreter, dependencies):
addTestProgram('thermo', 'nasapoly')
addTestScript('python', 'runTests.py',
interpreter=sys.executable,
dependencies=['testSolution.py'])
dependencies=['testSolution.py', localenv['python_module']])

View file

@ -10,10 +10,12 @@ os.environ['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'data', 'inputs')
testNames = []
class Test(object):
_validArgs = set(['arguments', 'options', 'artifacts', 'comparisons',
'tolerance', 'threshold', 'ignoreLines', 'extensions',
'dependencies'])
def __init__(self, testName, subdir, programName, blessedName, **kwargs):
assert set(kwargs.keys()) <= set(['arguments', 'options', 'artifacts',
'comparisons', 'tolerance', 'threshold',
'ignoreLines', 'extensions']), kwargs.keys()
assert set(kwargs.keys()) <= self._validArgs, kwargs.keys()
self.subdir = subdir
self.programName = programName
arguments = kwargs.get('arguments') or []
@ -45,6 +47,9 @@ class Test(object):
# reset: just delete the ".passed" file so that this test will be re-run
localenv.Alias('test-reset', self.reset(localenv))
for dep in kwargs.get('dependencies', []):
localenv.Depends(run, dep)
def run(self, env, *args):
source = list(args)
if not source:
@ -299,20 +304,23 @@ CompileAndTest('VPsilane_test', 'VPsilane_test', 'VPsilane_test', 'output_blesse
# Python Tests
if localenv['python_package'] == 'full':
testDeps = [localenv['python_module']]
Test('python-diamond', 'python', '$python_cmd', None,
options='../../samples/python/surface_chemistry/diamond_cvd/diamond.py',
comparisons=[('diamond_blessed.csv', 'diamond.csv')],
artifacts=['diamond.xml'])
artifacts=['diamond.xml'], dependencies=testDeps)
Test('python-frac', 'python', '$python_cmd', 'frac_blessed.out',
arguments='frac.py', artifacts=['frac.xml'])
arguments='frac.py', artifacts=['frac.xml'], dependencies=testDeps)
Test('python-tut1', pjoin('python','tut1'), '$python_cmd',
'output_blessed.txt', arguments='tut1.py', artifacts=['gri30.xml'])
'output_blessed.txt', arguments='tut1.py', artifacts=['gri30.xml'],
dependencies=testDeps)
Test('python-tut2', pjoin('python','tut2'), '$python_cmd',
'output_blessed.txt', arguments='tut2.py',
artifacts=['gri30.xml', 'diamond.xml'])
dependencies=testDeps, artifacts=['gri30.xml', 'diamond.xml'])
# Skipping Python Tutorial 3 (documentation only)
Test('python-tut4', pjoin('python','tut4'), '$python_cmd',
'output_blessed.txt', arguments='tut4.py', artifacts=['gri30.xml'])
'output_blessed.txt', arguments='tut4.py', artifacts=['gri30.xml'],
dependencies=testDeps)
finish_tests = localenv.Command('finish_tests', [], testResults.printReport)
localenv.Depends(finish_tests, 'test-run')