From 054d05edbed3e262ac38fb98318d9683a0d8e9ce Mon Sep 17 00:00:00 2001 From: Kris Wilson Date: Fri, 11 May 2018 23:56:26 -0700 Subject: [PATCH] Add tracebacks to IntegResults. --- pex/testing.py | 15 ++++++++++++--- tox.ini | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/pex/testing.py b/pex/testing.py index f4e5f174e..40e090e4d 100644 --- a/pex/testing.py +++ b/pex/testing.py @@ -7,6 +7,7 @@ import subprocess import sys import tempfile +import traceback from collections import namedtuple from textwrap import dedent @@ -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 @@ -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? diff --git a/tox.ini b/tox.ini index 85054f330..50350f131 100644 --- a/tox.ini +++ b/tox.ini @@ -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 =