Skip to content

Commit 2075e62

Browse files
committed
add code to surface errors
1 parent 6cdc16d commit 2075e62

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

eval_protocol/cli_commands/upload.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,30 @@ def pytest_collection_modifyitems(self, items):
186186
]
187187

188188
try:
189-
# Suppress pytest output
189+
# Run pytest collection with output captured so we can surface errors in CI
190190
import io
191191
import contextlib
192192

193-
with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):
194-
pytest.main(args, plugins=[plugin])
195-
except Exception:
196-
# If pytest collection fails, fall back to empty list
193+
stdout = io.StringIO()
194+
stderr = io.StringIO()
195+
with contextlib.redirect_stdout(stdout), contextlib.redirect_stderr(stderr):
196+
exit_code = pytest.main(args, plugins=[plugin])
197+
198+
if exit_code != 0:
199+
# In CI this helps diagnose why discovery returned an empty list
200+
sys.stderr.write(f"[ep upload] pytest collection failed with exit code {exit_code} for root {abs_root}\n")
201+
out = stdout.getvalue()
202+
err = stderr.getvalue()
203+
if out:
204+
sys.stderr.write("[ep upload] pytest collection stdout:\n")
205+
sys.stderr.write(out + "\n")
206+
if err:
207+
sys.stderr.write("[ep upload] pytest collection stderr:\n")
208+
sys.stderr.write(err + "\n")
209+
return []
210+
except Exception as e:
211+
# Log the exception instead of silently swallowing it
212+
sys.stderr.write(f"[ep upload] pytest collection raised an exception for root {abs_root}: {e!r}\n")
197213
return []
198214

199215
# Process collected items

0 commit comments

Comments
 (0)