Skip to content

Commit

Permalink
Always log prepare script stdout and stderr (#1480)
Browse files Browse the repository at this point in the history
- Always log prepare_script stdout to info level, and stderr to warn
level
  • Loading branch information
brynary authored Feb 7, 2025
1 parent 23f3b6e commit eb0d0ef
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
28 changes: 23 additions & 5 deletions qlty-check/src/executor/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,8 @@ impl Driver {
.dir(dir)
.full_env(plan.tool.env())
.stderr_capture()
.stdout_capture();
.stdout_capture()
.unchecked();

debug!("Running prepare_script: {}", &rerun);
let timer = Instant::now();
Expand All @@ -517,18 +518,35 @@ impl Driver {
invocation_label, &rerun
)
})?;
let duration = timer.elapsed().as_secs_f64();

info!(
"{}: prepare_script ran {} in {:.3}s (exit {}): {}",
"{}: prepare_script ran {} in {:.3}s (exit {}): stdout: {}",
plan.invocation_id,
invocation_label,
duration,
timer.elapsed().as_secs_f64(),
output.status.code().unwrap_or(-1),
String::from_utf8(output.stdout).unwrap_or_default()
);

Ok(())
if !output.stderr.is_empty() {
warn!(
"{}: {}: stderr: {}",
plan.invocation_id,
invocation_label,
String::from_utf8(output.stderr).unwrap_or_default()
);
}

if output.status.success() {
Ok(())
} else {
bail!(
"{}: prepare_script exited with non-zero code {}: {}",
plan.invocation_id,
output.status.code().unwrap_or(-1),
rerun
);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion qlty-cli/tests/cmd/check/prepare_script_fail.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Failed to run prepare_script for prepare_script_fail/lint:[..]INVALID_COMMAND[..]
[..]: prepare_script exited with non-zero code [..]:[..]INVALID_COMMAND[..]
...

0 comments on commit eb0d0ef

Please sign in to comment.