Skip to content

Commit df42242

Browse files
committed
Added a verbose flag, tuning to come as a follow-up.
1 parent 8c1bfd7 commit df42242

File tree

1 file changed

+40
-21
lines changed

1 file changed

+40
-21
lines changed

test/run-tests.py

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
FILTER_PATTERNS = [
3636
re.compile(r"Narrowing conversion"),
37-
re.compile(r"\[\s*\d+%\s*\]"),
37+
re.compile(r"\[\s*\d+%\s*]"),
3838
re.compile(r"first_scan_filesystem"),
3939
re.compile(r"loading_editor_layout"),
4040
]
@@ -98,7 +98,10 @@ def cleanup_temp_portable():
9898
# Other Helpers (unchanged from previous)
9999
# ──────────────────────────────────────────────
100100

101-
def filter_output(lines: list[str]) -> list[str]:
101+
def filter_output(lines: list[str], verbose: bool) -> list[str]:
102+
if verbose:
103+
return [line.rstrip() for line in lines if line.strip()] # just trim, keep everything
104+
# original quiet filtering
102105
result = []
103106
for line in lines:
104107
cleaned = line.rstrip()
@@ -109,7 +112,6 @@ def filter_output(lines: list[str]) -> list[str]:
109112
result.append(cleaned)
110113
return result
111114

112-
113115
def is_successful(output: str) -> bool:
114116
has_end = END_MARKER in output
115117
has_passed = PASSED_MARKER in output
@@ -127,7 +129,7 @@ def cleanup_godot_cache():
127129
print(f"Warning: Failed to clean .godot: {e}")
128130

129131

130-
def run_godot(args: list[str], desc: str, godot_bin: str, timeout_sec: int = TIMEOUT_SEC) -> tuple[int, str, bool]:
132+
def run_godot(args: list[str], desc: str, godot_bin: str, timeout_sec: int = TIMEOUT_SEC, verbose: bool = False) -> tuple[int, str, bool]:
131133
print(f"\n{'─' * 10} {desc} {'─' * 10}")
132134
print(f"→ {godot_bin} {' '.join(args)}")
133135

@@ -136,7 +138,6 @@ def run_godot(args: list[str], desc: str, godot_bin: str, timeout_sec: int = TIM
136138
stderr_path = Path(tmpdir) / "stderr.txt"
137139

138140
cmd = [godot_bin] + args
139-
140141
try:
141142
start = time.time()
142143
proc = subprocess.Popen(
@@ -146,7 +147,6 @@ def run_godot(args: list[str], desc: str, godot_bin: str, timeout_sec: int = TIM
146147
cwd=os.getcwd(),
147148
start_new_session=True,
148149
)
149-
150150
while proc.poll() is None:
151151
if time.time() - start > timeout_sec:
152152
print(f"→ TIMEOUT after {timeout_sec}s – killing")
@@ -163,7 +163,18 @@ def run_godot(args: list[str], desc: str, godot_bin: str, timeout_sec: int = TIM
163163
stderr = stderr_path.read_text("utf-8", errors="replace")
164164
full_output = stdout + stderr
165165

166-
print(full_output.rstrip())
166+
# ── Output printing logic ──
167+
if verbose:
168+
print(full_output.rstrip())
169+
else:
170+
# In quiet mode: show only summary / important parts
171+
lines = full_output.splitlines()
172+
filtered = filter_output(lines, verbose=False)
173+
if filtered:
174+
print("\n".join(filtered))
175+
else:
176+
print("(no relevant output)")
177+
167178
print(f"→ Exit code: {exit_code}")
168179
return exit_code, full_output, False
169180

@@ -172,38 +183,38 @@ def run_godot(args: list[str], desc: str, godot_bin: str, timeout_sec: int = TIM
172183
print(msg)
173184
return 1, msg, False
174185

175-
176-
def pre_import_project(godot_bin: str):
186+
def pre_import_project(godot_bin: str, verbose: bool):
177187
print("\nPre-importing project (headless, short timeout)...")
178188
cleanup_godot_cache()
179189

180190
args = ["--path", str(GODOT_PROJECT), "--import", "--headless"]
181-
exit_code, output, timed_out = run_godot(args, "Pre-import", godot_bin, timeout_sec=IMPORT_TIMEOUT_SEC)
191+
exit_code, output, timed_out = run_godot(args, "Pre-import", godot_bin, timeout_sec=IMPORT_TIMEOUT_SEC, verbose=verbose)
182192

183193
if timed_out or exit_code != 0:
184-
print("→ Pre-import failed/crashed — This is expected, continuing anyway")
194+
if verbose:
195+
print("→ Pre-import failed or timed out (full output above)")
196+
else:
197+
print("→ Pre-import failed/crashed — continuing anyway")
185198
else:
186199
print("→ Pre-import completed")
187200

188-
def run_tests(mode: str, godot_bin: str) -> bool:
201+
202+
def run_tests(mode: str, godot_bin: str, verbose) -> bool:
189203
overall_success = True
190204

191205
# ── One-time preparation ──
192206
print("\nPreparing project (one-time cleanup + pre-import)...")
193207
cleanup_godot_cache() # Clean once at start
194208

195-
pre_import_project(godot_bin) # Attempt import once (ignore failures)
209+
pre_import_project(godot_bin, verbose) # Attempt import once (ignore failures)
196210

197211
# No more cleanups after this point — let the cache persist
198212

199213
if mode in ("unit", "full"):
200214
args = ["--path", str(GODOT_PROJECT), "--debug", "--headless", "--quit"]
201-
_, output, timed_out = run_godot(args, "Unit / headless tests", godot_bin)
202-
203-
filtered = filter_output(output.splitlines())
204-
print("\nFiltered output:")
205-
print("\n".join(filtered))
215+
_, output, timed_out = run_godot(args, "Unit / headless tests", godot_bin, verbose=verbose)
206216

217+
# Summary parsing still uses full output
207218
if timed_out:
208219
print("→ Unit phase: TIMEOUT")
209220
overall_success = False
@@ -213,29 +224,37 @@ def run_tests(mode: str, godot_bin: str) -> bool:
213224
else:
214225
print("→ Unit phase: detected PASSED")
215226

227+
if not verbose:
228+
# Optional: print a small reminder about the known error
229+
if "ExampleInternal" in output:
230+
print(" (known non-fatal warning about 'ExampleInternal' suppressed)")
231+
216232
return overall_success
217233

218234

219235
# ──────────────────────────────────────────────
220236
# Main
221237
# ──────────────────────────────────────────────
222-
223238
def main():
224239
parser = argparse.ArgumentParser(description="Run godot-cpp test suite (temp portable Godot)")
225240
parser.add_argument("--unit-only", action="store_const", const="unit", dest="mode")
241+
parser.add_argument("--verbose", action="store_true", default=False,
242+
help="Show full unfiltered Godot output + more detailed runner messages")
226243
args = parser.parse_args()
227244

228245
mode = args.mode or "full"
246+
verbose = args.verbose
229247

230248
print(f"Original Godot: {ORIGINAL_GODOT}")
231249
print(f"Project: {GODOT_PROJECT}")
232-
print(f"Mode: {mode}\n")
250+
print(f"Mode: {mode}")
251+
print(f"Verbose: {verbose}\n")
233252

234253
# Setup temp portable copy
235254
godot_bin = setup_temp_portable_godot()
236255

237256
try:
238-
all_passed = run_tests(mode, godot_bin)
257+
all_passed = run_tests(mode, godot_bin, verbose)
239258
finally:
240259
# Always cleanup temp files
241260
cleanup_temp_portable()

0 commit comments

Comments
 (0)