diff options
| author | Daan De Meyer <daan.j.demeyer@gmail.com> | 2024-06-02 11:33:07 +0200 |
|---|---|---|
| committer | Jussi Pakkanen <jpakkane@gmail.com> | 2024-06-17 19:30:10 +0300 |
| commit | a3d3efd3cfc6e9b0ce8a7536527e1e9ca134f80a (patch) | |
| tree | 93d710f0803bc2c8ec2f7607faa5c142d5b82bb0 /mesonbuild | |
| parent | c199faf9807fb898e1c6744c43728dc87c93a0bc (diff) | |
| download | meson-a3d3efd3cfc6e9b0ce8a7536527e1e9ca134f80a.tar.gz | |
Add meson test --max-lines
Let's allow users to configure how many lines are shown at most when
a test fails.
Diffstat (limited to 'mesonbuild')
| -rw-r--r-- | mesonbuild/mtest.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 03d2eb254..c0ddb30ba 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -161,6 +161,8 @@ def add_arguments(parser: argparse.ArgumentParser) -> None: help='Which test setup to use.') parser.add_argument('--test-args', default=[], type=split_args, help='Arguments to pass to the specified test(s) or all tests') + parser.add_argument('--max-lines', default=100, dest='max_lines', type=int, + help='Maximum number of lines to show from a long test log. Since 1.5.0.') parser.add_argument('args', nargs='*', help='Optional list of test names to run. "testname" to run all tests with that name, ' '"subprojname:testname" to specifically run "testname" from "subprojname", ' @@ -510,7 +512,8 @@ class ConsoleLogger(TestLogger): HLINE = "\u2015" RTRI = "\u25B6 " - def __init__(self) -> None: + def __init__(self, max_lines: int) -> None: + self.max_lines = max_lines self.running_tests: OrderedSet['TestRun'] = OrderedSet() self.progress_test: T.Optional['TestRun'] = None self.progress_task: T.Optional[asyncio.Future] = None @@ -652,10 +655,10 @@ class ConsoleLogger(TestLogger): return log lines = log.splitlines() - if len(lines) < 100: + if len(lines) < self.max_lines: return log else: - return str(mlog.bold('Listing only the last 100 lines from a long log.\n')) + '\n'.join(lines[-100:]) + return str(mlog.bold(f'Listing only the last {self.max_lines} lines from a long log.\n')) + '\n'.join(lines[-self.max_lines:]) def print_log(self, harness: 'TestHarness', result: 'TestRun') -> None: if not result.verbose: @@ -1591,7 +1594,7 @@ class TestHarness: self.name_max_len = 0 self.is_run = False self.loggers: T.List[TestLogger] = [] - self.console_logger = ConsoleLogger() + self.console_logger = ConsoleLogger(options.max_lines) self.loggers.append(self.console_logger) self.need_console = False self.ninja: T.List[str] = None |
