diff mbox series

[2/3] rust: add qemu-api doctests to "meson test"

Message ID 20250405100603.253421-3-pbonzini@redhat.com (mailing list archive)
State New
Headers show
Series rust: update build system for Meson 1.8.0 | expand

Commit Message

Paolo Bonzini April 5, 2025, 10:06 a.m. UTC
Doctest are weird.  They are essentially integration tests, but they're
"ran" by executing rustdoc --test, which takes a compiler-ish
command line.  This is supported by Meson 1.8.0.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 .gitlab-ci.d/buildtest.yml |  5 -----
 rust/qemu-api/meson.build | 11 +++++++++++
 1 file changed, 12 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index 00f4bfcd9f3..088d5683c88 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -131,12 +131,7 @@  build-system-fedora-rust-nightly:
     IMAGE: fedora-rust-nightly
     CONFIGURE_ARGS: --disable-docs --enable-rust --enable-strict-rust-lints
     TARGETS: aarch64-softmmu
-    MAKE_CHECK_ARGS: check-build
-  after_script:
-    - source scripts/ci/gitlab-ci-section
-    - section_start test "Running Rust doctests"
-    - cd build
-    - pyvenv/bin/meson devenv -w ../rust ${CARGO-cargo} test --doc -p qemu_api
+    MAKE_CHECK_ARGS: check-build check-doc
 
   allow_failure: true
 
diff --git a/rust/qemu-api/meson.build b/rust/qemu-api/meson.build
index 8fa41c0a95e..ede6e14e5e0 100644
--- a/rust/qemu-api/meson.build
+++ b/rust/qemu-api/meson.build
@@ -53,6 +53,17 @@  rust.test('rust-qemu-api-tests', _qemu_api_rs,
 qemu_api = declare_dependency(link_with: [_qemu_api_rs],
   dependencies: [qemuutil_rs, qemu_api_macros, qom, hwcore, chardev, migration])
 
+# Doctests are essentially integration tests, so they need the same "depends" as
+# below and cannot be run with "cargo test --doc".  Developer tools are only
+# supported for versions 1.74.0 or newer of Rust.
+if rustc.version().version_compare('>=1.74.0')
+  rust.doctest('rust-qemu-api-doctests',
+       _qemu_api_rs,
+       protocol: 'rust',
+       dependencies: qemu_api,
+       suite: ['doc', 'rust'])
+endif
+
 test('rust-qemu-api-integration',
     executable(
         'rust-qemu-api-integration',