diff --git a/tests/regression/conftest.py b/tests/regression/conftest.py new file mode 100644 index 0000000000..67d0723126 --- /dev/null +++ b/tests/regression/conftest.py @@ -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.", + ) diff --git a/tests/regression/test_process_input_files.py b/tests/regression/test_process_input_files.py index 4a77f77fee..fbd20673e2 100644 --- a/tests/regression/test_process_input_files.py +++ b/tests/regression/test_process_input_files.py @@ -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: @@ -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 """ @@ -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)