Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tracebacks to IntegResults. #469

Merged
merged 1 commit into from
May 12, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions pex/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import subprocess
import sys
import tempfile
import traceback
from collections import namedtuple
from textwrap import dedent

Expand Down Expand Up @@ -203,11 +204,15 @@ def write_simple_pex(td, exe_contents, dists=None, sources=None, coverage=False)
return pb


class IntegResults(namedtuple('results', 'output return_code exception')):
class IntegResults(namedtuple('results', 'output return_code exception traceback')):
"""Convenience object to return integration run results."""

def assert_success(self):
assert self.exception is None and self.return_code is None
if not (self.exception is None and self.return_code is None):
print(self.traceback)
raise AssertionError('integration test failed: return_code=%s, exception=%r, traceback=%s' % (
self.return_code, self.exception, self.traceback
))

def assert_failure(self):
assert self.exception or self.return_code
Expand All @@ -227,16 +232,20 @@ def mock_logger(msg, v=None):
return mock_logger

exception = None
tb = None
error_code = None
output = []
log.set_logger(logger_callback(output))

try:
main(args=args)
except SystemExit as e:
error_code = e.code
except Exception as e:
exception = e
return IntegResults(output, error_code, exception)
tb = traceback.format_exc()

return IntegResults(output, error_code, exception, tb)


# TODO(wickman) Why not PEX.run?
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ envlist =

[testenv]
commands =
py.test {posargs:-vvs}
py.test {posargs:-vvsx}
# Ensure pex's main entrypoint can be run externally.
pex --cache-dir {envtmpdir}/buildcache wheel requests . -e pex.bin.pex:main --version
deps =
Expand Down