Skip to content
29 changes: 27 additions & 2 deletions src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,15 @@ pub fn run_err(command: &str, verbose: u8) -> Result<()> {
} else {
println!("{}", rtk);
}
timer.track(command, "rtk run-err", &raw, &rtk);
let label = err_label(command);
timer.track(command, &label, &raw, &rtk);
Ok(())
}

fn err_label(command: &str) -> String {
format!("rtk err {}", command)
}

/// Run tests and show only failures
pub fn run_test(command: &str, verbose: u8) -> Result<()> {
let timer = tracking::TimedExecution::start();
Expand Down Expand Up @@ -99,10 +104,15 @@ pub fn run_test(command: &str, verbose: u8) -> Result<()> {
} else {
println!("{}", summary);
}
timer.track(command, "rtk run-test", &raw, &summary);
let label = test_label(command);
timer.track(command, &label, &raw, &summary);
Ok(())
}

fn test_label(command: &str) -> String {
format!("rtk test {}", command)
}

fn filter_errors(output: &str) -> String {
lazy_static::lazy_static! {
static ref ERROR_PATTERNS: Vec<Regex> = vec![
Expand Down Expand Up @@ -268,4 +278,19 @@ mod tests {
assert!(filtered.contains("error"));
assert!(!filtered.contains("info"));
}

#[test]
fn test_err_label_includes_command() {
assert_eq!(
err_label("pre-commit run --verbose"),
"rtk err pre-commit run --verbose"
);
assert_eq!(err_label("mycommand"), "rtk err mycommand");
}

#[test]
fn test_test_label_includes_command() {
assert_eq!(test_label("cargo test --lib"), "rtk test cargo test --lib");
assert_eq!(test_label("pytest -x"), "rtk test pytest -x");
}
}
Loading