diff --git a/lib/pavilion/commands/result.py b/lib/pavilion/commands/result.py index cdc8b85d1..f15bb3780 100644 --- a/lib/pavilion/commands/result.py +++ b/lib/pavilion/commands/result.py @@ -218,11 +218,17 @@ def run(self, pav_cfg, args): else: fields = self.key_fields(args) flat_results = [] + key_results = set() all_passed = True for rslt in results: flat_results.append(utils.flatten_dictionary(rslt)) if rslt['result'] != TestRun.PASS: all_passed = False + + key_results = key_results.union(set(rslt.get('key_results', []))) + + fields += key_results + field_info = { 'created': {'transform': output.get_relative_timestamp}, 'started': {'transform': output.get_relative_timestamp}, diff --git a/lib/pavilion/test_config/file_format.py b/lib/pavilion/test_config/file_format.py index 83c4c813f..ddc8ea37a 100644 --- a/lib/pavilion/test_config/file_format.py +++ b/lib/pavilion/test_config/file_format.py @@ -858,6 +858,12 @@ class TestConfigLoader(yc.YamlConfigLoader): "strings). Other result values (including those " "from result parsers and other evaluations are " "available to reference as variables."), + yc.ListElem( + 'key_results', + sub_elem=yc.StrElem(), + help_text="The list of result keys that should be considered " + "'key results'. These results appear automatically " + "when running 'pav results'."), ModuleWrapperCatElem( 'module_wrappers', help_text="Whenever the given module[/version] is asked for in the 'build.modules' " diff --git a/lib/pavilion/test_run/test_run.py b/lib/pavilion/test_run/test_run.py index 714d210b5..178f90878 100644 --- a/lib/pavilion/test_run/test_run.py +++ b/lib/pavilion/test_run/test_run.py @@ -945,6 +945,7 @@ def gather_results(self, run_result: int, regather: bool = False, results = result.base_results(self) results['return_value'] = run_result + results['key_results'] = self.config.get('key_results', []) result_log("Base results:") result_log.indent(pprint.pformat(results)) diff --git a/test/tests/result_tests.py b/test/tests/result_tests.py index 4d6520cce..f82be1c97 100644 --- a/test/tests/result_tests.py +++ b/test/tests/result_tests.py @@ -1123,3 +1123,38 @@ def test_flatten_results(self): self.assertEqual(flattened, answer) self.assertEqual(unflattened, answer) + + def test_key_results(self): + """Check that specifying key results causes those values to show up + in the results table.""" + + cfg = self._quick_test_cfg() + + cfg['run']['cmds'] = [ + 'echo hello' + ] + cfg['result_parse']['regex'] = { + 'hello': { + 'regex': 'hello', + } + } + cfg['key_results'] = ['hello'] + + test = self._quick_test(cfg, name="key_results_test") + run_result = test.run() + results = test.gather_results(run_result) + test.save_results(results) + + result_cmd = commands.get_command('result') + result_cmd.silence() + + arg_parser = arguments.get_parser() + res_args = arg_parser.parse_args(("result", test.full_id)) + + result_cmd.run(self.pav_cfg, res_args) + cmd_out, cmd_err = result_cmd.clear_output() + + lines = cmd_out.split('\n') + + self.assertIn("Hello", lines[2]) + self.assertIn("hello", lines[4])