From ba2c9f115460f4ef8faeed6a1991ea48548a10a2 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Fri, 26 May 2017 11:45:43 -0700 Subject: [PATCH 1/3] Handle -q option --- mypy/waiter.py | 17 +++++++++++------ runtests.py | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/mypy/waiter.py b/mypy/waiter.py index f0c7de6002a6..90cf1ca4f4f8 100644 --- a/mypy/waiter.py +++ b/mypy/waiter.py @@ -9,7 +9,7 @@ from multiprocessing import cpu_count import pipes import re -from subprocess import Popen, STDOUT +from subprocess import Popen, STDOUT, DEVNULL import sys import tempfile import time @@ -25,20 +25,25 @@ 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, passthrough: bool = False) -> None: + env: Dict[str, str] = None, passthrough: Optional[int] = None) -> 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 + # None means no passthrough + # otherwise, it represents verbosity level self.passthrough = passthrough def start(self) -> None: - if self.passthrough: - self.outfile = None - else: + if self.passthrough is None: self.outfile = tempfile.TemporaryFile() + else: + if self.passthrough >= 0: + self.outfile = None + else: + self.outfile = DEVNULL self.start_time = time.perf_counter() self.process = Popen(self.args, cwd=self.cwd, env=self.env, stdout=self.outfile, stderr=STDOUT) @@ -51,7 +56,7 @@ def status(self) -> Optional[int]: return self.process.returncode def read_output(self) -> str: - if self.passthrough: + if self.passthrough is not None: return '' file = self.outfile file.seek(0) diff --git a/runtests.py b/runtests.py index 3371f9ae8b91..363391072bfc 100755 --- a/runtests.py +++ b/runtests.py @@ -111,7 +111,7 @@ 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, passthrough=True), + self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=self.verbosity), sequential=True) def add_python(self, name: str, *args: str, cwd: Optional[str] = None) -> None: From faeff181f94f56610c063ae7b12c15535b4ba152 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Mon, 29 May 2017 19:37:53 -0700 Subject: [PATCH 2/3] CR: pass -j, -q, -v to pytest --- mypy/waiter.py | 6 ++---- runtests.py | 7 +++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mypy/waiter.py b/mypy/waiter.py index 90cf1ca4f4f8..4f2a1f627c22 100644 --- a/mypy/waiter.py +++ b/mypy/waiter.py @@ -37,13 +37,11 @@ def __init__(self, name: str, args: List[str], *, cwd: str = None, self.passthrough = passthrough def start(self) -> None: - if self.passthrough is None: + if self.passthrough is None or self.passthrough < 0: self.outfile = tempfile.TemporaryFile() else: if self.passthrough >= 0: self.outfile = None - else: - self.outfile = DEVNULL self.start_time = time.perf_counter() self.process = Popen(self.args, cwd=self.cwd, env=self.env, stdout=self.outfile, stderr=STDOUT) @@ -56,7 +54,7 @@ def status(self) -> Optional[int]: return self.process.returncode def read_output(self) -> str: - if self.passthrough is not None: + if self.passthrough is not None and self.passthrough >= 0: return '' file = self.outfile file.seek(0) diff --git a/runtests.py b/runtests.py index 363391072bfc..7d6206ca0652 100755 --- a/runtests.py +++ b/runtests.py @@ -422,6 +422,13 @@ def main() -> None: pyt_arglist.append('--lf') if ff: pyt_arglist.append('--ff') + if verbosity >= 1: + pyt_arglist.extend(['-v'] * verbosity) + elif verbosity < 0: + pyt_arglist.extend(['-q'] * (-verbosity)) + if parallel_limit: + if '-n' not in pyt_arglist: + pyt_arglist.append('-n{}'.format(parallel_limit)) driver = Driver(whitelist=whitelist, blacklist=blacklist, lf=lf, ff=ff, arglist=arglist, pyt_arglist=pyt_arglist, verbosity=verbosity, From 2988e03e124e86e9f89e18d7399e6b2900f96b72 Mon Sep 17 00:00:00 2001 From: Max Moroz Date: Tue, 30 May 2017 11:14:06 -0700 Subject: [PATCH 3/3] CR fix --- mypy/waiter.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mypy/waiter.py b/mypy/waiter.py index 4f2a1f627c22..e8ba99d4efd8 100644 --- a/mypy/waiter.py +++ b/mypy/waiter.py @@ -40,8 +40,7 @@ def start(self) -> None: if self.passthrough is None or self.passthrough < 0: self.outfile = tempfile.TemporaryFile() else: - if self.passthrough >= 0: - self.outfile = None + self.outfile = None self.start_time = time.perf_counter() self.process = Popen(self.args, cwd=self.cwd, env=self.env, stdout=self.outfile, stderr=STDOUT) @@ -54,7 +53,7 @@ def status(self) -> Optional[int]: return self.process.returncode def read_output(self) -> str: - if self.passthrough is not None and self.passthrough >= 0: + if not self.outfile: return '' file = self.outfile file.seek(0)