Skip to content

Commit

Permalink
Add test to ensure passing --doctest_compilation_args multiple time…
Browse files Browse the repository at this point in the history
…s work
  • Loading branch information
GuillaumeGomez committed Dec 20, 2024
1 parent bc03e40 commit 2d914be
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions tests/rustdoc-ui/doctest/rustflags-multiple-args.rs
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 6 additions & 0 deletions tests/rustdoc-ui/doctest/rustflags-multiple-args.stdout
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2d914be

Please sign in to comment.