aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/shell-completions/bash/meson1
-rw-r--r--data/shell-completions/zsh/_meson1
-rw-r--r--docs/markdown/Unit-tests.md8
-rw-r--r--docs/markdown/snippets/test_max_lines.md6
-rw-r--r--mesonbuild/mtest.py11
5 files changed, 23 insertions, 4 deletions
diff --git a/data/shell-completions/bash/meson b/data/shell-completions/bash/meson
index dc437f1..88dc15e 100644
--- a/data/shell-completions/bash/meson
+++ b/data/shell-completions/bash/meson
@@ -580,6 +580,7 @@ _meson-test() {
quiet
timeout-multiplier
setup
+ max-lines
test-args
)
diff --git a/data/shell-completions/zsh/_meson b/data/shell-completions/zsh/_meson
index 402539f..7d6d89b 100644
--- a/data/shell-completions/zsh/_meson
+++ b/data/shell-completions/zsh/_meson
@@ -196,6 +196,7 @@ local -a meson_commands=(
'(--quiet -q)'{'--quiet','-q'}'[produce less output to the terminal]'
'(--timeout-multiplier -t)'{'--timeout-multiplier','-t'}'[a multiplier for test timeouts]:Python floating-point number: '
'--setup[which test setup to use]:test setup: '
+ '--max-lines[Maximum number of lines to show from a long test log]:Python integer number: '
'--test-args[arguments to pass to the tests]: : '
'*:Meson tests:__meson_test_names'
)
diff --git a/docs/markdown/Unit-tests.md b/docs/markdown/Unit-tests.md
index 6fda0f5..b5d3a1b 100644
--- a/docs/markdown/Unit-tests.md
+++ b/docs/markdown/Unit-tests.md
@@ -274,6 +274,14 @@ other useful information as the environmental variables. This is
useful, for example, when you run the tests on Travis-CI, Jenkins and
the like.
+By default, the output from tests will be limited to the last 100 lines. The
+maximum number of lines to show can be configured with the `--max-lines` option
+*(added 1.5.0)*:
+
+```console
+$ meson test --max-lines=1000 testname
+```
+
**Timeout**
In the test case options, the `timeout` option is specified in a number of seconds.
diff --git a/docs/markdown/snippets/test_max_lines.md b/docs/markdown/snippets/test_max_lines.md
new file mode 100644
index 0000000..ea10fbb
--- /dev/null
+++ b/docs/markdown/snippets/test_max_lines.md
@@ -0,0 +1,6 @@
+## The Meson test program supports a new "--max-lines" argument
+
+By default `meson test` only shows the last 100 lines of test output from tests
+that produce large amounts of output. This default can now be changed with the
+new `--max-lines` option. For example, `--max-lines=1000` will increase the
+maximum number of log output lines from 100 to 1000.
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 03d2eb2..c0ddb30 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