From 9480fe868a332d1d9591d47665e801937f8c2376 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Fri, 26 May 2017 10:54:18 -0700 Subject: [PATCH] Print pytest output as it happens --- mypy/waiter.py | 10 ++++++++-- runtests.py | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mypy/waiter.py b/mypy/waiter.py index 0f1759fefab8..f0c7de6002a6 100644 --- a/mypy/waiter.py +++ b/mypy/waiter.py @@ -25,16 +25,20 @@ class LazySubprocess: """Wrapper around a subprocess that runs a test task.""" def __init__(self, name: str, args: List[str], *, cwd: str = None, - env: Dict[str, str] = None) -> None: + env: Dict[str, str] = None, passthrough: bool = False) -> None: self.name = name self.args = args self.cwd = cwd self.env = env self.start_time = None # type: float self.end_time = None # type: float + self.passthrough = passthrough def start(self) -> None: - self.outfile = tempfile.TemporaryFile() + if self.passthrough: + self.outfile = None + else: + self.outfile = tempfile.TemporaryFile() self.start_time = time.perf_counter() self.process = Popen(self.args, cwd=self.cwd, env=self.env, stdout=self.outfile, stderr=STDOUT) @@ -47,6 +51,8 @@ def status(self) -> Optional[int]: return self.process.returncode def read_output(self) -> str: + if self.passthrough: + return '' file = self.outfile file.seek(0) # Assume it's ascii to avoid unicode headaches (and portability issues). diff --git a/runtests.py b/runtests.py index 83a6ffa0d3da..3371f9ae8b91 100755 --- a/runtests.py +++ b/runtests.py @@ -111,7 +111,8 @@ def add_pytest(self, name: str, pytest_args: List[str], coverage: bool = False) else: args = [sys.executable, '-m', 'pytest'] + pytest_args - self.waiter.add(LazySubprocess(full_name, args, env=self.env), sequential=True) + self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=True), + sequential=True) def add_python(self, name: str, *args: str, cwd: Optional[str] = None) -> None: name = 'run %s' % name