diff --git a/SConstruct b/SConstruct index 0680ae53e..c0d3be0f8 100644 --- a/SConstruct +++ b/SConstruct @@ -11,14 +11,13 @@ Basic usage: '[sudo] scons install' - Install Cantera. - 'scons test' - Run full regression test suite. + 'scons test' - Run full test suite. - 'scons test-clean' - Delete files created while running the - regression tests. + 'scons test-clean' - Delete files created while running the tests. - 'scons test-help' - List available regression tests. + 'scons test-help' - List available tests. - 'scons test-NAME' - Run the regression test named "FOO". + 'scons test-NAME' - Run the test named "NAME". 'scons samples' - Compile the C++ and Fortran samples @@ -1273,9 +1272,18 @@ if 'msi' in COMMAND_LINE_TARGETS: ### Tests ### if any(target.startswith('test') for target in COMMAND_LINE_TARGETS): - SConscript('test_problems/SConscript') + env['testNames'] = [] -# Tests written using the gtest framework -if any(target.startswith('newtest') for target in COMMAND_LINE_TARGETS): + # Tests written using the gtest framework, the Python unittest module, + # or the Matlab xunit package. VariantDir('build/test', 'test', duplicate=0) SConscript('build/test/SConscript') + + # Regression tests + SConscript('test_problems/SConscript') + + if 'test-help' in COMMAND_LINE_TARGETS: + print '\n*** Available tests ***\n' + for name in env['testNames']: + print 'test-%s' % name + sys.exit(0) diff --git a/test/SConscript b/test/SConscript index 54387ffee..75ca25605 100644 --- a/test/SConscript +++ b/test/SConscript @@ -36,10 +36,12 @@ def addTestProgram(subdir, progName): pjoin(subdir, '%s.cpp' % progName)) passedFile = File(pjoin(str(program[0].dir), '%s.passed' % program[0].name)) run_program = localenv.Command(passedFile, program, testRunner) - Alias('newtest', run_program) + Alias('test', run_program) + Alias('test-%s' % progName, run_program) + env['testNames'].append(progName) if os.path.exists(passedFile.abspath): - Alias('newtest-reset', localenv.Command('reset-%s%s' % (subdir, progName), - [], [Delete(passedFile.abspath)])) + Alias('test-reset', localenv.Command('reset-%s%s' % (subdir, progName), + [], [Delete(passedFile.abspath)])) def addTestScript(subdir, script, interpreter, dependencies): @@ -65,10 +67,12 @@ def addTestScript(subdir, script, interpreter, dependencies): if isinstance(dep, str): dep = File(pjoin(subdir, dep)) testenv.Depends(run_program, dep) - Alias('newtest', run_program) + Alias('test', run_program) if os.path.exists(passedFile.abspath): - Alias('newtest-reset', testenv.Command('reset-%s%s' % (subdir, script), - [], [Delete(passedFile.abspath)])) + Alias('test-reset', testenv.Command('reset-%s%s' % (subdir, script), + [], [Delete(passedFile.abspath)])) + + return run_program def addMatlabTest(script, dependencies=None): @@ -110,22 +114,27 @@ def addMatlabTest(script, dependencies=None): dep = File(pjoin('matlab', dep)) testenv.Depends(run_program, dep) - Alias('newtest', run_program) + Alias('test', run_program) if os.path.exists(passedFile.abspath): - Alias('newtest-reset', testenv.Command('reset-%s%s' % ('matlab', script), - [], [Delete(passedFile.abspath)])) + Alias('test-reset', testenv.Command('reset-%s%s' % ('matlab', script), + [], [Delete(passedFile.abspath)])) + return run_program # Instantiate tests addTestProgram('thermo', 'nasapoly') addTestProgram('kinetics', 'pdep') if localenv['python_package'] == 'full': - addTestScript('python', 'runTests.py', - interpreter=sys.executable, - dependencies=['testSolution.py', 'testReactors.py', - localenv['python_module']]) + pyTest= addTestScript('python', 'runTests.py', + interpreter=sys.executable, + dependencies=['testSolution.py', 'testReactors.py', + localenv['python_module']]) + localenv.Alias('python', pyTest) + env['testNames'].append('python') if localenv['matlab_toolbox'] == 'y': - addMatlabTest('runCanteraTests.m', - dependencies=mglob(localenv, 'matlab', 'm')) + matlabTest = addMatlabTest('runCanteraTests.m', + dependencies=mglob(localenv, 'matlab', 'm')) + localenv.Alias('matlab', matlabTest) + env['testNames'].append('matlab') diff --git a/test_problems/SConscript b/test_problems/SConscript index 0e722db75..fe1539f81 100644 --- a/test_problems/SConscript +++ b/test_problems/SConscript @@ -7,8 +7,6 @@ localenv.Append(CPPPATH=['#include', '#src', 'shared']) os.environ['PYTHONPATH'] = pjoin(os.getcwd(), '..', 'interfaces', 'python') os.environ['CANTERA_DATA'] = pjoin(os.getcwd(), '..', 'data', 'inputs') -testNames = [] - class Test(object): _validArgs = set(['arguments', 'options', 'artifacts', 'comparisons', 'tolerance', 'threshold', 'ignoreLines', 'extensions', @@ -42,7 +40,7 @@ class Test(object): localenv.Alias('test-run', run) localenv.Alias('test-clean', self.clean(localenv)) localenv.Alias('test-%s' % self.testName, run) - testNames.append(self.testName) + env['testNames'].append(self.testName) # reset: just delete the ".passed" file so that this test will be re-run localenv.Alias('test-reset', self.reset(localenv)) @@ -325,9 +323,3 @@ if localenv['python_package'] == 'full': finish_tests = localenv.Command('finish_tests', [], testResults.printReport) localenv.Depends(finish_tests, 'test-run') Alias('test', finish_tests) - -if 'test-help' in COMMAND_LINE_TARGETS: - print '\n*** Available regression tests ***\n' - for name in testNames: - print name - sys.exit(0)