From e4358613df9f28d19e24c54634a8a76dcc308f59 Mon Sep 17 00:00:00 2001 From: nmannall Date: Mon, 25 Nov 2024 14:55:56 +0000 Subject: [PATCH] Fix Python API mixin modifying the input file Move configuration involving the input and output files to before the run stage to allow mixins to change the file names if required --- reframe_tests/tests/base_tests.py | 23 ++++++++++++++++++----- reframe_tests/tests/mixins.py | 3 +-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/reframe_tests/tests/base_tests.py b/reframe_tests/tests/base_tests.py index a9b6581e..3f55c923 100644 --- a/reframe_tests/tests/base_tests.py +++ b/reframe_tests/tests/base_tests.py @@ -106,7 +106,7 @@ class GprMaxBaseTest(RunOnlyRegressionTest): model = parameter() sourcesdir = required - executable = "time -p python -m gprMax --log-level 10 --hide-progress-bars" + executable = "time -p python -m gprMax" regression_checks = variable(typ.List[RegressionCheck], value=[]) @@ -159,16 +159,29 @@ class GprMaxBaseTest(RunOnlyRegressionTest): self.prerun_cmds.append(f"source {path_to_pyenv}") @run_after("init") + def set_file_paths(self): + self.input_file = Path(f"{self.model}.in") + self.output_file = Path(f"{self.model}.h5") + + @run_before("run") def configure_test_run(self): """Configure gprMax commandline arguments and plot outputs Set the input and output files and add postrun commands to plot the outputs. """ - self.input_file = f"{self.model}.in" - self.output_file = f"{self.model}.h5" - self.executable_opts = [self.input_file, "-o", self.output_file] - self.keep_files = [self.input_file, self.output_file] + input_file = str(self.input_file) + output_file = str(self.output_file) + + self.executable_opts += [ + input_file, + "-o", + output_file, + "--log-level", + "10", + "--hide-progress-bars", + ] + self.keep_files += [input_file, output_file] """ if self.has_receiver_output: diff --git a/reframe_tests/tests/mixins.py b/reframe_tests/tests/mixins.py index 92968d3c..834ad139 100644 --- a/reframe_tests/tests/mixins.py +++ b/reframe_tests/tests/mixins.py @@ -72,11 +72,10 @@ class SnapshotMixin(GprMaxMixin): class PythonApiMixin(GprMaxMixin): - executable = "time -p python" - @run_after("setup") def set_python_input_file(self): """Input files for API tests will be python files""" + self.executable = "time -p python" self.input_file = self.input_file.with_suffix(".py")