Skip to content

Commit

Permalink
Move case1 flush to immediately after case1 setup
Browse files Browse the repository at this point in the history
I was hoping that, by having the case1 flush come after case2 setup, that would
mean that errors in case2 setup would prevent the case1 flush from
happening. But that doesn't seem to be the case: I introduced an error in case2
setup, and case1's xml files still reflected changed I had made in case1
setup. In addition, I realized that deferring the case1 flush wouldn't help with
appends to user_nl files (which don't rely on a flush). So I'm moving the case1
flush back to just after case1 setup, which is more clear.

I'm also adding a log message warning the user that the case is in an
inconsistent state, if an error occurs during 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
  • Loading branch information
billsacks committed Aug 6, 2016
1 parent 482e3c5 commit 1e5e620
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions utils/python/CIME/SystemTests/system_tests_compare_two_clone.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ def __init__(self,
# think, "okay, setup is done, I can move on to the build",
# which would be wrong.
shutil.rmtree(self._caseroot2)
self._activate_case1()
logger.warning("Test case setup failed. Case2 has been removed, "
"but the main case may be in an inconsistent state. "
"If you want to rerun this test, you should create "
"a new test rather than trying to rerun this one.")
raise

# ========================================================================
Expand Down Expand Up @@ -276,6 +281,13 @@ def _setup_cases(self):
self._activate_case1()
self._common_setup()
self._case_one_setup()
# Flush the case so that, if errors occur later, then at least case 1 is
# in a correct, post-setup state. Note that case 1 will be in its
# post-setup state even if case 2 setup fails. Putting the case1 flush
# after case 2 setup doesn't seem to help with that (presumably some
# flush is called automatically), and anyway wouldn't help with things
# like appending to user_nl files (which don't rely on flush).
self._case.flush()

# Set up case 2
self._activate_case2()
Expand All @@ -285,11 +297,8 @@ def _setup_cases(self):
# in a correct, post-setup state
self._case.flush()

# Flush case 1. We do this at the end rather than immediately after
# setting up case 1 so that, if an exception is raised in the set up for
# case 2, then case 1 will be in its original (pre-setup) state.
# Go back to case 1 to ensure that's where we are for any following code
self._activate_case1()
self._case.flush()

def _force_case2_settings(self):
"""
Expand Down

0 comments on commit 1e5e620

Please sign in to comment.