aboutsummaryrefslogtreecommitdiff
path: root/xtask
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2023-04-15 13:55:56 +0200
committerdatdenkikniet <jcdra1@gmail.com>2023-04-15 13:55:56 +0200
commit622a58db5a06b1c4b29d9036ffaa593edff771b2 (patch)
tree6c94fa1c221384475b0cd9f67e51b1d88483a5aa /xtask
parent461023e3b836db394dce0e034a1d329b1f5c8f48 (diff)
Also log command with enough verbosity
Diffstat (limited to 'xtask')
-rw-r--r--xtask/src/command.rs19
-rw-r--r--xtask/src/main.rs2
2 files changed, 16 insertions, 5 deletions
diff --git a/xtask/src/command.rs b/xtask/src/command.rs
index 71dda2b..d05a95b 100644
--- a/xtask/src/command.rs
+++ b/xtask/src/command.rs
@@ -1,7 +1,8 @@
use log::{error, info, Level};
use crate::{
- cargo_commands::FinalRunResult, ExtraArguments, Package, RunResult, Target, TestRunError,
+ argument_parsing::Globals, cargo_commands::FinalRunResult, ExtraArguments, Package, RunResult,
+ Target, TestRunError,
};
use core::fmt;
use std::{
@@ -305,6 +306,12 @@ impl core::fmt::Display for CargoCommand<'_> {
}
impl<'a> CargoCommand<'a> {
+ pub fn as_cmd_string(&self) -> String {
+ let executable = self.executable();
+ let args = self.args().join(" ");
+ format!("{executable} {args}")
+ }
+
fn command(&self) -> &str {
match self {
CargoCommand::Run { .. } | CargoCommand::Qemu { .. } => "run",
@@ -702,7 +709,7 @@ pub fn run_successful(run: &RunResult, expected_output_file: &str) -> Result<(),
}
}
-pub fn handle_results(results: Vec<FinalRunResult>) -> anyhow::Result<()> {
+pub fn handle_results(globals: &Globals, results: Vec<FinalRunResult>) -> anyhow::Result<()> {
let errors = results.iter().filter_map(|r| {
if let FinalRunResult::Failed(c, r) = r {
Some((c, r))
@@ -748,11 +755,15 @@ pub fn handle_results(results: Vec<FinalRunResult>) -> anyhow::Result<()> {
errors.clone().for_each(log_stdout_stderr(Level::Error));
successes.for_each(|(cmd, _)| {
- info!("✅ Success: {cmd}");
+ if globals.verbose > 0 {
+ info!("✅ Success: {cmd}\n {}", cmd.as_cmd_string());
+ } else {
+ info!("✅ Success: {cmd}");
+ }
});
errors.clone().for_each(|(cmd, _)| {
- error!("❌ Failed: {cmd}");
+ error!("❌ Failed: {cmd}\n {}", cmd.as_cmd_string());
});
let ecount = errors.count();
diff --git a/xtask/src/main.rs b/xtask/src/main.rs
index b572591..eab21b3 100644
--- a/xtask/src/main.rs
+++ b/xtask/src/main.rs
@@ -287,7 +287,7 @@ fn main() -> anyhow::Result<()> {
}
};
- handle_results(final_run_results)
+ handle_results(globals, final_run_results)
}
// run example binary `example`