1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#!/usr/bin/env python3
"""
Compiler ID handling for dhfortran: tests
Copyright (C) 2025 Alastair McKinstry <mckinstry@debian.org>
Released under the GPL-3 GNU Public License.
"""
import dhfortran.compilers as cp
def test_get_flavor():
gf = cp.default_compilers["gfortran"]
assert cp.get_fc_flavor("/usr/bin/gfortran") == gf
assert cp.get_fc_flavor("/usr/bin/gfortran-15") == gf
assert cp.get_fc_flavor(f"/usr/bin/{cp.multiarch}-gfortran-15") == gf
assert cp.get_fc_flavor("/etc/alternatives/f95") == gf
try:
x = cp.get_fc_flavor("/bin/garbage")
except Exception as ex:
pass
else:
assert 1
1, "get_fc_flavor('/bin/garbage') should fail"
def test_get_fc_default():
gf = cp.default_compilers["gfortran"]
assert cp.get_fc_default() == gf
def test_get_optional():
assert cp.get_fc_optional() is not None
if __name__ == "__main__":
import pytest
pytest.main()
|