From f917c07e4c4b7433fede11d70e61ef14de2e334b Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Fri, 19 Apr 2024 18:28:22 +1000 Subject: [PATCH] #3 Changed order in which compiler flags are used. --- source/fab/newtools/compiler.py | 6 ++++-- tests/unit_tests/tools/test_compiler.py | 17 ++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/source/fab/newtools/compiler.py b/source/fab/newtools/compiler.py index 69dcbd4f..9d637302 100644 --- a/source/fab/newtools/compiler.py +++ b/source/fab/newtools/compiler.py @@ -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) diff --git a/tests/unit_tests/tools/test_compiler.py b/tests/unit_tests/tools/test_compiler.py index fb8f94d7..8e65a20b 100644 --- a/tests/unit_tests/tools/test_compiler.py +++ b/tests/unit_tests/tools/test_compiler.py @@ -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(): @@ -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(): @@ -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: