Issue #23715: Enhance test.script_helper to investigate test_eintr failure

If Python failed, show also stdout in the assertion error.
This commit is contained in:
Victor Stinner 2015-03-20 13:38:08 +01:00
parent a453cd8d85
commit 1335ca5053
1 changed files with 23 additions and 4 deletions

View File

@ -86,10 +86,29 @@ def _assert_python(expected_success, *args, **env_vars):
rc = p.returncode rc = p.returncode
err = strip_python_stderr(err) err = strip_python_stderr(err)
if (rc and expected_success) or (not rc and not expected_success): if (rc and expected_success) or (not rc and not expected_success):
raise AssertionError( # Limit to 80 lines to ASCII characters
"Process return code is %d, command line was: %r, " maxlen = 80 * 100
"stderr follows:\n%s" % (rc, cmd_line, if len(out) > maxlen:
err.decode('ascii', 'ignore'))) out = b'(... truncated stdout ...)' + out[-maxlen:]
if len(err) > maxlen:
err = b'(... truncated stderr ...)' + err[-maxlen:]
out = out.decode('ascii', 'replace').rstrip()
err = err.decode('ascii', 'replace').rstrip()
raise AssertionError("Process return code is %d\n"
"command line: %r\n"
"\n"
"stdout:\n"
"---\n"
"%s\n"
"---\n"
"\n"
"stderr:\n"
"---\n"
"%s\n"
"---"
% (rc, cmd_line,
out,
err))
return rc, out, err return rc, out, err
def assert_python_ok(*args, **env_vars): def assert_python_ok(*args, **env_vars):