Repository navigation
shader_disasm: reset FAILED in main() and record read OSError in one() - #6190
Conversation
|
Two overlapping calls to The same input on this head gives status 1 when A runs alone. The parent Keep the failure details local to each invocation. For example, each worker can return its result and diagnostic to the caller that owns it. Reproduction on Windows: run the script below from the repository root with import builtins, concurrent.futures, runpy, sys, tempfile, threading
from pathlib import Path
from unittest.mock import patch
sys.path.insert(0, "tools")
import shader_disasm as s
sample = runpy.run_path("tests/test_shader_disasm.py")["fssm"]()
recorded, resume = threading.Event(), threading.Event()
original_one, original_open = s.one, builtins.open
def wrapped_one(path, *args, **kwargs):
result = original_one(path, *args, **kwargs)
if result == "failed":
recorded.set()
assert resume.wait(10)
return result
def opened(path, *args, **kwargs):
if Path(path).name == "bad.fssm":
raise PermissionError(13, "synthetic read failure", path)
return original_open(path, *args, **kwargs)
with tempfile.TemporaryDirectory() as tmp:
root = Path(tmp)
for run, names in (("A", ["bad", "good"]), ("B", ["good"])):
(root / run).mkdir()
for name in names:
(root / run / (name + ".fssm")).write_bytes(sample)
def invoke(run):
return s.main([str(root/run), "--out", str(root/(run+"-out")), "--backend", "python", "--jobs", "1"])
with patch.object(s, "one", wrapped_one), patch.object(s, "open", opened, create=True), concurrent.futures.ThreadPoolExecutor(1) as pool:
a = pool.submit(invoke, "A")
try:
assert recorded.wait(10)
print("B status", invoke("B"))
finally:
resume.set()
print("A status", a.result())AI-assisted. |
|
Tested
AI-assisted. |
Summary
tools/shader_disasm.py:FAILEDat the start ofmain(argv=None)so repeated in-process calls do not fail from stale errors left by an earlier run.OSErrorwhen reading.fssmfiles inone()and record(path, e.strerror or str(e))inFAILED(returning"failed") so an unreadable input fails cleanly viafail(...)instead of raising an unhandled traceback.tests/test_shader_disasm.py: addFailedStateAndReadErrorTestscovering staleFAILEDreset acrossmain()calls andPermissionErroron an.fssminput.Verification
python3 -m compileall -q tools/shader_disasm.py tests/test_shader_disasm.py-> passed.python3 -I tests/test_shader_disasm.py -v->Ran 31 tests in 1.890s->OK.AI-assisted.