Skip to content

Commit

Permalink
compare_test_results: should work much better when cases are not writ…
Browse files Browse the repository at this point in the history
…able
  • Loading branch information
jgfouca committed Apr 26, 2017
1 parent e53dbcc commit 9933df5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 7 deletions.
5 changes: 4 additions & 1 deletion scripts/lib/CIME/case_cmpgen_namelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ def case_cmpgen_namelists(case, compare=False, generate=False, compare_name=None
logging.warning(warn)
finally:
ts.set_status(NAMELIST_PHASE, TEST_PASS_STATUS if success else TEST_FAIL_STATUS)
append_status(output, logfile_name, caseroot=caseroot)
try:
append_status(output, logfile_name, caseroot=caseroot)
except IOError:
pass

return success

24 changes: 18 additions & 6 deletions scripts/lib/CIME/compare_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

import os, glob, logging

###############################################################################
def append_status_cprnc_log(msg, logfile_name, test_dir):
###############################################################################
try:
append_status(msg, logfile_name, caseroot=test_dir)
except IOError:
pass

###############################################################################
def compare_namelists(case, baseline_name, baseline_root, logfile_name, compiler):
###############################################################################
Expand All @@ -28,8 +36,12 @@ def compare_history(case, baseline_name, baseline_root, log_id, compiler):
baseline_full_dir = os.path.join(baseline_root, baseline_name, case.get_value("CASEBASEID"))

outfile_suffix = "%s.%s" % (baseline_name, log_id)
result, comments = compare_baseline(case, baseline_dir=baseline_full_dir,
outfile_suffix=outfile_suffix)
try:
result, comments = compare_baseline(case, baseline_dir=baseline_full_dir,
outfile_suffix=outfile_suffix)
except IOError:
result, comments = compare_baseline(case, baseline_dir=baseline_full_dir,
outfile_suffix=None)

return result, comments

Expand Down Expand Up @@ -67,12 +79,12 @@ def compare_test_results(baseline_name, baseline_root, test_root, compiler, test
ts = TestStatus(test_dir=test_dir)
test_name = ts.get_name()
if (compare_tests in [[], None] or CIME.utils.match_any(test_name, compare_tests)):
append_status(
append_status_cprnc_log(
"Comparing against baseline with compare_test_results:\n" +
"Baseline: %s\n"%(baseline_name) +
"In baseline_root: %s"%(baseline_root),
logfile_name,
caseroot=test_dir)
test_dir)

if (not hist_only):
nl_compare_result = None
Expand Down Expand Up @@ -143,9 +155,9 @@ def compare_test_results(baseline_name, baseline_root, test_root, compiler, test

print brief_result,

append_status(brief_result, logfile_name, caseroot=test_dir)
append_status_cprnc_log(brief_result, logfile_name, test_dir)

if detailed_comments:
append_status("Detailed comments:\n" + detailed_comments, logfile_name, caseroot=test_dir)
append_status_cprnc_log("Detailed comments:\n" + detailed_comments, logfile_name, test_dir)

return all_pass_or_skip
2 changes: 2 additions & 0 deletions scripts/lib/CIME/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ def __init__(self, test_dir=None, test_name=None, no_io=False):

if os.path.exists(self._filename):
self._parse_test_status_file()
if not os.access(self._filename, os.W_OK):
self._no_io = True
else:
expect(test_name is not None, "Must provide test_name if TestStatus file doesn't exist")

Expand Down

0 comments on commit 9933df5

Please sign in to comment.