File: compilers.py

package info (click to toggle)
dh-fortran 0.45
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 492 kB
  • sloc: f90: 5,686; perl: 531; python: 296; makefile: 79; sh: 7
file content (35 lines) | stat: -rw-r--r-- 796 bytes parent folder | download
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
#!/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():
    assert cp.get_fc_flavor("/usr/bin/gfortran") == "gfortran"
    assert cp.get_fc_flavor("/usr/bin/gfortran-14") == "gfortran14"
    assert cp.get_fc_flavor("/bin/aarch64-linux-gnu-gfortran-14") == "gfortran14"

    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_fort_root():
    assert cp.get_fort_root() == f"/usr/lib/{cp._multiarch}/fortran"


if __name__ == "__main__":
    import pytest

    pytest.main()