Skip to content

Update doctest xcompile flags #15455

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/cargo/ops/cargo_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,10 @@ fn run_doc_tests(
}

if doctest_xcompile {
p.arg("-Zunstable-options");
p.arg("--enable-per-target-ignores");
if let Some((runtool, runtool_args)) = compilation.target_runner(unit.kind) {
p.arg("--runtool").arg(runtool);
p.arg("--test-runtool").arg(runtool);
for arg in runtool_args {
p.arg("--runtool-arg").arg(arg);
p.arg("--test-runtool-arg").arg(arg);
}
}
if let Some(linker) = linker {
Expand Down
3 changes: 1 addition & 2 deletions src/doc/src/reference/unstable.md
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,7 @@ This flag changes `cargo test`'s behavior when handling doctests when
a target is passed. Currently, if a target is passed that is different
from the host cargo will simply skip testing doctests. If this flag is
present, cargo will continue as normal, passing the tests to doctest,
while also passing it a `--target` option, as well as enabling
`-Zunstable-features --enable-per-target-ignores` and passing along
while also passing it a `--target` option, as well as passing along
information from `.cargo/config.toml`. See the rustc issue for more information.

```sh
Expand Down
11 changes: 5 additions & 6 deletions tests/testsuite/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4738,8 +4738,7 @@ fn test_dep_with_dev() {

#[cargo_test(nightly, reason = "-Zdoctest-xcompile is unstable")]
fn cargo_test_doctest_xcompile_ignores() {
// -Zdoctest-xcompile also enables --enable-per-target-ignores which
// allows the ignore-TARGET syntax.
// Test for `ignore-...` syntax with -Zdoctest-xcompile.
let p = project()
.file("Cargo.toml", &basic_lib_manifest("foo"))
.file(
Expand All @@ -4766,15 +4765,15 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
.run();
#[cfg(target_arch = "x86_64")]
p.cargo("test")
.with_status(101)
.with_stdout_data(str![[r#"
...
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
...
"#]],
)
"#]])
.run();

// Should be the same with or without -Zdoctest-xcompile because `ignore-`
// syntax is always enabled.
#[cfg(not(target_arch = "x86_64"))]
p.cargo("test -Zdoctest-xcompile")
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
Expand Down