Skip to content

Commit

Permalink
bless_test_results: Need sane error code
Browse files Browse the repository at this point in the history
Return non-zero if there were significant problems during bless
  • Loading branch information
jgfouca committed Aug 17, 2016
1 parent 30a48da commit 26345c0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
6 changes: 3 additions & 3 deletions scripts/Tools/bless_test_results
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ changes, and updating baselines. Purpose is, instead of re-running tests
in generate mode, which is very slow, allow for very fast analsis and
blessing of diffs.
Be aware that restart test will overwrite the original namelist files
with versions of the files that you should not bless.
You may need to load modules for cprnc to work.
"""

from standard_script_setup import *
Expand Down Expand Up @@ -103,7 +102,8 @@ def _main_func(description):
baseline_name, test_root, compiler, test_id, namelists_only, hist_only, report_only, force, bless_tests = \
parse_command_line(sys.argv, description)

CIME.bless_test_results.bless_test_results(baseline_name, test_root, compiler, test_id, namelists_only, hist_only, report_only, force, bless_tests)
success = CIME.bless_test_results.bless_test_results(baseline_name, test_root, compiler, test_id, namelists_only, hist_only, report_only, force, bless_tests)
sys.exit(0 if success else 1)

###############################################################################

Expand Down
16 changes: 10 additions & 6 deletions utils/python/CIME/bless_test_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
###############################################################################
def bless_namelists(test_name, report_only, force, baseline_name):
###############################################################################
# Be aware that restart test will overwrite the original namelist files
# with versions of the files that should not be blessed. This forces us to
# re-run create_test.

# Update namelist files
print "Test '%s' had a namelist diff" % test_name
if (not report_only and
Expand Down Expand Up @@ -53,11 +57,6 @@ def bless_test_results(baseline_name, test_root, compiler, test_id=None, namelis
test_status_files = glob.glob("%s/%s/%s" % (test_root, test_id_glob, TEST_STATUS_FILENAME))
expect(test_status_files, "No matching test cases found in for %s/%s/%s" % (test_root, test_id_glob, TEST_STATUS_FILENAME))

# The env_mach_specific script may need these to be defined
compiler = _MACHINE.get_default_compiler() # this MUST match compiler that cprnc was built with
os.environ["COMPILER"] = compiler
os.environ["MPILIB"] = _MACHINE.get_default_MPIlib(attributes={"compiler":compiler})

broken_blesses = []
for test_status_file in test_status_files:
ts = TestStatus(test_dir=os.path.dirname(test_status_file))
Expand Down Expand Up @@ -106,7 +105,8 @@ def bless_test_results(baseline_name, test_root, compiler, test_id=None, namelis
print "###############################################################################"
print "Blessing results for test:", test_name, "most recent result:", overall_result
print "###############################################################################"
time.sleep(2)
if not force:
time.sleep(2)

# Get testcase dir for this test
if (test_id is None):
Expand Down Expand Up @@ -135,5 +135,9 @@ def bless_test_results(baseline_name, test_root, compiler, test_id=None, namelis
broken_blesses.append((test_name, reason))

# Make sure user knows that some tests were not blessed
success = True
for broken_bless, reason in broken_blesses:
logging.warning("FAILED TO BLESS TEST: %s, reason %s" % (broken_bless, reason))
success = False

return success

0 comments on commit 26345c0

Please sign in to comment.