diff --git a/scripts/pipeline.py b/scripts/pipeline.py index 26d746cf..5da0b06a 100644 --- a/scripts/pipeline.py +++ b/scripts/pipeline.py @@ -404,6 +404,11 @@ def main(): if args.target: truth_cmd.extend(["--target", args.target]) ok, _ = run(truth_cmd, "2c generate truth") + # A native file is one per platform, never per target: the export + # corrects it against the full model, which a targeted run does not + # write. + if ok and args.with_export and args.target: + ok, _ = run(truth_cmd[:-2], "2c generate truth (export model)") results["generate_truth"] = ok all_ok = all_ok and ok else: diff --git a/tests/test_audit_regressions.py b/tests/test_audit_regressions.py index de818c17..79152cbc 100644 --- a/tests/test_audit_regressions.py +++ b/tests/test_audit_regressions.py @@ -536,6 +536,33 @@ class PipelineRegressions(unittest.TestCase): self.assertEqual(raised.exception.code, 1) + def test_a_targeted_export_reads_a_full_model(self): + """--target wrote truth// only; the export read truth/.""" + commands: list[list[str]] = [] + + def fake_run(command, _label): + commands.append([str(part) for part in command]) + return True, "RetroArch: 1/1 OK\n" + + argv = ["pipeline.py", "--offline", "--skip-packs", "--skip-docs", + "--with-export", "--target", "switch"] + with ( + mock.patch.object(sys, "argv", argv), + mock.patch.object(pipeline, "run", side_effect=fake_run), + contextlib.redirect_stdout(io.StringIO()), + ): + with contextlib.suppress(SystemExit): + pipeline.main() + truth_runs = [c for c in commands if "scripts/generate_truth.py" in c] + export = next(c for c in commands if "scripts/export_native.py" in c) + read_dir = export[export.index("--truth-dir") + 1] + full_models = [ + c for c in truth_runs + if "--target" not in c and c[c.index("--output-dir") + 1] == read_dir + ] + self.assertTrue(full_models, truth_runs) + + class ResolverRegressions(unittest.TestCase): def _database(self, entries: dict[str, Path], suffix: str | None = None) -> dict: files = {}