diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index a64e708305..e558180fcf 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -2,16 +2,14 @@ """ This script is used to manage regression suites. A regression suite is a set of test cases that ensure one or more features in a model meet certain criteria. - Using this script one can setup or clean a regression suite. - When setting up a regression suite, this script will generate a script to run all tests in the suite, and additionally setup each individual test case. - When cleaning a regression suite, this script will remove any generated files for each individual test case, and the run script that runs all test cases. """ - +# -----import libraries----- +# {{{ from __future__ import absolute_import, division, print_function, \ unicode_literals @@ -22,10 +20,12 @@ import xml.etree.ElementTree as ET import subprocess +# }}} + def process_test_setup(test_tag, config_file, work_dir, model_runtime, - suite_script, baseline_dir, verbose): # {{{ - + script_code, baseline_dir, verbose, isparallel): + # {{{ if verbose: stdout = open(work_dir + '/manage_regression_suite.py.out', 'a') stderr = stdout @@ -85,71 +85,72 @@ def process_test_setup(test_tag, config_file, work_dir, model_runtime, subprocess.check_call( ['./setup_testcase.py', '-q', '-f', config_file, '--work_dir', work_dir, '-o', test_core, '-c', test_configuration, - '-r', test_resolution, '-t', test_test, '-m', model_runtime], + '-r', test_resolution, '-t', test_test, '-m', model_runtime], stdout=stdout, stderr=stderr) else: subprocess.check_call( ['./setup_testcase.py', '-q', '-f', config_file, '--work_dir', work_dir, '-o', test_core, '-c', test_configuration, - '-r', test_resolution, '-t', test_test, '-m', model_runtime, + '-r', test_resolution, '-t', test_test, '-m', model_runtime, '-b', baseline_dir], stdout=stdout, stderr=stderr) print(" -- Setup case '{}': -o {} -c {} -r {} -t {}".format( test_name, test_core, test_configuration, test_resolution, test_test)) - # Write step into suite script to cd into the base of the regression suite - suite_script.write("os.chdir(base_path)\n") - - # Write the step to define the output file - suite_script.write("case_output = open('case_outputs/{}', 'w')\n".format( - case_output_name)) - - # Write step to cd into test case directory - suite_script.write("os.chdir('{}/{}/{}/{}')\n".format( - test_core, test_configuration, test_resolution, test_test)) + if not isparallel: + # Write step into suite script to cd into the base of the regression suite + script_code += "os.chdir(base_path)\n" + + # Write the step to define the output file + script_code += "case_output = open('case_outputs/{}', 'w')\n".format( + case_output_name) + + # Write step to cd into test case directory + script_code += "os.chdir('{}/{}/{}/{}')\n".format( + test_core, test_configuration, test_resolution, test_test) + + for script in test_tag: + # Process test case script + if script.tag == 'script': + try: + script_name = script.attrib['name'] + except KeyError: + print("ERROR: