about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-20 15:39:26 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2024-12-20 22:35:00 +0100
commit2d914bed2dea1316fdbb55010f3bb2c5412942cb (patch)
tree823d36bc2f400d5a1986ad7a8514f9745acbfffd
parentbc03e40a29574c18ebfc04bd179065815ebe83f8 (diff)
downloadrust-2d914bed2dea1316fdbb55010f3bb2c5412942cb.tar.gz
rust-2d914bed2dea1316fdbb55010f3bb2c5412942cb.zip
Add test to ensure passing `--doctest_compilation_args` multiple times work
-rw-r--r--src/doc/rustdoc/src/unstable-features.md2
-rw-r--r--tests/rustdoc-ui/doctest/rustflags-multiple-args.rs17
-rw-r--r--tests/rustdoc-ui/doctest/rustflags-multiple-args.stdout6
3 files changed, 24 insertions, 1 deletions
diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md
index 667f07cf956..d1d42e47322 100644
--- a/src/doc/rustdoc/src/unstable-features.md
+++ b/src/doc/rustdoc/src/unstable-features.md
@@ -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
diff --git a/tests/rustdoc-ui/doctest/rustflags-multiple-args.rs b/tests/rustdoc-ui/doctest/rustflags-multiple-args.rs
new file mode 100644
index 00000000000..8519920e53b
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/rustflags-multiple-args.rs
@@ -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;
diff --git a/tests/rustdoc-ui/doctest/rustflags-multiple-args.stdout b/tests/rustdoc-ui/doctest/rustflags-multiple-args.stdout
new file mode 100644
index 00000000000..0e8a9e1efcf
--- /dev/null
+++ b/tests/rustdoc-ui/doctest/rustflags-multiple-args.stdout
@@ -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
+