diff --git a/CIME/test_scheduler.py b/CIME/test_scheduler.py index 2f05d946e03..acad9b9aba0 100644 --- a/CIME/test_scheduler.py +++ b/CIME/test_scheduler.py @@ -166,6 +166,20 @@ def _order_tests_by_runtime(tests, baseline_root): ) +############################################################################### +def _run_cmpgen_namelists(test_dir): + ############################################################################### + env = os.environ.copy() + env["PYTHONPATH"] = f"{get_cime_root()}:{get_tools_path()}" + cmdstat, output, _ = run_cmd( + "./case.cmpgen_namelists", + combine_output=True, + from_dir=test_dir, + env=env, + ) + return cmdstat, output + + ############################################################################### class TestScheduler(object): ############################################################################### @@ -998,24 +1012,11 @@ def _setup_phase(self, test): test, "./case.setup", SETUP_PHASE, from_dir=test_dir ) - # It's OK for this command to fail with baseline diffs but not catastrophically + # cmpgen_namelists is called again with checks later in _setup_phase(). This call is + # necessary for the correct behavior of --skip-tests-with-existing-baselines, and we don't + # need to check it for errors. if rv[0]: - env = os.environ.copy() - env["PYTHONPATH"] = f"{get_cime_root()}:{get_tools_path()}" - cmdstat, output, _ = run_cmd( - "./case.cmpgen_namelists", - combine_output=True, - from_dir=test_dir, - env=env, - ) - try: - expect( - cmdstat in [0, TESTS_FAILED_ERR_CODE], - "Fatal error in case.cmpgen_namelists: {}".format(output), - ) - except Exception: - self._update_test_status_file(test, SETUP_PHASE, TEST_FAIL_STATUS) - raise + _run_cmpgen_namelists(test_dir) if self._single_exe: with Case(self._get_test_dir(test), read_only=False) as case: @@ -1046,13 +1047,28 @@ def _sharedlib_build_phase(self, test): ) test_dir = self._get_test_dir(test) - return self._shell_cmd_for_phase( + result = self._shell_cmd_for_phase( test, "./case.build --sharedlib-only", SHAREDLIB_BUILD_PHASE, from_dir=test_dir, ) + # It's OK for this command to fail with baseline diffs but not catastrophically + env = os.environ.copy() + env["PYTHONPATH"] = f"{get_cime_root()}:{get_tools_path()}" + cmdstat, output = _run_cmpgen_namelists(test_dir) + try: + expect( + cmdstat in [0, TESTS_FAILED_ERR_CODE], + "Fatal error in case.cmpgen_namelists: {}".format(output), + ) + except Exception: + self._update_test_status_file(test, SETUP_PHASE, TEST_FAIL_STATUS) + raise + + return result + ########################################################################### def _get_build_group(self, test): ###########################################################################