Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Big cs.status upgrade #1363

Merged
merged 1 commit into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions scripts/Tools/cs.status
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
#!/usr/bin/env python
"""
List test results based on TestStatus files. Returns True if
no errors occured (not based on test statuses).
"""

from standard_script_setup import *
import argparse, sys, os, logging, glob
from CIME.test_status import *

###############################################################################
def parse_command_line(args, description):
###############################################################################
parser = argparse.ArgumentParser(
usage="""\n%s <Glob of TestStatus> [<Path/Glob to TestStatus> ...] [--verbose]
OR
%s --help
OR
%s --test

\033[1mEXAMPLES:\033[0m
\033[1;32m# Wait for all tests in a test area\033[0m
> %s path/to/testarea/*/TestStatus
""" % ((os.path.basename(args[0]), ) * 4),

description=description,

formatter_class=argparse.ArgumentDefaultsHelpFormatter
)

parser.add_argument("paths", nargs="*", help="Paths to TestStatus files.")

parser.add_argument("-s", "--summary", action="store_true",
help="Only show summary")

parser.add_argument("-t", "--test-id", action="append", default=[],
help="Only show summary")

parser.add_argument("-r", "--test-root", default=os.getcwd(),
help="Only show summary")

args = parser.parse_args(args[1:])

return args.paths, args.summary, args.test_id, args.test_root

###############################################################################
def cs_status(test_paths, summary=False):
###############################################################################
test_id_output = {}
for test_path in test_paths:
test_dir=os.path.dirname(test_path)
ts = TestStatus(test_dir=test_dir)
test_id = os.path.basename(test_dir).split(".")[-1]
test_name = ts.get_name()
status = ts.get_overall_test_status()
if not summary:
output = " %s (Overall: %s) details:\n" % (test_name, status)
output += ts.phase_statuses_dump(prefix=" ")
else:
output = " %s %s\n" % (status, test_name)

if test_id in test_id_output:
test_id_output[test_id] += output
else:
test_id_output[test_id] = output

for test_id in sorted(test_id_output):
print test_id
print test_id_output[test_id],

###############################################################################
def _main_func(description):
###############################################################################
test_paths, summary, test_ids, test_root = parse_command_line(sys.argv, description)
for test_id in test_ids:
test_paths.extend(glob.glob(os.path.join(test_root, "*%s/TestStatus" % test_id)))

cs_status(test_paths, summary)

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

if (__name__ == "__main__"):
_main_func(__doc__)
60 changes: 0 additions & 60 deletions scripts/Tools/cs_status

This file was deleted.

3 changes: 2 additions & 1 deletion scripts/lib/CIME/test_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,8 @@ def _setup_cs_files(self):
template = open(template_file, "r").read()
template = template.replace("<PATH>",
os.path.join(self._cime_root,"scripts","Tools")).replace\
("<TESTID>", self._test_id)
("<TESTID>", self._test_id).replace\
("<TESTROOT>", self._test_root)
if not os.path.exists(self._test_root):
os.makedirs(self._test_root)
cs_status_file = os.path.join(self._test_root, "cs.status.%s" % self._test_id)
Expand Down
12 changes: 7 additions & 5 deletions scripts/lib/CIME/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,24 +207,26 @@ def get_status(self, phase):
def get_comment(self, phase):
return self._phase_statuses[phase][1] if phase in self._phase_statuses else None

def phase_statuses_dump(self, fd, prefix=''):
def phase_statuses_dump(self, prefix=''):
"""
Args:
fd: file open for writing
prefix: string printed at the start of each line
"""
result = ""
if self._phase_statuses:
for phase, data in self._phase_statuses.iteritems():
status, comments = data
if not comments:
fd.write("%s%s %s %s\n" % (prefix, status, self._test_name, phase))
result += "%s%s %s %s\n" % (prefix, status, self._test_name, phase)
else:
fd.write("%s%s %s %s %s\n" % (prefix, status, self._test_name, phase, comments))
result += "%s%s %s %s %s\n" % (prefix, status, self._test_name, phase, comments)

return result

def flush(self):
if self._phase_statuses and not self._no_io:
with open(self._filename, "w") as fd:
self.phase_statuses_dump(fd)
fd.write(self.phase_statuses_dump())

def _parse_test_status(self, file_contents):
"""
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/cs.status.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /bin/bash

<PATH>/cs_status *.<TESTID>/TestStatus
<PATH>/cs.status "$@" <TESTROOT>/*.<TESTID>/TestStatus