Skip to content

Commit

Permalink
mtest: avoid stdout when printing warnings about the lack of things t…
Browse files Browse the repository at this point in the history
…o print

Since people may parse the output of `--list` as a list of tests,
putting logging info in stderr is nicer.
  • Loading branch information
eli-schwartz committed Jul 10, 2023
1 parent 6667d56 commit 6b28e51
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mesonbuild/mtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1906,17 +1906,17 @@ def tests_from_args(self, tests: T.List[TestSerialisation]) -> T.Generator[TestS
# succeed on an invalid pattern.
raise MesonException(f'{arg} test name does not match any test')

def get_tests(self) -> T.List[TestSerialisation]:
def get_tests(self, errorfile: T.Optional[T.IO] = sys.stdout) -> T.List[TestSerialisation]:
if not self.tests:
print('No tests defined.')
print('No tests defined.', file=errorfile)
return []

tests = [t for t in self.tests if self.test_suitable(t)]
if self.options.args:
tests = list(self.tests_from_args(tests))

if not tests:
print('No suitable tests defined.')
print('No suitable tests defined.', file=errorfile)
return []

return tests
Expand Down Expand Up @@ -2074,7 +2074,7 @@ def sigint_handler() -> None:
await l.finish(self)

def list_tests(th: TestHarness) -> bool:
tests = th.get_tests()
tests = th.get_tests(errorfile=sys.stderr)
for t in tests:
print(th.get_pretty_suite(t))
return not tests
Expand Down

0 comments on commit 6b28e51

Please sign in to comment.