Refuse a register entry that is no regular file, and say data source in what task-bench prints
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
"""The register a data-source task hands Haiku: the files the task's `generate-register` writes into the tree Haiku starts in.
|
||||
The script is seeded, so it writes the same register at the base and at the head, byte for byte; a task whose script doesn't is
|
||||
passed over."""
|
||||
A task counts only where its script writes the same register at the base and at the head, byte for byte, which a seeded script
|
||||
does."""
|
||||
import os
|
||||
import pathlib
|
||||
import shutil
|
||||
@@ -47,7 +47,8 @@ def registered_trees(bench: Bench, name: str, script: str) -> dict[Side, str] |
|
||||
|
||||
def generated(containers: Containers, tree: str, script: str) -> dict[str, bytes] | Failure:
|
||||
"""The register script writes when run at the top of tree, in the bench's image with no network: each file new to the tree,
|
||||
by its path from the top. NotGenerated where the script runs out of time, fails, writes a `.git` or writes no new file."""
|
||||
by its path from the top. NotGenerated where the script runs out of time, fails, writes a `.git`, writes no new file, or
|
||||
writes one that is no regular file."""
|
||||
before = set(entries(tree))
|
||||
ran = run_in_image(containers, ["--network", "none", *in_tree(containers, tree), "--volume", f"{script}:{MOUNTED}:ro", containers.image, MOUNTED])
|
||||
if isinstance(ran, TimedOut):
|
||||
@@ -55,9 +56,14 @@ def generated(containers: Containers, tree: str, script: str) -> dict[str, bytes
|
||||
if isinstance(ran, Failure):
|
||||
return ran
|
||||
if ran.code:
|
||||
return NotGenerated(f"its {GENERATE} exits {ran.code}")
|
||||
said = ran.output.strip().splitlines()[-1:]
|
||||
return NotGenerated(f"its {GENERATE} exits {ran.code}" + "".join(f" after printing `{line[:200]}`" for line in said))
|
||||
# git runs on the host in this tree next, and would run what a `.git/config` there names, outside the container.
|
||||
if os.path.lexists(os.path.join(tree, ".git")):
|
||||
return NotGenerated(f"its {GENERATE} writes a `.git`")
|
||||
register = on_disk(f"read the register in {tree}", lambda: {path: pathlib.Path(tree, path).read_bytes() for path in entries(tree) if path not in before})
|
||||
new = [path for path in entries(tree) if path not in before]
|
||||
# The host reads each next: it would follow a link into its own files, and never finish reading a pipe.
|
||||
if odd := [path for path in new if os.path.islink(os.path.join(tree, path)) or not os.path.isfile(os.path.join(tree, path))]:
|
||||
return NotGenerated(f"its {GENERATE} writes `{odd[0]}`, which is no regular file")
|
||||
register = on_disk(f"read the register in {tree}", lambda: {path: pathlib.Path(tree, path).read_bytes() for path in new})
|
||||
return register or NotGenerated(f"its {GENERATE} doesn't write any new file")
|
||||
|
||||
Reference in New Issue
Block a user