Skip to content

Commit

Permalink
Merge pull request #1597 from ESMCI/jgfouca/infer_machine_from_tests
Browse files Browse the repository at this point in the history
Add ability for create_test to infer non-default machine from tests
Test suite: scripts_regression_tests --fast
Test baseline:
Test namelist changes:
Test status: bit for bit

Fixes #1417

User interface changes?: None

Code review: @jedwards4b
  • Loading branch information
jedwards4b authored May 24, 2017
2 parents b4ae2d4 + 0c4e531 commit 7003fe2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions scripts/create_test
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ OR

logger.info("Testnames: %s" % test_names)
else:
if args.machine is None:
args.machine = update_acme_tests.infer_machine_name_from_tests(args.testargs)

mach_obj = Machines(machine=args.machine)
args.compiler = mach_obj.get_default_compiler() if args.compiler is None else args.compiler

Expand Down
32 changes: 31 additions & 1 deletion scripts/lib/update_acme_tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import CIME.utils
from CIME.utils import expect, convert_to_seconds
from CIME.utils import expect, convert_to_seconds, parse_test_name
from CIME.XML.machines import Machines

# Here are the tests belonging to acme suites. Format is
Expand Down Expand Up @@ -210,6 +210,36 @@ def get_test_suites():
###############################################################################
return _TEST_SUITES.keys()

###############################################################################
def infer_machine_name_from_tests(testargs):
###############################################################################
"""
>>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu"])
'melvin'
>>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A"])
>>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A", "NCK.f19_g16_rx1.A.melvin_gnu"])
'melvin'
>>> infer_machine_name_from_tests(["NCK.f19_g16_rx1.A.melvin_gnu", "NCK.f19_g16_rx1.A.melvin_gnu"])
'melvin'
"""
acme_test_suites = get_test_suites()

machine = None
for testarg in testargs:
testarg = testarg.strip()
if testarg.startswith("^"):
testarg = testarg[1:]

if testarg not in acme_test_suites:
machine_for_this_test = parse_test_name(testarg)[4]
if machine_for_this_test is not None:
if machine is None:
machine = machine_for_this_test
else:
expect(machine == machine_for_this_test, "Must have consistent machine '%s' != '%s'" % (machine, machine_for_this_test))

return machine

###############################################################################
def get_full_test_names(testargs, machine, compiler):
###############################################################################
Expand Down

0 comments on commit 7003fe2

Please sign in to comment.