diff --git a/testing_and_setup/compass/manage_regression_suite.py b/testing_and_setup/compass/manage_regression_suite.py index a8ef17551a..a64e708305 100755 --- a/testing_and_setup/compass/manage_regression_suite.py +++ b/testing_and_setup/compass/manage_regression_suite.py @@ -147,7 +147,7 @@ def process_test_setup(test_tag, config_file, work_dir, model_runtime, # }}} -def process_test_clean(test_tag, work_dir, suite_script): # {{{ +def process_test_clean(test_tag, work_dir): # {{{ dev_null = open('/dev/null', 'a') # Process test attributes @@ -304,15 +304,13 @@ def clean_suite(suite_tag, work_dir): # {{{ for child in suite_tag: # Process children within the if child.tag == 'test': - process_test_clean(child, work_dir, regression_script) + process_test_clean(child, work_dir) # }}} -def summarize_suite(suite_tag): # {{{ +def get_test_case_procs(suite_tag): # {{{ - max_procs = 1 - max_threads = 1 - max_cores = 1 + testcases = {} for child in suite_tag: if child.tag == 'test': @@ -367,9 +365,36 @@ def summarize_suite(suite_tag): # {{{ name = case.attrib['name'] cases.append(name) + prereqs = list() + for config_prereq in config_root.iter('prerequisite'): + prereq = dict() + for tag in ['core', 'configuration', 'resolution', 'test']: + prereq[tag] = config_prereq.attrib[tag] + + # Make sure the prerequisite is already in the test suite + found = False + for other_name, other_test in testcases.items(): + match = [prereq[tag] == other_test[tag] for tag in + ['core', 'configuration', 'resolution', 'test']] + if all(match): + found = True + prereq['name'] = other_name + break + + if not found: + raise ValueError( + 'Prerequisite of {} does not precede it in the test ' + 'suite: {} {} {} {}'.format( + test_name, prereq['core'], prereq['configuration'], + prereq['resolution'], prereq['test'])) + + prereqs.append(prereq) + del config_root del config_tree + procs = 1 + threads = 1 # Loop over all files in test_path that have the .xml extension. for file in os.listdir('{}'.format(test_path)): if fnmatch.fnmatch(file, '*.xml'): @@ -395,19 +420,33 @@ def summarize_suite(suite_tag): # {{{ except (KeyError, ValueError): threads = 1 - cores = threads * procs + del config_root + del config_tree + testcases[test_name] = {'core': test_core, + 'configuration': test_configuration, + 'resolution': test_resolution, + 'test': test_test, + 'path': test_path, + 'procs': procs, + 'threads': threads, + 'prereqs': prereqs} - if procs > max_procs: - max_procs = procs + return testcases # }}} - if threads > max_threads: - max_threads = threads - if cores > max_cores: - max_cores = cores +def summarize_suite(testcases): # {{{ - del config_root - del config_tree + max_procs = 1 + max_threads = 1 + max_cores = 1 + for name in testcases: + procs = testcases[name]['procs'] + threads = testcases[name]['threads'] + cores = threads * procs + + max_procs = max(max_procs, procs) + max_threads = max(max_threads, threads) + max_cores = max(max_cores, cores) print("\n") print(" Summary of test cases:") @@ -417,7 +456,7 @@ def summarize_suite(suite_tag): # {{{ # }}} -if __name__ == "__main__": +def main (): # {{{ # Define and process input arguments parser = argparse.ArgumentParser( description=__doc__, formatter_class=argparse.RawTextHelpFormatter) @@ -495,14 +534,15 @@ def summarize_suite(suite_tag): # {{{ if args.setup: print("\n") print("Setting Up Test Cases:") + testcases = get_test_case_procs(suite_root) setup_suite(suite_root, args.work_dir, args.model_runtime, args.config_file, args.baseline_dir, args.verbose) - summarize_suite(suite_root) + summarize_suite(testcases) if args.verbose: cmd = ['cat', args.work_dir + '/manage_regression_suite.py.out'] print('\nCase setup output:') - print(subprocess.check_output(cmd)) + print(subprocess.check_output(cmd).decode('utf-8')) write_history = True # Write the history of this command to the command_history file, for @@ -533,5 +573,10 @@ def summarize_suite(suite_tag): # {{{ history_file.write('**************************************************' '*********************\n') history_file.close() +# }}} + + +if __name__ == "__main__": + main() # vim: foldmethod=marker ai ts=4 sts=4 et sw=4 ft=python