Skip to content

Commit f36ee65

Browse files
committed
Auto merge of #9934 - ehuss:progress-test, r=alexcrichton
Differentiate tests in progress bar. Some people have expressed confusion when the progress bar includes the package name twice, such as: ``` Building [=======================> ] 301/307: rustc_interface, rustc_interface ``` This can happen in a variety of circumstances, but a common one is `cargo test`. This causes the library to be built in parallel with the library being built for unittests. This PR adds some additional markers to differentiate what is being built: - Lib as test: `lib_name(test)` - Binary as test: `bin_name(bin test)` - Example as test: `example_name(example test)`
2 parents 790b01f + 4e9302e commit f36ee65

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

src/cargo/core/compiler/job_queue.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -998,20 +998,30 @@ impl<'cfg> DrainState<'cfg> {
998998

999999
fn name_for_progress(&self, unit: &Unit) -> String {
10001000
let pkg_name = unit.pkg.name();
1001+
let target_name = unit.target.name();
10011002
match unit.mode {
10021003
CompileMode::Doc { .. } => format!("{}(doc)", pkg_name),
10031004
CompileMode::RunCustomBuild => format!("{}(build)", pkg_name),
1004-
_ => {
1005-
let annotation = match unit.target.kind() {
1006-
TargetKind::Lib(_) => return pkg_name.to_string(),
1007-
TargetKind::CustomBuild => return format!("{}(build.rs)", pkg_name),
1008-
TargetKind::Bin => "bin",
1009-
TargetKind::Test => "test",
1010-
TargetKind::Bench => "bench",
1011-
TargetKind::ExampleBin | TargetKind::ExampleLib(_) => "example",
1012-
};
1013-
format!("{}({})", unit.target.name(), annotation)
1014-
}
1005+
CompileMode::Test | CompileMode::Check { test: true } => match unit.target.kind() {
1006+
TargetKind::Lib(_) => format!("{}(test)", target_name),
1007+
TargetKind::CustomBuild => panic!("cannot test build script"),
1008+
TargetKind::Bin => format!("{}(bin test)", target_name),
1009+
TargetKind::Test => format!("{}(test)", target_name),
1010+
TargetKind::Bench => format!("{}(bench)", target_name),
1011+
TargetKind::ExampleBin | TargetKind::ExampleLib(_) => {
1012+
format!("{}(example test)", target_name)
1013+
}
1014+
},
1015+
_ => match unit.target.kind() {
1016+
TargetKind::Lib(_) => pkg_name.to_string(),
1017+
TargetKind::CustomBuild => format!("{}(build.rs)", pkg_name),
1018+
TargetKind::Bin => format!("{}(bin)", target_name),
1019+
TargetKind::Test => format!("{}(test)", target_name),
1020+
TargetKind::Bench => format!("{}(bench)", target_name),
1021+
TargetKind::ExampleBin | TargetKind::ExampleLib(_) => {
1022+
format!("{}(example)", target_name)
1023+
}
1024+
},
10151025
}
10161026
}
10171027

0 commit comments

Comments
 (0)