summaryrefslogtreecommitdiff
path: root/test cases/rust
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 /test cases/rust
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 'test cases/rust')
-rw-r--r--test cases/rust/9 unit tests/doctest1.rs12
-rw-r--r--test cases/rust/9 unit tests/meson.build13
2 files changed, 25 insertions, 0 deletions
diff --git a/test cases/rust/9 unit tests/doctest1.rs b/test cases/rust/9 unit tests/doctest1.rs
new file mode 100644
index 000000000..d270f7d67
--- /dev/null
+++ b/test cases/rust/9 unit tests/doctest1.rs
@@ -0,0 +1,12 @@
+//! This is a doctest
+//!
+//! ```
+//! assert_eq!(2+2, 4)
+//! ```
+
+/// ```ignore
+/// this one will be skipped
+/// ```
+fn my_func()
+{
+}
diff --git a/test cases/rust/9 unit tests/meson.build b/test cases/rust/9 unit tests/meson.build
index e62745781..aa9da6796 100644
--- a/test cases/rust/9 unit tests/meson.build
+++ b/test cases/rust/9 unit tests/meson.build
@@ -31,6 +31,19 @@ test(
suite : ['foo'],
)
+rustdoc = find_program('rustdoc', required: false)
+if rustdoc.found()
+ # rustdoc is invoked mostly like rustc. This is a simple example
+ # where it is easy enough to invoke it by hand.
+ test(
+ 'rust doctest',
+ rustdoc,
+ args : ['--test', '--crate-name', 'doctest1', '--crate-type', 'lib', files('doctest1.rs')],
+ protocol : 'rust',
+ suite : ['doctests'],
+ )
+endif
+
exe = executable('rust_exe', ['test2.rs', 'test.rs'], build_by_default : false)
rust = import('rust')