[SCons] Always re-run explicitly named tests

This commit is contained in:
Ray Speth 2013-01-11 22:56:40 +00:00
parent d4525f0db7
commit 8e7e81570a
2 changed files with 28 additions and 5 deletions

View file

@ -12,6 +12,8 @@ localenv.Append(LIBS=['gtest'] + localenv['cantera_libs'],
localenv['ENV']['PYTHONPATH'] = Dir('#interfaces/python').abspath localenv['ENV']['PYTHONPATH'] = Dir('#interfaces/python').abspath
localenv['ENV']['CANTERA_DATA'] = Dir('#build/data').abspath localenv['ENV']['CANTERA_DATA'] = Dir('#build/data').abspath
PASSED_FILES = {}
# Needed for Intel runtime libraries when compiling with ICC # Needed for Intel runtime libraries when compiling with ICC
if 'LD_LIBRARY_PATH' in os.environ: if 'LD_LIBRARY_PATH' in os.environ:
localenv['ENV']['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH'] localenv['ENV']['LD_LIBRARY_PATH'] = os.environ['LD_LIBRARY_PATH']
@ -42,6 +44,7 @@ def addTestProgram(subdir, progName):
program = localenv.Program(pjoin(subdir, progName), program = localenv.Program(pjoin(subdir, progName),
mglob(localenv, subdir, 'cpp')) mglob(localenv, subdir, 'cpp'))
passedFile = File(pjoin(str(program[0].dir), '%s.passed' % program[0].name)) passedFile = File(pjoin(str(program[0].dir), '%s.passed' % program[0].name))
PASSED_FILES[progName] = str(passedFile)
testResults.tests[passedFile.name] = program testResults.tests[passedFile.name] = program
run_program = localenv.Command(passedFile, program, testRunner) run_program = localenv.Command(passedFile, program, testRunner)
Alias('test', run_program) Alias('test', run_program)
@ -81,6 +84,7 @@ def addTestScript(testname, subdir, script, interpreter, dependencies=(), env_va
testenv = localenv.Clone() testenv = localenv.Clone()
passedFile = File(pjoin(subdir, '%s.passed' % testname)) passedFile = File(pjoin(subdir, '%s.passed' % testname))
PASSED_FILES[testname] = str(passedFile)
testResults.tests[passedFile.name] = True testResults.tests[passedFile.name] = True
run_program = testenv.Command(passedFile, pjoin(subdir, script), scriptRunner) run_program = testenv.Command(passedFile, pjoin(subdir, script), scriptRunner)
for dep in dependencies: for dep in dependencies:
@ -95,7 +99,7 @@ def addTestScript(testname, subdir, script, interpreter, dependencies=(), env_va
return run_program return run_program
def addMatlabTest(script, dependencies=None): def addMatlabTest(script, testName, dependencies=None):
def matlabRunner(target, source, env): def matlabRunner(target, source, env):
passedFile = target[0] passedFile = target[0]
del testResults.tests[passedFile.name] del testResults.tests[passedFile.name]
@ -128,6 +132,7 @@ def addMatlabTest(script, dependencies=None):
testenv = localenv.Clone() testenv = localenv.Clone()
passedFile = File(pjoin('matlab', '%s.passed' % (script))) passedFile = File(pjoin('matlab', '%s.passed' % (script)))
PASSED_FILES[testName] = str(passedFile)
testResults.tests[passedFile.name] = True testResults.tests[passedFile.name] = True
run_program = testenv.Command(passedFile, pjoin('matlab', script), matlabRunner) run_program = testenv.Command(passedFile, pjoin('matlab', script), matlabRunner)
@ -149,14 +154,14 @@ addTestProgram('thermo', 'thermo')
addTestProgram('kinetics', 'kinetics') addTestProgram('kinetics', 'kinetics')
if localenv['python_package'] == 'full': if localenv['python_package'] == 'full':
pyTest = addTestScript('python2-old', 'python', 'runTests.py', pyTest = addTestScript('python', 'python', 'runTests.py',
interpreter='$python_cmd', interpreter='$python_cmd',
dependencies=(mglob(localenv, 'python', 'py') + dependencies=(mglob(localenv, 'python', 'py') +
localenv['python_module'])) localenv['python_module']))
localenv.Alias('test-python', pyTest) localenv.Alias('test-python', pyTest)
env['testNames'].append('python') env['testNames'].append('python')
elif localenv['python_package'] == 'new': elif localenv['python_package'] == 'new':
pyTest = addTestScript('python2-new', 'python', 'runCythonTests.py', pyTest = addTestScript('cython2', 'python', 'runCythonTests.py',
interpreter='$python_cmd', interpreter='$python_cmd',
dependencies=(localenv['python2_module'] + dependencies=(localenv['python2_module'] +
mglob(localenv, '#interfaces/cython/cantera/test', 'py')), mglob(localenv, '#interfaces/cython/cantera/test', 'py')),
@ -165,7 +170,7 @@ elif localenv['python_package'] == 'new':
env['testNames'].append('cython2') env['testNames'].append('cython2')
if localenv['python3_package'] == 'y': if localenv['python3_package'] == 'y':
pyTest = addTestScript('python3-new', 'python', 'runCythonTests.py', pyTest = addTestScript('cython3', 'python', 'runCythonTests.py',
interpreter='$python3_cmd', interpreter='$python3_cmd',
dependencies=(localenv['python3_module'] + dependencies=(localenv['python3_module'] +
mglob(localenv, '#interfaces/cython/cantera/test', 'py')), mglob(localenv, '#interfaces/cython/cantera/test', 'py')),
@ -175,7 +180,14 @@ if localenv['python3_package'] == 'y':
if localenv['matlab_toolbox'] == 'y': if localenv['matlab_toolbox'] == 'y':
matlabTest = addMatlabTest('runCanteraTests.m', matlabTest = addMatlabTest('runCanteraTests.m', 'matlab',
dependencies=mglob(localenv, 'matlab', 'm')) dependencies=mglob(localenv, 'matlab', 'm'))
localenv.Alias('test-matlab', matlabTest) localenv.Alias('test-matlab', matlabTest)
env['testNames'].append('matlab') env['testNames'].append('matlab')
# Force explicitly-named tests to run even if SCons thinks they're up to date
for command in COMMAND_LINE_TARGETS:
if command.startswith('test-'):
name = command[5:]
if name in PASSED_FILES and os.path.exists(PASSED_FILES[name]):
os.remove(PASSED_FILES[name])

View file

@ -8,6 +8,9 @@ localenv.Append(CCFLAGS=env['warning_flags'])
os.environ['PYTHONPATH'] = pjoin(os.getcwd(), '..', 'interfaces', 'python') os.environ['PYTHONPATH'] = pjoin(os.getcwd(), '..', 'interfaces', 'python')
os.environ['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'build', 'data') os.environ['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'build', 'data')
PASSED_FILES = {}
class Test(object): class Test(object):
_validArgs = set(['arguments', 'options', 'artifacts', 'comparisons', _validArgs = set(['arguments', 'options', 'artifacts', 'comparisons',
'tolerance', 'threshold', 'ignoreLines', 'extensions', 'tolerance', 'threshold', 'ignoreLines', 'extensions',
@ -35,6 +38,7 @@ class Test(object):
self.testName = testName self.testName = testName
self.passedFile = '.passed-%s' % testName self.passedFile = '.passed-%s' % testName
PASSED_FILES[self.testName] = pjoin(self.subdir, self.passedFile)
testResults.tests[self.testName] = self testResults.tests[self.testName] = self
run = self.run(localenv) run = self.run(localenv)
@ -316,3 +320,10 @@ if localenv['python_package'] == 'full':
finish_tests = localenv.Command('finish_tests', [], testResults.printReport) finish_tests = localenv.Command('finish_tests', [], testResults.printReport)
localenv.Depends(finish_tests, 'test-run') localenv.Depends(finish_tests, 'test-run')
Alias('test', finish_tests) Alias('test', finish_tests)
# Force explicitly-named tests to run even if SCons thinks they're up to date
for command in COMMAND_LINE_TARGETS:
if command.startswith('test-'):
name = command[5:]
if name in PASSED_FILES and os.path.exists(PASSED_FILES[name]):
os.remove(PASSED_FILES[name])