Skip to content

Commit

Permalink
Fixes post-upstream-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jgfouca committed Aug 7, 2016
1 parent ea97b56 commit 1b775e4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
15 changes: 14 additions & 1 deletion utils/python/CIME/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,11 @@ def _consumer(self, test, test_phase, phase_method):
test_dir = self._get_test_dir(test)

with TestStatus(test_dir=test_dir, test_name=test) as ts:
ts.set_status(test_phase, status)
nl_problem = self._get_test_data(test)[2]
if test_phase == NAMELIST_PHASE and nl_problem:
ts.set_status(test_phase, TEST_FAIL_STATUS)
else:
ts.set_status(test_phase, status)

# On batch systems, we want to immediately submit to the queue, because
# it's very cheap to submit and will get us a better spot in line
Expand Down Expand Up @@ -815,6 +819,15 @@ def run_tests(self):
rv = True
for test in self._tests:
phase, status, nl_fail = self._get_test_data(test)

if status == TEST_PASS_STATUS and phase == RUN_PHASE:
# Be cautious about telling the user that the test passed. This
# status should match what they would see on the dashboard. Our
# self._test_states does not include comparison fail information,
# so we need to parse test status.
ts = TestStatus(self._get_test_dir(test))
status = ts.get_overall_test_status()

if status not in [TEST_PASS_STATUS, TEST_PENDING_STATUS]:
logger.info( "%s %s (phase %s)" % (status, test, phase))
rv = False
Expand Down
8 changes: 6 additions & 2 deletions utils/python/CIME/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ def set_status(self, phase, status, comments=""):
... ts.set_status(XML_PHASE, "PASS")
... ts.set_status(SETUP_PHASE, "PASS")
... ts.set_status(SETUP_PHASE, "FAIL")
... ts.set_status("%s_baseline" % COMPARE_PHASE, "FAIL")
... ts.set_status(SHAREDLIB_BUILD_PHASE, "PASS", comments='Time=42')
... result = OrderedDict(ts._phase_statuses)
... ts._phase_statuses = None
>>> result
OrderedDict([('CREATE_NEWCASE', ('PASS', '')), ('XML', ('PASS', '')), ('SETUP', ('FAIL', ''))])
OrderedDict([('CREATE_NEWCASE', ('PASS', '')), ('XML', ('PASS', '')), ('SETUP', ('FAIL', '')), ('COMPARE_baseline', ('FAIL', '')), ('SHAREDLIB_BUILD', ('PASS', 'Time=42'))])
"""
expect(self._ok_to_modify, "TestStatus not in a modifiable state, use 'with' syntax")
expect(phase in ALL_PHASES or phase.startswith(COMPARE_PHASE),
Expand Down Expand Up @@ -129,9 +131,11 @@ def _parse_test_status(self, file_contents):
... PASS ERS.foo.A CREATE_NEWCASE
... PASS ERS.foo.A XML
... FAIL ERS.foo.A SETUP
... PASS ERS.foo.A COMPARE_baseline
... PASS ERS.foo.A SHAREDLIB_BUILD Time=42
... '''
>>> _test_helper1(contents)
OrderedDict([('CREATE_NEWCASE', ('PASS', '')), ('XML', ('PASS', '')), ('SETUP', ('FAIL', ''))])
OrderedDict([('CREATE_NEWCASE', ('PASS', '')), ('XML', ('PASS', '')), ('SETUP', ('FAIL', '')), ('COMPARE_baseline', ('PASS', '')), ('SHAREDLIB_BUILD', ('PASS', 'Time=42'))])
"""
for line in file_contents.splitlines():
line = line.strip()
Expand Down
15 changes: 7 additions & 8 deletions utils/python/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ def test_resolve_variable_name(self):

def test_CIME_unit_tests(self):
# Find and run all the unit tests in the CIME directory tree
os.environ["PYTHONPATH"] = LIB_DIR
stat, output, _ = run_cmd("python -m doctest *.py 2>&1", from_dir=os.path.join(LIB_DIR,"CIME"))
stat, output, _ = run_cmd("PYTHONPATH=%s:$PYTHONPATH python -m doctest *.py 2>&1" % LIB_DIR, from_dir=os.path.join(LIB_DIR,"CIME"))
self.assertEqual(stat, 0, msg=output)

def test_CIMEXML_unit_tests(self):
# Find and run all the unit tests in the XML directory tree
os.environ["PYTHONPATH"] = LIB_DIR
stat, output, _ = run_cmd("python -m doctest *.py 2>&1", from_dir=os.path.join(LIB_DIR,"CIME","XML"))
stat, output, _ = run_cmd("PYTHONPATH=%s:$PYTHONPATH python -m doctest *.py 2>&1" % LIB_DIR, from_dir=os.path.join(LIB_DIR,"CIME","XML"))
self.assertEqual(stat, 0, msg=output)

###############################################################################
Expand Down Expand Up @@ -690,10 +688,11 @@ def simple_test(self, expect_works, extra_args):
cmd = "%s/create_test %s %s" % (SCRIPT_DIR, self._test_name, extra_args)
stat, output, errput = run_cmd(cmd)

self.assertEqual(stat, 0, msg="COMMAND '%s' SHOULD HAVE WORKED\ncreate_test output:\n%s\n\nerrput:\n%s\n\ncode: %d" % (cmd, output, errput, stat))
test_id = extra_args.split()[extra_args.split().index("-t") + 1]
cmd = "%s/wait_for_tests *%s*/TestStatus" % (TOOLS_DIR, test_id)
stat, output, errput = run_cmd("%s/wait_for_tests *%s*/TestStatus" % (TOOLS_DIR, test_id), from_dir=self._testroot)
if self._hasbatch:
self.assertEqual(stat, 0, msg="COMMAND '%s' SHOULD HAVE WORKED\ncreate_test output:\n%s\n\nerrput:\n%s\n\ncode: %d" % (cmd, output, errput, stat))
test_id = extra_args.split()[extra_args.split().index("-t") + 1]
cmd = "%s/wait_for_tests *%s*/TestStatus" % (TOOLS_DIR, test_id)
stat, output, errput = run_cmd(cmd, from_dir=self._testroot)

if (expect_works):
self.assertEqual(stat, 0, msg="COMMAND '%s' SHOULD HAVE WORKED\nOutput:\n%s\n\nerrput:\n%s\n\ncode: %d" % (cmd, output, errput, stat))
Expand Down

0 comments on commit 1b775e4

Please sign in to comment.