Add test to ensure passing --doctest_compilation_args multiple times work

This commit is contained in:
Guillaume Gomez 2024-12-20 15:39:26 +01:00
parent bc03e40a29
commit 2d914bed2d
3 changed files with 24 additions and 1 deletions

View File

@ -667,7 +667,7 @@ This flag can be passed multiple times to nest wrappers.
## Passing arguments to rustc when compiling doctests
You can use the `--doctest-compilation-args` option if you want to add options when compiling the
You can use the `--doctest-compilation-args` flag if you want to add options when compiling the
doctest. For example if you have:
```rust,no_run

View File

@ -0,0 +1,17 @@
// This test checks that the test behave when `--doctest-compilation-args` is passed
// multiple times.
//@ check-pass
//@ compile-flags: --test -Zunstable-options --doctest-compilation-args=--cfg=testcase_must_be_present
//@ compile-flags: --doctest-compilation-args=--cfg=another
//@ normalize-stdout-test: "tests/rustdoc-ui/doctest" -> "$$DIR"
//@ normalize-stdout-test: "finished in \d+\.\d+s" -> "finished in $$TIME"
/// ```
/// #[cfg(testcase_must_be_present)]
/// #[cfg(another)]
/// fn must_be_present() {}
///
/// fn main() { must_be_present() }
/// ```
pub struct Bar;

View File

@ -0,0 +1,6 @@
running 1 test
test $DIR/rustflags-multiple-args.rs - Bar (line 10) ... ok
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in $TIME