From b7b5a093a18def063aaf3f0afaf0324f9abcbcf3 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 9 Aug 2023 18:19:59 +0300 Subject: [PATCH 1/2] Fix cargo errors counter --- src/cargo/core/compiler/mod.rs | 2 +- tests/testsuite/build.rs | 2 +- tests/testsuite/build_script.rs | 2 +- tests/testsuite/check.rs | 4 ++-- tests/testsuite/fix.rs | 2 +- tests/testsuite/install.rs | 2 +- tests/testsuite/messages.rs | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 0801783dc7b..d4af919854b 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -422,7 +422,7 @@ fn rustc(cx: &mut Context<'_, '_>, unit: &Unit, exec: &Arc) -> Car }; let errors = match output_options.errors_seen { 0 => String::new(), - 1 => " due to previous error".to_string(), + 1 => " due to 1 previous error".to_string(), count => format!(" due to {} previous errors", count), }; let name = descriptive_pkg_name(&name, &target, &mode); diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index fe4f7f6df04..250aeb08512 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -760,7 +760,7 @@ fn cargo_compile_with_invalid_code() { p.cargo("build") .with_status(101) .with_stderr_contains( - "[ERROR] could not compile `foo` (bin \"foo\") due to previous error\n", + "[ERROR] could not compile `foo` (bin \"foo\") due to 1 previous error\n", ) .run(); assert!(p.root().join("Cargo.lock").is_file()); diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 649e9017bea..1abe8f52cd7 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -1716,7 +1716,7 @@ fn build_deps_not_for_normal() { .with_stderr_contains("[..]can't find crate for `aaaaa`[..]") .with_stderr_contains( "\ -[ERROR] could not compile `foo` (lib) due to previous error +[ERROR] could not compile `foo` (lib) due to 1 previous error Caused by: process didn't exit successfully: [..] diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index db153fc3cc5..55d24f04a08 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -804,7 +804,7 @@ fn short_message_format() { .with_stderr_contains( "\ src/lib.rs:1:27: error[E0308]: mismatched types -error: could not compile `foo` (lib) due to previous error +error: could not compile `foo` (lib) due to 1 previous error ", ) .run(); @@ -1250,7 +1250,7 @@ fn check_fixable_error_no_fix() { [CHECKING] foo v0.0.1 ([..]) {}\ [WARNING] `foo` (lib) generated 1 warning -[ERROR] could not compile `foo` (lib) due to previous error; 1 warning emitted +[ERROR] could not compile `foo` (lib) due to 1 previous error; 1 warning emitted ", rustc_message ); diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index ac44309894f..ccff2eaab70 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -29,7 +29,7 @@ fn do_not_fix_broken_builds() { p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") .with_status(101) - .with_stderr_contains("[ERROR] could not compile `foo` (lib) due to previous error") + .with_stderr_contains("[ERROR] could not compile `foo` (lib) due to 1 previous error") .run(); assert!(p.read_file("src/lib.rs").contains("let mut x = 3;")); } diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index fd53b607bf3..0177aee3a7f 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1010,7 +1010,7 @@ fn compile_failure() { .with_status(101) .with_stderr_contains( "\ -[ERROR] could not compile `foo` (bin \"foo\") due to previous error +[ERROR] could not compile `foo` (bin \"foo\") due to 1 previous error [ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be \ found at `[..]target`.\nTo reuse those artifacts with a future compilation, \ set the environment variable `CARGO_TARGET_DIR` to that path. diff --git a/tests/testsuite/messages.rs b/tests/testsuite/messages.rs index 2c534d8f071..fb92593bccb 100644 --- a/tests/testsuite/messages.rs +++ b/tests/testsuite/messages.rs @@ -136,7 +136,7 @@ fn deduplicate_errors() { .with_stderr(&format!( "\ [COMPILING] foo v0.0.1 [..] -{}error: could not compile `foo` (lib) due to previous error +{}error: could not compile `foo` (lib) due to 1 previous error ", rustc_message )) From 3e297a6803735a54c398fdd4077ff7b65dae1cca Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 29 Nov 2023 18:30:07 +0200 Subject: [PATCH 2/2] Update test for override respects spec metadata --- tests/testsuite/replace.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testsuite/replace.rs b/tests/testsuite/replace.rs index a28079a41bb..6c31a023e79 100644 --- a/tests/testsuite/replace.rs +++ b/tests/testsuite/replace.rs @@ -1399,7 +1399,7 @@ fn override_respects_spec_metadata() { [..] [..] [..] -error: could not compile `foo` (lib) due to previous error +error: could not compile `foo` (lib) due to 1 previous error ", ) .with_status(101)