From 4639cf536c4230ac02b715f8c2be673915a72977 Mon Sep 17 00:00:00 2001 From: Mahfuzullah Galib Date: Wed, 11 Dec 2024 17:55:09 +0600 Subject: [PATCH 1/3] as per issue/comment https://github.com/rust-lang/cargo/issues/12118#issuecomment-1541860834 added warning about skipping doctest on xcompiling even when not under verbose flag --- src/cargo/ops/cargo_test.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index c3e4eec860f..82c2a8f37bb 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -194,6 +194,10 @@ fn run_doc_tests( CompileKind::Host => {} CompileKind::Target(target) => { if target.short_name() != compilation.host { + + gctx.shell().concise(|shell| { + shell.warn("skipping cross-compilation doctest(s), use --verbose to see the full list in detail".to_string()) + })?; // Skip doctests, -Zdoctest-xcompile not enabled. gctx.shell().verbose(|shell| { shell.note(format!( From e7585367656a4efc5e115cac3bebf49151f553f8 Mon Sep 17 00:00:00 2001 From: Mahfuzullah Galib Date: Thu, 12 Dec 2024 22:34:06 +0600 Subject: [PATCH 2/3] warns once if only even if multiple doctests are skipped --- src/cargo/ops/cargo_test.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index 82c2a8f37bb..fd53fb0a634 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -178,6 +178,7 @@ fn run_doc_tests( let mut errors = Vec::new(); let doctest_xcompile = gctx.cli_unstable().doctest_xcompile; let color = gctx.shell().color_choice(); + let mut warned_once = false; for doctest_info in &compilation.to_doc_test { let Doctest { @@ -194,10 +195,13 @@ fn run_doc_tests( CompileKind::Host => {} CompileKind::Target(target) => { if target.short_name() != compilation.host { + if !warned_once { + gctx.shell().concise(|shell| { + shell.warn("skipping cross-compilation doctest(s), use --verbose to see the full list in detail".to_string()) + })?; + warned_once = true; + } - gctx.shell().concise(|shell| { - shell.warn("skipping cross-compilation doctest(s), use --verbose to see the full list in detail".to_string()) - })?; // Skip doctests, -Zdoctest-xcompile not enabled. gctx.shell().verbose(|shell| { shell.note(format!( From 13071f56645bd17479e1b12d23252fa8f297d30e Mon Sep 17 00:00:00 2001 From: Mahfuzullah Galib Date: Thu, 12 Dec 2024 23:06:32 +0600 Subject: [PATCH 3/3] added a fullstop in the end of a warning and modified the test for my earlier changes --- src/cargo/ops/cargo_test.rs | 2 +- tests/testsuite/cross_compile.rs | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cargo/ops/cargo_test.rs b/src/cargo/ops/cargo_test.rs index fd53fb0a634..873aae47dfc 100644 --- a/src/cargo/ops/cargo_test.rs +++ b/src/cargo/ops/cargo_test.rs @@ -197,7 +197,7 @@ fn run_doc_tests( if target.short_name() != compilation.host { if !warned_once { gctx.shell().concise(|shell| { - shell.warn("skipping cross-compilation doctest(s), use --verbose to see the full list in detail".to_string()) + shell.warn("skipping cross-compilation doctest(s), use --verbose to see the full list in detail.".to_string()) })?; warned_once = true; } diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 185c480abb5..53e7e2e033f 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -469,6 +469,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]) +[WARNING] skipping cross-compilation doctest(s), use --verbose to see the full list in detail. "#]]) .with_stdout_data(str![[r#"