summaryrefslogtreecommitdiff
path: root/mesonbuild
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2024-11-15 11:11:41 +0100
committerDylan Baker <dylan@pnwbakers.com>2024-12-06 09:56:12 -0800
commit2fd0dacf06712857993496b7da1dc16dce71f523 (patch)
tree58519aa2240125c966902f752373fd41c54e73b3 /mesonbuild
parentf9f69d835e01cc6467455b3ad166a7a367920304 (diff)
downloadmeson-2fd0dacf06712857993496b7da1dc16dce71f523.tar.gz
mtest: rust: allow parsing doctest output
Doctests have a slightly different output compared to what "protocol: rust" supports: running 2 tests test ../doctest1.rs - my_func (line 7) ... ignored test ../doctest1.rs - (line 3) ... ok test result: ok. 1 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.12s Add a little more parsing in order to accept this; a simple minded split() fails to unpack the tuple. I plan to contribute an extension of the rust module to invoke doctests, for now this allows running rustdoc --test with "protocol: 'rust'" and get information about the subtests: ▶ 4/8 ../doctest1.rs:my_func:7 SKIP ▶ 4/8 ../doctest1.rs:3 OK 4/8 rust_unit_tests:doctests / rust doctest OK 0.28s 1 subtests passed Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'mesonbuild')
-rw-r--r--mesonbuild/mtest.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py
index 503cb1432..27e0f796a 100644
--- a/mesonbuild/mtest.py
+++ b/mesonbuild/mtest.py
@@ -81,6 +81,9 @@ if sys.maxunicode >= 0x10000:
UNENCODABLE_XML_CHR_RANGES = [fr'{chr(low)}-{chr(high)}' for (low, high) in UNENCODABLE_XML_UNICHRS]
UNENCODABLE_XML_CHRS_RE = re.compile('([' + ''.join(UNENCODABLE_XML_CHR_RANGES) + '])')
+RUST_TEST_RE = re.compile(r'^test (?!result)(.*) \.\.\. (.*)$')
+RUST_DOCTEST_RE = re.compile(r'^(.*?) - (.*? |)\(line (\d+)\)')
+
def is_windows() -> bool:
platname = platform.system().lower()
@@ -1157,8 +1160,14 @@ class TestRunRust(TestRun):
n = 1
async for line in lines:
- if line.startswith('test ') and not line.startswith('test result'):
- _, name, _, result = line.rstrip().split(' ')
+ match = RUST_TEST_RE.match(line)
+ if match:
+ name, result = match.groups()
+ doctest = RUST_DOCTEST_RE.match(name)
+ if doctest:
+ name = ':'.join((x.rstrip() for x in doctest.groups() if x))
+ else:
+ name = name.rstrip()
name = name.replace('::', '.')
t = parse_res(n, name, result)
self.results.append(t)