Skip to content

Commit 70d54be

Browse files
committed
Make it more clear which module is being tested when running cargo test
1 parent 1ca930b commit 70d54be

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/cargo/ops/cargo_test.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::ffi::OsString;
22

33
use crate::core::compiler::{Compilation, CompileKind, Doctest, UnitOutput};
44
use crate::core::shell::Verbosity;
5-
use crate::core::Workspace;
5+
use crate::core::{TargetKind, Workspace};
66
use crate::ops;
77
use crate::util::errors::CargoResult;
88
use crate::util::{CargoTestError, Config, ProcessError, Test};
@@ -85,7 +85,24 @@ fn run_unit_tests(
8585
} in compilation.tests.iter()
8686
{
8787
let test = unit.target.name().to_string();
88-
let exe_display = path.strip_prefix(cwd).unwrap_or(path).display();
88+
89+
let test_path = unit.target.src_path().path().unwrap();
90+
let exe_display = if let TargetKind::Test = unit.target.kind() {
91+
format!(
92+
"{} ({})",
93+
test_path
94+
.strip_prefix(unit.pkg.root())
95+
.unwrap_or(&test_path)
96+
.display(),
97+
path.strip_prefix(cwd).unwrap_or(path).display()
98+
)
99+
} else {
100+
format!(
101+
"unittests ({})",
102+
path.strip_prefix(cwd).unwrap_or(path).display()
103+
)
104+
};
105+
89106
let mut cmd = compilation.target_process(path, unit.kind, &unit.pkg, *script_meta)?;
90107
cmd.args(test_args);
91108
if unit.target.harness() && config.shell().verbosity() == Verbosity::Quiet {

0 commit comments

Comments
 (0)