diff --git a/source/fab/tools/compiler.py b/source/fab/tools/compiler.py index 7236d793..7448411b 100644 --- a/source/fab/tools/compiler.py +++ b/source/fab/tools/compiler.py @@ -474,21 +474,7 @@ class Nvc(CCompiler): def __init__(self, name: str = "nvc", exec_name: str = "nvc"): super().__init__(name, exec_name, suite="nvidia", openmp_flag="-mp", - version_regex=r"nvc (\d[\d\.-]+\d)") - - def run_version_command( - self, version_command: Optional[str] = '--version') -> str: - '''Run the compiler's command to get its version. This implementation - runs the function in the base class, and changes any '-' into a - '.' to support nvidia version numbers which have dashes, e.g. 23.5-0. - - :param version_command: The compiler argument used to get version info. - - :returns: The output from the version command, with any '-' replaced - with '.' - ''' - version_string = super().run_version_command() - return version_string.replace("-", ".") + version_regex=r"nvc (\d[\d\.]+\d)") # ============================================================================ @@ -506,21 +492,7 @@ def __init__(self, name: str = "nvfortran", exec_name: str = "nvfortran"): module_folder_flag="-module", openmp_flag="-mp", syntax_only_flag="-Msyntax-only", - version_regex=r"nvfortran (\d[\d\.-]+\d)") - - def run_version_command( - self, version_command: Optional[str] = '--version') -> str: - '''Run the compiler's command to get its version. This implementation - runs the function in the base class, and changes any '-' into a - '.' to support nvidia version numbers which have dashes, e.g. 23.5-0. - - :param version_command: The compiler argument used to get version info. - - :returns: The output from the version command, with any '-' replaced - with '.' - ''' - version_string = super().run_version_command() - return version_string.replace("-", ".") + version_regex=r"nvfortran (\d[\d\.]+\d)") # ============================================================================ @@ -545,7 +517,7 @@ class Craycc(CCompiler): def __init__(self, name: str = "craycc-cc", exec_name: str = "cc"): super().__init__(name, exec_name, suite="cray", mpi=True, openmp_flag="-homp", - version_regex=r"Cray [Cc][^\d]* (\d[\d\.]+\d) ") + version_regex=r"Cray [Cc][^\d]* (\d[\d\.]+\d)") # ============================================================================ @@ -564,4 +536,4 @@ def __init__(self, name: str = "crayftn-ftn", exec_name: str = "ftn"): openmp_flag="-homp", syntax_only_flag="-syntax-only", version_regex=(r"Cray Fortran : Version " - r"(\d[\d\.]+\d) ")) + r"(\d[\d\.]+\d)")) diff --git a/tests/unit_tests/tools/test_compiler.py b/tests/unit_tests/tools/test_compiler.py index 60c18d78..fbbce38f 100644 --- a/tests/unit_tests/tools/test_compiler.py +++ b/tests/unit_tests/tools/test_compiler.py @@ -778,7 +778,7 @@ def test_nvc_get_version_23_5_0(): """) nvc = Nvc() with mock.patch.object(nvc, "run", mock.Mock(return_value=full_output)): - assert nvc.get_version() == (23, 5, 0) + assert nvc.get_version() == (23, 5) def test_nvc_get_version_with_icc_string(): @@ -819,7 +819,7 @@ def test_nvfortran_get_version_23_5_0(): nvfortran = Nvfortran() with mock.patch.object(nvfortran, "run", mock.Mock(return_value=full_output)): - assert nvfortran.get_version() == (23, 5, 0) + assert nvfortran.get_version() == (23, 5) def test_nvfortran_get_version_with_ifort_string():