From ec0dc7e664ff0abf7e598f938013d67df0b58b50 Mon Sep 17 00:00:00 2001 From: Etienne Filhol Date: Mon, 30 Nov 2026 09:56:57 +0100 Subject: [PATCH] fix(standard): give a proof's driver the files its options need --- app/nullius/standard/proofs/prove.py | 4 +++- app/tests/test_standard_controls.py | 14 +++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/app/nullius/standard/proofs/prove.py b/app/nullius/standard/proofs/prove.py index 303bf743..5d217895 100644 --- a/app/nullius/standard/proofs/prove.py +++ b/app/nullius/standard/proofs/prove.py @@ -75,6 +75,8 @@ def __init__(self, bench: dict, ds: dict, work: str, licences=None, options: Opt self.up = install.upstream(bench) self.data = install.dataset(bench, ds, self.up) install.driver_packages(bench) # its driver.install, once: start() then finds it + self.files = {"NULLIUS_FILE_" + n.upper(): install.download(bench["files"][n]["url"], bench["files"][n]["sha256"]) + for n in definitions.option_needs(bench, self.options)["files"]} # as a run gives its driver self.bench, self.ds, self.work = bench, ds, work self.licences = licences if licences is not None else run.Licences(bench) @@ -86,7 +88,7 @@ def start(self, n: int) -> jsonl.Proc: env = run.base_env(home, {**extra, **credentials, "NULLIUS_UPSTREAM": self.up or "", "NULLIUS_DATASET": self.data or "", "NULLIUS_DATASET_ID": self.ds["id"], "PYTHONPATH": run.driver_path(), "PYTHONDONTWRITEBYTECODE": "1", "NULLIUS_VERSION": str(self.bench.get("_version") or ""), - **run.option_env(self.options)}) + **run.option_env(self.options), **self.files}) return jsonl.Proc(cmd, self.bench["_here"], env, os.path.join(self.work, f"driver-{n}.log")).start() diff --git a/app/tests/test_standard_controls.py b/app/tests/test_standard_controls.py index 542df30a..f5bdcf5f 100644 --- a/app/tests/test_standard_controls.py +++ b/app/tests/test_standard_controls.py @@ -424,7 +424,8 @@ def setUp(self): src = f.read() with open(os.path.join(here, "driver.py"), "w") as f: f.write(src.replace('return {"units": list(WORDS)}', - 'import os\n return {"units": list(WORDS) if os.environ.get("NULLIUS_OPTION_SITES") == "on" else []}')) + 'import os\n if os.environ.get("NULLIUS_OPTION_WORDS") == "on" and not os.path.isfile(os.environ.get("NULLIUS_FILE_WORDS", "")):\n return {"units": []}\n' + ' return {"units": list(WORDS) if os.environ.get("NULLIUS_OPTION_SITES") == "on" else []}')) with open(os.path.join(here, "standard.json")) as f: d = json.load(f) d["options"] = {"sites": {"summary": "The sites.", "values": ["off", "on"], "default": "off"}, @@ -465,6 +466,17 @@ def test_the_options_reach_the_units_driver_and_each_controls_run(self): self.assertEqual(dflt["units"]["problems"], ["units: no ids"]) self.assertEqual(dflt["nop"]["problems"], ["the units check failed: the control was not run"]) + def test_the_files_an_option_needs_reach_the_units_driver(self): + words = os.path.join(self.tmp, "words.txt") + open(words, "w").close() + self.b["files"] = {"words": {"url": "https://example.invalid/words.txt", "sha256": "0" * 64}} + self.b["options"]["words"] = {"summary": "Words.", "values": ["off", "on"], "default": "off", + "needs": {"on": {"files": ["words"]}}} + with patch.object(install, "download", return_value=words) as got: + kit = self.prove(bench_options={"sites": "on", "words": "on"}, write=False)["kit"] + self.assertEqual(kit["units"]["units"], 3, kit["units"]) + self.assertEqual({c.args for c in got.call_args_list}, {("https://example.invalid/words.txt", "0" * 64)}) + def test_a_name_or_a_value_the_benchmark_does_not_allow_is_refused_before_anything_runs(self): was = json.dumps(self.b.get("proven")) for given, why in (({"sites": "maybe"}, "'maybe' is not one of off, on"), ({"nope": "x"}, "has no option 'nope'")):