From d89ec98b4763cda13da0ae22515c27f4dfe5c1b9 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Fri, 16 Oct 2020 12:37:30 -0700 Subject: mtest: Add support for rust unit tests Rust has it's own built in unit test format, which is invoked by compiling a rust executable with the `--test` flag to rustc. The tests are then run by simply invoking that binary. They output a custom test format, which this patch adds parsing support for. This means that we can report each subtest in the junit we generate correctly, which should be helpful for orchestration systems like gitlab and jenkins which can parse junit XML. --- docs/markdown/snippets/rust_test_format_support.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 docs/markdown/snippets/rust_test_format_support.md (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/rust_test_format_support.md b/docs/markdown/snippets/rust_test_format_support.md new file mode 100644 index 0000000..69e9aa1 --- /dev/null +++ b/docs/markdown/snippets/rust_test_format_support.md @@ -0,0 +1,4 @@ +## Meson test() now accepts `protocol : 'rust'` + +This allows native rust tests to be run and parsed by meson, simply set the +protocol to `rust` and meson takes care of the rest. -- cgit v1.1 From 3d80a88bd3c3dc8f9e20bbda485b0b436fd79fb3 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 21 Oct 2020 16:07:31 -0700 Subject: modules: Add an unstable-rust module Like other language specific modules this module is module for holding rust specific helpers. This commit adds a test() function, which simplifies using rust's internal unittest mechanism. Rust tests are generally placed in the same code files as they are testing, in contrast to languages like C/C++ and python which generally place the tests in separate translation units. For meson this is somewhat problematic from a repetition point of view, as the only changes are generally adding --test, and possibly some dependencies. The rustmod.test() method provides a mechanism to remove the repatition: it takes a rust target, copies it, and then addes the `--test` option, then creates a Test() target with the `rust` protocol. You can pass additional dependencies via the `dependencies` keyword. This all makes for a nice, DRY, test definition. --- docs/markdown/snippets/unstable-rust-module.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 docs/markdown/snippets/unstable-rust-module.md (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/unstable-rust-module.md b/docs/markdown/snippets/unstable-rust-module.md new file mode 100644 index 0000000..15a7ecb --- /dev/null +++ b/docs/markdown/snippets/unstable-rust-module.md @@ -0,0 +1,4 @@ +## Untable Rust module + +A new unstable module has been added to make using rust with meson easier. +Currently it adds a single function to ease defining rust tests. -- cgit v1.1