Skip to content

Commit

Permalink
Merge branch 'linker-lib-flags' into additional_compilers
Browse files Browse the repository at this point in the history
  • Loading branch information
hiker committed Nov 21, 2024
2 parents 20fe928 + 0464dc5 commit f7b49e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
10 changes: 9 additions & 1 deletion source/fab/tools/compiler_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,20 @@ def __str__(self):
return f"{type(self).__name__}({self._compiler.name})"

def get_version(self) -> Tuple[int, ...]:
"""
"""Determines the version of the compiler. The implementation in the
compiler wrapper additionally ensures that the wrapper compiler and
compiler wrapper report both the same version. This verifies that the
user's build environment is as expected. For example, this will check
if mpif90 from mpif90-ifort does indeed invoke ifort (and not e.g.
gfortran).
:returns: a tuple of at least 2 integers, representing the version
e.g. (6, 10, 1) for version '6.10.1'.
:raises RuntimeError: if the compiler was not found, or if it returned
an unrecognised output from the version command.
:raises RuntimeError: if the compiler wrapper and wrapped compiler
have different version numbers.
"""

if self._version is not None:
Expand Down
17 changes: 8 additions & 9 deletions tests/unit_tests/tools/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,19 +659,18 @@ def test_ifort_get_version_with_icc_string():
"0.5.1.",
"0.5..1"])
def test_ifort_get_version_invalid_version(version):
'''Tests the icc class with an icc version string that contains an invalid
version number.'''
'''Tests the ifort class with an ifort version string that contains an
invalid version number.'''
full_output = dedent(f"""
icc (ICC) {version} 20230609
Copyright (C) 1985-2023 Intel Corporation. All rights reserved.
ifort (IFORT) {version} 20140422
Copyright (C) 1985-2014 Intel Corporation. All rights reserved.
""")
icc = Ifort()
with mock.patch.object(icc, "run", mock.Mock(return_value=full_output)):
ifort = Ifort()
with mock.patch.object(ifort, "run", mock.Mock(return_value=full_output)):
with pytest.raises(RuntimeError) as err:
icc.get_version()
assert ("Unexpected version output format for compiler"
in str(err.value))
ifort.get_version()
assert "Unexpected version output format for compiler" in str(err.value)


# ============================================================================
Expand Down

0 comments on commit f7b49e0

Please sign in to comment.