Skip to content

Commit

Permalink
#3 Changed order in which compiler flags are used.
Browse files Browse the repository at this point in the history
  • Loading branch information
hiker committed Apr 19, 2024
1 parent 51b02ec commit f917c07
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
6 changes: 4 additions & 2 deletions source/fab/newtools/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ def __init__(self, name: str, exec_name: str, category: Categories,

def compile_file(self, input_file: Path, output_file: Path,
add_flags: Union[None, List[str]] = None):
params = [input_file.name, self._compile_flag,
self._output_flag, str(output_file)]
params = [self._compile_flag]
if add_flags:
params += add_flags

params.extend([input_file.name,
self._output_flag, str(output_file)])

return self.run(cwd=input_file.parent,
additional_parameters=params)

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 @@ -57,9 +57,9 @@ def test_compiler_syntax_only():
fc.run = mock.Mock()
fc.compile_file(Path("a.f90"), "a.o", syntax_only=True)
fc.run.assert_called_with(cwd=Path('.'),
additional_parameters=['a.f90', '-c', '-o',
'a.o', '-fsyntax-only',
"-J", "/tmp"])
additional_parameters=['-c', '-fsyntax-only',
"-J", '/tmp', 'a.f90',
'-o', 'a.o', ])


def test_compiler_module_output():
Expand All @@ -70,9 +70,8 @@ def test_compiler_module_output():
fc.run = mock.MagicMock()
fc.compile_file(Path("a.f90"), "a.o", syntax_only=True)
fc.run.assert_called_with(cwd=PosixPath('.'),
additional_parameters=['a.f90', '-c', '-o',
'a.o',
'-J', '/module_out'])
additional_parameters=['-c', '-J', '/module_out',
'a.f90', '-o', 'a.o'])


def test_compiler_with_add_args():
Expand All @@ -86,9 +85,9 @@ def test_compiler_with_add_args():
syntax_only=True)
# Notice that "-J/b" has been removed
fc.run.assert_called_with(cwd=PosixPath('.'),
additional_parameters=['a.f90', '-c', '-o',
'a.o', "-O3",
'-J', '/module_out'])
additional_parameters=['-c', "-O3",
'-J', '/module_out',
'a.f90', '-o', 'a.o'])


class TestGetCompilerVersion:
Expand Down

0 comments on commit f917c07

Please sign in to comment.