Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions tests/regression/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
def pytest_addoption(parser):
parser.addoption(
"--local-repository",
action="store",
default=None,
help="Location of the local repository of reference MFiles.",
)
32 changes: 26 additions & 6 deletions tests/regression/test_process_input_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,15 @@ def test_input_file(
opt_params_only: bool,
hide_model_logs,
cli_runner,
request,
):
"""Tests each input file in the 'input_files' directory.

The test will locate and download a remote reference MFile that was
generated by running the input file on the 'main' branch.
The test will locate a remote reference file:
* Normally, this is a file that was generated in the PROCESS CI by
running an input file on the main branch.
* If a `--local-repository` directory is provided, the reference file is found
in that directory.

The input file will then be run locally and compared to the reference file.
The test will fail if:
Expand All @@ -312,7 +316,7 @@ def test_input_file(
:param reg_tolerance: user specified tolerance, percentage differences below which
are ignored.
:type reg_tolerance: float
:param opt_params_only: if True, user specificied that only optimisation parameters
:param opt_params_only: if True, user specified that only optimisation parameters
should be compared in the test.
:type opt_params_only: bool
"""
Expand All @@ -327,9 +331,25 @@ def test_input_file(

scenario = RegressionTestScenario(new_input_file)

reference_mfile = tracked_regression_test_assets.get_reference_mfile(
scenario.scenario_name
)
local_repo = request.config.getoption("--local-repository")

if local_repo is None:
reference_mfile = tracked_regression_test_assets.get_reference_mfile(
scenario.scenario_name
)
else:
# Note that the MFILE must be present in the local repository with the exact
# naming pattern as the IN.DAT (including capitalisation, IN.DAT and MFILE.DAT
# must be capitals):
# - MY.IN.DAT -> MY.MFILE.DAT
# - MY_IN.DAT -> MY_MFILE.DAT
# - myIN.DAT -> myMFILE.DAT
# This naming convention is consistent with PROCESS but is inconsistent with the
# remote repository for legacy reasons (i.e. scenario_name does not follow
# this convention).
reference_mfile = Path(
local_repo, input_file.name.replace("IN.DAT", "MFILE.DAT")
)

scenario.run(solver_name, cli_runner)

Expand Down
Loading