Resolve merge conflicts with test string changes.

This commit is contained in:
Zach Lute 2018-09-09 16:48:57 -07:00
commit b020d3789a
46 changed files with 474 additions and 393 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "cargo"
version = "0.30.0"
version = "0.31.0"
authors = ["Yehuda Katz <wycats@gmail.com>",
"Carl Lerche <me@carllerche.com>",
"Alex Crichton <alex@alexcrichton.com>"]
@ -18,7 +18,7 @@ path = "src/cargo/lib.rs"
[dependencies]
atty = "0.2"
crates-io = { path = "src/crates-io", version = "0.18" }
crates-io = { path = "src/crates-io", version = "0.19" }
crossbeam-utils = "0.5"
crypto-hash = "0.3.1"
curl = "0.4.13"

View File

@ -147,8 +147,14 @@ pub trait AppExt: Sized {
a global configuration.",
).value_name("VCS")
.possible_values(&["git", "hg", "pijul", "fossil", "none"]),
)._arg(opt("bin", "Use a binary (application) template [default]"))
)
._arg(opt("bin", "Use a binary (application) template [default]"))
._arg(opt("lib", "Use a library template"))
._arg(
opt("edition", "Edition to set for the crate generated")
.possible_values(&["2015", "2018"])
.value_name("YEAR")
)
._arg(
opt(
"name",
@ -339,6 +345,7 @@ pub trait ArgMatchesExt {
self._is_present("lib"),
self.value_of_path("path", config).unwrap(),
self._value_of("name").map(|s| s.to_string()),
self._value_of("edition").map(|s| s.to_string()),
)
}

View File

@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::env;
use std::path::{Path, PathBuf};
use std::str::{self, FromStr};
use std::str;
use core::profiles::Profiles;
use core::{Dependency, Workspace};
@ -393,16 +393,9 @@ fn env_args(
// ...including target.'cfg(...)'.rustflags
if let Some(target_cfg) = target_cfg {
if let Some(table) = config.get_table("target")? {
let cfgs = table.val.keys().filter_map(|t| {
if t.starts_with("cfg(") && t.ends_with(')') {
let cfg = &t[4..t.len() - 1];
CfgExpr::from_str(cfg).ok().and_then(|c| {
if c.matches(target_cfg) {
Some(t)
} else {
None
}
})
let cfgs = table.val.keys().filter_map(|key| {
if CfgExpr::matches_key(key, target_cfg) {
Some(key)
} else {
None
}

View File

@ -4,10 +4,9 @@ use std::ffi::OsStr;
use std::path::PathBuf;
use semver::Version;
use lazycell::LazyCell;
use core::{Feature, Package, PackageId, Target, TargetKind};
use util::{self, join_paths, process, CargoResult, Config, ProcessBuilder};
use core::{Edition, Package, PackageId, Target, TargetKind};
use util::{self, join_paths, process, CargoResult, CfgExpr, Config, ProcessBuilder};
use super::BuildContext;
pub struct Doctest {
@ -77,23 +76,31 @@ pub struct Compilation<'cfg> {
config: &'cfg Config,
rustc_process: ProcessBuilder,
target_runner: LazyCell<Option<(PathBuf, Vec<String>)>>,
target_runner: Option<(PathBuf, Vec<String>)>,
}
impl<'cfg> Compilation<'cfg> {
pub fn new<'a>(bcx: &BuildContext<'a, 'cfg>) -> CargoResult<Compilation<'cfg>> {
let mut rustc = bcx.rustc.process();
// If we're using cargo as a rustc wrapper then we're in a situation
// like `cargo fix`. For now just disregard the `RUSTC_WRAPPER` env var
// (which is typically set to `sccache` for now). Eventually we'll
// probably want to implement `RUSTC_WRAPPER` for `cargo fix`, but we'll
// leave that open as a bug for now.
let mut rustc = if bcx.build_config.cargo_as_rustc_wrapper {
let mut rustc = bcx.rustc.process_no_wrapper();
let prog = rustc.get_program().to_owned();
rustc.env("RUSTC", prog);
rustc.program(env::current_exe()?);
rustc
} else {
bcx.rustc.process()
};
for (k, v) in bcx.build_config.extra_rustc_env.iter() {
rustc.env(k, v);
}
for arg in bcx.build_config.extra_rustc_args.iter() {
rustc.arg(arg);
}
if bcx.build_config.cargo_as_rustc_wrapper {
let prog = rustc.get_program().to_owned();
rustc.env("RUSTC", prog);
rustc.program(env::current_exe()?);
}
let srv = bcx.build_config.rustfix_diagnostic_server.borrow();
if let Some(server) = &*srv {
server.configure(&mut rustc);
@ -116,15 +123,14 @@ impl<'cfg> Compilation<'cfg> {
rustc_process: rustc,
host: bcx.host_triple().to_string(),
target: bcx.target_triple().to_string(),
target_runner: LazyCell::new(),
target_runner: target_runner(&bcx)?,
})
}
/// See `process`.
pub fn rustc_process(&self, pkg: &Package, target: &Target) -> CargoResult<ProcessBuilder> {
let mut p = self.fill_env(self.rustc_process.clone(), pkg, true)?;
let manifest = pkg.manifest();
if manifest.features().is_enabled(Feature::edition()) {
if target.edition() != Edition::Edition2015 {
p.arg(format!("--edition={}", target.edition()));
}
Ok(p)
@ -133,8 +139,7 @@ impl<'cfg> Compilation<'cfg> {
/// See `process`.
pub fn rustdoc_process(&self, pkg: &Package, target: &Target) -> CargoResult<ProcessBuilder> {
let mut p = self.fill_env(process(&*self.config.rustdoc()?), pkg, false)?;
let manifest = pkg.manifest();
if manifest.features().is_enabled(Feature::edition()) {
if target.edition() != Edition::Edition2015 {
p.arg("-Zunstable-options");
p.arg(format!("--edition={}", target.edition()));
}
@ -150,11 +155,8 @@ impl<'cfg> Compilation<'cfg> {
self.fill_env(process(cmd), pkg, true)
}
fn target_runner(&self) -> CargoResult<&Option<(PathBuf, Vec<String>)>> {
self.target_runner.try_borrow_with(|| {
let key = format!("target.{}.runner", self.target);
Ok(self.config.get_path_and_args(&key)?.map(|v| v.val))
})
fn target_runner(&self) -> &Option<(PathBuf, Vec<String>)> {
&self.target_runner
}
/// See `process`.
@ -163,7 +165,7 @@ impl<'cfg> Compilation<'cfg> {
cmd: T,
pkg: &Package,
) -> CargoResult<ProcessBuilder> {
let builder = if let Some((ref runner, ref args)) = *self.target_runner()? {
let builder = if let Some((ref runner, ref args)) = *self.target_runner() {
let mut builder = process(runner);
builder.args(args);
builder.arg(cmd);
@ -257,3 +259,39 @@ fn pre_version_component(v: &Version) -> String {
ret
}
fn target_runner(bcx: &BuildContext) -> CargoResult<Option<(PathBuf, Vec<String>)>> {
let target = bcx.target_triple();
// try target.{}.runner
let key = format!("target.{}.runner", target);
if let Some(v) = bcx.config.get_path_and_args(&key)? {
return Ok(Some(v.val));
}
// try target.'cfg(...)'.runner
if let Some(target_cfg) = bcx.target_info.cfg() {
if let Some(table) = bcx.config.get_table("target")? {
let mut matching_runner = None;
for key in table.val.keys() {
if CfgExpr::matches_key(key, target_cfg) {
let key = format!("target.{}.runner", key);
if let Some(runner) = bcx.config.get_path_and_args(&key)? {
// more than one match, error out
if matching_runner.is_some() {
bail!("several matching instances of `target.'cfg(..)'.runner` \
in `.cargo/config`")
}
matching_runner = Some(runner.val);
}
}
}
return Ok(matching_runner);
}
}
Ok(None)
}

View File

@ -85,6 +85,7 @@ impl FromStr for Edition {
}
}
#[derive(PartialEq)]
enum Status {
Stable,
Unstable,
@ -106,7 +107,7 @@ macro_rules! features {
$(
pub fn $feature() -> &'static Feature {
fn get(features: &Features) -> bool {
features.$feature
stab!($stab) == Status::Stable || features.$feature
}
static FEAT: Feature = Feature {
name: stringify!($feature),
@ -173,7 +174,7 @@ features! {
[unstable] alternative_registries: bool,
// Using editions
[unstable] edition: bool,
[stable] edition: bool,
// Renaming a package in the manifest via the `package` key
[unstable] rename_dependency: bool,

View File

@ -210,7 +210,11 @@ impl SourceId {
}
pub fn display_registry(&self) -> String {
format!("registry `{}`", url_display(self.url()))
if self.is_default_registry() {
"crates.io index".to_string()
} else {
format!("`{}` index", url_display(self.url()))
}
}
/// Is this source from a filesystem path

View File

@ -30,6 +30,7 @@ pub struct NewOptions {
/// Absolute path to the directory for the new project
pub path: PathBuf,
pub name: Option<String>,
pub edition: Option<String>,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
@ -65,6 +66,7 @@ struct MkOptions<'a> {
name: &'a str,
source_files: Vec<SourceFileInformation>,
bin: bool,
edition: Option<&'a str>,
}
impl NewOptions {
@ -74,6 +76,7 @@ impl NewOptions {
lib: bool,
path: PathBuf,
name: Option<String>,
edition: Option<String>,
) -> CargoResult<NewOptions> {
let kind = match (bin, lib) {
(true, true) => bail!("can't specify both lib and binary outputs"),
@ -87,6 +90,7 @@ impl NewOptions {
kind,
path,
name,
edition,
};
Ok(opts)
}
@ -321,6 +325,7 @@ pub fn new(opts: &NewOptions, config: &Config) -> CargoResult<()> {
name,
source_files: vec![plan_new_source_file(opts.kind.is_bin(), name.to_string())],
bin: opts.kind.is_bin(),
edition: opts.edition.as_ref().map(|s| &**s),
};
mk(config, &mkopts).chain_err(|| {
@ -397,6 +402,7 @@ pub fn init(opts: &NewOptions, config: &Config) -> CargoResult<()> {
name,
bin: src_paths_types.iter().any(|x| x.bin),
source_files: src_paths_types,
edition: opts.edition.as_ref().map(|s| &**s),
};
mk(config, &mkopts).chain_err(|| {
@ -530,11 +536,16 @@ path = {}
name = "{}"
version = "0.1.0"
authors = [{}]
edition = {}
[dependencies]
{}"#,
name,
toml::Value::String(author),
match opts.edition {
Some(edition) => toml::Value::String(edition.to_string()),
None => toml::Value::String("2018".to_string()),
},
cargotoml_path_specifier
).as_bytes(),
)?;

View File

@ -60,6 +60,17 @@ impl fmt::Display for Cfg {
}
impl CfgExpr {
/// Utility function to check if the key, "cfg(..)" matches the `target_cfg`
pub fn matches_key(key: &str, target_cfg: &[Cfg]) -> bool {
if key.starts_with("cfg(") && key.ends_with(')') {
let cfg = &key[4..key.len() - 1 ];
CfgExpr::from_str(cfg).ok().map(|ce| ce.matches(target_cfg)).unwrap_or(false)
} else {
false
}
}
pub fn matches(&self, cfg: &[Cfg]) -> bool {
match *self {
CfgExpr::Not(ref e) => !e.matches(cfg),

View File

@ -66,17 +66,20 @@ impl Rustc {
/// Get a process builder set up to use the found rustc version, with a wrapper if Some
pub fn process(&self) -> ProcessBuilder {
if let Some(ref wrapper) = self.wrapper {
let mut cmd = util::process(wrapper);
{
match self.wrapper {
Some(ref wrapper) if !wrapper.as_os_str().is_empty() => {
let mut cmd = util::process(wrapper);
cmd.arg(&self.path);
cmd
}
cmd
} else {
util::process(&self.path)
_ => self.process_no_wrapper()
}
}
pub fn process_no_wrapper(&self) -> ProcessBuilder {
util::process(&self.path)
}
pub fn cached_output(&self, cmd: &ProcessBuilder) -> CargoResult<(String, String)> {
self.cache.lock().unwrap().cached_output(cmd)
}

View File

@ -1,6 +1,6 @@
[package]
name = "crates-io"
version = "0.18.0"
version = "0.19.0"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT OR Apache-2.0"
repository = "https://github.com/rust-lang/cargo"

View File

@ -46,7 +46,7 @@ their dependencies, compile them all, and update the `Cargo.lock`:
```console
$ cargo build
Updating registry `https://github.com/rust-lang/crates.io-index`
Updating crates.io index
Downloading memchr v0.1.5
Downloading libc v0.1.10
Downloading regex-syntax v0.2.1

View File

@ -83,6 +83,11 @@ rustflags = ["..", ".."]
# are concatenated. The `cfg` syntax only applies to rustflags, and not to
# linker.
rustflags = ["..", ".."]
# Similar for the $triple configuration, but using the `cfg` syntax.
# If one or more `cfg`s, and a $triple target are candidates, then the $triple
# will be used
# If several `cfg` are candidates, then the build will error
runner = ".."
# Configuration keys related to the registry
[registry]

View File

@ -31,6 +31,24 @@ Versioning](http://semver.org/), so make sure you follow some basic rules:
traits, fields, types, functions, methods or anything else.
* Use version numbers with three numeric parts such as 1.0.0 rather than 1.0.
#### The `edition` field (optional)
You can opt in to a specific Rust Edition for your package with the
`edition` key in `Cargo.toml`. If you don't specify the edition, it will
default to 2015.
```toml
[package]
# ...
edition = '2018'
```
The `edition` key affects which edition your package is compiled with. Cargo
will always generate projects via `cargo new` with the `edition` key set to the
latest edition. Setting the `edition` key in `[package]` will affect all
targets/crates in the package, including test suites, benchmarks, binaries,
examples, etc.
#### The `build` field (optional)
This field specifies a file in the project root which is a [build script][1] for
@ -714,6 +732,12 @@ proc-macro = false
# stops it from generating a test harness. This is useful when the binary being
# built manages the test runner itself.
harness = true
# If set then a target can be configured to use a different edition than the
# `[package]` is configured to use, perhaps only compiling a library with the
# 2018 edition or only compiling one unit test with the 2015 edition. By default
# all targets are compiled with the edition specified in `[package]`.
edition = '2015'
```
The `[package]` also includes the optional `autobins`, `autoexamples`,

View File

@ -199,30 +199,6 @@ cargo +nightly build --out-dir=out -Z unstable-options
```
### Edition
* Tracking Issue: [rust-lang/rust#44581](https://github.com/rust-lang/rust/issues/44581)
* RFC: [#2052](https://github.com/rust-lang/rfcs/blob/master/text/2052-epochs.md)
You can opt in to a specific Rust Edition for your package with the `edition`
key in `Cargo.toml`. If you don't specify the edition, it will default to
2015. You need to include the appropriate `cargo-features`.
You can also specify `edition` on a per-target level, where it will otherwise
default to the package `edition`.
```toml
cargo-features = ["edition"]
[package]
...
edition = "2018"
[[bin]]
...
edition = "2015"
```
### Profile Overrides
* Tracking Issue: [rust-lang/rust#48683](https://github.com/rust-lang/rust/issues/48683)
* RFC: [#2282](https://github.com/rust-lang/rfcs/blob/master/text/2282-profile-dependencies.md)

View File

@ -56,7 +56,7 @@ fn depend_on_alt_registry() {
.masquerade_as_nightly_cargo()
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[DOWNLOADING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] foo v0.0.1 ([CWD])
@ -109,7 +109,7 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() {
.masquerade_as_nightly_cargo()
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
@ -151,7 +151,7 @@ fn depend_on_alt_registry_depends_on_same_registry() {
.masquerade_as_nightly_cargo()
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
@ -193,8 +193,8 @@ fn depend_on_alt_registry_depends_on_crates_io() {
.masquerade_as_nightly_cargo()
.with_stderr(&format!(
"\
[UPDATING] registry `{alt_reg}`
[UPDATING] registry `{reg}`
[UPDATING] `{alt_reg}` index
[UPDATING] `{reg}` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1 (registry `[ROOT][..]`)
@ -358,11 +358,10 @@ fn alt_registry_and_crates_io_deps() {
p.cargo("build")
.masquerade_as_nightly_cargo()
.with_stderr_contains(format!(
"[UPDATING] registry `{}`",
"[UPDATING] `{}` index",
registry::alt_registry_path().to_str().unwrap()
))
.with_stderr_contains(&format!(
"[UPDATING] registry `{}`",
)).with_stderr_contains(&format!(
"[UPDATING] `{}` index",
registry::registry_path().to_str().unwrap()))
.with_stderr_contains("[DOWNLOADING] crates_io_dep v0.0.1 (registry `[ROOT][..]`)")
.with_stderr_contains("[DOWNLOADING] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)")

View File

@ -549,45 +549,42 @@ fn bench_autodiscover_2015() {
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[project]
name = "foo"
version = "0.0.1"
authors = []
edition = "2015"
[project]
name = "foo"
version = "0.0.1"
authors = []
edition = "2015"
[[bench]]
name = "bench_magic"
required-features = ["magic"]
"#,
[[bench]]
name = "bench_magic"
required-features = ["magic"]
"#,
).file("src/lib.rs", "")
.file(
"benches/bench_basic.rs",
r#"
#![feature(test)]
#[allow(unused_extern_crates)]
extern crate foo;
extern crate test;
#![feature(test)]
#[allow(unused_extern_crates)]
extern crate foo;
extern crate test;
#[bench]
fn bench_basic(_b: &mut test::Bencher) {}
"#,
#[bench]
fn bench_basic(_b: &mut test::Bencher) {}
"#,
).file(
"benches/bench_magic.rs",
r#"
#![feature(test)]
#[allow(unused_extern_crates)]
extern crate foo;
extern crate test;
#![feature(test)]
#[allow(unused_extern_crates)]
extern crate foo;
extern crate test;
#[bench]
fn bench_magic(_b: &mut test::Bencher) {}
"#,
#[bench]
fn bench_magic(_b: &mut test::Bencher) {}
"#,
).build();
p.cargo("bench bench_basic")
.masquerade_as_nightly_cargo()
.with_stderr(
"warning: \
An explicit [[bench]] section is specified in Cargo.toml which currently

View File

@ -3551,7 +3551,7 @@ fn build_all_member_dependency_same_name() {
p.cargo("build --all")
.with_stderr(
"[..] Updating registry `[..]`\n\
"[..] Updating `[..]` index\n\
[..] Downloading a v0.1.0 ([..])\n\
[..] Compiling a v0.1.0\n\
[..] Compiling a v0.1.0 ([..])\n\
@ -3928,19 +3928,17 @@ fn target_edition() {
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
[package]
name = "foo"
version = "0.0.1"
[lib]
edition = "2018"
"#,
[lib]
edition = "2018"
"#,
).file("src/lib.rs", "")
.build();
p.cargo("build -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains(
"\
[COMPILING] foo v0.0.1 ([..])
@ -3955,62 +3953,26 @@ fn target_edition_override() {
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "2018"
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "2018"
[lib]
edition = "2015"
"#,
).file("src/lib.rs", "")
[lib]
edition = "2015"
"#,
).file(
"src/lib.rs",
"
pub fn async() {}
pub fn try() {}
pub fn await() {}
"
)
.build();
p.cargo("build -v")
.masquerade_as_nightly_cargo()
.with_stderr_contains(
"\
[COMPILING] foo v0.0.1 ([..])
[RUNNING] `rustc [..]--edition=2015 [..]
",
).run();
}
#[test]
fn target_edition_feature_gated() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[lib]
edition = "2018"
"#,
).file("src/lib.rs", "")
.build();
p.cargo("build -v")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"\
error: failed to parse manifest at `[..]`
Caused by:
editions are unstable
Caused by:
feature `edition` is required
consider adding `cargo-features = [\"edition\"]` to the manifest
",
).run();
p.cargo("build -v").run();
}
#[test]

View File

@ -2706,7 +2706,7 @@ fn warnings_hidden_for_upstream() {
p.cargo("build -v")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.1.0 ([..])
[COMPILING] bar v0.1.0
[RUNNING] `rustc [..]`
@ -2760,7 +2760,7 @@ fn warnings_printed_on_vv() {
p.cargo("build -vv")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.1.0 ([..])
[COMPILING] bar v0.1.0
[RUNNING] `rustc [..]`

View File

@ -222,7 +222,7 @@ fn works_through_the_registry() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[DOWNLOADING] [..]
[DOWNLOADING] [..]
[COMPILING] baz v0.1.0
@ -266,7 +266,7 @@ fn ignore_version_from_other_platform() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[DOWNLOADING] [..]
[COMPILING] bar v0.1.0
[COMPILING] foo v0.0.1 ([..])

View File

@ -684,3 +684,9 @@ fn proc_macro() {
).build();
p.cargo("check -v").env("RUST_LOG", "cargo=trace").run();
}
#[test]
fn does_not_use_empty_rustc_wrapper() {
let p = project().file("src/lib.rs", "").build();
p.cargo("check").env("RUSTC_WRAPPER", "").run();
}

View File

@ -104,7 +104,7 @@ fn publish_with_target() {
.arg("--target")
.arg(&target)
.with_stderr(&format!(
" Updating registry `{registry}`
" Updating `{registry}` index
Packaging foo v0.0.0 ([CWD])
Verifying foo v0.0.0 ([CWD])
Compiling foo v0.0.0 ([CWD]/target/package/foo-0.0.0)

View File

@ -330,7 +330,7 @@ fn crates_io_then_directory() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.1.0 ([..])
[COMPILING] bar v0.1.0
[COMPILING] foo v0.1.0 ([CWD])

View File

@ -967,7 +967,7 @@ fn doc_all_member_dependency_same_name() {
Package::new("bar", "0.1.0").publish();
p.cargo("doc --all")
.with_stderr_contains("[..] Updating registry `[..]`")
.with_stderr_contains("[..] Updating `[..]` index")
.with_stderr_contains("[..] Documenting bar v0.1.0 ([..])")
.run();
}

View File

@ -10,7 +10,6 @@ fn edition_works_for_build_script() {
.file(
"Cargo.toml",
r#"
cargo-features = ['edition']
[package]
name = 'foo'
version = '0.1.0'

View File

@ -355,8 +355,6 @@ fn upgrade_extern_crate() {
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[package]
name = "foo"
version = "0.1.0"
@ -392,7 +390,6 @@ fn upgrade_extern_crate() {
";
p.cargo("fix --allow-no-vcs")
.env("__CARGO_FIX_YOLO", "1")
.masquerade_as_nightly_cargo()
.with_stderr(stderr)
.with_stdout("")
.run();
@ -830,8 +827,6 @@ fn prepare_for_and_enable() {
.file(
"Cargo.toml",
r#"
cargo-features = ['edition']
[package]
name = 'foo'
version = '0.1.0'
@ -853,7 +848,6 @@ information about transitioning to the 2018 edition see:
";
p.cargo("fix --edition --allow-no-vcs")
.masquerade_as_nightly_cargo()
.with_stderr_contains(stderr)
.with_status(101)
.run();
@ -925,7 +919,6 @@ fn fix_idioms() {
.file(
"Cargo.toml",
r#"
cargo-features = ['edition']
[package]
name = 'foo'
version = '0.1.0'
@ -947,7 +940,6 @@ fn fix_idioms() {
[FINISHED] [..]
";
p.cargo("fix --edition-idioms --allow-no-vcs")
.masquerade_as_nightly_cargo()
.with_stderr(stderr)
.with_status(0)
.run();
@ -1117,3 +1109,26 @@ fn doesnt_rebuild_dependencies() {
")
.run();
}
#[test]
fn does_not_crash_with_rustc_wrapper() {
// We don't have /usr/bin/env on Windows.
if cfg!(windows) {
return;
}
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("fix --allow-no-vcs")
.env("RUSTC_WRAPPER", "/usr/bin/env")
.run();
}

View File

@ -82,7 +82,7 @@ fn no_index_update() {
.build();
p.cargo("generate-lockfile")
.with_stderr("[UPDATING] registry `[..]`")
.with_stderr("[UPDATING] `[..]` index")
.run();
p.cargo("generate-lockfile -Zno-index-update")

View File

@ -2358,7 +2358,7 @@ fn include_overrides_gitignore() {
p.cargo("build -v")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] filetime [..]
[DOWNLOADING] libc [..]
[COMPILING] libc [..]

View File

@ -13,7 +13,7 @@ fn cargo_process(s: &str) -> Execs {
#[test]
fn simple_lib() {
cargo_process("init --lib --vcs none")
cargo_process("init --lib --vcs none --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] library project")
.run();
@ -29,7 +29,7 @@ fn simple_lib() {
fn simple_bin() {
let path = paths::root().join("foo");
fs::create_dir(&path).unwrap();
cargo_process("init --bin --vcs none")
cargo_process("init --bin --vcs none --edition 2015")
.env("USER", "foo")
.cwd(&path)
.with_stderr("[CREATED] binary (application) project")

View File

@ -26,7 +26,7 @@ fn simple() {
cargo_process("install foo")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] foo v0.0.1 (registry [..])
[INSTALLING] foo v0.0.1
[COMPILING] foo v0.0.1
@ -52,7 +52,7 @@ fn multiple_pkgs() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] foo v0.0.1 (registry `[CWD]/registry`)
[INSTALLING] foo v0.0.1
[COMPILING] foo v0.0.1
@ -96,7 +96,7 @@ fn pick_max_version() {
cargo_process("install foo")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] foo v0.2.1 (registry [..])
[INSTALLING] foo v0.2.1
[COMPILING] foo v0.2.1
@ -129,7 +129,7 @@ fn missing() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[ERROR] could not find `bar` in registry `[..]`
",
).run();
@ -142,7 +142,7 @@ fn bad_version() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[ERROR] could not find `foo` in registry `[..]` with version `=0.2.0`
",
).run();
@ -225,8 +225,7 @@ fn install_path() {
cargo_process("install --path").arg(p.root()).run();
assert_has_installed_exe(cargo_home(), "foo");
cargo_process("install --path .")
.cwd(p.root())
p.cargo("install --path .")
.with_status(101)
.with_stderr(
"\
@ -692,8 +691,7 @@ fn subcommand_works_out_of_the_box() {
fn installs_from_cwd_by_default() {
let p = project().file("src/main.rs", "fn main() {}").build();
cargo_process("install")
.cwd(p.root())
p.cargo("install")
.with_stderr_contains(
"warning: Using `cargo install` to install the binaries for the \
project in current working directory is deprecated, \
@ -725,8 +723,7 @@ fn installs_from_cwd_with_2018_warnings() {
).file("src/main.rs", "fn main() {}")
.build();
cargo_process("install")
.cwd(p.root())
p.cargo("install")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr_contains(
@ -1243,15 +1240,6 @@ fn install_ignores_cargo_config() {
pkg("bar", "0.0.1");
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.1.0"
authors = []
"#,
)
.file(
".cargo/config",
r#"
@ -1262,6 +1250,6 @@ fn install_ignores_cargo_config() {
.file("src/main.rs", "fn main() {}")
.build();
cargo_process("install bar").cwd(p.root()).with_status(0).run();
p.cargo("install bar").run();
assert_has_installed_exe(cargo_home(), "bar");
}

View File

@ -224,7 +224,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
.with_status(101)
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
error: checksum for `bar v0.1.0` changed between lock files
this could be indicative of a few possible errors:
@ -284,7 +284,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
.with_status(101)
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
error: checksum for `bar v0.1.0` was not previously calculated, but a checksum \
could now be calculated
@ -479,7 +479,7 @@ fn locked_correct_error() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
error: the lock file needs to be updated but --locked was passed to prevent this
",
).run();

View File

@ -903,7 +903,6 @@ fn cargo_metadata_no_deps_cwd() {
.build();
p.cargo("metadata --no-deps")
.cwd(p.root())
.with_json(MANIFEST_OUTPUT)
.run();
}
@ -916,7 +915,6 @@ fn cargo_metadata_bad_version() {
.build();
p.cargo("metadata --no-deps --format-version 2")
.cwd(p.root())
.with_status(1)
.with_stderr_contains(
"\

View File

@ -14,7 +14,7 @@ fn create_empty_gitconfig() {
#[test]
fn simple_lib() {
cargo_process("new --lib foo --vcs none")
cargo_process("new --lib foo --vcs none --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] library `foo` project")
.run();
@ -47,7 +47,7 @@ mod tests {
#[test]
fn simple_bin() {
cargo_process("new --bin foo")
cargo_process("new --bin foo --edition 2015")
.env("USER", "foo")
.with_stderr("[CREATED] binary (application) `foo` project")
.run();
@ -75,7 +75,7 @@ fn both_lib_and_bin() {
#[test]
fn simple_git() {
cargo_process("new --lib foo").env("USER", "foo").run();
cargo_process("new --lib foo --edition 2015").env("USER", "foo").run();
assert!(paths::root().is_dir());
assert!(paths::root().join("foo/Cargo.toml").is_file());
@ -455,3 +455,39 @@ fn explicit_project_name() {
.with_stderr("[CREATED] library `bar` project")
.run();
}
#[test]
fn new_with_edition_2015() {
cargo_process("new --edition 2015 foo")
.env("USER", "foo")
.run();
let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
assert!(manifest.contains("edition = \"2015\""));
}
#[test]
fn new_with_edition_2018() {
cargo_process("new --edition 2018 foo")
.env("USER", "foo")
.run();
let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
assert!(manifest.contains("edition = \"2018\""));
}
#[test]
fn new_default_edition() {
cargo_process("new foo")
.env("USER", "foo")
.run();
let manifest = fs::read_to_string(paths::root().join("foo/Cargo.toml")).unwrap();
assert!(manifest.contains("edition = \"2018\""));
}
#[test]
fn new_with_bad_edition() {
cargo_process("new --edition something_else foo")
.env("USER", "foo")
.with_stderr_contains("error: 'something_else' isn't a valid value[..]")
.with_status(1)
.run();
}

View File

@ -38,7 +38,7 @@ fn override_simple() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[UPDATING] git repository `[..]`
[COMPILING] bar v0.1.0 ([ROOT][..])
[COMPILING] foo v0.0.1 ([CWD])
@ -183,7 +183,7 @@ fn transitive() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[UPDATING] git repository `[..]`
[DOWNLOADING] baz v0.2.0 (registry [..])
[COMPILING] bar v0.1.0 ([ROOT][..])
@ -231,7 +231,7 @@ fn persists_across_rebuilds() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[UPDATING] git repository `[ROOT][..]`
[COMPILING] bar v0.1.0 ([ROOT][..])
[COMPILING] foo v0.0.1 ([CWD])
@ -275,7 +275,7 @@ fn replace_registry_with_path() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] bar v0.1.0 ([ROOT][..])
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
@ -336,7 +336,7 @@ fn use_a_spec_to_select() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[UPDATING] git repository `[..]`
[DOWNLOADING] [..]
[DOWNLOADING] [..]
@ -393,7 +393,7 @@ fn override_adds_some_deps() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[UPDATING] git repository `[..]`
[DOWNLOADING] baz v0.1.1 (registry [..])
[COMPILING] baz v0.1.1
@ -411,13 +411,13 @@ fn override_adds_some_deps() {
.with_stderr(
"\
[UPDATING] git repository `[ROOT][..]`
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
",
).run();
p.cargo("update -p https://github.com/rust-lang/crates.io-index#bar")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
",
).run();
@ -508,7 +508,7 @@ fn override_wrong_name() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[UPDATING] git repository [..]
error: no matching package for override `[..]baz:0.1.0` found
location searched: [ROOT][..]
@ -550,7 +550,7 @@ fn override_with_nothing() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[UPDATING] git repository [..]
[ERROR] failed to load source for a dependency on `bar`
@ -629,7 +629,7 @@ fn multiple_specs() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[UPDATING] git repository [..]
error: overlapping replacement specifications found:
@ -717,7 +717,7 @@ fn update() {
p.cargo("update")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] git repository `[..]`
",
).run();
@ -1039,7 +1039,7 @@ fn no_warnings_when_replace_is_used_in_another_workspace_member() {
.with_stdout("")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[COMPILING] bar v0.1.0 ([..])
[COMPILING] first_crate v0.1.0 ([..])
[FINISHED] [..]",

View File

@ -490,8 +490,7 @@ fn package_git_submodule() {
None,
).unwrap();
cargo_process("package --no-verify -v")
.cwd(project.root())
project.cargo("package --no-verify -v")
.with_stderr_contains("[ARCHIVING] bar/Makefile")
.run();
}
@ -625,8 +624,7 @@ fn repackage_on_source_change() {
std::mem::drop(file);
// Check that cargo rebuilds the tarball
cargo_process("package")
.cwd(p.root())
p.cargo("package")
.with_stderr(
"\
[WARNING] [..]
@ -973,45 +971,19 @@ fn edition_with_metadata() {
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "2018"
[package.metadata.docs.rs]
features = ["foobar"]
"#,
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "2018"
[package.metadata.docs.rs]
features = ["foobar"]
"#,
).file("src/lib.rs", "")
.build();
p.cargo("package").masquerade_as_nightly_cargo().run();
}
#[test]
fn test_edition_missing() {
// no edition = 2015
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
authors = []
"#,
).file("src/lib.rs", r#" "#)
.build();
p.cargo("build -v").masquerade_as_nightly_cargo()
// --edition is still in flux and we're not passing -Zunstable-options
// from Cargo so it will probably error. Only partially match the output
// until stuff stabilizes
.with_stderr_contains("\
[COMPILING] foo v0.0.1 ([..])
[RUNNING] `rustc [..]--edition=2015 [..]
").run();
p.cargo("package").run();
}
#[test]
@ -1020,18 +992,16 @@ fn test_edition_malformed() {
.file(
"Cargo.toml",
r#"
cargo-features = ["edition"]
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "chicken"
"#,
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "chicken"
"#,
).file("src/lib.rs", r#" "#)
.build();
p.cargo("build -v")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"\
@ -1046,39 +1016,6 @@ Caused by:
).run();
}
#[test]
fn test_edition_nightly() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
edition = "2015"
"#,
).file("src/lib.rs", r#" "#)
.build();
p.cargo("build -v")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"\
error: failed to parse manifest at `[..]`
Caused by:
editions are unstable
Caused by:
feature `edition` is required
consider adding `cargo-features = [\"edition\"]` to the manifest
",
).run();
}
#[test]
fn package_lockfile() {
let p = project()

View File

@ -50,7 +50,7 @@ fn replace() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[DOWNLOADING] baz v0.1.0 ([..])
[COMPILING] bar v0.1.0 ([CWD]/bar)
[COMPILING] baz v0.1.0
@ -91,7 +91,7 @@ fn nonexistent() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] bar v0.1.0 ([CWD]/bar)
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
@ -180,7 +180,7 @@ fn patch_to_git() {
.with_stderr(
"\
[UPDATING] git repository `[ROOT][..]`
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] bar v0.1.0 ([ROOT][..])
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
@ -216,7 +216,7 @@ fn unused() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[DOWNLOADING] bar v0.1.0 [..]
[COMPILING] bar v0.1.0
[COMPILING] foo v0.0.1 ([CWD])
@ -274,7 +274,7 @@ fn unused_git() {
.with_stderr(
"\
[UPDATING] git repository `[ROOT][..]`
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[DOWNLOADING] bar v0.1.0 [..]
[COMPILING] bar v0.1.0
[COMPILING] foo v0.0.1 ([CWD])
@ -308,7 +308,7 @@ fn add_patch() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[DOWNLOADING] bar v0.1.0 [..]
[COMPILING] bar v0.1.0
[COMPILING] foo v0.0.1 ([CWD])
@ -367,7 +367,7 @@ fn add_ignored_patch() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[DOWNLOADING] bar v0.1.0 [..]
[COMPILING] bar v0.1.0
[COMPILING] foo v0.0.1 ([CWD])
@ -424,7 +424,7 @@ fn new_minor() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] bar v0.1.1 [..]
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
@ -471,7 +471,7 @@ fn transitive_new_minor() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] baz v0.1.1 [..]
[COMPILING] bar v0.1.0 [..]
[COMPILING] foo v0.0.1 ([CWD])
@ -507,7 +507,7 @@ fn new_major() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] bar v0.2.0 [..]
[COMPILING] foo v0.0.1 ([CWD])
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
@ -534,7 +534,7 @@ fn new_major() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[DOWNLOADING] bar v0.2.0 [..]
[COMPILING] bar v0.2.0
[COMPILING] foo v0.0.1 ([CWD])
@ -582,7 +582,7 @@ fn transitive_new_major() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[ROOT][..]`
[UPDATING] `[ROOT][..]` index
[COMPILING] baz v0.2.0 [..]
[COMPILING] bar v0.1.0 [..]
[COMPILING] foo v0.0.1 ([CWD])

View File

@ -30,7 +30,7 @@ fn simple() {
.arg(publish::registry().to_string())
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
@ -103,7 +103,7 @@ fn old_token_location() {
.arg(publish::registry().to_string())
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
@ -178,7 +178,7 @@ wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
@ -255,7 +255,7 @@ wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])
@ -323,7 +323,7 @@ fn git_deps() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[ERROR] crates cannot be published to crates.io with dependencies sourced from \
a repository\neither publish `foo` as its own crate on crates.io and \
specify a crates.io version as a dependency or pull it into this \
@ -361,7 +361,7 @@ fn path_dependency_no_version() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[ERROR] all path dependencies must have a version specified when publishing.
dependency `bar` does not specify a version
",
@ -425,7 +425,7 @@ fn dont_publish_dirty() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
error: 1 files in the working directory contain changes that were not yet \
committed into git:
@ -601,7 +601,7 @@ fn dry_run() {
.arg(publish::registry().to_string())
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[WARNING] manifest has no documentation, [..]
See [..]
[PACKAGING] foo v0.0.1 ([CWD])

View File

@ -98,7 +98,6 @@ fn cargo_read_manifest_cwd() {
.build();
p.cargo("read-manifest")
.cwd(p.root())
.with_json(MANIFEST_OUTPUT)
.run();
}

View File

@ -39,7 +39,7 @@ fn simple() {
p.cargo("build")
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[DOWNLOADING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ([CWD])
@ -84,7 +84,7 @@ fn deps() {
p.cargo("build")
.with_stderr(&format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1
@ -119,7 +119,7 @@ fn nonexistent() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
error: no matching package named `nonexistent` found
location searched: registry [..]
required by package `foo v0.0.1 ([..])`
@ -151,7 +151,7 @@ fn wrong_case() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
error: no matching package named `Init` found
location searched: registry [..]
did you mean: init
@ -184,7 +184,7 @@ fn mis_hyphenated() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
error: no matching package named `mis_hyphenated` found
location searched: registry [..]
did you mean: mis-hyphenated
@ -264,7 +264,7 @@ fn bad_cksum() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry [..]
[UPDATING] [..] index
[DOWNLOADING] bad-cksum [..]
[ERROR] unable to get packages from source
@ -311,7 +311,7 @@ required by package `foo v0.0.1 ([..])`
p.cargo("build")
.with_stderr(format!(
"\
[UPDATING] registry `{reg}`
[UPDATING] `{reg}` index
[DOWNLOADING] notyet v0.0.1 (registry `[ROOT][..]`)
[COMPILING] notyet v0.0.1
[COMPILING] foo v0.0.1 ([CWD])
@ -366,7 +366,7 @@ required by package `foo v0.0.1 ([..])`
"\
[PACKAGING] foo v0.0.1 ([CWD])
[VERIFYING] foo v0.0.1 ([CWD])
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] notyet v0.0.1 (registry `[ROOT][..]`)
[COMPILING] notyet v0.0.1
[COMPILING] foo v0.0.1 ([CWD][..])
@ -397,7 +397,7 @@ fn lockfile_locks() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ([CWD])
@ -434,7 +434,7 @@ fn lockfile_locks_transitively() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1
@ -479,7 +479,7 @@ fn yanks_are_not_used() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] baz v0.0.1
@ -586,7 +586,7 @@ fn update_with_lockfile_if_packages_missing() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.0.1 (registry `[ROOT][..]`)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
",
@ -621,7 +621,7 @@ fn update_lockfile() {
p.cargo("update -p bar --precise 0.0.2")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] bar v0.0.1 -> v0.0.2
",
).run();
@ -641,7 +641,7 @@ fn update_lockfile() {
p.cargo("update -p bar")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] bar v0.0.2 -> v0.0.3
",
).run();
@ -663,7 +663,7 @@ fn update_lockfile() {
p.cargo("update -p bar")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] bar v0.0.3 -> v0.0.4
[ADDING] spam v0.2.5
",
@ -674,7 +674,7 @@ fn update_lockfile() {
p.cargo("update -p bar")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] bar v0.0.4 -> v0.0.5
[REMOVING] spam v0.2.5
",
@ -727,7 +727,7 @@ fn dev_dependency_not_used() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] [..] v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ([CWD])
@ -811,7 +811,7 @@ fn updating_a_dep() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.0.1 (registry `[ROOT][..]`)
[COMPILING] bar v0.0.1
[COMPILING] a v0.0.1 ([CWD]/a)
@ -837,7 +837,7 @@ fn updating_a_dep() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.1.0 (registry `[ROOT][..]`)
[COMPILING] bar v0.1.0
[COMPILING] a v0.0.1 ([CWD]/a)
@ -995,7 +995,7 @@ fn fetch_downloads() {
p.cargo("fetch")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] a v0.1.0 (registry [..])
",
).run();
@ -1028,7 +1028,7 @@ fn update_transitive_dependency() {
p.cargo("update -pb")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] b v0.1.0 -> v0.1.1
",
).run();
@ -1085,7 +1085,7 @@ fn update_backtracking_ok() {
p.cargo("update -p hyper")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] hyper v0.6.5 -> v0.6.6
[UPDATING] openssl v0.1.0 -> v0.1.1
",
@ -1124,7 +1124,7 @@ fn update_multiple_packages() {
p.cargo("update -pa -pb")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] a v0.1.0 -> v0.1.1
[UPDATING] b v0.1.0 -> v0.1.1
",
@ -1133,7 +1133,7 @@ fn update_multiple_packages() {
p.cargo("update -pb -pc")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] c v0.1.0 -> v0.1.1
",
).run();
@ -1265,7 +1265,7 @@ fn only_download_relevant() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] baz v0.1.0 ([..])
[COMPILING] baz v0.1.0
[COMPILING] bar v0.5.0 ([..])

View File

@ -247,7 +247,7 @@ fn rename_twice() {
.with_status(101)
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] foo v0.1.0 (registry [..])
error: multiple dependencies listed for the same crate must all have the same \
name, but the dependency on `foo v0.1.0` is listed as having different names

View File

@ -359,22 +359,20 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option<bool>)
"Cargo.toml",
&format!(
r#"
cargo-features = ["edition"]
[project]
name = "foo"
version = "0.0.1"
authors = []
edition = "{rust_edition}"
{autoexamples}
[project]
name = "foo"
version = "0.0.1"
authors = []
edition = "{rust_edition}"
{autoexamples}
[features]
magic = []
[features]
magic = []
[[example]]
name = "do_magic"
required-features = ["magic"]
"#,
[[example]]
name = "do_magic"
required-features = ["magic"]
"#,
rust_edition = rust_edition,
autoexamples = autoexamples
),
@ -382,8 +380,8 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option<bool>)
.file(
"examples/do_magic.rs",
r#"
fn main() { println!("magic example"); }
"#,
fn main() { println!("magic example"); }
"#,
).build()
}
@ -395,7 +393,6 @@ fn run_example_autodiscover_2015() {
let p = autodiscover_examples_project("2015", None);
p.cargo("run --example a")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"warning: \
@ -427,7 +424,6 @@ fn run_example_autodiscover_2015_with_autoexamples_enabled() {
let p = autodiscover_examples_project("2015", Some(true));
p.cargo("run --example a")
.masquerade_as_nightly_cargo()
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])
@ -445,7 +441,6 @@ fn run_example_autodiscover_2015_with_autoexamples_disabled() {
let p = autodiscover_examples_project("2015", Some(false));
p.cargo("run --example a")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr("error: no example target named `a`\n")
.run();
@ -459,7 +454,6 @@ fn run_example_autodiscover_2018() {
let p = autodiscover_examples_project("2018", None);
p.cargo("run --example a")
.masquerade_as_nightly_cargo()
.with_stderr(
"\
[COMPILING] foo v0.0.1 ([CWD])

View File

@ -111,7 +111,7 @@ fn not_update() {
.with_stdout_contains(
"hoare = \"0.1.1\" # Design by contract style assertions for Rust",
)
.with_stderr("") // without "Updating registry ..."
.with_stderr("") // without "Updating ... index"
.run();
}
@ -122,7 +122,7 @@ fn replace_default() {
cargo_process("search postgres")
.with_stdout_contains("hoare = \"0.1.1\" # Design by contract style assertions for Rust")
.with_stderr_contains("[..]Updating registry[..]")
.with_stderr_contains("[..]Updating [..] index")
.run();
}
@ -154,7 +154,7 @@ wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] registry `[CWD]/registry`
[UPDATING] `[CWD]/registry` index
",
)
.with_stdout_contains(
@ -181,7 +181,7 @@ wants the location of the index. Please use '--index' instead.
This will soon become a hard error, so it's either recommended
to update to a fixed version or contact the upstream maintainer
about this warning.
[UPDATING] registry `[CWD]/registry`
[UPDATING] `[CWD]/registry` index
",
)
.with_stdout_contains(

View File

@ -167,3 +167,83 @@ fn custom_runner() {
",
).run();
}
// can set a custom runner via `target.'cfg(..)'.runner`
#[test]
fn custom_runner_cfg() {
let p = project()
.file("src/main.rs", "fn main() {}")
.file(
".cargo/config",
r#"
[target.'cfg(not(target_os = "none"))']
runner = "nonexistent-runner -r"
"#,
).build();
p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains(&format!(
"\
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
",
)).run();
}
// custom runner set via `target.$triple.runner` have precende over `target.'cfg(..)'.runner`
#[test]
fn custom_runner_cfg_precedence() {
let target = rustc_host();
let p = project()
.file("src/main.rs", "fn main() {}")
.file(
".cargo/config",
&format!(
r#"
[target.'cfg(not(target_os = "none"))']
runner = "ignored-runner"
[target.{}]
runner = "nonexistent-runner -r"
"#,
target
),
).build();
p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains(&format!(
"\
[COMPILING] foo v0.0.1 (CWD)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
[RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param`
",
)).run();
}
#[test]
fn custom_runner_cfg_collision() {
let p = project()
.file("src/main.rs", "fn main() {}")
.file(
".cargo/config",
r#"
[target.'cfg(not(target_arch = "avr"))']
runner = "true"
[target.'cfg(not(target_os = "none"))']
runner = "false"
"#,
).build();
p.cargo("run -- --param")
.with_status(101)
.with_stderr_contains(&format!(
"\
[ERROR] several matching instances of `target.'cfg(..)'.runner` in `.cargo/config`
",
)).run();
}

View File

@ -106,7 +106,7 @@ fn transitive_minor_update() {
p.cargo("update -p serde")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
",
).run();
}
@ -153,7 +153,7 @@ fn conservative() {
p.cargo("update -p serde")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] serde v0.1.0 -> v0.1.1
",
).run();
@ -369,7 +369,7 @@ fn update_precise() {
p.cargo("update -p serde:0.2.1 --precise 0.2.0")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[UPDATING] serde v0.2.1 -> v0.2.0
",
).run();

View File

@ -39,7 +39,6 @@ fn cargo_verify_project_cwd() {
.build();
p.cargo("verify-project")
.cwd(p.root())
.with_stdout(verify_project_success_output())
.run();
}

View File

@ -58,7 +58,7 @@ fn no_warning_on_success() {
.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] bar v0.0.1 ([..])
[COMPILING] bar v0.0.1
[COMPILING] foo v0.0.1 ([..])
@ -78,7 +78,7 @@ fn no_warning_on_bin_failure() {
.with_stderr_does_not_contain("hidden stderr")
.with_stderr_does_not_contain(&format!("[WARNING] {}", WARNING1))
.with_stderr_does_not_contain(&format!("[WARNING] {}", WARNING2))
.with_stderr_contains("[UPDATING] registry `[..]`")
.with_stderr_contains("[UPDATING] `[..]` index")
.with_stderr_contains("[DOWNLOADING] bar v0.0.1 ([..])")
.with_stderr_contains("[COMPILING] bar v0.0.1")
.with_stderr_contains("[COMPILING] foo v0.0.1 ([..])")
@ -95,7 +95,7 @@ fn warning_on_lib_failure() {
.with_stdout_does_not_contain("hidden stdout")
.with_stderr_does_not_contain("hidden stderr")
.with_stderr_does_not_contain("[COMPILING] foo v0.0.1 ([..])")
.with_stderr_contains("[UPDATING] registry `[..]`")
.with_stderr_contains("[UPDATING] `[..]` index")
.with_stderr_contains("[DOWNLOADING] bar v0.0.1 ([..])")
.with_stderr_contains("[COMPILING] bar v0.0.1")
.with_stderr_contains(&format!("[WARNING] {}", WARNING1))

View File

@ -556,7 +556,7 @@ fn share_dependencies() {
p.cargo("build")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] dep1 v0.1.3 ([..])
[COMPILING] dep1 v0.1.3
[COMPILING] foo v0.1.0 ([..])
@ -599,7 +599,7 @@ fn fetch_fetches_all() {
p.cargo("fetch")
.with_stderr(
"\
[UPDATING] registry `[..]`
[UPDATING] `[..]` index
[DOWNLOADING] dep1 v0.1.3 ([..])
",
).run();
@ -641,7 +641,7 @@ fn lock_works_for_everyone() {
Package::new("dep2", "0.1.0").publish();
p.cargo("generate-lockfile")
.with_stderr("[UPDATING] registry `[..]`")
.with_stderr("[UPDATING] `[..]` index")
.run();
Package::new("dep1", "0.1.1").publish();
@ -699,7 +699,7 @@ fn explicit_package_argument_works_with_virtual_manifest() {
).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
.file("bar/src/main.rs", "fn main() {}");
let p = p.build();
p.cargo("build --package bar").cwd(p.root()).run();
p.cargo("build --package bar").run();
assert!(p.root().join("Cargo.lock").is_file());
assert!(p.bin("bar").is_file());
assert!(!p.root().join("bar/Cargo.lock").is_file());
@ -1222,7 +1222,6 @@ fn relative_path_for_root_works() {
let p = p.build();
p.cargo("build --manifest-path ./Cargo.toml")
.cwd(p.root())
.run();
p.cargo("build --manifest-path ../Cargo.toml")