mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
Stabilize doctest-xcompile
This stabilizes the doctest-xcompile feature by unconditionally enabling it.
This commit is contained in:
parent
a14791c355
commit
bead46769c
@ -769,7 +769,6 @@ unstable_cli_options!(
|
||||
codegen_backend: bool = ("Enable the `codegen-backend` option in profiles in .cargo/config.toml file"),
|
||||
config_include: bool = ("Enable the `include` key in config files"),
|
||||
direct_minimal_versions: bool = ("Resolve minimal dependency versions instead of maximum (direct dependencies only)"),
|
||||
doctest_xcompile: bool = ("Compile and run doctests for non-host target using runner config"),
|
||||
dual_proc_macros: bool = ("Build proc-macros for both the host and the target"),
|
||||
feature_unification: bool = ("Enable new feature unification modes in workspaces"),
|
||||
features: Option<Vec<String>>,
|
||||
@ -879,6 +878,8 @@ const STABILIZED_LINTS: &str = "The `[lints]` table is now always available.";
|
||||
const STABILIZED_CHECK_CFG: &str =
|
||||
"Compile-time checking of conditional (a.k.a. `-Zcheck-cfg`) is now always enabled.";
|
||||
|
||||
const STABILIZED_DOCTEST_XCOMPILE: &str = "Doctest cross-compiling is now always enabled.";
|
||||
|
||||
fn deserialize_comma_separated_list<'de, D>(
|
||||
deserializer: D,
|
||||
) -> Result<Option<Vec<String>>, D::Error>
|
||||
@ -1275,7 +1276,7 @@ impl CliUnstable {
|
||||
"codegen-backend" => self.codegen_backend = parse_empty(k, v)?,
|
||||
"config-include" => self.config_include = parse_empty(k, v)?,
|
||||
"direct-minimal-versions" => self.direct_minimal_versions = parse_empty(k, v)?,
|
||||
"doctest-xcompile" => self.doctest_xcompile = parse_empty(k, v)?,
|
||||
"doctest-xcompile" => stabilized_warn(k, "1.88", STABILIZED_DOCTEST_XCOMPILE),
|
||||
"dual-proc-macros" => self.dual_proc_macros = parse_empty(k, v)?,
|
||||
"feature-unification" => self.feature_unification = parse_empty(k, v)?,
|
||||
"gc" => self.gc = parse_empty(k, v)?,
|
||||
|
@ -176,7 +176,6 @@ fn run_doc_tests(
|
||||
) -> Result<Vec<UnitTestError>, CliError> {
|
||||
let gctx = ws.gctx();
|
||||
let mut errors = Vec::new();
|
||||
let doctest_xcompile = gctx.cli_unstable().doctest_xcompile;
|
||||
let color = gctx.shell().color_choice();
|
||||
|
||||
for doctest_info in &compilation.to_doc_test {
|
||||
@ -189,28 +188,6 @@ fn run_doc_tests(
|
||||
env,
|
||||
} = doctest_info;
|
||||
|
||||
if !doctest_xcompile {
|
||||
match unit.kind {
|
||||
CompileKind::Host => {}
|
||||
CompileKind::Target(target) => {
|
||||
if target.short_name() != compilation.host {
|
||||
// Skip doctests, -Zdoctest-xcompile not enabled.
|
||||
gctx.shell().verbose(|shell| {
|
||||
shell.note(format!(
|
||||
"skipping doctests for {} ({}), \
|
||||
cross-compilation doctests are not yet supported\n\
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile \
|
||||
for more information.",
|
||||
unit.pkg,
|
||||
unit.target.description_named()
|
||||
))
|
||||
})?;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gctx.shell().status("Doc-tests", unit.target.name())?;
|
||||
let mut p = compilation.rustdoc_process(unit, *script_meta)?;
|
||||
|
||||
@ -237,19 +214,17 @@ fn run_doc_tests(
|
||||
p.arg("--target").arg(target.rustc_target());
|
||||
}
|
||||
|
||||
if doctest_xcompile {
|
||||
if let Some((runtool, runtool_args)) = compilation.target_runner(unit.kind) {
|
||||
p.arg("--test-runtool").arg(runtool);
|
||||
for arg in runtool_args {
|
||||
p.arg("--test-runtool-arg").arg(arg);
|
||||
}
|
||||
}
|
||||
if let Some(linker) = linker {
|
||||
let mut joined = OsString::from("linker=");
|
||||
joined.push(linker);
|
||||
p.arg("-C").arg(joined);
|
||||
if let Some((runtool, runtool_args)) = compilation.target_runner(unit.kind) {
|
||||
p.arg("--test-runtool").arg(runtool);
|
||||
for arg in runtool_args {
|
||||
p.arg("--test-runtool-arg").arg(arg);
|
||||
}
|
||||
}
|
||||
if let Some(linker) = linker {
|
||||
let mut joined = OsString::from("linker=");
|
||||
joined.push(linker);
|
||||
p.arg("-C").arg(joined);
|
||||
}
|
||||
|
||||
if unit.profile.panic != PanicStrategy::Unwind {
|
||||
p.arg("-C").arg(format!("panic={}", unit.profile.panic));
|
||||
|
@ -84,7 +84,6 @@ Each new feature described below should explain how to use it.
|
||||
* [root-dir](#root-dir) --- Controls the root directory relative to which paths are printed
|
||||
* Compile behavior
|
||||
* [mtime-on-use](#mtime-on-use) --- Updates the last-modified timestamp on every dependency every time it is used, to provide a mechanism to delete unused artifacts.
|
||||
* [doctest-xcompile](#doctest-xcompile) --- Supports running doctests with the `--target` flag.
|
||||
* [build-std](#build-std) --- Builds the standard library instead of using pre-built binaries.
|
||||
* [build-std-features](#build-std-features) --- Sets features to use with the standard library.
|
||||
* [binary-dep-depinfo](#binary-dep-depinfo) --- Causes the dep-info file to track binary dependencies.
|
||||
@ -278,21 +277,6 @@ Available template variables:
|
||||
The `-Zroot-dir` flag sets the root directory relative to which paths are printed.
|
||||
This affects both diagnostics and paths emitted by the `file!()` macro.
|
||||
|
||||
## doctest-xcompile
|
||||
* Tracking Issue: [#7040](https://github.com/rust-lang/cargo/issues/7040)
|
||||
* Tracking Rustc Issue: [#64245](https://github.com/rust-lang/rust/issues/64245)
|
||||
|
||||
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 passing along
|
||||
information from `.cargo/config.toml`. See the rustc issue for more information.
|
||||
|
||||
```sh
|
||||
cargo test --target foo -Zdoctest-xcompile
|
||||
```
|
||||
|
||||
## Build-plan
|
||||
* Tracking Issue: [#5579](https://github.com/rust-lang/cargo/issues/5579)
|
||||
|
||||
@ -2171,3 +2155,7 @@ See [`cargo fix --edition`](../commands/cargo-fix.md) and [The Edition Guide](..
|
||||
|
||||
Support for automatically deleting old files was stabilized in Rust 1.88.
|
||||
More information can be found in the [config chapter](config.md#cache).
|
||||
|
||||
## doctest-xcompile
|
||||
|
||||
Doctest cross-compiling is now unconditionally enabled starting in Rust 1.88. Running doctests with `cargo test` will now honor the `--target` flag.
|
||||
|
@ -1246,7 +1246,7 @@ fn non_build_script_deps_adopt_specified_target_unconditionally() {
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn no_cross_doctests_works_with_artifacts() {
|
||||
fn cross_doctests_works_with_artifacts() {
|
||||
if cross_compile::disabled() {
|
||||
return;
|
||||
}
|
||||
@ -1302,9 +1302,11 @@ fn no_cross_doctests_works_with_artifacts() {
|
||||
println!("c");
|
||||
let target = cross_compile::alternate();
|
||||
|
||||
// This will build the library, but does not build or run doc tests.
|
||||
// This should probably be a warning or error.
|
||||
p.cargo("test -Z bindeps -v --doc --target")
|
||||
if !cross_compile::can_run_on_host() {
|
||||
return;
|
||||
}
|
||||
|
||||
p.cargo("test -Z bindeps -v --target")
|
||||
.arg(&target)
|
||||
.masquerade_as_nightly_cargo(&["bindeps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
@ -1312,30 +1314,12 @@ fn no_cross_doctests_works_with_artifacts() {
|
||||
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/lib.rs [..]--target [ALT_TARGET] [..]
|
||||
[RUNNING] `rustc --crate-name bar --edition=2015 bar/src/main.rs [..]--target [ALT_TARGET] [..]
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]`
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), cross-compilation doctests are not yet supported
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile for more information.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
if !cross_compile::can_run_on_host() {
|
||||
return;
|
||||
}
|
||||
|
||||
// This tests the library, but does not run the doc tests.
|
||||
p.cargo("test -Z bindeps -v --target")
|
||||
.arg(&target)
|
||||
.masquerade_as_nightly_cargo(&["bindeps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[FRESH] bar v0.5.0 ([ROOT]/foo/bar)
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]--test[..]
|
||||
[RUNNING] `rustc --crate-name foo [..]
|
||||
[RUNNING] `rustc --crate-name foo [..]
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `[ROOT]/foo/target/[ALT_TARGET]/debug/deps/foo-[HASH][EXE]`
|
||||
[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), cross-compilation doctests are not yet supported
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile for more information.
|
||||
[DOCTEST] foo
|
||||
[RUNNING] `rustdoc [..]--test src/lib.rs --test-run-directory [ROOT]/foo --target [ALT_TARGET] [..]
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
@ -5600,10 +5600,10 @@ test check_target ... ok
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
// Remove check once 1.88 is stable
|
||||
if cargo_test_support::is_nightly() {
|
||||
p.cargo("test --workspace -Z doctest-xcompile --doc --target")
|
||||
p.cargo("test --workspace --doc --target")
|
||||
.arg(&target)
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
test foo/src/lib.rs - (line 2) ... ok
|
||||
|
@ -1,4 +1,4 @@
|
||||
<svg width="1230px" height="866px" xmlns="http://www.w3.org/2000/svg">
|
||||
<svg width="1230px" height="848px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
@ -46,69 +46,67 @@
|
||||
</tspan>
|
||||
<tspan x="10px" y="280px"><tspan> -Z direct-minimal-versions Resolve minimal dependency versions instead of maximum (direct dependencies only)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="298px"><tspan> -Z doctest-xcompile Compile and run doctests for non-host target using runner config</tspan>
|
||||
<tspan x="10px" y="298px"><tspan> -Z dual-proc-macros Build proc-macros for both the host and the target</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="316px"><tspan> -Z dual-proc-macros Build proc-macros for both the host and the target</tspan>
|
||||
<tspan x="10px" y="316px"><tspan> -Z feature-unification Enable new feature unification modes in workspaces</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="334px"><tspan> -Z feature-unification Enable new feature unification modes in workspaces</tspan>
|
||||
<tspan x="10px" y="334px"><tspan> -Z gc Track cache usage and "garbage collect" unused files</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="352px"><tspan> -Z gc Track cache usage and "garbage collect" unused files</tspan>
|
||||
<tspan x="10px" y="352px"><tspan> -Z git Enable support for shallow git fetch operations</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="370px"><tspan> -Z git Enable support for shallow git fetch operations</tspan>
|
||||
<tspan x="10px" y="370px"><tspan> -Z gitoxide Use gitoxide for the given git interactions, or all of them if no argument is given</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="388px"><tspan> -Z gitoxide Use gitoxide for the given git interactions, or all of them if no argument is given</tspan>
|
||||
<tspan x="10px" y="388px"><tspan> -Z host-config Enable the `[host]` section in the .cargo/config.toml file</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="406px"><tspan> -Z host-config Enable the `[host]` section in the .cargo/config.toml file</tspan>
|
||||
<tspan x="10px" y="406px"><tspan> -Z minimal-versions Resolve minimal dependency versions instead of maximum</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="424px"><tspan> -Z minimal-versions Resolve minimal dependency versions instead of maximum</tspan>
|
||||
<tspan x="10px" y="424px"><tspan> -Z msrv-policy Enable rust-version aware policy within cargo</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="442px"><tspan> -Z msrv-policy Enable rust-version aware policy within cargo</tspan>
|
||||
<tspan x="10px" y="442px"><tspan> -Z mtime-on-use Configure Cargo to update the mtime of used files</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="460px"><tspan> -Z mtime-on-use Configure Cargo to update the mtime of used files</tspan>
|
||||
<tspan x="10px" y="460px"><tspan> -Z no-embed-metadata Avoid embedding metadata in library artifacts</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="478px"><tspan> -Z no-embed-metadata Avoid embedding metadata in library artifacts</tspan>
|
||||
<tspan x="10px" y="478px"><tspan> -Z no-index-update Do not update the registry index even if the cache is outdated</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="496px"><tspan> -Z no-index-update Do not update the registry index even if the cache is outdated</tspan>
|
||||
<tspan x="10px" y="496px"><tspan> -Z package-workspace Handle intra-workspace dependencies when packaging</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="514px"><tspan> -Z package-workspace Handle intra-workspace dependencies when packaging</tspan>
|
||||
<tspan x="10px" y="514px"><tspan> -Z panic-abort-tests Enable support to run tests with -Cpanic=abort</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="532px"><tspan> -Z panic-abort-tests Enable support to run tests with -Cpanic=abort</tspan>
|
||||
<tspan x="10px" y="532px"><tspan> -Z profile-rustflags Enable the `rustflags` option in profiles in .cargo/config.toml file</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="550px"><tspan> -Z profile-rustflags Enable the `rustflags` option in profiles in .cargo/config.toml file</tspan>
|
||||
<tspan x="10px" y="550px"><tspan> -Z public-dependency Respect a dependency's `public` field in Cargo.toml to control public/private dependencies</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="568px"><tspan> -Z public-dependency Respect a dependency's `public` field in Cargo.toml to control public/private dependencies</tspan>
|
||||
<tspan x="10px" y="568px"><tspan> -Z publish-timeout Enable the `publish.timeout` key in .cargo/config.toml file</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="586px"><tspan> -Z publish-timeout Enable the `publish.timeout` key in .cargo/config.toml file</tspan>
|
||||
<tspan x="10px" y="586px"><tspan> -Z root-dir Set the root directory relative to which paths are printed (defaults to workspace root)</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="604px"><tspan> -Z root-dir Set the root directory relative to which paths are printed (defaults to workspace root)</tspan>
|
||||
<tspan x="10px" y="604px"><tspan> -Z rustdoc-depinfo Use dep-info files in rustdoc rebuild detection</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="622px"><tspan> -Z rustdoc-depinfo Use dep-info files in rustdoc rebuild detection</tspan>
|
||||
<tspan x="10px" y="622px"><tspan> -Z rustdoc-map Allow passing external documentation mappings to rustdoc</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="640px"><tspan> -Z rustdoc-map Allow passing external documentation mappings to rustdoc</tspan>
|
||||
<tspan x="10px" y="640px"><tspan> -Z rustdoc-scrape-examples Allows Rustdoc to scrape code examples from reverse-dependencies</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="658px"><tspan> -Z rustdoc-scrape-examples Allows Rustdoc to scrape code examples from reverse-dependencies</tspan>
|
||||
<tspan x="10px" y="658px"><tspan> -Z sbom Enable the `sbom` option in build config in .cargo/config.toml file</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="676px"><tspan> -Z sbom Enable the `sbom` option in build config in .cargo/config.toml file</tspan>
|
||||
<tspan x="10px" y="676px"><tspan> -Z script Enable support for single-file, `.rs` packages</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="694px"><tspan> -Z script Enable support for single-file, `.rs` packages</tspan>
|
||||
<tspan x="10px" y="694px"><tspan> -Z target-applies-to-host Enable the `target-applies-to-host` key in the .cargo/config.toml file</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="712px"><tspan> -Z target-applies-to-host Enable the `target-applies-to-host` key in the .cargo/config.toml file</tspan>
|
||||
<tspan x="10px" y="712px"><tspan> -Z trim-paths Enable the `trim-paths` option in profiles</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="730px"><tspan> -Z trim-paths Enable the `trim-paths` option in profiles</tspan>
|
||||
<tspan x="10px" y="730px"><tspan> -Z unstable-options Allow the usage of unstable options</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="748px"><tspan> -Z unstable-options Allow the usage of unstable options</tspan>
|
||||
<tspan x="10px" y="748px"><tspan> -Z warnings Allow use of the build.warnings config key</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="766px"><tspan> -Z warnings Allow use of the build.warnings config key</tspan>
|
||||
<tspan x="10px" y="766px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="784px">
|
||||
<tspan x="10px" y="784px"><tspan>Run with `cargo -Z [FLAG] [COMMAND]`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="802px"><tspan>Run with `cargo -Z [FLAG] [COMMAND]`</tspan>
|
||||
<tspan x="10px" y="802px">
|
||||
</tspan>
|
||||
<tspan x="10px" y="820px">
|
||||
<tspan x="10px" y="820px"><tspan>See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information about these flags.</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="838px"><tspan>See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html for more information about these flags.</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="856px">
|
||||
<tspan x="10px" y="838px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 6.7 KiB After Width: | Height: | Size: 6.5 KiB |
@ -452,6 +452,11 @@ fn cross_tests() {
|
||||
"src/lib.rs",
|
||||
&format!(
|
||||
r#"
|
||||
//! ```
|
||||
//! extern crate foo;
|
||||
//! assert!(true);
|
||||
//! ```
|
||||
|
||||
use std::env;
|
||||
pub fn foo() {{ assert_eq!(env::consts::ARCH, "{}"); }}
|
||||
#[test] fn test_foo() {{ foo() }}
|
||||
@ -469,6 +474,7 @@ fn cross_tests() {
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] unittests src/lib.rs (target/[ALT_TARGET]/debug/deps/foo-[HASH][EXE])
|
||||
[RUNNING] unittests src/bin/bar.rs (target/[ALT_TARGET]/debug/deps/bar-[HASH][EXE])
|
||||
[DOCTEST] foo
|
||||
|
||||
"#]])
|
||||
.with_stdout_data(str![[r#"
|
||||
@ -485,104 +491,12 @@ test test ... ok
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn no_cross_doctests() {
|
||||
if cross_compile::disabled() {
|
||||
return;
|
||||
}
|
||||
|
||||
let p = project()
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
//! ```
|
||||
//! extern crate foo;
|
||||
//! assert!(true);
|
||||
//! ```
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
let host_output = "\
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] unittests src/lib.rs (target/debug/deps/foo-[HASH][EXE])
|
||||
[DOCTEST] foo
|
||||
";
|
||||
|
||||
println!("a");
|
||||
p.cargo("test").with_stderr_data(host_output).run();
|
||||
|
||||
println!("b");
|
||||
let target = rustc_host();
|
||||
p.cargo("test -v --target")
|
||||
.arg(&target)
|
||||
// Unordered since the two `rustc` invocations happen concurrently.
|
||||
.with_stderr_data(
|
||||
str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]--crate-type lib[..]
|
||||
[RUNNING] `rustc --crate-name foo [..]--test[..]
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `[ROOT]/foo/target/[HOST_TARGET]/debug/deps/foo-[HASH][EXE]`
|
||||
[DOCTEST] foo
|
||||
[RUNNING] `rustdoc [..]--target [HOST_TARGET][..]`
|
||||
|
||||
"#]]
|
||||
.unordered(),
|
||||
)
|
||||
.with_stdout_data(str![[r#"
|
||||
|
||||
running 0 tests
|
||||
|
||||
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
|
||||
|
||||
running 1 test
|
||||
test src/lib.rs - (line 2) ... ok
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
println!("c");
|
||||
let target = cross_compile::alternate();
|
||||
|
||||
// This will build the library, but does not build or run doc tests.
|
||||
// This should probably be a warning or error.
|
||||
p.cargo("test -v --doc --target")
|
||||
.arg(&target)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), cross-compilation doctests are not yet supported
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile for more information.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
if !cross_compile::can_run_on_host() {
|
||||
return;
|
||||
}
|
||||
|
||||
// This tests the library, but does not run the doc tests.
|
||||
p.cargo("test -v --target")
|
||||
.arg(&target)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.0.1 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo [..]--test[..]
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
[RUNNING] `[ROOT]/foo/target/[ALT_TARGET]/debug/deps/foo-[HASH][EXE]`
|
||||
[NOTE] skipping doctests for foo v0.0.1 ([ROOT]/foo) (lib), cross-compilation doctests are not yet supported
|
||||
See https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#doctest-xcompile for more information.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
@ -1218,7 +1132,10 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zdoctest-xcompile is unstable")]
|
||||
#[cargo_test(
|
||||
nightly,
|
||||
reason = "waiting for 1.88 to be stable for doctest xcompile flags"
|
||||
)]
|
||||
fn doctest_xcompile_linker() {
|
||||
if cross_compile::disabled() {
|
||||
return;
|
||||
@ -1249,10 +1166,9 @@ fn doctest_xcompile_linker() {
|
||||
.build();
|
||||
|
||||
// Fails because `my-linker-tool` doesn't actually exist.
|
||||
p.cargo("test --doc -v -Zdoctest-xcompile --target")
|
||||
p.cargo("test --doc -v --target")
|
||||
.arg(&target)
|
||||
.with_status(101)
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.1.0 ([ROOT]/foo)
|
||||
[RUNNING] `rustc --crate-name foo --edition=2015 src/lib.rs [..] --out-dir [ROOT]/foo/target/[ALT_TARGET]/debug/deps --target [ALT_TARGET] [..]
|
||||
|
@ -58,8 +58,8 @@ fn custom_target_minimal() {
|
||||
.run();
|
||||
|
||||
// Ensure that the correct style of flag is passed to --target with doc tests.
|
||||
p.cargo("test --doc --target src/../custom-target.json -v -Zdoctest-xcompile")
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile", "no_core", "lang_items"])
|
||||
p.cargo("test --doc --target src/../custom-target.json -v")
|
||||
.masquerade_as_nightly_cargo(&["no_core", "lang_items"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[FRESH] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
@ -663,7 +663,7 @@ fn doctest() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("test --doc -v -Zdoctest-xcompile")
|
||||
p.cargo("test --doc -v")
|
||||
.build_std(&setup)
|
||||
.with_stdout_data(str![[r#"
|
||||
|
||||
|
@ -4736,9 +4736,12 @@ fn test_dep_with_dev() {
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zdoctest-xcompile is unstable")]
|
||||
#[cargo_test(
|
||||
nightly,
|
||||
reason = "waiting for 1.88 to be stable for doctest xcompile flags"
|
||||
)]
|
||||
fn cargo_test_doctest_xcompile_ignores() {
|
||||
// Test for `ignore-...` syntax with -Zdoctest-xcompile.
|
||||
// Check ignore-TARGET syntax.
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_lib_manifest("foo"))
|
||||
.file(
|
||||
@ -4769,75 +4772,14 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; fini
|
||||
...
|
||||
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"])
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
p.cargo("test -Zdoctest-xcompile")
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zdoctest-xcompile is unstable")]
|
||||
fn cargo_test_doctest_xcompile() {
|
||||
if !cross_compile::can_run_on_host() {
|
||||
return;
|
||||
}
|
||||
let p = project()
|
||||
.file("Cargo.toml", &basic_lib_manifest("foo"))
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
|
||||
///```
|
||||
///assert!(1 == 1);
|
||||
///```
|
||||
pub fn foo() -> u8 {
|
||||
4
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("build").run();
|
||||
p.cargo(&format!("test --target {}", cross_compile::alternate()))
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
running 0 tests
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
p.cargo(&format!(
|
||||
"test --target {} -Zdoctest-xcompile",
|
||||
cross_compile::alternate()
|
||||
))
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zdoctest-xcompile is unstable")]
|
||||
#[cargo_test(
|
||||
nightly,
|
||||
reason = "waiting for 1.88 to be stable for doctest xcompile flags"
|
||||
)]
|
||||
fn cargo_test_doctest_xcompile_runner() {
|
||||
if !cross_compile::can_run_on_host() {
|
||||
return;
|
||||
@ -4906,25 +4848,24 @@ running 0 tests
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
p.cargo(&format!(
|
||||
"test --target {} -Zdoctest-xcompile",
|
||||
cross_compile::alternate()
|
||||
))
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
|
||||
.with_stdout_data(str![[r#"
|
||||
p.cargo(&format!("test --target {}", cross_compile::alternate()))
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
...
|
||||
"#]])
|
||||
.with_stderr_data(str![[r#"
|
||||
.with_stderr_data(str![[r#"
|
||||
...
|
||||
this is a runner
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zdoctest-xcompile is unstable")]
|
||||
#[cargo_test(
|
||||
nightly,
|
||||
reason = "waiting for 1.88 to be stable for doctest xcompile flags"
|
||||
)]
|
||||
fn cargo_test_doctest_xcompile_no_runner() {
|
||||
if !cross_compile::can_run_on_host() {
|
||||
return;
|
||||
@ -4956,17 +4897,13 @@ running 0 tests
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
p.cargo(&format!(
|
||||
"test --target {} -Zdoctest-xcompile",
|
||||
cross_compile::alternate()
|
||||
))
|
||||
.masquerade_as_nightly_cargo(&["doctest-xcompile"])
|
||||
.with_stdout_data(str![[r#"
|
||||
p.cargo(&format!("test --target {}", cross_compile::alternate()))
|
||||
.with_stdout_data(str![[r#"
|
||||
...
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
|
||||
...
|
||||
"#]])
|
||||
.run();
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test(nightly, reason = "-Zpanic-abort-tests in rustc is unstable")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user