-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsetup_fortran90.py
More file actions
53 lines (42 loc) · 1.35 KB
/
Copy pathsetup_fortran90.py
File metadata and controls
53 lines (42 loc) · 1.35 KB
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
"""
setup for the tests of the module string_to_fortran90
"""
import general_utilities as gu
from string_to_code import to_fortran90
_GFOTRAN = "gfortran"
_FILE_EXTENSION = "f90"
def _compile_code(in_code, tmp_folder):
source_filename = gu.get_unique_filename(tmp_folder, _FILE_EXTENSION)
gu.save_str_to_file(tmp_folder / source_filename, in_code)
executable_filename = gu.get_unique_filename(tmp_folder, "o")
gu.subprocess_run_with_check(
[
_GFOTRAN,
"-Wall",
"-Wextra",
"-Wpedantic",
"-Waliasing",
"-Wconversion-extra",
"-Wimplicit-interface",
"-Wimplicit-procedure",
"-Wsurprising",
"-Werror",
source_filename,
"-o",
executable_filename,
],
cwd=str(tmp_folder),
)
return executable_filename
def _run_code(in_code, tmp_folder):
return gu.run_executable(_compile_code(in_code, tmp_folder), tmp_folder)
def get_test_data():
"""returns test data for the module string_to_fortran90"""
return gu.Language(
tool_names=[_GFOTRAN],
string_to_code=to_fortran90.proc,
printer_program_to_code=to_fortran90.proc_printer_program,
run_code=_run_code,
id="fortran90",
source_code_file_extension=_FILE_EXTENSION,
)