Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix build script output with crate name when running in extra verbose mode. Fixes #6158. #6164

Merged
merged 2 commits into from
Oct 19, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,8 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
} else {
state.running(&cmd);
let output = if extra_verbose {
state.capture_output(&cmd, true)
let prefix = format!("[{} {}] ", id.name(), id.version());
state.capture_output(&cmd, Some(prefix), true)
} else {
cmd.exec_with_output()
};
Expand Down
6 changes: 4 additions & 2 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,17 @@ impl<'a> JobState<'a> {
pub fn capture_output(
&self,
cmd: &ProcessBuilder,
prefix: Option<String>,
print_output: bool,
) -> CargoResult<Output> {
let prefix = prefix.unwrap_or_else(|| String::new());
cmd.exec_with_streaming(
&mut |out| {
let _ = self.tx.send(Message::Stdout(out.to_string()));
let _ = self.tx.send(Message::Stdout(format!("{}{}", prefix, out)));
Ok(())
},
&mut |err| {
let _ = self.tx.send(Message::Stderr(err.to_string()));
let _ = self.tx.send(Message::Stderr(format!("{}{}", prefix, err)));
Ok(())
},
print_output,
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl Executor for DefaultExecutor {
_mode: CompileMode,
state: &job_queue::JobState<'_>,
) -> CargoResult<()> {
state.capture_output(&cmd, false).map(drop)
state.capture_output(&cmd, None, false).map(drop)
}
}

Expand Down Expand Up @@ -645,7 +645,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
false,
).map(drop)
} else {
state.capture_output(&rustdoc, false).map(drop)
state.capture_output(&rustdoc, None, false).map(drop)
};
exec_result.chain_err(|| format!("Could not document `{}`.", name))?;
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/build_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2803,13 +2803,13 @@ fn output_shows_on_vv() {
).build();

p.cargo("build -vv")
.with_stdout("stdout")
.with_stdout("[foo 0.5.0] stdout")
.with_stderr(
"\
[COMPILING] foo v0.5.0 ([..])
[RUNNING] `rustc [..]`
[RUNNING] `[..]`
stderr
[foo 0.5.0] stderr
[RUNNING] `rustc [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
Expand Down
30 changes: 15 additions & 15 deletions tests/testsuite/metabuild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ fn metabuild_basic() {
let p = basic_project();
p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb")
.with_stdout_contains("Hello mb-other")
.with_stdout_contains("[foo 0.0.1] Hello mb")
.with_stdout_contains("[foo 0.0.1] Hello mb-other")
.run();
}

Expand Down Expand Up @@ -164,12 +164,12 @@ fn metabuild_optional_dep() {

p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_does_not_contain("Hello mb")
.with_stdout_does_not_contain("[foo 0.0.1] Hello mb")
.run();

p.cargo("build -vv --features mb")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb")
.with_stdout_contains("[foo 0.0.1] Hello mb")
.run();
}

Expand Down Expand Up @@ -206,7 +206,7 @@ fn metabuild_lib_name() {

p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb")
.with_stdout_contains("[foo 0.0.1] Hello mb")
.run();
}

Expand Down Expand Up @@ -235,12 +235,12 @@ fn metabuild_fresh() {

p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb")
.with_stdout_contains("[foo 0.0.1] Hello mb")
.run();

p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_does_not_contain("Hello mb")
.with_stdout_does_not_contain("[foo 0.0.1] Hello mb")
.with_stderr(
"\
[FRESH] mb [..]
Expand Down Expand Up @@ -279,7 +279,7 @@ fn metabuild_links() {

p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb")
.with_stdout_contains("[foo 0.0.1] Hello mb")
.run();
}

Expand Down Expand Up @@ -376,10 +376,10 @@ fn metabuild_workspace() {

p.cargo("build -vv --all")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb1 [..]member1")
.with_stdout_contains("Hello mb2 [..]member1")
.with_stdout_contains("Hello mb1 [..]member2")
.with_stdout_does_not_contain("Hello mb2 [..]member2")
.with_stdout_contains("[member1 0.0.1] Hello mb1 [..]member1")
.with_stdout_contains("[member1 0.0.1] Hello mb2 [..]member1")
.with_stdout_contains("[member2 0.0.1] Hello mb1 [..]member2")
.with_stdout_does_not_contain("[member2 0.0.1] Hello mb2 [..]member2")
.run();
}

Expand Down Expand Up @@ -572,8 +572,8 @@ fn metabuild_two_versions() {

p.cargo("build -vv --all")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb1 [..]member1")
.with_stdout_contains("Hello mb2 [..]member2")
.with_stdout_contains("[member1 0.0.1] Hello mb1 [..]member1")
.with_stdout_contains("[member2 0.0.1] Hello mb2 [..]member2")
.run();

assert_eq!(
Expand Down Expand Up @@ -628,7 +628,7 @@ fn metabuild_external_dependency() {

p.cargo("build -vv")
.masquerade_as_nightly_cargo()
.with_stdout_contains("Hello mb")
.with_stdout_contains("[dep 1.0.0] Hello mb")
.run();

assert_eq!(
Expand Down
24 changes: 12 additions & 12 deletions tests/testsuite/profile_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn profile_selection_build() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
[FINISHED] dev [unoptimized + debuginfo] [..]
Expand Down Expand Up @@ -113,7 +113,7 @@ fn profile_selection_build_release() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[FINISHED] release [optimized] [..]
Expand Down Expand Up @@ -174,8 +174,8 @@ fn profile_selection_build_all_targets() {
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
foo custom build PROFILE=debug DEBUG=false OPT_LEVEL=3
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=false OPT_LEVEL=3
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]`
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]`
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]`
Expand Down Expand Up @@ -241,7 +241,7 @@ fn profile_selection_build_all_targets_release() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]`
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]`
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]`
Expand Down Expand Up @@ -296,7 +296,7 @@ fn profile_selection_test() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..]/target/debug/build/foo-[..]/build-script-build`
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
Expand Down Expand Up @@ -360,7 +360,7 @@ fn profile_selection_test_release() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..]/target/release/build/foo-[..]/build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
Expand Down Expand Up @@ -424,7 +424,7 @@ fn profile_selection_bench() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..]target/release/build/foo-[..]/build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
Expand Down Expand Up @@ -493,7 +493,7 @@ fn profile_selection_check_all_targets() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..]
Expand Down Expand Up @@ -543,7 +543,7 @@ fn profile_selection_check_all_targets_release() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..]target/release/build/foo-[..]/build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[foo 0.0.1] foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,metadata -C opt-level=3 -C codegen-units=2 --test [..]
Expand Down Expand Up @@ -607,7 +607,7 @@ fn profile_selection_check_all_targets_test() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..]
[RUNNING] `rustc --crate-name test1 tests/test1.rs [..]--emit=dep-info,metadata -C codegen-units=1 -C debuginfo=2 --test [..]
Expand Down Expand Up @@ -653,7 +653,7 @@ fn profile_selection_doc() {
[COMPILING] foo [..]
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..]target/debug/build/foo-[..]/build-script-build`
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[foo 0.0.1] foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[DOCUMENTING] foo [..]
[RUNNING] `rustdoc --crate-name foo src/lib.rs [..]
[FINISHED] dev [unoptimized + debuginfo] [..]
Expand Down