Skip to content

Commit ba2c9f1

Browse files
committed
Handle -q option
1 parent 3ba42e8 commit ba2c9f1

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

mypy/waiter.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from multiprocessing import cpu_count
1010
import pipes
1111
import re
12-
from subprocess import Popen, STDOUT
12+
from subprocess import Popen, STDOUT, DEVNULL
1313
import sys
1414
import tempfile
1515
import time
@@ -25,20 +25,25 @@ class LazySubprocess:
2525
"""Wrapper around a subprocess that runs a test task."""
2626

2727
def __init__(self, name: str, args: List[str], *, cwd: str = None,
28-
env: Dict[str, str] = None, passthrough: bool = False) -> None:
28+
env: Dict[str, str] = None, passthrough: Optional[int] = None) -> None:
2929
self.name = name
3030
self.args = args
3131
self.cwd = cwd
3232
self.env = env
3333
self.start_time = None # type: float
3434
self.end_time = None # type: float
35+
# None means no passthrough
36+
# otherwise, it represents verbosity level
3537
self.passthrough = passthrough
3638

3739
def start(self) -> None:
38-
if self.passthrough:
39-
self.outfile = None
40-
else:
40+
if self.passthrough is None:
4141
self.outfile = tempfile.TemporaryFile()
42+
else:
43+
if self.passthrough >= 0:
44+
self.outfile = None
45+
else:
46+
self.outfile = DEVNULL
4247
self.start_time = time.perf_counter()
4348
self.process = Popen(self.args, cwd=self.cwd, env=self.env,
4449
stdout=self.outfile, stderr=STDOUT)
@@ -51,7 +56,7 @@ def status(self) -> Optional[int]:
5156
return self.process.returncode
5257

5358
def read_output(self) -> str:
54-
if self.passthrough:
59+
if self.passthrough is not None:
5560
return ''
5661
file = self.outfile
5762
file.seek(0)

runtests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def add_pytest(self, name: str, pytest_args: List[str], coverage: bool = False)
111111
else:
112112
args = [sys.executable, '-m', 'pytest'] + pytest_args
113113

114-
self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=True),
114+
self.waiter.add(LazySubprocess(full_name, args, env=self.env, passthrough=self.verbosity),
115115
sequential=True)
116116

117117
def add_python(self, name: str, *args: str, cwd: Optional[str] = None) -> None:

0 commit comments

Comments
 (0)