Skip to content

Commit

Permalink
Fixes passing compiler/comp-interace to run_tests.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonb5 committed Dec 6, 2023
1 parent 5b8788b commit 4d70147
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions CIME/tests/test_sys_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,29 @@ def setUpClass(cls):
cls._testroot = os.path.join(cls.TEST_ROOT, "TestUnitTests")
cls._testdirs = []

def _has_unit_test_support(self):
if self.TEST_COMPILER is None:
compiler = self.MACHINE.get_default_compiler()
else:
compiler = self.TEST_COMPILER
def setUp(self):
super().setUp()

self._driver = utils.get_cime_default_driver()
self._has_pfunit = self._has_unit_test_support()

mach = self.MACHINE.get_machine_name()
def _has_unit_test_support(self):
cmake_macros_dir = Files().get_value("CMAKE_MACROS_DIR")

macros_to_check = [
os.path.join(cmake_macros_dir, "{}_{}.cmake".format(compiler, mach)),
os.path.join(cmake_macros_dir, "{}.cmake".format(mach)),
os.path.join(
os.environ.get("HOME"), ".cime", "{}_{}.cmake".format(compiler, mach)
cmake_macros_dir,
"{}_{}.cmake".format(self._compiler, self._machine),
),
os.path.join(cmake_macros_dir, "{}.cmake".format(self._machine)),
os.path.join(
os.environ.get("HOME"),
".cime",
"{}_{}.cmake".format(self._compiler, self._machine),
),
os.path.join(
os.environ.get("HOME"), ".cime", "{}.cmake".format(self._machine)
),
os.path.join(os.environ.get("HOME"), ".cime", "{}.cmake".format(mach)),
]

for macro_to_check in macros_to_check:
Expand All @@ -44,7 +51,7 @@ def _has_unit_test_support(self):

def test_a_unit_test(self):
cls = self.__class__
if not self._has_unit_test_support():
if not self._has_pfunit:
self.skipTest(
"Skipping TestUnitTest - PFUNIT_PATH not found for the default compiler on this machine"
)
Expand All @@ -59,8 +66,7 @@ def test_a_unit_test(self):
test_spec_dir = os.path.join(
os.path.dirname(unit_test_tool), "Examples", "interpolate_1d", "tests"
)
args = "--build-dir {} --test-spec-dir {}".format(test_dir, test_spec_dir)
args += " --machine {}".format(self.MACHINE.get_machine_name())
args = f"--build-dir {test_dir} --test-spec-dir {test_spec_dir} --machine {self._machine} --compiler {self._compiler} --comp-interface {self._driver}"
utils.run_cmd_no_fail("{} {}".format(unit_test_tool, args))
cls._do_teardown.append(test_dir)

Expand All @@ -83,8 +89,7 @@ def test_b_cime_f90_unit_tests(self):
test_spec_dir, "scripts", "fortran_unit_testing", "run_tests.py"
)
)
args = "--build-dir {} --test-spec-dir {}".format(test_dir, test_spec_dir)
args += " --machine {}".format(self.MACHINE.get_machine_name())
args = f"--build-dir {test_dir} --test-spec-dir {test_spec_dir} --machine {self._machine} --compiler {self._compiler} --comp-interface {self._driver}"
utils.run_cmd_no_fail("{} {}".format(unit_test_tool, args))
cls._do_teardown.append(test_dir)

Expand Down

0 comments on commit 4d70147

Please sign in to comment.