test(search-with-proof): flush the disk-bound write inside the program

tests/test_search_worker.py::test_run_timeout_truncation_and_disk_bound
failed on the ubuntu-26.04 runner (run 45352669096) with exit status 0,
where it requires a non-zero status. The runner's Python 3.14 buffers
131072 bytes by default, so a 16 KiB write to an unclosed file is flushed
only at interpreter exit, where the error is ignored. The program now
closes its file, so ENOSPC surfaces on every Python version.
This commit is contained in:
Marius Ciepluch
2026-11-24 20:16:23 +01:00
parent c4720ba186
commit 7c707d61f9
+4 -1
View File
@@ -141,7 +141,10 @@ def test_run_timeout_truncation_and_disk_bound(tmp_path):
result = worker.tool("run", {"command": ["/usr/bin/python3", "-I", "-c", 'print("x" * 20000)']})
assert result["truncated"] and len(result["stdout"]) == 16384
worker.limits["disk_bytes"] = 4096
result = worker.tool("run", {"command": ["/usr/bin/python3", "-I", "-c", 'open("/scratch/full", "wb").write(b"x" * 16384)']})
# Close inside the program: with a write buffer of 16 KiB or more the error surfaces only at flush,
# and an unclosed file flushed at interpreter exit leaves exit status 0.
overflow = 'with open("/scratch/full", "wb") as stream: stream.write(b"x" * 16384)'
result = worker.tool("run", {"command": ["/usr/bin/python3", "-I", "-c", overflow]})
assert result["exit_code"] != 0
assert "No space left" in result["stderr"]