Added support for command line options for regression tests

This commit is contained in:
Ray Speth 2011-12-14 05:55:40 +00:00
parent 5c95d30807
commit be92c4cbc5
2 changed files with 13 additions and 8 deletions

View file

@ -56,16 +56,19 @@ def regression_test(target, source, env):
else: else:
clargs = [] clargs = []
# Name to use for the output file # Name to use for the output file
if 'blessed' in blessedName: if 'blessed' in blessedName:
outputName = blessedName.replace('blessed', 'output') outputName = blessedName.replace('blessed', 'output')
else: else:
outputName = 'test_output.txt' outputName = 'test_output.txt'
# command line options
clopts = env['test_command_options'].split()
# Run the test program
dir = str(target[0].dir.abspath) dir = str(target[0].dir.abspath)
with open(pjoin(dir,outputName), 'w') as outfile: with open(pjoin(dir,outputName), 'w') as outfile:
code = subprocess.call([program.abspath] + clargs, code = subprocess.call([program.abspath] + clopts + clargs,
stdout=outfile, stderr=outfile, stdout=outfile, stderr=outfile,
cwd=dir) cwd=dir)

View file

@ -7,14 +7,15 @@ os.environ['PYTHONPATH'] = pjoin(os.getcwd(), '..','Cantera','python')
class Test(object): class Test(object):
def __init__(self, subdir, programName, def __init__(self, subdir, programName,
blessedName, arguments=(), blessedName, arguments=(), options='',
extensions=('cpp',), artifacts=(), extensions=('cpp',), artifacts=(),
comparisons=(), tolerance=1e-5, threshold=1e-14): comparisons=(), tolerance=1e-5, threshold=1e-14):
self.subdir = subdir self.subdir = subdir
self.programName = programName self.programName = programName
if isinstance(arguments, str): if isinstance(arguments, str):
arguments = [arguments] arguments = [arguments]
self.arguments = arguments self.arguments = arguments # file arguments
self.options = options
self.blessedName = blessedName self.blessedName = blessedName
self.extensions = extensions self.extensions = extensions
self.artifacts = artifacts self.artifacts = artifacts
@ -30,6 +31,7 @@ class Test(object):
arguments = [pjoin(self.subdir, arg) for arg in self.arguments] arguments = [pjoin(self.subdir, arg) for arg in self.arguments]
source = [prog, pjoin(self.subdir, self.blessedName)] + arguments source = [prog, pjoin(self.subdir, self.blessedName)] + arguments
test = env.RegressionTest(pjoin(self.subdir, self.passedFile), source, test = env.RegressionTest(pjoin(self.subdir, self.passedFile), source,
test_command_options=self.options,
test_comparisons=self.comparisons, test_comparisons=self.comparisons,
test_csv_threshold=self.threshold, test_csv_threshold=self.threshold,
test_csv_tolerance=self.tolerance) test_csv_tolerance=self.tolerance)
@ -184,10 +186,10 @@ tests = [Test(pjoin('cathermo', 'DH_graph_1'),
arguments='haca2.xml', arguments='haca2.xml',
artifacts=['results.txt', 'diamond.xml'], artifacts=['results.txt', 'diamond.xml'],
extensions=['^surfaceSolver.cpp']), # needs .csv, extra tests extensions=['^surfaceSolver.cpp']), # needs .csv, extra tests
# # Disabled because of need for command line arguments Test(pjoin('VCSnonideal', 'NaCl_equil'),
# Test(pjoin('VCSnonideal', 'NaCl_equil'), 'nacl_equil', 'good_out.txt',
# 'nacl_equil', options='-d 3',
# 'good_out.txt'), # needs .csv diff artifacts=['vcs_equilibrate_res.csv']), # not testing this file because it's not really csv
Test('VPsilane_test', 'VPsilane_test', 'output_blessed.txt') Test('VPsilane_test', 'VPsilane_test', 'output_blessed.txt')
] ]