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

currently only reads the first Macros file found, this fixes that so … #4535

Merged
merged 3 commits into from
Dec 11, 2023
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
4 changes: 4 additions & 0 deletions CIME/tests/scripts_regression_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from CIME.provenance import get_test_success, save_test_success
from CIME import utils
from CIME.tests.base import BaseTestCase
from CIME.config import Config

os.environ["CIME_GLOBAL_WALLTIME"] = "0:05:00"

Expand Down Expand Up @@ -151,6 +152,9 @@ def configure_tests(
):
config = CIME.utils.get_cime_config()

customize_path = os.path.join(utils.get_src_root(), "cime_config", "customize")
Config.load(customize_path)

if timeout:
BaseTestCase.GLOBAL_TIMEOUT = str(timeout)

Expand Down
39 changes: 22 additions & 17 deletions CIME/tests/test_sys_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,42 @@ 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:
if os.path.exists(macro_to_check):
macro_text = open(macro_to_check, "r").read()

return "PFUNIT_PATH" in macro_text
if "PFUNIT_PATH" in macro_text:
return True

return False

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
Loading