Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 6b011fc

Browse files
Merge #1061
1061: Indicate a cfg(test) build in window/progress messages r=Xanewok a=alexheretic Currently you get your crates cropping up a couple of times in the build progress messages. The 2nd time is building the crate with `cfg(test)`. This change helps make that clear. Using [glyph-brush](https://github.com/alexheretic/glyph-brush) as an example: ## Before ``` window/progress {id: "progress_1", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush_layout", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush_layout", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush", title: "Building"} window/progress {id: "progress_1", message: "gfx_glyph", title: "Building"} window/progress {id: "progress_1", message: "gfx_glyph", title: "Building"} window/progress {id: "progress_1", message: "opengl", title: "Building"} window/progress {id: "progress_1", message: "bench", title: "Building"} window/progress {id: "progress_1", message: "depth", title: "Building"} window/progress {id: "progress_1", message: "paragraph", title: "Building"} window/progress {id: "progress_1", message: "performance", title: "Building"} window/progress {id: "progress_1", message: "varied", title: "Building"} window/progress {id: "progress_1", message: "gfx_noop", title: "Building"} window/progress {done: true, id: "progress_1", title: "Building"} ``` ## After ``` window/progress {id: "progress_1", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush_layout", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush_layout cfg(test)", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush", title: "Building"} window/progress {id: "progress_1", message: "glyph_brush cfg(test)", title: "Building"} window/progress {id: "progress_1", message: "gfx_glyph", title: "Building"} window/progress {id: "progress_1", message: "gfx_glyph cfg(test)", title: "Building"} window/progress {id: "progress_1", message: "opengl", title: "Building"} window/progress {id: "progress_1", message: "bench cfg(test)", title: "Building"} window/progress {id: "progress_1", message: "depth", title: "Building"} window/progress {id: "progress_1", message: "paragraph", title: "Building"} window/progress {id: "progress_1", message: "performance", title: "Building"} window/progress {id: "progress_1", message: "varied", title: "Building"} window/progress {id: "progress_1", message: "gfx_noop cfg(test)", title: "Building"} window/progress {done: true, id: "progress_1", title: "Building"} ``` ## Format I went with **"$crate cfg(test)"**, but maybe **"$crate(test)"** is enough/better. Is one more like current rustc/cargo output than the other? I don't mind too much as long as I can tell it's a cfg(test) build clearly. _Also easy to change later_. Co-authored-by: Alex Butler <[email protected]>
2 parents 32d4577 + 879d6f2 commit 6b011fc

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

src/build/cargo.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@ impl Executor for RlsExecutor {
366366
let cargo_args = cargo_cmd.get_args();
367367
let crate_name =
368368
parse_arg(cargo_args, "--crate-name").expect("no crate-name in rustc command line");
369+
let cfg_test = cargo_args.iter().any(|arg| arg == "--test");
369370
trace!("exec: {} {:?}", crate_name, cargo_cmd);
370371

371372
// Send off a window/progress notification for this compile target.
@@ -374,8 +375,11 @@ impl Executor for RlsExecutor {
374375
{
375376
let progress_sender = self.progress_sender.lock().unwrap();
376377
progress_sender
377-
.send(ProgressUpdate::Message(crate_name.clone()))
378-
.expect("Failed to send progress update");
378+
.send(ProgressUpdate::Message(if cfg_test {
379+
format!("{} cfg(test)", crate_name)
380+
} else {
381+
crate_name.clone()
382+
})).expect("Failed to send progress update");
379383
}
380384

381385
let out_dir = parse_arg(cargo_args, "--out-dir").expect("no out-dir in rustc command line");

src/build/plan.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,14 @@ impl JobQueue {
578578
{
579579
let crate_name = proc_argument_value(&job, "--crate-name").and_then(|x| x.to_str());
580580
let update = match crate_name {
581-
Some(name) => ProgressUpdate::Message(name.to_owned()),
581+
Some(name) => {
582+
let cfg_test = job.get_args().iter().any(|arg| arg == "--test");
583+
ProgressUpdate::Message(if cfg_test {
584+
format!("{} cfg(test)", name)
585+
} else {
586+
name.to_owned()
587+
})
588+
}
582589
None => {
583590
// divide by zero is avoided by earlier assert!
584591
let percentage = compiler_messages.len() as f64 / self.0.len() as f64;

0 commit comments

Comments
 (0)