From e406c311a79cbff8f919c2580a756e5c7efd54d0 Mon Sep 17 00:00:00 2001 From: Bill Sacks Date: Wed, 27 Jul 2016 20:36:05 -0600 Subject: [PATCH] Add _common_setup to SystemTestsCompareTwo Also add some necessary settings in REP test, in _common_setup Test suite: None Test baseline: N/A Test namelist changes: N/A Test status: N/A Fixes: None User interface changes?: No Code review: None --- utils/python/CIME/SystemTests/rep.py | 10 +++++++ .../SystemTests/system_tests_compare_two.py | 27 +++++++++++++++++-- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/utils/python/CIME/SystemTests/rep.py b/utils/python/CIME/SystemTests/rep.py index b8664a3fc0c3..478a8d335352 100644 --- a/utils/python/CIME/SystemTests/rep.py +++ b/utils/python/CIME/SystemTests/rep.py @@ -15,6 +15,16 @@ def __init__(self, case): self.set_description_first_phase('Run 1') self.set_description_second_phase('Run 2') + def _common_setup(self): + # TODO(wjs, 2016-07-27) Many of these settings are made for most tests - + # especially setting HIST_OPTION and HIST_N. Should these be moved to + # some common place to avoid duplication by all tests (and in case some + # other "standard" settings are added in the future)? + self._case.set_value("CONTINUE_RUN",False) + self._case.set_value("REST_OPTION","none") + self._case.set_value("HIST_OPTION","$STOP_OPTION") + self._case.set_value("HIST_N","$STOP_N") + def _setup_first_phase(self): pass diff --git a/utils/python/CIME/SystemTests/system_tests_compare_two.py b/utils/python/CIME/SystemTests/system_tests_compare_two.py index ea55c11ef5d3..b02a462727cb 100644 --- a/utils/python/CIME/SystemTests/system_tests_compare_two.py +++ b/utils/python/CIME/SystemTests/system_tests_compare_two.py @@ -8,14 +8,23 @@ Classes that inherit from this are REQUIRED to implement the following methods: -(1) _setup_first_phase +(1) _common_setup + This method will be called before both the first and second phase of the + two-phase test, before either _setup_first_phase or + _setup_second_phase. This should contain settings needed for both phases of + the run, such as setting CONTINUE_RUN to False. In principle, these settings + could just be made once, but for robustness and communication purposes, this + is executed before both run phases. + +(2) _setup_first_phase This method will be called to set up the run for the first phase of the two-phase test -(2) _setup_second_phase +(3) _setup_second_phase This method will be called to set up the run for the second phase of the two-phase test + In addition, the __init__ method in subclasses MAY set various attributes AFTER calling SystemTestsCompareTwo.__init__, via calls to the following. However, this is only for the sake of enhancing communication via logging, file names, @@ -126,6 +135,18 @@ def set_description_second_phase(self, description): # base class # ======================================================================== + def _common_setup(self): + """ + This method will be called before both the first and second phase of the + two-phase test, before either _setup_first_phase or + _setup_second_phase. This should contain settings needed for both phases of + the run, such as setting CONTINUE_RUN to False. In principle, these settings + could just be made once, but for robustness and communication purposes, this + is executed before both run phases. + """ + raise NotImplementedError + + def _setup_first_phase(self): """ Sets up the run for the first phase of the two-phase test. @@ -152,6 +173,7 @@ def run(self): Runs both phases of the two-phase test and compares their results """ + self._common_setup() self._setup_first_phase() self._case.flush() logger.info('Doing first run: ' + self._description_first_phase) @@ -162,6 +184,7 @@ def run(self): self._status_run1 = "FAIL" return False + self._common_setup() self._setup_second_phase() self._case.flush() logger.info('Doing second run: ' + self._description_second_phase)