File: main.py

package info (click to toggle)
dh-fortran 0.57
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 816 kB
  • sloc: f90: 5,705; python: 1,485; perl: 610; makefile: 80; sh: 7
file content (107 lines) | stat: -rw-r--r-- 2,912 bytes parent folder | download | duplicates (4)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/python3
"""
Test Driver for dh-fortran/main.py

Copyright (C) 2025 Alastair McKinstry <mckinstry@debian.org>
Released under the GPL-3 Gnu Public License.
"""

from click.testing import CliRunner
import dhfortran.main as main
import dhfortran.debhelper as dh


def test_dh_fortran():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, [])
    assert result.exit_code == 0
    # assert result.output == 'Hello Peter!\n'


def test_dh_fortran_get_fc_default_simple():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["get_fc_default"])
    assert result.exit_code == 0
    assert result.output == "gfortran-15\n"


def test_dh_fortran_get_fc_default_flang():
    runner = CliRunner()
    runner.env["FC"] = "flang-new-21"
    result = runner.invoke(main.dh_fortran, ["get_fc_default"])
    assert result.exit_code == 0
    assert result.output == "flang-21\n"


def test_dh_fortran_get_fc_flags():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["get_fc_flags"])
    assert result.exit_code == 0
    assert (
        result.output
        == "-g -O2 -ffile-prefix-map=/home/alastair/git/dh-fortran/dhfortran=. -fstack-protector-strong -fstack-clash-protection -mbranch-protection=standard\n"
    )


def test_dh_fortran_get_fc_exe():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["get_fc_exe"])
    assert result.exit_code == 0
    assert result.output == "gfortran-15\n"


def test_dh_fortran_get_fc_exe_env():
    runner = CliRunner()
    runner.env["FC"] = "flang-new-21"
    result = runner.invoke(main.dh_fortran, ["get_fc_exe"])
    assert result.exit_code == 0
    assert result.output == "flang-new-21\n"


def test_dh_fortran_get_fc_exe_param():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["get_fc_exe", "--flavor", "flang21"])
    assert result.exit_code == 0
    assert result.output == "flang-new-21\n"


def test_dh_fortran_get_fc_exe_param():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["get_fc_exe", "--flavor", "flangX"])
    assert result.exit_code == 2


def test_dh_fortran_clean():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["clean"])
    assert result.exit_code == 0


def test_dh_fortran_configure():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["configure"])
    assert result.exit_code == 0


def test_dh_fortran_build():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["build"])
    assert result.exit_code == 0


def test_dh_fortran_install():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["install"])
    assert result.exit_code == 0


def test_dh_fortran_test():
    runner = CliRunner()
    result = runner.invoke(main.dh_fortran, ["test"])
    assert result.exit_code == 0


if __name__ == "__main__":
    import pytest

    pytest.main()