Stabilize cache-messages

This commit is contained in:
Eric Huss 2019-09-24 18:17:36 -07:00
parent 8b0561d68f
commit bd73e8dab5
18 changed files with 243 additions and 400 deletions

View file

@ -35,7 +35,6 @@ Available unstable (nightly-only) flags:
-Z unstable-options -- Allow the usage of unstable options such as --registry
-Z config-profile -- Read profiles from .cargo/config files
-Z install-upgrade -- `cargo install` will upgrade instead of failing
-Z cache-messages -- Cache compiler messages
-Z timings -- Display concurrency information
-Z doctest-xcompile -- Compile and run doctests for non-host target using runner config

View file

@ -79,7 +79,6 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
}
compile_opts.build_config.primary_unit_rustc = Some(wrapper);
compile_opts.build_config.force_rebuild = true;
ops::compile(&ws, &compile_opts)?;
Ok(())

View file

@ -43,8 +43,6 @@ pub struct BuildConfig {
/// An optional override of the rustc path for primary units only
pub primary_unit_rustc: Option<ProcessBuilder>,
pub rustfix_diagnostic_server: RefCell<Option<RustfixDiagnosticServer>>,
/// Whether or not Cargo should cache compiler output on disk.
cache_messages: bool,
}
impl BuildConfig {
@ -101,15 +99,9 @@ impl BuildConfig {
build_plan: false,
primary_unit_rustc: None,
rustfix_diagnostic_server: RefCell::new(None),
cache_messages: config.cli_unstable().cache_messages,
})
}
/// Whether or not Cargo should cache compiler messages on disk.
pub fn cache_messages(&self) -> bool {
self.cache_messages
}
/// Whether or not the *user* wants JSON output. Whether or not rustc
/// actually uses JSON is decided in `add_error_format`.
pub fn emit_json(&self) -> bool {

View file

@ -553,6 +553,14 @@ fn compute_metadata<'a, 'cfg>(
bcx.rustc.verbose_version.hash(&mut hasher);
if cx.is_primary_package(unit) {
// This is primarily here for clippy. This ensures that the clippy
// artifacts are separate from the `check` ones.
if let Some(proc) = &cx.bcx.build_config.primary_unit_rustc {
proc.get_program().hash(&mut hasher);
}
}
// Seed the contents of `__CARGO_DEFAULT_LIB_METADATA` to the hasher if present.
// This should be the release channel, to get a different hash for each channel.
if let Ok(ref channel) = __cargo_default_lib_metadata {

View file

@ -1083,11 +1083,23 @@ fn calculate_normal<'a, 'cfg>(
// Fill out a bunch more information that we'll be tracking typically
// hashed to take up less space on disk as we just need to know when things
// change.
let extra_flags = if unit.mode.is_doc() {
let mut extra_flags = if unit.mode.is_doc() {
cx.bcx.rustdocflags_args(unit)
} else {
cx.bcx.rustflags_args(unit)
};
}
.to_vec();
if cx.is_primary_package(unit) {
// This is primarily here for clippy arguments.
if let Some(proc) = &cx.bcx.build_config.primary_unit_rustc {
let args = proc
.get_args()
.iter()
.map(|s| s.to_string_lossy().to_string());
extra_flags.extend(args);
}
}
let profile_hash = util::hash_u64((&unit.profile, unit.mode, cx.bcx.extra_args_for(unit)));
// Include metadata since it is exposed as environment variables.
let m = unit.pkg.manifest().metadata();
@ -1104,7 +1116,7 @@ fn calculate_normal<'a, 'cfg>(
local: Mutex::new(local),
memoized_hash: Mutex::new(None),
metadata,
rustflags: extra_flags.to_vec(),
rustflags: extra_flags,
fs_status: FsStatus::Stale,
outputs,
})

View file

@ -36,6 +36,9 @@
//! # Detailed information used for logging the reason why
//! # something is being recompiled.
//! lib-$pkgname-$META.json
//! # The console output from the compiler. This is cached
//! # so that warnings can be redisplayed for "fresh" units.
//! output
//!
//! # This is the root directory for all rustc artifacts except build
//! # scripts, examples, and test and bench executables. Almost every

View file

@ -136,9 +136,7 @@ fn compile<'a, 'cfg: 'a>(
};
work.then(link_targets(cx, unit, false)?)
} else {
let work = if cx.bcx.build_config.cache_messages()
&& cx.bcx.show_warnings(unit.pkg.package_id())
{
let work = if cx.bcx.show_warnings(unit.pkg.package_id()) {
replay_output_cache(
unit.pkg.package_id(),
unit.target,
@ -663,79 +661,31 @@ fn add_cap_lints(bcx: &BuildContext<'_, '_>, unit: &Unit<'_>, cmd: &mut ProcessB
/// Add error-format flags to the command.
///
/// This is somewhat odd right now, but the general overview is that if
/// `-Zcache-messages` or `pipelined` is enabled then Cargo always uses JSON
/// output. This has several benefits, such as being easier to parse, handles
/// changing formats (for replaying cached messages), ensures atomic output (so
/// messages aren't interleaved), etc.
///
/// It is intended in the future that Cargo *always* uses the JSON output (by
/// turning on cache-messages by default), and this function can be simplified.
/// Cargo always uses JSON output. This has several benefits, such as being
/// easier to parse, handles changing formats (for replaying cached messages),
/// ensures atomic output (so messages aren't interleaved), allows for
/// intercepting messages like rmeta artifacts, etc. rustc includes a
/// "rendered" field in the JSON message with the message properly formatted,
/// which Cargo will extract and display to the user.
fn add_error_format_and_color(
cx: &Context<'_, '_>,
cmd: &mut ProcessBuilder,
pipelined: bool,
) -> CargoResult<()> {
// If this unit is producing a required rmeta file then we need to know
// when the rmeta file is ready so we can signal to the rest of Cargo that
// it can continue dependent compilations. To do this we are currently
// required to switch the compiler into JSON message mode, but we still
// want to present human readable errors as well. (this rabbit hole just
// goes and goes)
//
// All that means is that if we're not already in JSON mode we need to
// switch to JSON mode, ensure that rustc error messages can be rendered
// prettily, and then when parsing JSON messages from rustc we need to
// internally understand that we should extract the `rendered` field and
// present it if we can.
if cx.bcx.build_config.cache_messages() || pipelined {
cmd.arg("--error-format=json");
let mut json = String::from("--json=diagnostic-rendered-ansi");
if pipelined {
json.push_str(",artifacts");
}
match cx.bcx.build_config.message_format {
MessageFormat::Short | MessageFormat::Json { short: true, .. } => {
json.push_str(",diagnostic-short");
}
_ => {}
}
cmd.arg(json);
} else {
let mut color = true;
match cx.bcx.build_config.message_format {
MessageFormat::Human => (),
MessageFormat::Json {
ansi,
short,
render_diagnostics,
} => {
cmd.arg("--error-format").arg("json");
// If ansi is explicitly requested, enable it. If we're
// rendering diagnostics ourselves then also enable it because
// we'll figure out what to do with the colors later.
if ansi || render_diagnostics {
cmd.arg("--json=diagnostic-rendered-ansi");
}
if short {
cmd.arg("--json=diagnostic-short");
}
color = false;
}
MessageFormat::Short => {
cmd.arg("--error-format").arg("short");
}
}
if color {
let color = if cx.bcx.config.shell().supports_color() {
"always"
} else {
"never"
};
cmd.args(&["--color", color]);
}
cmd.arg("--error-format=json");
let mut json = String::from("--json=diagnostic-rendered-ansi");
if pipelined {
// Pipelining needs to know when rmeta files are finished. Tell rustc
// to emit a message that cargo will intercept.
json.push_str(",artifacts");
}
match cx.bcx.build_config.message_format {
MessageFormat::Short | MessageFormat::Json { short: true, .. } => {
json.push_str(",diagnostic-short");
}
_ => {}
}
cmd.arg(json);
Ok(())
}
@ -1058,7 +1008,8 @@ struct OutputOptions {
color: bool,
/// Where to write the JSON messages to support playback later if the unit
/// is fresh. The file is created lazily so that in the normal case, lots
/// of empty files are not created. This is None if caching is disabled.
/// of empty files are not created. If this is None, the output will not
/// be cached (such as when replaying cached messages).
cache_cell: Option<(PathBuf, LazyCell<File>)>,
}
@ -1066,14 +1017,10 @@ impl OutputOptions {
fn new<'a>(cx: &Context<'a, '_>, unit: &Unit<'a>) -> OutputOptions {
let look_for_metadata_directive = cx.rmeta_required(unit);
let color = cx.bcx.config.shell().supports_color();
let cache_cell = if cx.bcx.build_config.cache_messages() {
let path = cx.files().message_cache_path(unit);
// Remove old cache, ignore ENOENT, which is the common case.
drop(fs::remove_file(&path));
Some((path, LazyCell::new()))
} else {
None
};
let path = cx.files().message_cache_path(unit);
// Remove old cache, ignore ENOENT, which is the common case.
drop(fs::remove_file(&path));
let cache_cell = Some((path, LazyCell::new()));
OutputOptions {
format: cx.bcx.build_config.message_format,
look_for_metadata_directive,
@ -1100,15 +1047,27 @@ fn on_stderr_line(
target: &Target,
options: &mut OutputOptions,
) -> CargoResult<()> {
// Check if caching is enabled.
if let Some((path, cell)) = &mut options.cache_cell {
// Cache the output, which will be replayed later when Fresh.
let f = cell.try_borrow_mut_with(|| File::create(path))?;
debug_assert!(!line.contains('\n'));
f.write_all(line.as_bytes())?;
f.write_all(&[b'\n'])?;
if on_stderr_line_inner(state, line, package_id, target, options)? {
// Check if caching is enabled.
if let Some((path, cell)) = &mut options.cache_cell {
// Cache the output, which will be replayed later when Fresh.
let f = cell.try_borrow_mut_with(|| File::create(path))?;
debug_assert!(!line.contains('\n'));
f.write_all(line.as_bytes())?;
f.write_all(&[b'\n'])?;
}
}
Ok(())
}
/// Returns true if the line should be cached.
fn on_stderr_line_inner(
state: &JobState<'_>,
line: &str,
package_id: PackageId,
target: &Target,
options: &mut OutputOptions,
) -> CargoResult<bool> {
// We primarily want to use this function to process JSON messages from
// rustc. The compiler should always print one JSON message per line, and
// otherwise it may have other output intermingled (think RUST_LOG or
@ -1116,7 +1075,7 @@ fn on_stderr_line(
// JSON message.
if !line.starts_with('{') {
state.stderr(line.to_string());
return Ok(());
return Ok(true);
}
let mut compiler_message: Box<serde_json::value::RawValue> = match serde_json::from_str(line) {
@ -1128,7 +1087,7 @@ fn on_stderr_line(
Err(e) => {
debug!("failed to parse json: {:?}", e);
state.stderr(line.to_string());
return Ok(());
return Ok(true);
}
};
@ -1164,14 +1123,13 @@ fn on_stderr_line(
.expect("strip should never fail")
};
state.stderr(rendered);
return Ok(());
return Ok(true);
}
}
// Remove color information from the rendered string. When pipelining is
// enabled and/or when cached messages are enabled we're always asking
// for ANSI colors from rustc, so unconditionally postprocess here and
// remove ansi color codes.
// Remove color information from the rendered string if color is not
// enabled. Cargo always asks for ANSI colors from rustc. This allows
// cached replay to enable/disable colors without re-invoking rustc.
MessageFormat::Json { ansi: false, .. } => {
#[derive(serde::Deserialize, serde::Serialize)]
struct CompilerMessage {
@ -1213,7 +1171,7 @@ fn on_stderr_line(
log::debug!("looks like metadata finished early!");
state.rmeta_produced();
}
return Ok(());
return Ok(false);
}
}
@ -1231,7 +1189,7 @@ fn on_stderr_line(
// instead. We want the stdout of Cargo to always be machine parseable as
// stderr has our colorized human-readable messages.
state.stdout(msg);
Ok(())
Ok(true)
}
fn replay_output_cache(
@ -1244,7 +1202,7 @@ fn replay_output_cache(
let target = target.clone();
let mut options = OutputOptions {
format,
look_for_metadata_directive: false,
look_for_metadata_directive: true,
color,
cache_cell: None,
};

View file

@ -335,7 +335,6 @@ pub struct CliUnstable {
pub dual_proc_macros: bool,
pub mtime_on_use: bool,
pub install_upgrade: bool,
pub cache_messages: bool,
pub named_profiles: bool,
pub binary_dep_depinfo: bool,
pub build_std: Option<Vec<String>>,
@ -393,7 +392,6 @@ impl CliUnstable {
// can also be set in .cargo/config or with and ENV
"mtime-on-use" => self.mtime_on_use = true,
"install-upgrade" => self.install_upgrade = true,
"cache-messages" => self.cache_messages = true,
"named-profiles" => self.named_profiles = true,
"binary-dep-depinfo" => self.binary_dep_depinfo = true,
"build-std" => {

View file

@ -23,11 +23,11 @@ index each time.
* Original Issue: [#6477](https://github.com/rust-lang/cargo/pull/6477)
* Cache usage meta tracking issue: [#7150](https://github.com/rust-lang/cargo/issues/7150)
The `-Z mtime-on-use` flag is an experiment to have Cargo update the mtime of
used files to make it easier for tools like cargo-sweep to detect which files
The `-Z mtime-on-use` flag is an experiment to have Cargo update the mtime of
used files to make it easier for tools like cargo-sweep to detect which files
are stale. For many workflows this needs to be set on *all* invocations of cargo.
To make this more practical setting the `unstable.mtime_on_use` flag in `.cargo/config`
or the corresponding ENV variable will apply the `-Z mtime-on-use` to all
or the corresponding ENV variable will apply the `-Z mtime-on-use` to all
invocations of nightly cargo. (the config flag is ignored by stable)
### avoid-dev-deps
@ -323,25 +323,6 @@ my_dep = { version = "1.2.3", public = true }
private_dep = "2.0.0" # Will be 'private' by default
```
### cache-messages
* Tracking Issue: [#6986](https://github.com/rust-lang/cargo/issues/6986)
The `cache-messages` feature causes Cargo to cache the messages generated by
the compiler. This is primarily useful if a crate compiles successfully with
warnings. Previously, re-running Cargo would not display any output. With the
`cache-messages` feature, it will quickly redisplay the previous warnings.
```
cargo +nightly check -Z cache-messages
```
This works with any command that runs the compiler (`build`, `check`, `test`,
etc.).
This also changes the way Cargo interacts with the compiler, helping to
prevent interleaved messages when multiple crates attempt to display a message
at the same time.
### build-std
* Tracking Repository: https://github.com/rust-lang/wg-cargo-std-aware

View file

@ -1145,14 +1145,14 @@ fn cargo_default_env_metadata_env_var() {
.with_stderr(&format!(
"\
[COMPILING] bar v0.0.1 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type dylib \
[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type dylib \
--emit=[..]link \
-C prefer-dynamic -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
-C extra-filename=[..] \
@ -1173,14 +1173,14 @@ fn cargo_default_env_metadata_env_var() {
.with_stderr(&format!(
"\
[COMPILING] bar v0.0.1 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/lib.rs --color never --crate-type dylib \
[RUNNING] `rustc --crate-name bar bar/src/lib.rs [..]--crate-type dylib \
--emit=[..]link \
-C prefer-dynamic -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
-C extra-filename=[..] \
@ -1557,7 +1557,7 @@ fn lto_build() {
.with_stderr(
"\
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/main.rs --color never --crate-type bin \
[RUNNING] `rustc --crate-name test src/main.rs [..]--crate-type bin \
--emit=[..]link \
-C opt-level=3 \
-C lto \
@ -1577,7 +1577,7 @@ fn verbose_build() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
@ -1595,7 +1595,7 @@ fn verbose_release_build() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level=3 \
-C metadata=[..] \
@ -1644,7 +1644,7 @@ fn verbose_release_build_deps() {
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.0 ([CWD]/foo)
[RUNNING] `rustc --crate-name foo foo/src/lib.rs --color never \
[RUNNING] `rustc --crate-name foo foo/src/lib.rs [..]\
--crate-type dylib --crate-type rlib \
--emit=[..]link \
-C prefer-dynamic \
@ -1653,7 +1653,7 @@ fn verbose_release_build_deps() {
--out-dir [..] \
-L dependency=[CWD]/target/release/deps`
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level=3 \
-C metadata=[..] \
@ -2995,29 +2995,6 @@ fn panic_abort_compiles_with_panic_abort() {
.run();
}
#[cargo_test]
fn explicit_color_config_is_propagated_to_rustc() {
let p = project()
.file("Cargo.toml", &basic_manifest("test", "0.0.0"))
.file("src/lib.rs", "")
.build();
p.cargo("build -v --color always")
.with_stderr_contains("[..]rustc [..] src/lib.rs --color always[..]")
.run();
p.cargo("clean").run();
p.cargo("build -v --color never")
.with_stderr(
"\
[COMPILING] test v0.0.0 ([..])
[RUNNING] `rustc [..] --color never [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
.run();
}
#[cargo_test]
fn compiler_json_error_format() {
let p = project()
@ -3043,10 +3020,8 @@ fn compiler_json_error_format() {
.file("bar/src/lib.rs", r#"fn dead() {}"#)
.build();
// Use `jobs=1` to ensure that the order of messages is consistent.
p.cargo("build -v --message-format=json --jobs=1")
.with_json(
r#"
let output = |fresh| {
r#"
{
"reason":"compiler-artifact",
"package_id":"foo 0.5.0 ([..])",
@ -3068,7 +3043,7 @@ fn compiler_json_error_format() {
"executable": null,
"features": [],
"filenames": "{...}",
"fresh": false
"fresh": $FRESH
}
{
@ -3109,7 +3084,7 @@ fn compiler_json_error_format() {
"[..].rlib",
"[..].rmeta"
],
"fresh": false
"fresh": $FRESH
}
{
@ -3156,102 +3131,21 @@ fn compiler_json_error_format() {
"executable": "[..]/foo/target/debug/foo[EXE]",
"features": [],
"filenames": "{...}",
"fresh": false
"fresh": $FRESH
}
"#,
)
"#
.replace("$FRESH", fresh)
};
// Use `jobs=1` to ensure that the order of messages is consistent.
p.cargo("build -v --message-format=json --jobs=1")
.with_json(&output("false"))
.run();
// With fresh build, we should repeat the artifacts,
// but omit compiler warnings.
// and replay the cached compiler warnings.
p.cargo("build -v --message-format=json --jobs=1")
.with_json(
r#"
{
"reason":"compiler-artifact",
"package_id":"foo 0.5.0 ([..])",
"target":{
"kind":["custom-build"],
"crate_types":["bin"],
"doctest": false,
"edition": "2015",
"name":"build-script-build",
"src_path":"[..]build.rs"
},
"profile": {
"debug_assertions": true,
"debuginfo": 2,
"opt_level": "0",
"overflow_checks": true,
"test": false
},
"executable": null,
"features": [],
"filenames": "{...}",
"fresh": true
}
{
"reason":"compiler-artifact",
"profile": {
"debug_assertions": true,
"debuginfo": 2,
"opt_level": "0",
"overflow_checks": true,
"test": false
},
"executable": null,
"features": [],
"package_id":"bar 0.5.0 ([..])",
"target":{
"kind":["lib"],
"crate_types":["lib"],
"doctest": true,
"edition": "2015",
"name":"bar",
"src_path":"[..]lib.rs"
},
"filenames":[
"[..].rlib",
"[..].rmeta"
],
"fresh": true
}
{
"reason":"build-script-executed",
"package_id":"foo 0.5.0 ([..])",
"linked_libs":[],
"linked_paths":[],
"env":[],
"cfgs":["xyz"]
}
{
"reason":"compiler-artifact",
"package_id":"foo 0.5.0 ([..])",
"target":{
"kind":["bin"],
"crate_types":["bin"],
"doctest": false,
"edition": "2015",
"name":"foo",
"src_path":"[..]main.rs"
},
"profile": {
"debug_assertions": true,
"debuginfo": 2,
"opt_level": "0",
"overflow_checks": true,
"test": false
},
"executable": "[..]/foo/target/debug/foo[EXE]",
"features": [],
"filenames": "{...}",
"fresh": true
}
"#,
)
.with_json(&output("true"))
.run();
}
@ -4227,11 +4121,11 @@ fn build_filter_infer_profile() {
p.cargo("build -v")
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
"[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link[..]",
)
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link[..]",
)
.run();
@ -4239,15 +4133,15 @@ fn build_filter_infer_profile() {
p.root().join("target").rm_rf();
p.cargo("build -v --test=t1")
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
"[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 [..]",
)
.with_stderr_contains(
"[RUNNING] `rustc --crate-name t1 tests/t1.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name t1 tests/t1.rs [..]--emit=[..]link \
-C debuginfo=2 [..]",
)
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link -C debuginfo=2 [..]",
)
.run();
@ -4256,16 +4150,16 @@ fn build_filter_infer_profile() {
// Bench uses test profile without `--release`.
p.cargo("build -v --bench=b1")
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
"[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 [..]",
)
.with_stderr_contains(
"[RUNNING] `rustc --crate-name b1 benches/b1.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name b1 benches/b1.rs [..]--emit=[..]link \
-C debuginfo=2 [..]",
)
.with_stderr_does_not_contain("opt-level")
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link -C debuginfo=2 [..]",
)
.run();
@ -4277,17 +4171,17 @@ fn targets_selected_default() {
p.cargo("build -v")
// Binaries.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link[..]",
)
// Benchmarks.
.with_stderr_does_not_contain(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C opt-level=3 --test [..]",
)
// Unit tests.
.with_stderr_does_not_contain(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C debuginfo=2 --test [..]",
)
.run();
@ -4299,12 +4193,12 @@ fn targets_selected_all() {
p.cargo("build -v --all-targets")
// Binaries.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link[..]",
)
// Unit tests.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C debuginfo=2 --test [..]",
)
.run();
@ -4316,12 +4210,12 @@ fn all_targets_no_lib() {
p.cargo("build -v --all-targets")
// Binaries.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link[..]",
)
// Unit tests.
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C debuginfo=2 --test [..]",
)
.run();

View file

@ -11,7 +11,7 @@ fn build_lib_only() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \

View file

@ -32,7 +32,7 @@ fn custom_build_script_failed() {
.with_stderr(
"\
[COMPILING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin [..]`
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin [..]`
[RUNNING] `[..]/build-script-build`
[ERROR] failed to run custom build command for `foo v0.5.0 ([CWD])`
@ -1136,19 +1136,19 @@ fn build_cmd_with_a_build_cmd() {
[COMPILING] a v0.5.0 ([CWD]/a)
[RUNNING] `rustc [..] a/build.rs [..] --extern b=[..]`
[RUNNING] `[..]/a-[..]/build-script-build`
[RUNNING] `rustc --crate-name a [..]lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name a [..]lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..]target/debug/deps \
-L [..]target/debug/deps`
[COMPILING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name build_script_build build.rs --color never --crate-type bin \
[RUNNING] `rustc --crate-name build_script_build build.rs [..]--crate-type bin \
--emit=[..]link \
-C debuginfo=2 -C metadata=[..] --out-dir [..] \
-L [..]target/debug/deps \
--extern a=[..]liba[..].rlib`
[RUNNING] `[..]/foo-[..]/build-script-build`
[RUNNING] `rustc --crate-name foo [..]lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo [..]lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \

View file

@ -1,4 +1,6 @@
use cargo_test_support::{clippy_is_available, is_nightly, process, project, registry::Package};
use cargo_test_support::{
clippy_is_available, is_coarse_mtime, process, project, registry::Package, sleep_ms,
};
use std::path::Path;
fn as_str(bytes: &[u8]) -> &str {
@ -7,10 +9,6 @@ fn as_str(bytes: &[u8]) -> &str {
#[cargo_test]
fn simple() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// A simple example that generates two warnings (unused functions).
let p = project()
.file(
@ -38,16 +36,14 @@ fn simple() {
// -q so the output is the same as rustc (no "Compiling" or "Finished").
let cargo_output1 = p
.cargo("check -Zcache-messages -q --color=never")
.masquerade_as_nightly_cargo()
.cargo("check -q --color=never")
.exec_with_output()
.expect("cargo to run");
assert_eq!(as_str(&rustc_output.stderr), as_str(&cargo_output1.stderr));
assert!(cargo_output1.stdout.is_empty());
// Check that the cached version is exactly the same.
let cargo_output2 = p
.cargo("check -Zcache-messages -q")
.masquerade_as_nightly_cargo()
.cargo("check -q")
.exec_with_output()
.expect("cargo to run");
assert_eq!(as_str(&rustc_output.stderr), as_str(&cargo_output2.stderr));
@ -57,10 +53,6 @@ fn simple() {
// same as `simple`, except everything is using the short format
#[cargo_test]
fn simple_short() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
let p = project()
.file(
"src/lib.rs",
@ -84,15 +76,13 @@ fn simple_short() {
assert!(rustc_output.status.success());
let cargo_output1 = p
.cargo("check -Zcache-messages -q --color=never --message-format=short")
.masquerade_as_nightly_cargo()
.cargo("check -q --color=never --message-format=short")
.exec_with_output()
.expect("cargo to run");
assert_eq!(as_str(&rustc_output.stderr), as_str(&cargo_output1.stderr));
// assert!(cargo_output1.stdout.is_empty());
let cargo_output2 = p
.cargo("check -Zcache-messages -q --message-format=short")
.masquerade_as_nightly_cargo()
.cargo("check -q --message-format=short")
.exec_with_output()
.expect("cargo to run");
println!("{}", String::from_utf8_lossy(&cargo_output2.stdout));
@ -102,10 +92,6 @@ fn simple_short() {
#[cargo_test]
fn color() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// Check enabling/disabling color.
let p = project().file("src/lib.rs", "fn a() {}").build();
@ -132,24 +118,21 @@ fn color() {
// First pass, non-cached, with color, should be the same.
let cargo_output1 = p
.cargo("check -Zcache-messages -q --color=always")
.masquerade_as_nightly_cargo()
.cargo("check -q --color=always")
.exec_with_output()
.expect("cargo to run");
assert_eq!(rustc_color, as_str(&cargo_output1.stderr));
// Replay cached, with color.
let cargo_output2 = p
.cargo("check -Zcache-messages -q --color=always")
.masquerade_as_nightly_cargo()
.cargo("check -q --color=always")
.exec_with_output()
.expect("cargo to run");
assert_eq!(rustc_color, as_str(&cargo_output2.stderr));
// Replay cached, no color.
let cargo_output_nocolor = p
.cargo("check -Zcache-messages -q --color=never")
.masquerade_as_nightly_cargo()
.cargo("check -q --color=never")
.exec_with_output()
.expect("cargo to run");
assert_eq!(rustc_nocolor, as_str(&cargo_output_nocolor.stderr));
@ -157,10 +140,6 @@ fn color() {
#[cargo_test]
fn cached_as_json() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// Check that cached JSON output is the same.
let p = project().file("src/lib.rs", "fn a() {}").build();
@ -177,16 +156,14 @@ fn cached_as_json() {
// Check JSON output, not fresh.
let cargo_output1 = p
.cargo("check -Zcache-messages --message-format=json")
.masquerade_as_nightly_cargo()
.cargo("check --message-format=json")
.exec_with_output()
.expect("cargo to run");
assert_eq!(as_str(&cargo_output1.stdout), orig_cargo_out);
// Check JSON output, fresh.
let cargo_output2 = p
.cargo("check -Zcache-messages --message-format=json")
.masquerade_as_nightly_cargo()
.cargo("check --message-format=json")
.exec_with_output()
.expect("cargo to run");
// The only difference should be this field.
@ -196,17 +173,10 @@ fn cached_as_json() {
#[cargo_test]
fn clears_cache_after_fix() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// Make sure the cache is invalidated when there is no output.
let p = project().file("src/lib.rs", "fn asdf() {}").build();
// Fill the cache.
p.cargo("check -Zcache-messages")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[..]asdf[..]")
.run();
p.cargo("check").with_stderr_contains("[..]asdf[..]").run();
let cpath = p
.glob("target/debug/.fingerprint/foo-*/output")
.next()
@ -215,10 +185,12 @@ fn clears_cache_after_fix() {
assert!(std::fs::read_to_string(cpath).unwrap().contains("asdf"));
// Fix it.
if is_coarse_mtime() {
sleep_ms(1000);
}
p.change_file("src/lib.rs", "");
p.cargo("check -Zcache-messages")
.masquerade_as_nightly_cargo()
p.cargo("check")
.with_stdout("")
.with_stderr(
"\
@ -230,8 +202,7 @@ fn clears_cache_after_fix() {
assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 0);
// And again, check the cache is correct.
p.cargo("check -Zcache-messages")
.masquerade_as_nightly_cargo()
p.cargo("check")
.with_stdout("")
.with_stderr(
"\
@ -243,10 +214,6 @@ fn clears_cache_after_fix() {
#[cargo_test]
fn rustdoc() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// Create a warning in rustdoc.
let p = project()
.file(
@ -262,24 +229,19 @@ fn rustdoc() {
)
.build();
// At this time, rustdoc does not support --json-rendered=termcolor. So it
// will always be uncolored with -Zcache-messages.
let rustdoc_output = p
.cargo("doc -Zcache-messages -q")
.masquerade_as_nightly_cargo()
.cargo("doc -q --color=always")
.exec_with_output()
.expect("rustdoc to run");
assert!(rustdoc_output.status.success());
let rustdoc_stderr = as_str(&rustdoc_output.stderr);
assert!(rustdoc_stderr.contains("private"));
// Invert this when --json-rendered is added.
assert!(!rustdoc_stderr.contains("\x1b["));
assert!(rustdoc_stderr.contains("\x1b["));
assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 1);
// Check the cached output.
let rustdoc_output = p
.cargo("doc -Zcache-messages -q")
.masquerade_as_nightly_cargo()
.cargo("doc -q --color=always")
.exec_with_output()
.expect("rustdoc to run");
assert_eq!(as_str(&rustdoc_output.stderr), rustdoc_stderr);
@ -287,28 +249,16 @@ fn rustdoc() {
#[cargo_test]
fn fix() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// Make sure `fix` is not broken by caching.
let p = project().file("src/lib.rs", "pub fn try() {}").build();
p.cargo("fix --edition --allow-no-vcs -Zcache-messages")
.masquerade_as_nightly_cargo()
.run();
p.cargo("fix --edition --allow-no-vcs").run();
assert_eq!(p.read_file("src/lib.rs"), "pub fn r#try() {}");
}
#[cargo_test]
fn clippy() {
if !is_nightly() {
// --json-rendered is unstable
eprintln!("skipping test: requires nightly");
return;
}
if !clippy_is_available() {
return;
}
@ -317,34 +267,48 @@ fn clippy() {
// This is just a random clippy lint (assertions_on_constants) that
// hopefully won't change much in the future.
let p = project()
.file("src/lib.rs", "pub fn f() { assert!(true); }")
.file(
"src/lib.rs",
"pub fn f() { assert!(true); }\n\
fn unused_func() {}",
)
.build();
p.cargo("clippy-preview -Zunstable-options -Zcache-messages")
p.cargo("clippy-preview -Zunstable-options -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[RUNNING] `clippy[..]")
.with_stderr_contains("[..]assert!(true)[..]")
.run();
// `check` should be separate from clippy.
p.cargo("check -v")
.with_stderr_contains(
"\
[CHECKING] foo [..]
[RUNNING] `rustc[..]
[WARNING] [..]unused_func[..]
",
)
.with_stderr_does_not_contain("[..]assert!(true)[..]")
.run();
// Again, reading from the cache.
p.cargo("clippy-preview -Zunstable-options -Zcache-messages")
p.cargo("clippy-preview -Zunstable-options -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[FRESH] foo [..]")
.with_stderr_contains("[..]assert!(true)[..]")
.run();
// FIXME: Unfortunately clippy is sharing the same hash with check. This
// causes the cache to be reused when it shouldn't.
p.cargo("check -Zcache-messages")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[..]assert!(true)[..]") // This should not be here.
// And `check` should also be fresh, reading from cache.
p.cargo("check -v")
.with_stderr_contains("[FRESH] foo [..]")
.with_stderr_contains("[WARNING] [..]unused_func[..]")
.with_stderr_does_not_contain("[..]assert!(true)[..]")
.run();
}
#[cargo_test]
fn very_verbose() {
if !is_nightly() {
// --json-rendered is unstable
return;
}
// Handle cap-lints in dependencies.
Package::new("bar", "1.0.0")
.file("src/lib.rs", "fn not_used() {}")
@ -365,18 +329,48 @@ fn very_verbose() {
.file("src/lib.rs", "")
.build();
p.cargo("check -Zcache-messages -vv")
.masquerade_as_nightly_cargo()
p.cargo("check -vv")
.with_stderr_contains("[..]not_used[..]")
.run();
p.cargo("check -Zcache-messages")
.masquerade_as_nightly_cargo()
.with_stderr("[FINISHED] [..]")
.run();
p.cargo("check").with_stderr("[FINISHED] [..]").run();
p.cargo("check -Zcache-messages -vv")
.masquerade_as_nightly_cargo()
p.cargo("check -vv")
.with_stderr_contains("[..]not_used[..]")
.run();
}
#[cargo_test]
fn doesnt_create_extra_files() {
// Ensure it doesn't create `output` files when not needed.
Package::new("dep", "1.0.0")
.file("src/lib.rs", "fn unused() {}")
.publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
[dependencies]
dep = "1.0"
"#,
)
.file("src/lib.rs", "")
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("build").run();
assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 0);
assert_eq!(p.glob("target/debug/.fingerprint/dep-*/output").count(), 0);
if is_coarse_mtime() {
sleep_ms(1000);
}
p.change_file("src/lib.rs", "fn unused() {}");
p.cargo("build").run();
assert_eq!(p.glob("target/debug/.fingerprint/foo-*/output").count(), 1);
}

View file

@ -3,7 +3,7 @@ use std::fmt::{self, Write};
use cargo_test_support::install::exe;
use cargo_test_support::paths::CargoPathExt;
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_manifest, project};
use cargo_test_support::{basic_manifest, is_nightly, project};
#[cargo_test]
fn check_success() {
@ -675,6 +675,11 @@ fn check_artifacts() {
#[cargo_test]
fn short_message_format() {
if !is_nightly() {
// This relies on a bug fix https://github.com/rust-lang/rust/pull/64753.
// This check may be removed once 1.40 is stable.
return;
}
let foo = project()
.file("src/lib.rs", "fn foo() { let _x: bool = 'a'; }")
.build();

View file

@ -376,7 +376,7 @@ fn linker_and_ar() {
.with_stderr_contains(&format!(
"\
[COMPILING] foo v0.5.0 ([CWD])
[RUNNING] `rustc --crate-name foo src/foo.rs --color never --crate-type bin \
[RUNNING] `rustc --crate-name foo src/foo.rs [..]--crate-type bin \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [CWD]/target/{target}/debug/deps \

View file

@ -26,7 +26,7 @@ fn profile_overrides() {
.with_stderr(
"\
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level=1 \
-C debug-assertions=on \
@ -62,7 +62,7 @@ fn opt_level_override_0() {
.with_stderr(
"\
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C debuginfo=2 \
-C metadata=[..] \
@ -95,7 +95,7 @@ fn debug_override_1() {
.with_stderr(
"\
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C debuginfo=1 \
-C metadata=[..] \
@ -131,7 +131,7 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) {
.with_stderr(&format!(
"\
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level={level} \
-C debuginfo=2 \
@ -204,7 +204,7 @@ fn top_level_overrides_deps() {
.with_stderr(&format!(
"\
[COMPILING] foo v0.0.0 ([CWD]/foo)
[RUNNING] `rustc --crate-name foo foo/src/lib.rs --color never \
[RUNNING] `rustc --crate-name foo foo/src/lib.rs [..]\
--crate-type dylib --crate-type rlib \
--emit=[..]link \
-C prefer-dynamic \
@ -214,7 +214,7 @@ fn top_level_overrides_deps() {
--out-dir [CWD]/target/release/deps \
-L dependency=[CWD]/target/release/deps`
[COMPILING] test v0.0.0 ([CWD])
[RUNNING] `rustc --crate-name test src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name test src/lib.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level=1 \
-C debuginfo=2 \

View file

@ -628,14 +628,14 @@ fn example_with_release_flag() {
.with_stderr(
"\
[COMPILING] bar v0.5.0 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/bar.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name bar bar/src/bar.rs [..]--crate-type lib \
--emit=[..]link \
-C opt-level=3 \
-C metadata=[..] \
--out-dir [CWD]/target/release/deps \
-L dependency=[CWD]/target/release/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name a examples/a.rs --color never --crate-type bin \
[RUNNING] `rustc --crate-name a examples/a.rs [..]--crate-type bin \
--emit=[..]link \
-C opt-level=3 \
-C metadata=[..] \
@ -657,14 +657,14 @@ fast2",
.with_stderr(
"\
[COMPILING] bar v0.5.0 ([CWD]/bar)
[RUNNING] `rustc --crate-name bar bar/src/bar.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name bar bar/src/bar.rs [..]--crate-type lib \
--emit=[..]link \
-C debuginfo=2 \
-C metadata=[..] \
--out-dir [CWD]/target/debug/deps \
-L dependency=[CWD]/target/debug/deps`
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name a examples/a.rs --color never --crate-type bin \
[RUNNING] `rustc --crate-name a examples/a.rs [..]--crate-type bin \
--emit=[..]link \
-C debuginfo=2 \
-C metadata=[..] \

View file

@ -15,7 +15,7 @@ fn build_lib_for_foo() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
@ -37,7 +37,7 @@ fn lib() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C debug-assertions=off \
-C metadata=[..] \
@ -60,12 +60,12 @@ fn build_main_and_allow_unstable_options() {
.with_stderr(format!(
"\
[COMPILING] {name} v{version} ([CWD])
[RUNNING] `rustc --crate-name {name} src/lib.rs --color never --crate-type lib \
[RUNNING] `rustc --crate-name {name} src/lib.rs [..]--crate-type lib \
--emit=[..]link -C debuginfo=2 \
-C metadata=[..] \
--out-dir [..] \
-L dependency=[CWD]/target/debug/deps`
[RUNNING] `rustc --crate-name {name} src/main.rs --color never --crate-type bin \
[RUNNING] `rustc --crate-name {name} src/main.rs [..]--crate-type bin \
--emit=[..]link -C debuginfo=2 \
-C debug-assertions \
-C metadata=[..] \
@ -106,10 +106,10 @@ fn build_with_args_to_one_of_multiple_binaries() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=[..]link \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link \
-C debuginfo=2 -C metadata=[..] \
--out-dir [..]`
[RUNNING] `rustc --crate-name bar src/bin/bar.rs --color never --crate-type bin --emit=[..]link \
[RUNNING] `rustc --crate-name bar src/bin/bar.rs [..]--crate-type bin --emit=[..]link \
-C debuginfo=2 -C debug-assertions [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
@ -145,10 +145,10 @@ fn build_with_args_to_one_of_multiple_tests() {
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib --emit=[..]link \
[RUNNING] `rustc --crate-name foo src/lib.rs [..]--crate-type lib --emit=[..]link \
-C debuginfo=2 -C metadata=[..] \
--out-dir [..]`
[RUNNING] `rustc --crate-name bar tests/bar.rs --color never --emit=[..]link -C debuginfo=2 \
[RUNNING] `rustc --crate-name bar tests/bar.rs [..]--emit=[..]link -C debuginfo=2 \
-C debug-assertions [..]--test[..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
@ -219,7 +219,7 @@ fn build_only_bar_dependency() {
.with_stderr(
"\
[COMPILING] bar v0.1.0 ([..])
[RUNNING] `rustc --crate-name bar [..] --color never --crate-type lib [..] -C debug-assertions [..]`
[RUNNING] `rustc --crate-name bar [..]--crate-type lib [..] -C debug-assertions [..]`
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
",
)
@ -232,17 +232,17 @@ fn targets_selected_default() {
p.cargo("rustc -v")
// bin
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link[..]",
)
// bench
.with_stderr_does_not_contain(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C opt-level=3 --test [..]",
)
// unit test
.with_stderr_does_not_contain(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C debuginfo=2 --test [..]",
)
.run();
@ -254,12 +254,12 @@ fn targets_selected_all() {
p.cargo("rustc -v --all-targets")
// bin
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--crate-type bin \
--emit=[..]link[..]",
)
// unit test
.with_stderr_contains(
"[RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=[..]link \
"[RUNNING] `rustc --crate-name foo src/main.rs [..]--emit=[..]link \
-C debuginfo=2 --test [..]",
)
.run();