| 39 | |
| 40 | |
| 41 | def existing_output(context, case, symlink=False): |
| 42 | runner, marker = untouched_runner(case) |
| 43 | registry = context.registry(case, image=digest(runner)) |
| 44 | original = case / "caller-directory" |
| 45 | original.mkdir() |
| 46 | sentinel = original / "caller-data" |
| 47 | sentinel.write_bytes(b"caller-owned bytes\x00unchanged\n") |
| 48 | old_meta = original / "meta.json" |
| 49 | old_meta.write_bytes(b'{"caller":"preexisting-marker"}\n') |
| 50 | before = {path.name: digest(path) for path in original.iterdir()} |
| 51 | destination = case / "bundle" if symlink else original |
| 52 | if symlink: |
| 53 | destination.symlink_to(original, target_is_directory=True) |
| 54 | process, _ = context.collect(case, registry, runner=runner, destination=destination) |
| 55 | require(process["exit"] == 2, "existing output must be rejected") |
| 56 | require(not marker.exists(), "existing output rejection executed runner") |
| 57 | require({path.name: digest(path) for path in original.iterdir()} == before, |
| 58 | "collector changed preexisting caller data/marker") |
| 59 | require(not symlink or destination.is_symlink(), "collector replaced caller symlink") |
| 60 | return {"class": "administrative", "caller_bytes_preserved": True, "symlink": symlink} |
| 61 | |
| 62 | |
| 63 | def invalid_registry(context, case): |