Skip to content

Commit 9bf31a6

Browse files
committed
gh-127747: Fix w/o strace and with -Werror
A non-zero exit code occurs if the strace binary isn't found, and no events will be parsed in that case (there is no output). Handle that case by checking exit code before checking for events. Still asserting around events rather than returning false, so that hopefully if there's some change to `strace` that breaks the parsing, will see that as a test failure rather than silently loosing strace tests because they are auto-disabled.
1 parent 7d02313 commit 9bf31a6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Lib/test/support/strace_helper.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,10 @@ def get_syscalls(code, strace_flags, prelude="", cleanup="",
180180
@cache
181181
def _can_strace():
182182
res = strace_python("import sys; sys.exit(0)", [], check=False)
183-
assert res.events(), "Should have parsed multiple calls"
184-
185-
return res.strace_returncode == 0 and res.python_returncode == 0
183+
if res.strace_returncode == 0 and res.python_returncode == 0:
184+
assert res.events(), "Should have parsed multiple calls"
185+
return True
186+
return False
186187

187188

188189
def requires_strace():

0 commit comments

Comments
 (0)