mirror of
https://github.com/Cantera/cantera.git
synced 2025-02-25 18:55:29 -06:00
[SCons] Add commands for building (but not running) tests
This commit is contained in:
parent
cd5d7a9e34
commit
43b1fffe14
@ -25,6 +25,10 @@ Basic usage:
|
|||||||
|
|
||||||
'scons test-NAME' - Run the test named "NAME".
|
'scons test-NAME' - Run the test named "NAME".
|
||||||
|
|
||||||
|
'scons build-NAME' - Build the program for the test named "NAME".
|
||||||
|
|
||||||
|
'scons build-tests' - Build the programs for all tests.
|
||||||
|
|
||||||
'scons samples' - Compile the C++ and Fortran samples.
|
'scons samples' - Compile the C++ and Fortran samples.
|
||||||
|
|
||||||
'scons msi' - Build a Windows installer (.msi) for Cantera.
|
'scons msi' - Build a Windows installer (.msi) for Cantera.
|
||||||
@ -111,7 +115,7 @@ else:
|
|||||||
logger.logger.setLevel("INFO")
|
logger.logger.setLevel("INFO")
|
||||||
|
|
||||||
for command in COMMAND_LINE_TARGETS:
|
for command in COMMAND_LINE_TARGETS:
|
||||||
if command not in valid_commands and not command.startswith('test'):
|
if command not in valid_commands and not command.startswith(('test', 'build-')):
|
||||||
logger.error(f"Unrecognized command line target: {command!r}")
|
logger.error(f"Unrecognized command line target: {command!r}")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
@ -2351,7 +2355,7 @@ if 'msi' in COMMAND_LINE_TARGETS:
|
|||||||
build_msi = Alias('msi', msi_target)
|
build_msi = Alias('msi', msi_target)
|
||||||
|
|
||||||
### Tests ###
|
### Tests ###
|
||||||
if any(target.startswith('test') for target in COMMAND_LINE_TARGETS):
|
if any(target.startswith(('test', 'build-')) for target in COMMAND_LINE_TARGETS):
|
||||||
env['testNames'] = []
|
env['testNames'] = []
|
||||||
env['test_results'] = env.Command('test_results', [], test_results.print_report)
|
env['test_results'] = env.Command('test_results', [], test_results.print_report)
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ of the GTest test suite by changing the `program` name above.
|
|||||||
Before running any of the GTest programs through VS Code, you will first need to
|
Before running any of the GTest programs through VS Code, you will first need to
|
||||||
use SCons to compile the corresponding test program, for example by running
|
use SCons to compile the corresponding test program, for example by running
|
||||||
```sh
|
```sh
|
||||||
scons test-thermo
|
scons build-thermo
|
||||||
```
|
```
|
||||||
|
|
||||||
If you make any changes to the test program or the Cantera library code, re-run this
|
If you make any changes to the test program or the Cantera library code, re-run this
|
||||||
@ -360,11 +360,11 @@ help with running either the C++ or Python tests through GDB on Linux.
|
|||||||
|
|
||||||
### Running C++ (GoogleTest) Tests
|
### Running C++ (GoogleTest) Tests
|
||||||
|
|
||||||
First, run the target test through SCons to make sure the Cantera library and the test
|
First, build the target test through SCons to make sure the Cantera library and the test
|
||||||
executable are up to date. We'll use the `kinetics` test subset as an example, with the
|
executable are up to date. We'll use the `kinetics` test subset as an example, with the
|
||||||
goal of debugging the `PlogLowPressure` test.
|
goal of debugging the `PlogLowPressure` test.
|
||||||
```sh
|
```sh
|
||||||
scons test-kinetics
|
scons build-kinetics
|
||||||
```
|
```
|
||||||
|
|
||||||
Next, you need to set some environment variables that specify where the test program can
|
Next, you need to set some environment variables that specify where the test program can
|
||||||
|
@ -104,7 +104,9 @@ def addTestProgram(subdir, progName, env_vars={}):
|
|||||||
run_program = testenv.Command(passedFile, program, gtestRunner)
|
run_program = testenv.Command(passedFile, program, gtestRunner)
|
||||||
env.Depends(run_program, env['build_targets'])
|
env.Depends(run_program, env['build_targets'])
|
||||||
env.Depends(env['test_results'], run_program)
|
env.Depends(env['test_results'], run_program)
|
||||||
Alias('test-%s' % progName, run_program)
|
Alias(f'test-{progName}', run_program)
|
||||||
|
Alias(f'build-{progName}', program)
|
||||||
|
Alias('build-tests', program)
|
||||||
env['testNames'].append(progName)
|
env['testNames'].append(progName)
|
||||||
else:
|
else:
|
||||||
test_results.failed['test-%s (googletest disabled)' % progName] = 1
|
test_results.failed['test-%s (googletest disabled)' % progName] = 1
|
||||||
|
@ -71,7 +71,9 @@ class Test(object):
|
|||||||
localenv.Depends(env['test_results'], run)
|
localenv.Depends(env['test_results'], run)
|
||||||
localenv.Depends(run, env['build_targets'])
|
localenv.Depends(run, env['build_targets'])
|
||||||
localenv.Alias('test-clean', self.clean(localenv))
|
localenv.Alias('test-clean', self.clean(localenv))
|
||||||
localenv.Alias('test-%s' % self.testName, run)
|
localenv.Alias(f'test-{self.testName}', run)
|
||||||
|
localenv.Alias(f'build-{self.testName}', self.program)
|
||||||
|
localenv.Alias('build-tests', self.program)
|
||||||
env['testNames'].append(self.testName)
|
env['testNames'].append(self.testName)
|
||||||
|
|
||||||
# reset: just delete the ".passed" file so that this test will be re-run
|
# reset: just delete the ".passed" file so that this test will be re-run
|
||||||
|
Loading…
Reference in New Issue
Block a user