Skip to content

Commit

Permalink
Fix missing last lines from Godot when run from tests/run.py
Browse files Browse the repository at this point in the history
  • Loading branch information
touilleMan committed Dec 26, 2024
1 parent 692b9cf commit 9eb0594
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,21 +171,24 @@ def run_test(
]
print(" ".join(cmd), flush=True)
res = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

total_output = b""
subprocess_done = False
while True:
buff: bytes = res.stdout.read1() # type: ignore
total_output += buff
os.write(sys.stdout.fileno(), buff)
if subprocess_done:
break
try:
res.wait(timeout=0.1)
# Subprocess is done, but we still have one more stdin/stderr pump to do
subprocess_done = True
buff = res.stdout.read()

except subprocess.TimeoutExpired:
# Subprocess is still running
pass
# Use `read1` to avoid blocking on the read
buff: bytes = res.stdout.read1() # type: ignore

total_output += buff
os.write(sys.stdout.fileno(), buff)
if res.returncode is not None:
break

if res.returncode != 0:
raise SystemExit(f"{RED}{test_name}: Non-zero return code: {res.returncode}{NO_COLOR}")

Expand Down

0 comments on commit 9eb0594

Please sign in to comment.