mirror of
https://github.com/rust-lang/cargo
synced 2024-09-28 20:15:04 +00:00
fix: correct error count for cargo check --message-format json
This commit is contained in:
parent
01e1ab55dd
commit
71c830ccef
|
@ -1867,10 +1867,19 @@ fn on_stderr_line_inner(
|
|||
|
||||
#[derive(serde::Deserialize)]
|
||||
struct CompilerMessage {
|
||||
message: String,
|
||||
level: String,
|
||||
}
|
||||
if let Ok(message) = serde_json::from_str::<CompilerMessage>(compiler_message.get()) {
|
||||
count_diagnostic(&message.level, options);
|
||||
|
||||
if let Ok(msg) = serde_json::from_str::<CompilerMessage>(compiler_message.get()) {
|
||||
if msg.message.starts_with("aborting due to")
|
||||
|| msg.message.ends_with("warning emitted")
|
||||
|| msg.message.ends_with("warnings emitted")
|
||||
{
|
||||
// Skip this line; we'll print our own summary at the end.
|
||||
return Ok(true);
|
||||
}
|
||||
count_diagnostic(&msg.level, options);
|
||||
}
|
||||
|
||||
let msg = machine_message::FromCompiler {
|
||||
|
|
|
@ -95,7 +95,7 @@ fn cargo_fail_with_no_stderr() {
|
|||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] foo v0.5.0 ([ROOT]/foo)
|
||||
[ERROR] could not compile `foo` (bin "foo") due to 2 previous errors
|
||||
[ERROR] could not compile `foo` (bin "foo") due to 1 previous error
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
|
|
|
@ -327,12 +327,6 @@ fn pkgid_json_message_metadata_consistency() {
|
|||
"reason": "compiler-message",
|
||||
"...": "{...}"
|
||||
},
|
||||
{
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||
"reason": "compiler-message",
|
||||
"...": "{...}"
|
||||
},
|
||||
{
|
||||
"manifest_path": "[ROOT]/foo/Cargo.toml",
|
||||
"package_id": "path+[ROOTURL]/foo#0.5.0",
|
||||
|
|
Loading…
Reference in a new issue