diff --git a/src/bin/cargo/commands/fix.rs b/src/bin/cargo/commands/fix.rs index 5d1b6e3a3eb..e2fc23e1879 100644 --- a/src/bin/cargo/commands/fix.rs +++ b/src/bin/cargo/commands/fix.rs @@ -54,7 +54,7 @@ pub fn cli() -> App { .arg( Arg::with_name("idioms") .long("edition-idioms") - .help("Fix warnings to migrate to the idioms of an edition") + .help("Fix warnings to migrate to the idioms of an edition"), ) .arg( Arg::with_name("allow-no-vcs") @@ -133,15 +133,18 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { tests: FilterRule::All, } } - ops::fix(&ws, &mut ops::FixOptions { - edition: args.is_present("edition"), - prepare_for: args.value_of("prepare-for"), - idioms: args.is_present("idioms"), - compile_opts: opts, - allow_dirty: args.is_present("allow-dirty"), - allow_no_vcs: args.is_present("allow-no-vcs"), - allow_staged: args.is_present("allow-staged"), - broken_code: args.is_present("broken-code"), - })?; + ops::fix( + &ws, + &mut ops::FixOptions { + edition: args.is_present("edition"), + prepare_for: args.value_of("prepare-for"), + idioms: args.is_present("idioms"), + compile_opts: opts, + allow_dirty: args.is_present("allow-dirty"), + allow_no_vcs: args.is_present("allow-no-vcs"), + allow_staged: args.is_present("allow-staged"), + broken_code: args.is_present("broken-code"), + }, + )?; Ok(()) } diff --git a/src/bin/cargo/commands/locate_project.rs b/src/bin/cargo/commands/locate_project.rs index 79fa1c8bb6a..3ece3b348d9 100644 --- a/src/bin/cargo/commands/locate_project.rs +++ b/src/bin/cargo/commands/locate_project.rs @@ -16,7 +16,8 @@ pub struct ProjectLocation<'a> { pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let root = args.root_manifest(config)?; - let root = root.to_str() + let root = root + .to_str() .ok_or_else(|| { format_err!( "your package path contains characters \ diff --git a/src/bin/cargo/commands/mod.rs b/src/bin/cargo/commands/mod.rs index 526bcccae07..c62f2aad211 100644 --- a/src/bin/cargo/commands/mod.rs +++ b/src/bin/cargo/commands/mod.rs @@ -35,8 +35,8 @@ pub fn builtin() -> Vec { ] } - pub fn builtin_exec(cmd: &str) -> Option) -> CliResult> { - let f = match cmd { +pub fn builtin_exec(cmd: &str) -> Option) -> CliResult> { + let f = match cmd { "bench" => bench::exec, "build" => build::exec, "check" => check::exec, diff --git a/src/bin/cargo/commands/new.rs b/src/bin/cargo/commands/new.rs index 770df65062e..517b9085d04 100644 --- a/src/bin/cargo/commands/new.rs +++ b/src/bin/cargo/commands/new.rs @@ -20,8 +20,9 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { } else { path }; - config - .shell() - .status("Created", format!("{} `{}` package", opts.kind, package_name))?; + config.shell().status( + "Created", + format!("{} `{}` package", opts.kind, package_name), + )?; Ok(()) } diff --git a/src/bin/cargo/commands/owner.rs b/src/bin/cargo/commands/owner.rs index 0fa0268a7d1..b6f774a0be8 100644 --- a/src/bin/cargo/commands/owner.rs +++ b/src/bin/cargo/commands/owner.rs @@ -12,13 +12,15 @@ pub fn cli() -> App { "remove", "LOGIN", "Name of a user or team to remove as an owner", - ).short("r"), + ) + .short("r"), ) .arg(opt("list", "List owners of a crate").short("l")) .arg(opt("index", "Registry index to modify owners for").value_name("INDEX")) .arg(opt("token", "API token to use when authenticating").value_name("TOKEN")) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) - .after_help("\ + .after_help( + "\ This command will modify the owners for a crate on the specified registry (or default). Owners of a crate can upload new versions and yank old versions. Explicitly named owners can also modify the set of owners, so take care! @@ -34,9 +36,11 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { krate: args.value_of("crate").map(|s| s.to_string()), token: args.value_of("token").map(|s| s.to_string()), index: args.value_of("index").map(|s| s.to_string()), - to_add: args.values_of("add") + to_add: args + .values_of("add") .map(|xs| xs.map(|s| s.to_string()).collect()), - to_remove: args.values_of("remove") + to_remove: args + .values_of("remove") .map(|xs| xs.map(|s| s.to_string()).collect()), list: args.is_present("list"), registry, diff --git a/src/bin/cargo/commands/package.rs b/src/bin/cargo/commands/package.rs index d29891622ea..212c5ee93da 100644 --- a/src/bin/cargo/commands/package.rs +++ b/src/bin/cargo/commands/package.rs @@ -9,7 +9,8 @@ pub fn cli() -> App { opt( "list", "Print files included in a package without making one", - ).short("l"), + ) + .short("l"), ) .arg(opt( "no-verify", diff --git a/src/bin/cargo/commands/search.rs b/src/bin/cargo/commands/search.rs index 5c8d4236034..f9cf7e25d34 100644 --- a/src/bin/cargo/commands/search.rs +++ b/src/bin/cargo/commands/search.rs @@ -13,7 +13,8 @@ pub fn cli() -> App { opt( "limit", "Limit the number of results (default: 10, max: 100)", - ).value_name("LIMIT"), + ) + .value_name("LIMIT"), ) .arg(opt("registry", "Registry to use").value_name("REGISTRY")) } diff --git a/src/bin/cargo/commands/test.rs b/src/bin/cargo/commands/test.rs index 1cdb22e9c33..8c1a3751c37 100644 --- a/src/bin/cargo/commands/test.rs +++ b/src/bin/cargo/commands/test.rs @@ -97,7 +97,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let doc = args.is_present("doc"); if doc { if let CompileFilter::Only { .. } = compile_opts.filter { - return Err(CliError::new(format_err!("Can't mix --doc with other target selecting options"), 101)) + return Err(CliError::new( + format_err!("Can't mix --doc with other target selecting options"), + 101, + )); } compile_opts.build_config.mode = CompileMode::Doctest; compile_opts.filter = ops::CompileFilter::new( diff --git a/src/bin/cargo/main.rs b/src/bin/cargo/main.rs index ad40f1b7afa..269f0873be8 100644 --- a/src/bin/cargo/main.rs +++ b/src/bin/cargo/main.rs @@ -1,12 +1,12 @@ #![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project -#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive +#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure))] // there's a false positive use cargo; -#[cfg(feature = "pretty-env-logger")] -extern crate pretty_env_logger; #[cfg(not(feature = "pretty-env-logger"))] extern crate env_logger; +#[cfg(feature = "pretty-env-logger")] +extern crate pretty_env_logger; #[macro_use] extern crate failure; use git2_curl; @@ -14,8 +14,6 @@ use git2_curl; #[macro_use] extern crate serde_derive; - - use std::collections::BTreeSet; use std::env; use std::fs; diff --git a/src/cargo/core/compiler/build_plan.rs b/src/cargo/core/compiler/build_plan.rs index c30a81e89b0..a011b5a6527 100644 --- a/src/cargo/core/compiler/build_plan.rs +++ b/src/cargo/core/compiler/build_plan.rs @@ -11,10 +11,10 @@ use std::collections::BTreeMap; use super::context::OutputFile; use super::{CompileMode, Context, Kind, Unit}; use crate::core::TargetKind; +use crate::util::{internal, CargoResult, ProcessBuilder}; use semver; use serde_json; use std::path::PathBuf; -use crate::util::{internal, CargoResult, ProcessBuilder}; #[derive(Debug, Serialize)] struct Invocation { diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index d21f52f6446..8d806d4ef1d 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -77,10 +77,11 @@ impl FromStr for Edition { match s { "2015" => Ok(Edition::Edition2015), "2018" => Ok(Edition::Edition2018), - s => { - bail!("supported edition values are `2015` or `2018`, but `{}` \ - is unknown", s) - } + s => bail!( + "supported edition values are `2015` or `2018`, but `{}` \ + is unknown", + s + ), } } } @@ -396,9 +397,9 @@ thread_local!( /// that called `masquerade_as_nightly_cargo` pub fn nightly_features_allowed() -> bool { if ENABLE_NIGHTLY_FEATURES.with(|c| c.get()) { - return true + return true; } - match &channel()[..] { + match &channel()[..] { "nightly" | "dev" => NIGHTLY_FEATURES_ALLOWED.with(|c| c.get()), _ => false, } diff --git a/src/cargo/core/mod.rs b/src/cargo/core/mod.rs index 3312ba3458c..f94291f74e9 100644 --- a/src/cargo/core/mod.rs +++ b/src/cargo/core/mod.rs @@ -1,10 +1,8 @@ pub use self::dependency::Dependency; -pub use self::features::{CliUnstable, Edition, Feature, Features}; pub use self::features::{ - maybe_allow_nightly_features, - enable_nightly_features, - nightly_features_allowed + enable_nightly_features, maybe_allow_nightly_features, nightly_features_allowed, }; +pub use self::features::{CliUnstable, Edition, Feature, Features}; pub use self::manifest::{EitherManifest, VirtualManifest}; pub use self::manifest::{LibKind, Manifest, Target, TargetKind}; pub use self::package::{Package, PackageSet}; diff --git a/src/cargo/core/resolver/context.rs b/src/cargo/core/resolver/context.rs index 063bf7af4f5..5879d353851 100644 --- a/src/cargo/core/resolver/context.rs +++ b/src/cargo/core/resolver/context.rs @@ -3,9 +3,9 @@ use std::rc::Rc; use crate::core::interning::InternedString; use crate::core::{Dependency, FeatureValue, PackageId, SourceId, Summary}; -use im_rc; use crate::util::CargoResult; use crate::util::Graph; +use im_rc; use super::errors::ActivateResult; use super::types::{ConflictReason, DepInfo, GraphNode, Method, RcList, RegistryQueryer}; diff --git a/src/cargo/core/resolver/errors.rs b/src/cargo/core/resolver/errors.rs index 37f5e5e1371..900a6f0a17c 100644 --- a/src/cargo/core/resolver/errors.rs +++ b/src/cargo/core/resolver/errors.rs @@ -2,10 +2,10 @@ use std::collections::BTreeMap; use std::fmt; use crate::core::{Dependency, PackageId, Registry, Summary}; -use failure::{Error, Fail}; -use semver; use crate::util::lev_distance::lev_distance; use crate::util::{CargoError, Config}; +use failure::{Error, Fail}; +use semver; use super::context::Context; use super::types::{Candidate, ConflictReason}; diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index f5253666d3f..32048d94284 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -1,17 +1,17 @@ #![cfg_attr(test, deny(warnings))] // Clippy isn't enforced by CI, and know that @alexcrichton isn't a fan :) -#![cfg_attr(feature = "cargo-clippy", allow(clippy::boxed_local))] // bug rust-lang-nursery/rust-clippy#1123 -#![cfg_attr(feature = "cargo-clippy", allow(clippy::cyclomatic_complexity))] // large project -#![cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))] // there's an intentional incoherence +#![cfg_attr(feature = "cargo-clippy", allow(clippy::boxed_local))] // bug rust-lang-nursery/rust-clippy#1123 +#![cfg_attr(feature = "cargo-clippy", allow(clippy::cyclomatic_complexity))] // large project +#![cfg_attr(feature = "cargo-clippy", allow(clippy::derive_hash_xor_eq))] // there's an intentional incoherence #![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_into_iter_loop))] // explicit loops are clearer -#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_iter_loop))] // explicit loops are clearer -#![cfg_attr(feature = "cargo-clippy", allow(clippy::identity_op))] // used for vertical alignment -#![cfg_attr(feature = "cargo-clippy", allow(clippy::implicit_hasher))] // large project -#![cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] // large project -#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure_call))] // closures over try catch blocks -#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project -#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] // there's an exceptionally complex type -#![cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] // perhaps Rc should be special cased in Clippy? +#![cfg_attr(feature = "cargo-clippy", allow(clippy::explicit_iter_loop))] // explicit loops are clearer +#![cfg_attr(feature = "cargo-clippy", allow(clippy::identity_op))] // used for vertical alignment +#![cfg_attr(feature = "cargo-clippy", allow(clippy::implicit_hasher))] // large project +#![cfg_attr(feature = "cargo-clippy", allow(clippy::large_enum_variant))] // large project +#![cfg_attr(feature = "cargo-clippy", allow(clippy::redundant_closure_call))] // closures over try catch blocks +#![cfg_attr(feature = "cargo-clippy", allow(clippy::too_many_arguments))] // large project +#![cfg_attr(feature = "cargo-clippy", allow(clippy::type_complexity))] // there's an exceptionally complex type +#![cfg_attr(feature = "cargo-clippy", allow(clippy::wrong_self_convention))] // perhaps Rc should be special cased in Clippy? extern crate atty; extern crate bytesize; diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index d6bfaf78b8d..e49500e280d 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -26,7 +26,9 @@ use std::collections::{HashMap, HashSet}; use std::path::PathBuf; use std::sync::Arc; -use crate::core::compiler::{BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor}; +use crate::core::compiler::{ + BuildConfig, BuildContext, Compilation, Context, DefaultExecutor, Executor, +}; use crate::core::compiler::{CompileMode, Kind, Unit}; use crate::core::profiles::{Profiles, UnitFor}; use crate::core::resolver::{Method, Resolve}; diff --git a/src/cargo/ops/cargo_fetch.rs b/src/cargo/ops/cargo_fetch.rs index 670014e79fa..179b659f8c7 100644 --- a/src/cargo/ops/cargo_fetch.rs +++ b/src/cargo/ops/cargo_fetch.rs @@ -1,9 +1,9 @@ use crate::core::compiler::{BuildConfig, CompileMode, Kind, TargetInfo}; use crate::core::{PackageSet, Resolve, Workspace}; use crate::ops; -use std::collections::HashSet; use crate::util::CargoResult; use crate::util::Config; +use std::collections::HashSet; pub struct FetchOptions<'a> { pub config: &'a Config, diff --git a/src/cargo/ops/cargo_run.rs b/src/cargo/ops/cargo_run.rs index 42a7074c5c1..28ad8f24073 100644 --- a/src/cargo/ops/cargo_run.rs +++ b/src/cargo/ops/cargo_run.rs @@ -1,9 +1,9 @@ use std::iter; use std::path::Path; +use crate::core::{nightly_features_allowed, TargetKind, Workspace}; use crate::ops; use crate::util::{self, CargoResult, ProcessError}; -use crate::core::{TargetKind, Workspace, nightly_features_allowed}; pub fn run( ws: &Workspace, @@ -19,13 +19,16 @@ pub fn run( .into_iter() .flat_map(|pkg| { iter::repeat(pkg).zip(pkg.manifest().targets().iter().filter(|target| { - !target.is_lib() && !target.is_custom_build() && if !options.filter.is_specific() { - target.is_bin() - } else { - options.filter.target_run(target) - } + !target.is_lib() + && !target.is_custom_build() + && if !options.filter.is_specific() { + target.is_bin() + } else { + options.filter.target_run(target) + } })) - }).collect(); + }) + .collect(); if bins.is_empty() { if !options.filter.is_specific() { diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 3b653b00158..b8a3104f193 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -1,28 +1,30 @@ pub use self::cargo_clean::{clean, CleanOptions}; pub use self::cargo_compile::{compile, compile_with_exec, compile_ws, CompileOptions}; pub use self::cargo_compile::{CompileFilter, FilterRule, Packages}; -pub use self::cargo_read_manifest::{read_package, read_packages}; -pub use self::cargo_run::run; -pub use self::cargo_install::{install, install_list, uninstall}; -pub use self::cargo_new::{init, new, NewOptions, VersionControl}; pub use self::cargo_doc::{doc, DocOptions}; +pub use self::cargo_fetch::{fetch, FetchOptions}; pub use self::cargo_generate_lockfile::generate_lockfile; pub use self::cargo_generate_lockfile::update_lockfile; pub use self::cargo_generate_lockfile::UpdateOptions; -pub use self::lockfile::{load_pkg_lockfile, write_pkg_lockfile}; -pub use self::cargo_test::{run_benches, run_tests, TestOptions}; +pub use self::cargo_install::{install, install_list, uninstall}; +pub use self::cargo_new::{init, new, NewOptions, VersionControl}; +pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions}; pub use self::cargo_package::{package, PackageOpts}; -pub use self::registry::{publish, registry_configuration, RegistryConfig}; +pub use self::cargo_pkgid::pkgid; +pub use self::cargo_read_manifest::{read_package, read_packages}; +pub use self::cargo_run::run; +pub use self::cargo_test::{run_benches, run_tests, TestOptions}; +pub use self::fix::{fix, fix_maybe_exec_rustc, FixOptions}; +pub use self::lockfile::{load_pkg_lockfile, write_pkg_lockfile}; +pub use self::registry::HttpTimeout; +pub use self::registry::{configure_http_handle, http_handle_and_timeout}; pub use self::registry::{http_handle, needs_custom_http_transport, registry_login, search}; pub use self::registry::{modify_owners, yank, OwnersOptions, PublishOpts}; -pub use self::registry::{configure_http_handle, http_handle_and_timeout}; -pub use self::registry::HttpTimeout; -pub use self::cargo_fetch::{fetch, FetchOptions}; -pub use self::cargo_pkgid::pkgid; -pub use self::resolve::{add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws, - resolve_ws_precisely, resolve_ws_with_method}; -pub use self::cargo_output_metadata::{output_metadata, ExportInfo, OutputMetadataOptions}; -pub use self::fix::{fix, FixOptions, fix_maybe_exec_rustc}; +pub use self::registry::{publish, registry_configuration, RegistryConfig}; +pub use self::resolve::{ + add_overrides, get_resolved_packages, resolve_with_previous, resolve_ws, resolve_ws_precisely, + resolve_ws_with_method, +}; mod cargo_clean; mod cargo_compile; @@ -37,7 +39,7 @@ mod cargo_pkgid; mod cargo_read_manifest; mod cargo_run; mod cargo_test; +mod fix; mod lockfile; mod registry; mod resolve; -mod fix; diff --git a/src/cargo/ops/registry.rs b/src/cargo/ops/registry.rs index a450c719a61..daafa444eef 100644 --- a/src/cargo/ops/registry.rs +++ b/src/cargo/ops/registry.rs @@ -5,10 +5,10 @@ use std::str; use std::time::Duration; use std::{cmp, env}; +use crate::registry::{NewCrate, NewCrateDependency, Registry}; use curl::easy::{Easy, InfoType, SslOpt}; use git2; use log::Level; -use crate::registry::{NewCrate, NewCrateDependency, Registry}; use url::percent_encoding::{percent_encode, QUERY_ENCODE_SET}; diff --git a/src/cargo/sources/git/mod.rs b/src/cargo/sources/git/mod.rs index 0b437865493..86d0094d19e 100644 --- a/src/cargo/sources/git/mod.rs +++ b/src/cargo/sources/git/mod.rs @@ -1,4 +1,4 @@ -pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote, GitRevision}; pub use self::source::{canonicalize_url, GitSource}; -mod utils; +pub use self::utils::{fetch, GitCheckout, GitDatabase, GitRemote, GitRevision}; mod source; +mod utils; diff --git a/src/cargo/sources/git/source.rs b/src/cargo/sources/git/source.rs index b5a601ae91a..ba3b5c3d97d 100644 --- a/src/cargo/sources/git/source.rs +++ b/src/cargo/sources/git/source.rs @@ -242,8 +242,8 @@ impl<'cfg> Source for GitSource<'cfg> { #[cfg(test)] mod test { use super::ident; - use url::Url; use crate::util::ToUrl; + use url::Url; #[test] pub fn test_url_to_path_ident_with_path() { diff --git a/src/cargo/sources/git/utils.rs b/src/cargo/sources/git/utils.rs index 423d68b1f0a..a1b2ff5f847 100644 --- a/src/cargo/sources/git/utils.rs +++ b/src/cargo/sources/git/utils.rs @@ -109,7 +109,8 @@ impl GitRemote { let (repo, rev) = match repo_and_rev { Some(pair) => pair, None => { - let repo = self.clone_into(into, cargo_config) + let repo = self + .clone_into(into, cargo_config) .chain_err(|| format!("failed to clone into: {}", into.display()))?; let rev = reference.resolve(&repo)?; (repo, rev) @@ -211,9 +212,10 @@ impl GitReference { let obj = obj.peel(ObjectType::Commit)?; Ok(obj.id()) })() - .chain_err(|| format!("failed to find tag `{}`", s))?, + .chain_err(|| format!("failed to find tag `{}`", s))?, GitReference::Branch(ref s) => { - let b = repo.find_branch(s, git2::BranchType::Local) + let b = repo + .find_branch(s, git2::BranchType::Local) .chain_err(|| format!("failed to find branch `{}`", s))?; b.get() .target() @@ -253,7 +255,8 @@ impl<'a> GitCheckout<'a> { config: &Config, ) -> CargoResult> { let dirname = into.parent().unwrap(); - fs::create_dir_all(&dirname).chain_err(|| format!("Couldn't mkdir {}", dirname.display()))?; + fs::create_dir_all(&dirname) + .chain_err(|| format!("Couldn't mkdir {}", dirname.display()))?; if into.exists() { paths::remove_dir_all(into)?; } @@ -720,7 +723,8 @@ pub fn fetch( let mut repo_reinitialized = false; loop { debug!("initiating fetch of {} from {}", refspec, url); - let res = repo.remote_anonymous(url.as_str())? + let res = repo + .remote_anonymous(url.as_str())? .fetch(&[refspec], Some(&mut opts), None); let err = match res { Ok(()) => break, @@ -759,7 +763,9 @@ fn fetch_with_cli( .arg(url.to_string()) .arg(refspec) .cwd(repo.path()); - config.shell().verbose(|s| s.status("Running", &cmd.to_string()))?; + config + .shell() + .verbose(|s| s.status("Running", &cmd.to_string()))?; cmd.exec()?; Ok(()) } @@ -876,10 +882,12 @@ fn init(path: &Path, bare: bool) -> CargoResult { /// update path above. fn github_up_to_date(handle: &mut Easy, url: &Url, oid: &git2::Oid) -> bool { macro_rules! r#try { - ($e:expr) => (match $e { - Some(e) => e, - None => return false, - }) + ($e:expr) => { + match $e { + Some(e) => e, + None => return false, + } + }; } // This expects GitHub urls in the form `github.com/user/repo` and nothing diff --git a/src/cargo/sources/registry/local.rs b/src/cargo/sources/registry/local.rs index e3865257b70..b0ff3e8a79c 100644 --- a/src/cargo/sources/registry/local.rs +++ b/src/cargo/sources/registry/local.rs @@ -3,11 +3,11 @@ use std::io::SeekFrom; use std::path::Path; use crate::core::PackageId; -use hex; use crate::sources::registry::{MaybeLock, RegistryConfig, RegistryData}; use crate::util::errors::{CargoResult, CargoResultExt}; use crate::util::paths; use crate::util::{Config, FileLock, Filesystem, Sha256}; +use hex; pub struct LocalRegistry<'cfg> { index_path: Filesystem, diff --git a/src/cargo/util/cfg.rs b/src/cargo/util/cfg.rs index 4f77a694dbf..670e6ee798c 100644 --- a/src/cargo/util/cfg.rs +++ b/src/cargo/util/cfg.rs @@ -1,6 +1,6 @@ -use std::str::{self, FromStr}; -use std::iter; use std::fmt; +use std::iter; +use std::str::{self, FromStr}; use crate::util::{CargoError, CargoResult}; @@ -63,9 +63,12 @@ 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 ]; + let cfg = &key[4..key.len() - 1]; - CfgExpr::from_str(cfg).ok().map(|ce| ce.matches(target_cfg)).unwrap_or(false) + CfgExpr::from_str(cfg) + .ok() + .map(|ce| ce.matches(target_cfg)) + .unwrap_or(false) } else { false } @@ -128,7 +131,8 @@ impl<'a> Parser<'a> { t: Tokenizer { s: s.char_indices().peekable(), orig: s, - }.peekable(), + } + .peekable(), } } diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 533c6f9a4d5..1985cd575ed 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -1,18 +1,18 @@ -use std::path::PathBuf; use std::fs; +use std::path::PathBuf; -use clap::{self, SubCommand}; -use crate::CargoResult; -use crate::core::Workspace; use crate::core::compiler::{BuildConfig, MessageFormat}; +use crate::core::Workspace; use crate::ops::{CompileFilter, CompileOptions, NewOptions, Packages, VersionControl}; use crate::sources::CRATES_IO_REGISTRY; -use crate::util::paths; use crate::util::important_paths::find_root_manifest_for_wd; +use crate::util::paths; +use crate::CargoResult; +use clap::{self, SubCommand}; -pub use clap::{AppSettings, Arg, ArgMatches}; -pub use crate::{CliError, CliResult, Config}; pub use crate::core::compiler::CompileMode; +pub use crate::{CliError, CliResult, Config}; +pub use clap::{AppSettings, Arg, ArgMatches}; pub type App = clap::App<'static, 'static>; @@ -96,11 +96,12 @@ pub trait AppExt: Sized { fn arg_features(self) -> Self { self._arg( opt("features", "Space-separated list of features to activate").value_name("FEATURES"), - )._arg(opt("all-features", "Activate all available features")) - ._arg(opt( - "no-default-features", - "Do not activate the `default` feature", - )) + ) + ._arg(opt("all-features", "Activate all available features")) + ._arg(opt( + "no-default-features", + "Do not activate the `default` feature", + )) } fn arg_release(self, release: &'static str) -> Self { @@ -116,7 +117,9 @@ pub trait AppExt: Sized { } fn arg_target_dir(self) -> Self { - self._arg(opt("target-dir", "Directory for all generated artifacts").value_name("DIRECTORY")) + self._arg( + opt("target-dir", "Directory for all generated artifacts").value_name("DIRECTORY"), + ) } fn arg_manifest_path(self) -> Self { @@ -146,22 +149,24 @@ pub trait AppExt: Sized { control system (git, hg, pijul, or fossil) or do not \ initialize any version control at all (none), overriding \ a global configuration.", - ).value_name("VCS") - .possible_values(&["git", "hg", "pijul", "fossil", "none"]), - ) - ._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", - "Set the resulting package name, defaults to the directory name", - ).value_name("NAME"), + .value_name("VCS") + .possible_values(&["git", "hg", "pijul", "fossil", "none"]), + ) + ._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", + "Set the resulting package name, defaults to the directory name", ) + .value_name("NAME"), + ) } fn arg_index(self) -> Self { @@ -369,14 +374,11 @@ pub trait ArgMatchesExt { // but the user wants to switch back to crates.io for a single // command. Ok(None) + } else { + Ok(Some(registry.to_string())) } - else { - Ok(Some(registry.to_string())) - } - } - None => { - config.default_registry() } + None => config.default_registry(), } } @@ -439,7 +441,7 @@ pub fn values(args: &ArgMatches, name: &str) -> Vec { #[derive(PartialEq, PartialOrd, Eq, Ord)] pub enum CommandInfo { - BuiltIn { name: String, about: Option, }, + BuiltIn { name: String, about: Option }, External { name: String, path: PathBuf }, } diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 16028523bed..05ee2dcd155 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -26,13 +26,13 @@ use crate::core::profiles::ConfigProfiles; use crate::core::shell::Verbosity; use crate::core::{CliUnstable, Shell, SourceId, Workspace}; use crate::ops; -use url::Url; use crate::util::errors::{internal, CargoResult, CargoResultExt}; use crate::util::paths; use crate::util::toml as cargo_toml; use crate::util::Filesystem; use crate::util::Rustc; use crate::util::ToUrl; +use url::Url; use self::ConfigValue as CV; diff --git a/src/cargo/util/dependency_queue.rs b/src/cargo/util/dependency_queue.rs index 639f95f7c90..0e6c22cabeb 100644 --- a/src/cargo/util/dependency_queue.rs +++ b/src/cargo/util/dependency_queue.rs @@ -93,7 +93,8 @@ impl DependencyQueue { let mut my_dependencies = HashSet::new(); for dep in dependencies { my_dependencies.insert(dep.clone()); - let rev = self.reverse_dep_map + let rev = self + .reverse_dep_map .entry(dep.clone()) .or_insert_with(HashSet::new); rev.insert(key.clone()); @@ -122,13 +123,13 @@ impl DependencyQueue { results.insert(key.clone(), IN_PROGRESS); - let depth = 1 - + map.get(&key) - .into_iter() - .flat_map(|it| it) - .map(|dep| depth(dep, map, results)) - .max() - .unwrap_or(0); + let depth = 1 + map + .get(&key) + .into_iter() + .flat_map(|it| it) + .map(|dep| depth(dep, map, results)) + .max() + .unwrap_or(0); *results.get_mut(key).unwrap() = depth; @@ -151,7 +152,8 @@ impl DependencyQueue { // TODO: it'd be best here to throw in a heuristic of crate size as // well. For example how long did this crate historically take to // compile? How large is its source code? etc. - let next = self.dep_map + let next = self + .dep_map .iter() .filter(|&(_, &(ref deps, _))| deps.is_empty()) .map(|(key, _)| key.clone()) diff --git a/src/cargo/util/diagnostic_server.rs b/src/cargo/util/diagnostic_server.rs index 11553a9daba..440ea4c8010 100644 --- a/src/cargo/util/diagnostic_server.rs +++ b/src/cargo/util/diagnostic_server.rs @@ -5,15 +5,15 @@ use std::collections::HashSet; use std::env; use std::io::{BufReader, Read, Write}; use std::net::{Shutdown, SocketAddr, TcpListener, TcpStream}; -use std::sync::Arc; use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::Arc; use std::thread::{self, JoinHandle}; use failure::{Error, ResultExt}; use serde_json; -use crate::util::{Config, ProcessBuilder}; use crate::util::errors::CargoResult; +use crate::util::{Config, ProcessBuilder}; const DIAGNOSICS_SERVER_VAR: &str = "__CARGO_FIX_DIAGNOSTICS_SERVER"; const PLEASE_REPORT_THIS_BUG: &str = @@ -53,8 +53,8 @@ pub enum Message { impl Message { pub fn post(&self) -> Result<(), Error> { - let addr = env::var(DIAGNOSICS_SERVER_VAR) - .context("diagnostics collector misconfigured")?; + let addr = + env::var(DIAGNOSICS_SERVER_VAR).context("diagnostics collector misconfigured")?; let mut client = TcpStream::connect(&addr).context("failed to connect to parent diagnostics target")?; @@ -116,9 +116,9 @@ impl<'a> DiagnosticPrinter<'a> { krate, ))?; } else { - self.config.shell().warn( - "failed to automatically apply fixes suggested by rustc" - )?; + self.config + .shell() + .warn("failed to automatically apply fixes suggested by rustc")?; } if !files.is_empty() { writeln!( @@ -137,7 +137,7 @@ impl<'a> DiagnosticPrinter<'a> { Message::EditionAlreadyEnabled { file, edition } => { // Like above, only warn once per file if !self.edition_already_enabled.insert(file.clone()) { - return Ok(()) + return Ok(()); } let msg = format!( @@ -158,10 +158,14 @@ information about transitioning to the {0} edition see: self.config.shell().error(&msg)?; Ok(()) } - Message::IdiomEditionMismatch { file, idioms, edition } => { + Message::IdiomEditionMismatch { + file, + idioms, + edition, + } => { // Same as above if !self.idiom_mismatch.insert(file.clone()) { - return Ok(()) + return Ok(()); } self.config.shell().error(&format!( "\ @@ -238,7 +242,7 @@ impl RustfixDiagnosticServer { Err(e) => warn!("invalid diagnostics message: {}", e), } if done.load(Ordering::SeqCst) { - break + break; } } } diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index d508c27b39d..c837babe0ef 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -1,13 +1,13 @@ #![allow(unknown_lints)] use std::fmt; +use std::path::PathBuf; use std::process::{ExitStatus, Output}; use std::str; -use std::path::PathBuf; use crate::core::{TargetKind, Workspace}; -use failure::{Context, Error, Fail}; use clap; +use failure::{Context, Error, Fail}; pub use failure::Error as CargoError; pub type CargoResult = Result; @@ -306,8 +306,8 @@ pub fn process_error( #[cfg(unix)] fn status_to_string(status: ExitStatus) -> String { - use std::os::unix::process::*; use libc; + use std::os::unix::process::*; if let Some(signal) = status.signal() { let name = match signal as libc::c_int { diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index 2133e32127f..f349594542e 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -1,16 +1,16 @@ use std::fs::{self, File, OpenOptions}; -use std::io::{Read, Seek, SeekFrom, Write}; use std::io; +use std::io::{Read, Seek, SeekFrom, Write}; use std::path::{Display, Path, PathBuf}; -use termcolor::Color::Cyan; use fs2::{lock_contended_error, FileExt}; #[allow(unused_imports)] use libc; +use termcolor::Color::Cyan; -use crate::util::Config; -use crate::util::paths; use crate::util::errors::{CargoError, CargoResult, CargoResultExt}; +use crate::util::paths; +use crate::util::Config; pub struct FileLock { f: Option, @@ -208,7 +208,8 @@ impl Filesystem { // If we want an exclusive lock then if we fail because of NotFound it's // likely because an intermediate directory didn't exist, so try to // create the directory and then continue. - let f = opts.open(&path) + let f = opts + .open(&path) .or_else(|e| { if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive { fs::create_dir_all(path.parent().unwrap())?; @@ -295,16 +296,10 @@ fn acquire( // implement file locking. We detect that here via the return value of // locking (e.g. inspecting errno). #[cfg(unix)] - Err(ref e) if e.raw_os_error() == Some(libc::ENOTSUP) => - { - return Ok(()) - } + Err(ref e) if e.raw_os_error() == Some(libc::ENOTSUP) => return Ok(()), #[cfg(target_os = "linux")] - Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => - { - return Ok(()) - } + Err(ref e) if e.raw_os_error() == Some(libc::ENOSYS) => return Ok(()), Err(e) => { if e.raw_os_error() != lock_contended_error().raw_os_error() { diff --git a/src/cargo/util/important_paths.rs b/src/cargo/util/important_paths.rs index b09d7ef27ba..931d22c10b1 100644 --- a/src/cargo/util/important_paths.rs +++ b/src/cargo/util/important_paths.rs @@ -1,7 +1,7 @@ -use std::fs; -use std::path::{Path, PathBuf}; use crate::util::errors::CargoResult; use crate::util::paths; +use std::fs; +use std::path::{Path, PathBuf}; /// Find the root Cargo.toml pub fn find_root_manifest_for_wd(cwd: &Path) -> CargoResult { diff --git a/src/cargo/util/job.rs b/src/cargo/util/job.rs index 44c61f0ca92..6959987866f 100644 --- a/src/cargo/util/job.rs +++ b/src/cargo/util/job.rs @@ -23,8 +23,8 @@ pub fn setup() -> Option { #[cfg(unix)] mod imp { - use std::env; use libc; + use std::env; pub type Setup = (); @@ -52,8 +52,8 @@ mod imp { use self::winapi::um::handleapi::*; use self::winapi::um::jobapi2::*; use self::winapi::um::processthreadsapi::*; - use self::winapi::um::winnt::*; use self::winapi::um::winnt::HANDLE; + use self::winapi::um::winnt::*; pub struct Setup { job: Handle, diff --git a/src/cargo/util/lockserver.rs b/src/cargo/util/lockserver.rs index 0e5f524835c..9a0ce39b1bc 100644 --- a/src/cargo/util/lockserver.rs +++ b/src/cargo/util/lockserver.rs @@ -157,8 +157,8 @@ impl Drop for LockServerStarted { impl LockServerClient { pub fn lock(addr: &SocketAddr, name: &Path) -> Result { - let mut client = - TcpStream::connect(&addr).with_context(|_| "failed to connect to parent lock server")?; + let mut client = TcpStream::connect(&addr) + .with_context(|_| "failed to connect to parent lock server")?; client .write_all(name.display().to_string().as_bytes()) .and_then(|_| client.write_all(b"\n")) @@ -170,4 +170,3 @@ impl LockServerClient { Ok(LockServerClient { _socket: client }) } } - diff --git a/src/cargo/util/mod.rs b/src/cargo/util/mod.rs index 69f2d0e6852..74c6335cb89 100644 --- a/src/cargo/util/mod.rs +++ b/src/cargo/util/mod.rs @@ -3,52 +3,52 @@ use std::time::Duration; pub use self::cfg::{Cfg, CfgExpr}; pub use self::config::{homedir, Config, ConfigValue}; pub use self::dependency_queue::{DependencyQueue, Dirty, Fresh, Freshness}; +pub use self::diagnostic_server::RustfixDiagnosticServer; +pub use self::errors::{internal, process_error}; pub use self::errors::{CargoError, CargoResult, CargoResultExt, CliResult, Test}; pub use self::errors::{CargoTestError, CliError, ProcessError}; -pub use self::errors::{internal, process_error}; pub use self::flock::{FileLock, Filesystem}; pub use self::graph::Graph; -pub use self::hex::{short_hash, to_hex, hash_u64}; +pub use self::hex::{hash_u64, short_hash, to_hex}; pub use self::lev_distance::lev_distance; -pub use self::paths::{dylib_path, join_paths, bytes2path, path2bytes}; +pub use self::lockserver::{LockServer, LockServerClient, LockServerStarted}; +pub use self::paths::{bytes2path, dylib_path, join_paths, path2bytes}; pub use self::paths::{dylib_path_envvar, normalize_path, without_prefix}; pub use self::process_builder::{process, ProcessBuilder}; +pub use self::progress::{Progress, ProgressStyle}; +pub use self::read2::read2; pub use self::rustc::Rustc; pub use self::sha256::Sha256; pub use self::to_semver::ToSemver; pub use self::to_url::ToUrl; -pub use self::vcs::{FossilRepo, GitRepo, HgRepo, PijulRepo, existing_vcs_repo}; -pub use self::read2::read2; -pub use self::progress::{Progress, ProgressStyle}; -pub use self::lockserver::{LockServer, LockServerStarted, LockServerClient}; -pub use self::diagnostic_server::RustfixDiagnosticServer; +pub use self::vcs::{existing_vcs_repo, FossilRepo, GitRepo, HgRepo, PijulRepo}; +mod cfg; +pub mod command_prelude; pub mod config; +mod dependency_queue; +pub mod diagnostic_server; pub mod errors; +mod flock; pub mod graph; pub mod hex; pub mod important_paths; pub mod job; pub mod lev_distance; +mod lockserver; pub mod machine_message; pub mod network; pub mod paths; pub mod process_builder; pub mod profile; +mod progress; +mod read2; +mod rustc; +mod sha256; pub mod to_semver; pub mod to_url; pub mod toml; -pub mod command_prelude; -mod cfg; -mod dependency_queue; -mod rustc; -mod sha256; mod vcs; -mod flock; -mod read2; -mod progress; -mod lockserver; -pub mod diagnostic_server; pub fn elapsed(duration: Duration) -> String { let secs = duration.as_secs(); diff --git a/src/cargo/util/network.rs b/src/cargo/util/network.rs index c11dfd55436..cdf98929cb5 100644 --- a/src/cargo/util/network.rs +++ b/src/cargo/util/network.rs @@ -3,8 +3,8 @@ use git2; use failure::Error; -use crate::util::Config; use crate::util::errors::{CargoResult, HttpNot200}; +use crate::util::Config; pub struct Retry<'a> { config: &'a Config, @@ -19,9 +19,7 @@ impl<'a> Retry<'a> { }) } - pub fn r#try(&mut self, f: impl FnOnce() -> CargoResult) - -> CargoResult> - { + pub fn r#try(&mut self, f: impl FnOnce() -> CargoResult) -> CargoResult> { match f() { Err(ref e) if maybe_spurious(e) && self.remaining > 0 => { let msg = format!( @@ -85,7 +83,7 @@ where let mut retry = Retry::new(config)?; loop { if let Some(ret) = retry.r#try(&mut callback)? { - return Ok(ret) + return Ok(ret); } } } @@ -95,11 +93,13 @@ fn with_retry_repeats_the_call_then_works() { let error1 = HttpNot200 { code: 501, url: "Uri".to_string(), - }.into(); + } + .into(); let error2 = HttpNot200 { code: 502, url: "Uri".to_string(), - }.into(); + } + .into(); let mut results: Vec> = vec![Ok(()), Err(error1), Err(error2)]; let config = Config::default().unwrap(); let result = with_retry(&config, || results.pop().unwrap()); diff --git a/src/cargo/util/paths.rs b/src/cargo/util/paths.rs index 363245f420d..7994b101a24 100644 --- a/src/cargo/util/paths.rs +++ b/src/cargo/util/paths.rs @@ -127,7 +127,8 @@ pub fn read_bytes(path: &Path) -> CargoResult> { } f.read_to_end(&mut ret)?; Ok(ret) - })().chain_err(|| format!("failed to read `{}`", path.display()))?; + })() + .chain_err(|| format!("failed to read `{}`", path.display()))?; Ok(res) } @@ -136,7 +137,8 @@ pub fn write(path: &Path, contents: &[u8]) -> CargoResult<()> { let mut f = File::create(path)?; f.write_all(contents)?; Ok(()) - })().chain_err(|| format!("failed to write `{}`", path.display()))?; + })() + .chain_err(|| format!("failed to write `{}`", path.display()))?; Ok(()) } @@ -156,7 +158,8 @@ pub fn write_if_changed, C: AsRef<[u8]>>(path: P, contents: C) -> f.write_all(contents)?; } Ok(()) - })().chain_err(|| format!("failed to write `{}`", path.as_ref().display()))?; + })() + .chain_err(|| format!("failed to write `{}`", path.as_ref().display()))?; Ok(()) } @@ -170,7 +173,8 @@ pub fn append(path: &Path, contents: &[u8]) -> CargoResult<()> { f.write_all(contents)?; Ok(()) - })().chain_err(|| format!("failed to write `{}`", path.display()))?; + })() + .chain_err(|| format!("failed to write `{}`", path.display()))?; Ok(()) } diff --git a/src/cargo/util/process_builder.rs b/src/cargo/util/process_builder.rs index 5c8ccaf43e1..4ab936b058e 100644 --- a/src/cargo/util/process_builder.rs +++ b/src/cargo/util/process_builder.rs @@ -9,7 +9,7 @@ use failure::Fail; use jobserver::Client; use shell_escape::escape; -use crate::util::{process_error, CargoResult, CargoResultExt, read2}; +use crate::util::{process_error, read2, CargoResult, CargoResultExt}; /// A builder object for an external process, similar to `std::process::Command`. #[derive(Clone, Debug)] @@ -133,11 +133,7 @@ impl ProcessBuilder { pub fn exec(&self) -> CargoResult<()> { let mut command = self.build_command(); let exit = command.status().chain_err(|| { - process_error( - &format!("could not execute process {}", self), - None, - None, - ) + process_error(&format!("could not execute process {}", self), None, None) })?; if exit.success() { @@ -147,7 +143,8 @@ impl ProcessBuilder { &format!("process didn't exit successfully: {}", self), Some(exit), None, - ).into()) + ) + .into()) } } @@ -175,11 +172,7 @@ impl ProcessBuilder { let mut command = self.build_command(); let output = command.output().chain_err(|| { - process_error( - &format!("could not execute process {}", self), - None, - None, - ) + process_error(&format!("could not execute process {}", self), None, None) })?; if output.status.success() { @@ -189,7 +182,8 @@ impl ProcessBuilder { &format!("process didn't exit successfully: {}", self), Some(output.status), Some(&output), - ).into()) + ) + .into()) } } @@ -227,7 +221,8 @@ impl ProcessBuilder { None => return, } }; - { // scope for new_lines + { + // scope for new_lines let new_lines = if capture_output { let dst = if is_out { &mut stdout } else { &mut stderr }; let start = dst.len(); @@ -257,13 +252,7 @@ impl ProcessBuilder { })?; child.wait() })() - .chain_err(|| { - process_error( - &format!("could not execute process {}", self), - None, - None, - ) - })?; + .chain_err(|| process_error(&format!("could not execute process {}", self), None, None))?; let output = Output { stdout, stderr, @@ -332,9 +321,9 @@ pub fn process>(cmd: T) -> ProcessBuilder { #[cfg(unix)] mod imp { + use crate::util::{process_error, ProcessBuilder}; use crate::CargoResult; use std::os::unix::process::CommandExt; - use crate::util::{process_error, ProcessBuilder}; pub fn exec_replace(process_builder: &ProcessBuilder) -> CargoResult<()> { let mut command = process_builder.build_command(); @@ -353,10 +342,10 @@ mod imp { mod imp { extern crate winapi; - use crate::CargoResult; - use crate::util::{process_error, ProcessBuilder}; use self::winapi::shared::minwindef::{BOOL, DWORD, FALSE, TRUE}; use self::winapi::um::consoleapi::SetConsoleCtrlHandler; + use crate::util::{process_error, ProcessBuilder}; + use crate::CargoResult; unsafe extern "system" fn ctrlc_handler(_: DWORD) -> BOOL { // Do nothing. Let the child process handle it. @@ -366,10 +355,7 @@ mod imp { pub fn exec_replace(process_builder: &ProcessBuilder) -> CargoResult<()> { unsafe { if SetConsoleCtrlHandler(Some(ctrlc_handler), TRUE) == FALSE { - return Err(process_error( - "Could not set Ctrl-C handler.", - None, - None).into()); + return Err(process_error("Could not set Ctrl-C handler.", None, None).into()); } } diff --git a/src/cargo/util/profile.rs b/src/cargo/util/profile.rs index e7db1805a0e..e892fcc7522 100644 --- a/src/cargo/util/profile.rs +++ b/src/cargo/util/profile.rs @@ -1,10 +1,10 @@ +use std::cell::RefCell; use std::env; use std::fmt; +use std::io::{stdout, StdoutLock, Write}; +use std::iter::repeat; use std::mem; use std::time; -use std::iter::repeat; -use std::cell::RefCell; -use std::io::{stdout, StdoutLock, Write}; thread_local!(static PROFILE_STACK: RefCell> = RefCell::new(Vec::new())); thread_local!(static MESSAGES: RefCell> = RefCell::new(Vec::new())); @@ -46,8 +46,7 @@ impl Drop for Profiler { (start, stack.len()) }); let duration = start.elapsed(); - let duration_ms = - duration.as_secs() * 1000 + u64::from(duration.subsec_millis()); + let duration_ms = duration.as_secs() * 1000 + u64::from(duration.subsec_millis()); let msg = ( stack_len, @@ -72,7 +71,8 @@ impl Drop for Profiler { repeat(" ").take(lvl + 1).collect::(), time, msg - ).expect("printing profiling info to stdout"); + ) + .expect("printing profiling info to stdout"); print(lvl + 1, &msgs[last..i], enabled, stdout); last = i; diff --git a/src/cargo/util/progress.rs b/src/cargo/util/progress.rs index 21429a3aa2e..fc28fefd200 100644 --- a/src/cargo/util/progress.rs +++ b/src/cargo/util/progress.rs @@ -94,7 +94,7 @@ impl<'cfg> Progress<'cfg> { // draw to the console every so often. Currently there's a 100ms // delay between updates. if !s.throttle.allowed() { - return Ok(()) + return Ok(()); } s.tick(cur, max, "") @@ -140,12 +140,12 @@ impl Throttle { if self.first { let delay = Duration::from_millis(500); if self.last_update.elapsed() < delay { - return false + return false; } } else { let interval = Duration::from_millis(100); if self.last_update.elapsed() < interval { - return false + return false; } } self.update(); @@ -183,7 +183,7 @@ impl<'cfg> State<'cfg> { // make sure we have enough room for the header if self.format.max_width < 15 { - return Ok(()) + return Ok(()); } self.config.shell().status_header(&self.name)?; let mut line = prefix.to_string(); @@ -255,7 +255,7 @@ impl Format { let mut avail_msg_len = self.max_width - string.len() - 15; let mut ellipsis_pos = 0; if avail_msg_len <= 3 { - return + return; } for c in msg.chars() { let display_width = c.width().unwrap_or(0); @@ -401,8 +401,5 @@ fn test_progress_status_too_short() { max_print: 24, max_width: 24, }; - assert_eq!( - format.progress_status(1, 1, ""), - None - ); + assert_eq!(format.progress_status(1, 1, ""), None); } diff --git a/src/cargo/util/rustc.rs b/src/cargo/util/rustc.rs index be63780a9ac..d8c568a10ae 100644 --- a/src/cargo/util/rustc.rs +++ b/src/cargo/util/rustc.rs @@ -1,16 +1,16 @@ #![allow(deprecated)] // for SipHasher -use std::path::{Path, PathBuf}; -use std::hash::{Hash, Hasher, SipHasher}; use std::collections::hash_map::{Entry, HashMap}; -use std::sync::Mutex; -use std::process::Stdio; use std::env; +use std::hash::{Hash, Hasher, SipHasher}; +use std::path::{Path, PathBuf}; +use std::process::Stdio; +use std::sync::Mutex; use serde_json; -use crate::util::{self, internal, profile, CargoResult, ProcessBuilder}; use crate::util::paths; +use crate::util::{self, internal, profile, CargoResult, ProcessBuilder}; /// Information on the `rustc` executable #[derive(Debug)] @@ -73,7 +73,7 @@ impl Rustc { cmd.arg(&self.path); cmd } - _ => self.process_no_wrapper() + _ => self.process_no_wrapper(), } } diff --git a/src/cargo/util/to_semver.rs b/src/cargo/util/to_semver.rs index b3b2f64f584..eeab79c61f6 100644 --- a/src/cargo/util/to_semver.rs +++ b/src/cargo/util/to_semver.rs @@ -1,5 +1,5 @@ -use semver::Version; use crate::util::errors::CargoResult; +use semver::Version; pub trait ToSemver { fn to_semver(self) -> CargoResult; diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index d1cca34c85b..0765e7fccc6 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1024,7 +1024,8 @@ impl TomlManifest { if summary.features().contains_key("default-features") { warnings.push( "`default-features = [\"..\"]` was found in [features]. \ - Did you mean to use `default = [\"..\"]`?".to_string() + Did you mean to use `default = [\"..\"]`?" + .to_string(), ) } diff --git a/src/cargo/util/vcs.rs b/src/cargo/util/vcs.rs index 30fbf793baa..84474867640 100644 --- a/src/cargo/util/vcs.rs +++ b/src/cargo/util/vcs.rs @@ -1,5 +1,5 @@ -use std::path::Path; use std::fs::create_dir; +use std::path::Path; use git2; @@ -13,8 +13,12 @@ use crate::util::{process, CargoResult}; pub fn existing_vcs_repo(path: &Path, cwd: &Path) -> bool { fn in_git_repo(path: &Path, cwd: &Path) -> bool { if let Ok(repo) = GitRepo::discover(path, cwd) { - repo.is_path_ignored(path).map(|ignored| !ignored).unwrap_or(true) - } else { false } + repo.is_path_ignored(path) + .map(|ignored| !ignored) + .unwrap_or(true) + } else { + false + } } in_git_repo(path, cwd) || HgRepo::discover(path, cwd).is_ok() @@ -69,7 +73,11 @@ impl FossilRepo { db_path.push(db_fname); // then create the fossil DB in that location - process("fossil").cwd(cwd).arg("init").arg(&db_path).exec()?; + process("fossil") + .cwd(cwd) + .arg("init") + .arg(&db_path) + .exec()?; // open it in that new directory process("fossil") diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index 975ba013210..83cdcab404c 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -1,7 +1,7 @@ -use std::fs::File; -use std::io::Write; use crate::support::registry::{self, alt_api_path, Package}; use crate::support::{basic_manifest, paths, project}; +use std::fs::File; +use std::io::Write; #[test] fn is_feature_gated() { @@ -18,7 +18,8 @@ fn is_feature_gated() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").alternative(true).publish(); @@ -47,7 +48,8 @@ fn depend_on_alt_registry() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").alternative(true).publish(); @@ -64,7 +66,8 @@ fn depend_on_alt_registry() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", reg = registry::alt_registry_path().to_str().unwrap() - )).run(); + )) + .run(); p.cargo("clean").masquerade_as_nightly_cargo().run(); @@ -77,7 +80,8 @@ fn depend_on_alt_registry() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -97,7 +101,8 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").alternative(true).publish(); @@ -120,7 +125,8 @@ fn depend_on_alt_registry_depends_on_same_registry_no_index() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", reg = registry::alt_registry_path().to_str().unwrap() - )).run(); + )) + .run(); } #[test] @@ -140,7 +146,8 @@ fn depend_on_alt_registry_depends_on_same_registry() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").alternative(true).publish(); @@ -163,7 +170,8 @@ fn depend_on_alt_registry_depends_on_same_registry() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", reg = registry::alt_registry_path().to_str().unwrap() - )).run(); + )) + .run(); } #[test] @@ -183,7 +191,8 @@ fn depend_on_alt_registry_depends_on_crates_io() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").publish(); @@ -208,7 +217,8 @@ fn depend_on_alt_registry_depends_on_crates_io() { ", alt_reg = registry::alt_registry_path().to_str().unwrap(), reg = registry::registry_path().to_str().unwrap() - )).run(); + )) + .run(); } #[test] @@ -230,7 +240,8 @@ fn registry_and_path_dep_works() { path = "bar" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -243,7 +254,8 @@ fn registry_and_path_dep_works() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -265,7 +277,8 @@ fn registry_incompatible_with_git() { git = "" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").masquerade_as_nightly_cargo().with_status(101) @@ -287,7 +300,8 @@ fn cannot_publish_to_crates_io_with_registry_dependency() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").alternative(true).publish(); @@ -316,7 +330,8 @@ fn publish_with_registry_dependency() { version = "0.0.1" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").alternative(true).publish(); @@ -351,7 +366,8 @@ fn alt_registry_and_crates_io_deps() { version = "0.1.0" registry = "alternative" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("crates_io_dep", "0.0.1").publish(); @@ -364,9 +380,11 @@ fn alt_registry_and_crates_io_deps() { .with_stderr_contains(format!( "[UPDATING] `{}` index", registry::alt_registry_path().to_str().unwrap() - )).with_stderr_contains(&format!( + )) + .with_stderr_contains(&format!( "[UPDATING] `{}` index", - registry::registry_path().to_str().unwrap())) + registry::registry_path().to_str().unwrap() + )) .with_stderr_contains("[DOWNLOADED] crates_io_dep v0.0.1 (registry `[ROOT][..]`)") .with_stderr_contains("[DOWNLOADED] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)") .with_stderr_contains("[COMPILING] alt_reg_dep v0.1.0 (registry `[ROOT][..]`)") @@ -404,7 +422,8 @@ fn publish_to_alt_registry() { version = "0.0.1" authors = [] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); // Setup the registry by publishing a package @@ -442,7 +461,8 @@ fn publish_with_crates_io_dep() { [dependencies.bar] version = "0.0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").publish(); @@ -470,7 +490,8 @@ fn passwords_in_url_forbidden() { [registries.alternative] index = "ssh://git:secret@foobar.com" "#, - ).unwrap(); + ) + .unwrap(); let p = project() .file( @@ -483,7 +504,8 @@ fn passwords_in_url_forbidden() { version = "0.0.1" authors = [] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --registry alternative -Zunstable-options") diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index 502cbe1b5b4..01063fc4a6f 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -11,7 +11,8 @@ fn bad1() { [target] nonexistent-target = "foo" "#, - ).build(); + ) + .build(); p.cargo("build -v --target=nonexistent-target") .with_status(101) .with_stderr( @@ -19,7 +20,8 @@ fn bad1() { [ERROR] expected table for configuration key `target.nonexistent-target`, \ but found string in [..]config ", - ).run(); + ) + .run(); } #[test] @@ -32,7 +34,8 @@ fn bad2() { [http] proxy = 3.0 "#, - ).build(); + ) + .build(); p.cargo("publish -v") .with_status(101) .with_stderr( @@ -51,7 +54,8 @@ Caused by: Caused by: found TOML configuration value of unknown type `float` ", - ).run(); + ) + .run(); } #[test] @@ -64,7 +68,8 @@ fn bad3() { [http] proxy = true "#, - ).build(); + ) + .build(); Package::new("foo", "1.0.0").publish(); p.cargo("publish -v") @@ -76,7 +81,8 @@ error: failed to update registry [..] Caused by: error in [..]config: `http.proxy` expected a string, but found a boolean ", - ).run(); + ) + .run(); } #[test] @@ -88,7 +94,8 @@ fn bad4() { [cargo-new] name = false "#, - ).build(); + ) + .build(); p.cargo("new -v foo") .with_status(101) .with_stderr( @@ -98,7 +105,8 @@ fn bad4() { Caused by: error in [..]config: `cargo-new.name` expected a string, but found a boolean ", - ).run(); + ) + .run(); } #[test] @@ -111,7 +119,8 @@ fn bad6() { [http] user-agent = true "#, - ).build(); + ) + .build(); Package::new("foo", "1.0.0").publish(); p.cargo("publish -v") @@ -123,7 +132,8 @@ error: failed to update registry [..] Caused by: error in [..]config: `http.user-agent` expected a string, but found a boolean ", - ).run(); + ) + .run(); } #[test] @@ -136,7 +146,8 @@ fn bad_cargo_config_jobs() { [build] jobs = -1 "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_status(101) .with_stderr( @@ -145,7 +156,8 @@ fn bad_cargo_config_jobs() { could not load config key `build.jobs`: \ invalid value: integer `-1`, expected u32 ", - ).run(); + ) + .run(); } #[test] @@ -158,7 +170,8 @@ fn default_cargo_config_jobs() { [build] jobs = 1 "#, - ).build(); + ) + .build(); p.cargo("build -v").run(); } @@ -172,7 +185,8 @@ fn good_cargo_config_jobs() { [build] jobs = 4 "#, - ).build(); + ) + .build(); p.cargo("build -v").run(); } @@ -190,7 +204,8 @@ fn invalid_global_config() { [dependencies] foo = "0.1.0" "#, - ).file(".cargo/config", "4") + ) + .file(".cargo/config", "4") .file("src/lib.rs", "") .build(); @@ -209,7 +224,8 @@ Caused by: Caused by: expected an equals, found eof at line 1 ", - ).run(); + ) + .run(); } #[test] @@ -228,7 +244,8 @@ fn bad_cargo_lock() { Caused by: missing field `name` for key `package` ", - ).run(); + ) + .run(); } #[test] @@ -247,7 +264,8 @@ fn duplicate_packages_in_cargo_lock() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "Cargo.lock", r#" @@ -268,7 +286,8 @@ fn duplicate_packages_in_cargo_lock() { version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -279,7 +298,8 @@ fn duplicate_packages_in_cargo_lock() { Caused by: package `bar` is specified twice in the lockfile ", - ).run(); + ) + .run(); } #[test] @@ -298,7 +318,8 @@ fn bad_source_in_cargo_lock() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "Cargo.lock", r#" @@ -314,7 +335,8 @@ fn bad_source_in_cargo_lock() { version = "0.1.0" source = "You shall not parse" "#, - ).build(); + ) + .build(); p.cargo("build --verbose") .with_status(101) @@ -325,7 +347,8 @@ fn bad_source_in_cargo_lock() { Caused by: invalid source `You shall not parse` for key `package.source` ", - ).run(); + ) + .run(); } #[test] @@ -342,7 +365,8 @@ fn bad_dependency_in_lockfile() { "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -361,7 +385,8 @@ fn bad_git_dependency() { [dependencies] foo = { git = "file:.." } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") @@ -380,7 +405,8 @@ Caused by: Caused by: [..]'file:///' is not a valid local file URI[..] ", - ).run(); + ) + .run(); } #[test] @@ -397,14 +423,16 @@ fn bad_crate_type() { [lib] crate-type = ["bad_type", "rlib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") .with_status(101) .with_stderr_contains( "error: failed to run `rustc` to learn about crate-type bad_type information", - ).run(); + ) + .run(); } #[test] @@ -423,7 +451,8 @@ fn malformed_override() { foo: "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -438,7 +467,8 @@ Caused by: Caused by: expected a table key, found a newline at line 8 ", - ).run(); + ) + .run(); } #[test] @@ -460,7 +490,8 @@ fn duplicate_binary_names() { name = "e" path = "b.rs" "#, - ).file("a.rs", r#"fn main() -> () {}"#) + ) + .file("a.rs", r#"fn main() -> () {}"#) .file("b.rs", r#"fn main() -> () {}"#) .build(); @@ -473,7 +504,8 @@ fn duplicate_binary_names() { Caused by: found duplicate binary name e, but all binary targets must have a unique name ", - ).run(); + ) + .run(); } #[test] @@ -495,7 +527,8 @@ fn duplicate_example_names() { name = "ex" path = "examples/ex2.rs" "#, - ).file("examples/ex.rs", r#"fn main () -> () {}"#) + ) + .file("examples/ex.rs", r#"fn main () -> () {}"#) .file("examples/ex2.rs", r#"fn main () -> () {}"#) .build(); @@ -508,7 +541,8 @@ fn duplicate_example_names() { Caused by: found duplicate example name ex, but all example targets must have a unique name ", - ).run(); + ) + .run(); } #[test] @@ -530,7 +564,8 @@ fn duplicate_bench_names() { name = "ex" path = "benches/ex2.rs" "#, - ).file("benches/ex.rs", r#"fn main () {}"#) + ) + .file("benches/ex.rs", r#"fn main () {}"#) .file("benches/ex2.rs", r#"fn main () {}"#) .build(); @@ -543,7 +578,8 @@ fn duplicate_bench_names() { Caused by: found duplicate bench name ex, but all bench targets must have a unique name ", - ).run(); + ) + .run(); } #[test] @@ -567,7 +603,8 @@ fn duplicate_deps() { [target.x86_64-unknown-linux-gnu.dependencies] bar = { path = "linux-bar" } "#, - ).file("src/main.rs", r#"fn main () {}"#) + ) + .file("src/main.rs", r#"fn main () {}"#) .build(); p.cargo("build") @@ -580,7 +617,8 @@ Caused by: Dependency 'bar' has different source paths depending on the build target. Each dependency must \ have a single canonical source path irrespective of build target. ", - ).run(); + ) + .run(); } #[test] @@ -604,7 +642,8 @@ fn duplicate_deps_diff_sources() { [target.x86_64-unknown-linux-gnu.dependencies] bar = { path = "linux-bar" } "#, - ).file("src/main.rs", r#"fn main () {}"#) + ) + .file("src/main.rs", r#"fn main () {}"#) .build(); p.cargo("build") @@ -617,7 +656,8 @@ Caused by: Dependency 'bar' has different source paths depending on the build target. Each dependency must \ have a single canonical source path irrespective of build target. ", - ).run(); + ) + .run(); } #[test] @@ -634,7 +674,8 @@ fn unused_keys() { [target.foo] bar = "3" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -644,7 +685,8 @@ warning: unused manifest key: target.foo.bar [COMPILING] foo v0.1.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); let p = project() .file( @@ -658,7 +700,8 @@ warning: unused manifest key: target.foo.bar [profile.debug] debug = 1 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -668,7 +711,8 @@ warning: unused manifest key: profile.debug warning: use `[profile.dev]` to configure debug builds [..] [..]", - ).run(); + ) + .run(); let p = project() .file( @@ -681,7 +725,8 @@ warning: use `[profile.dev]` to configure debug builds authors = ["wycats@example.com"] bulid = "foo" "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("build") .with_stderr( @@ -690,7 +735,8 @@ warning: unused manifest key: project.bulid [COMPILING] foo [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); let p = project() .at("bar") @@ -706,7 +752,8 @@ warning: unused manifest key: project.bulid [lib] build = "foo" "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("build") .with_stderr( @@ -715,7 +762,8 @@ warning: unused manifest key: lib.build [COMPILING] foo [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -728,7 +776,8 @@ fn unused_keys_in_virtual_manifest() { members = ["bar"] bulid = "foo" "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", r"") .build(); p.cargo("build --all") @@ -738,7 +787,8 @@ fn unused_keys_in_virtual_manifest() { [COMPILING] bar [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -755,7 +805,8 @@ fn empty_dependencies() { [dependencies] bar = {} "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").publish(); @@ -766,7 +817,8 @@ fn empty_dependencies() { warning: dependency (bar) specified without providing a local path, Git repository, or version \ to use. This will be considered an error in future versions ", - ).run(); + ) + .run(); } #[test] @@ -789,7 +841,8 @@ in the future. [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -808,7 +861,8 @@ fn ambiguous_git_reference() { branch = "master" tag = "some-tag" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") @@ -819,7 +873,8 @@ fn ambiguous_git_reference() { Only one of `branch`, `tag` or `rev` is allowed. \ This will be considered an error in future versions ", - ).run(); + ) + .run(); } #[test] @@ -849,7 +904,8 @@ fn bad_source_config2() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -857,7 +913,8 @@ fn bad_source_config2() { registry = 'http://example.com' replace-with = 'bar' "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -872,7 +929,8 @@ Caused by: could not find a configured source with the name `bar` \ when attempting to lookup `crates-io` (configuration in [..]) ", - ).run(); + ) + .run(); } #[test] @@ -889,7 +947,8 @@ fn bad_source_config3() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -897,7 +956,8 @@ fn bad_source_config3() { registry = 'http://example.com' replace-with = 'crates-io' "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -911,7 +971,8 @@ Caused by: Caused by: detected a cycle of `replace-with` sources, [..] ", - ).run(); + ) + .run(); } #[test] @@ -928,7 +989,8 @@ fn bad_source_config4() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -940,7 +1002,8 @@ fn bad_source_config4() { registry = 'http://example.com' replace-with = 'crates-io' "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -955,7 +1018,8 @@ Caused by: detected a cycle of `replace-with` sources, the source `crates-io` is \ eventually replaced with itself (configuration in [..]) ", - ).run(); + ) + .run(); } #[test] @@ -972,7 +1036,8 @@ fn bad_source_config5() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -983,7 +1048,8 @@ fn bad_source_config5() { [source.bar] registry = 'not a url' "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -994,7 +1060,8 @@ error: configuration key `source.bar.registry` specified an invalid URL (in [..] Caused by: invalid url `not a url`: [..] ", - ).run(); + ) + .run(); } #[test] @@ -1012,7 +1079,8 @@ fn both_git_and_path_specified() { git = "https://127.0.0.1" path = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); foo.cargo("build -v") @@ -1023,7 +1091,8 @@ fn both_git_and_path_specified() { Only one of `git` or `path` is allowed. \ This will be considered an error in future versions ", - ).run(); + ) + .run(); } #[test] @@ -1040,7 +1109,8 @@ fn bad_source_config6() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -1048,7 +1118,8 @@ fn bad_source_config6() { registry = 'http://example.com' replace-with = ['not', 'a', 'string'] "#, - ).build(); + ) + .build(); p.cargo("build").with_status(101).with_stderr( "error: expected a string, but found a array for `source.crates-io.replace-with` in [..]", @@ -1071,7 +1142,8 @@ fn ignored_git_revision() { path = "bar" branch = "spam" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); foo.cargo("build -v") @@ -1080,7 +1152,8 @@ fn ignored_git_revision() { "\ [WARNING] key `branch` is ignored for dependency (bar). \ This will be considered an error in future versions", - ).run(); + ) + .run(); } #[test] @@ -1097,7 +1170,8 @@ fn bad_source_config7() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -1105,7 +1179,8 @@ fn bad_source_config7() { registry = 'http://example.com' local-registry = 'file:///another/file' "#, - ).build(); + ) + .build(); Package::new("bar", "0.1.0").publish(); @@ -1129,7 +1204,8 @@ fn bad_dependency() { [dependencies] bar = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -1141,7 +1217,8 @@ error: failed to parse manifest at `[..]` Caused by: invalid type: integer `3`, expected a version string like [..] ", - ).run(); + ) + .run(); } #[test] @@ -1158,7 +1235,8 @@ fn bad_debuginfo() { [profile.dev] debug = 'a' "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -1170,7 +1248,8 @@ error: failed to parse manifest at `[..]` Caused by: invalid type: string \"a\", expected a boolean or an integer for [..] ", - ).run(); + ) + .run(); } #[test] @@ -1185,7 +1264,8 @@ fn bad_opt_level() { authors = [] build = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -1197,5 +1277,6 @@ error: failed to parse manifest at `[..]` Caused by: invalid type: integer `3`, expected a boolean or a string for key [..] ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/bad_manifest_path.rs b/tests/testsuite/bad_manifest_path.rs index 242d2976316..df67c310115 100644 --- a/tests/testsuite/bad_manifest_path.rs +++ b/tests/testsuite/bad_manifest_path.rs @@ -14,7 +14,8 @@ fn assert_not_a_cargo_toml(command: &str, manifest_path_argument: &str) { .with_stderr( "[ERROR] the manifest-path must be a path \ to a Cargo.toml file", - ).run(); + ) + .run(); } fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) { @@ -32,7 +33,8 @@ fn assert_cargo_toml_doesnt_exist(command: &str, manifest_path_argument: &str) { .with_stderr(format!( "[ERROR] manifest path `{}` does not exist", expected_path - )).run(); + )) + .run(); } #[test] @@ -328,7 +330,8 @@ fn verify_project_dir_containing_cargo_toml() { .with_stdout( "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ ", - ).run(); + ) + .run(); } #[test] @@ -344,7 +347,8 @@ fn verify_project_dir_plus_file() { .with_stdout( "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ ", - ).run(); + ) + .run(); } #[test] @@ -360,7 +364,8 @@ fn verify_project_dir_plus_path() { .with_stdout( "{\"invalid\":\"the manifest-path must be a path to a Cargo.toml file\"}\ ", - ).run(); + ) + .run(); } #[test] @@ -372,5 +377,6 @@ fn verify_project_dir_to_nonexistent_cargo_toml() { .with_stdout( "{\"invalid\":\"manifest path `foo[..]bar[..]baz[..]Cargo.toml` does not exist\"}\ ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index bb1f9a150c7..2022abed8c3 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -29,7 +29,8 @@ fn cargo_bench_simple() { fn bench_hello(_b: &mut test::Bencher) { assert_eq!(hello(), "hello") }"#, - ).build(); + ) + .build(); p.cargo("build").run(); assert!(p.bin("foo").is_file()); @@ -42,7 +43,8 @@ fn cargo_bench_simple() { [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bench_hello ... bench: [..]") + ) + .with_stdout_contains("test bench_hello ... bench: [..]") .run(); } @@ -61,19 +63,22 @@ fn bench_bench_implicit() { extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { } fn main() { println!("Hello main!"); }"#, - ).file( + ) + .file( "tests/other.rs", r#" #![feature(test)] extern crate test; #[bench] fn run3(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( "benches/mybench.rs", r#" #![feature(test)] extern crate test; #[bench] fn run2(_ben: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench --benches") .with_stderr( @@ -83,7 +88,8 @@ fn bench_bench_implicit() { [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/mybench-[..][EXE] ", - ).with_stdout_contains("test run2 ... bench: [..]") + ) + .with_stdout_contains("test run2 ... bench: [..]") .run(); } @@ -102,19 +108,22 @@ fn bench_bin_implicit() { extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { } fn main() { println!("Hello main!"); }"#, - ).file( + ) + .file( "tests/other.rs", r#" #![feature(test)] extern crate test; #[bench] fn run3(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( "benches/mybench.rs", r#" #![feature(test)] extern crate test; #[bench] fn run2(_ben: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench --bins") .with_stderr( @@ -123,7 +132,8 @@ fn bench_bin_implicit() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] ", - ).with_stdout_contains("test run1 ... bench: [..]") + ) + .with_stdout_contains("test run1 ... bench: [..]") .run(); } @@ -140,13 +150,15 @@ fn bench_tarname() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( "benches/bin2.rs", r#" #![feature(test)] extern crate test; #[bench] fn run2(_ben: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench --bench bin2") .with_stderr( @@ -155,7 +167,8 @@ fn bench_tarname() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/bin2-[..][EXE] ", - ).with_stdout_contains("test run2 ... bench: [..]") + ) + .with_stdout_contains("test run2 ... bench: [..]") .run(); } @@ -172,19 +185,22 @@ fn bench_multiple_targets() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( "benches/bin2.rs", r#" #![feature(test)] extern crate test; #[bench] fn run2(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( "benches/bin3.rs", r#" #![feature(test)] extern crate test; #[bench] fn run3(_ben: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench --bench bin1 --bench bin2") .with_stdout_contains("test run1 ... bench: [..]") @@ -210,7 +226,8 @@ fn cargo_bench_verbose() { fn main() {} #[bench] fn bench_hello(_b: &mut test::Bencher) {} "#, - ).build(); + ) + .build(); p.cargo("bench -v hello") .with_stderr( @@ -219,7 +236,8 @@ fn cargo_bench_verbose() { [RUNNING] `rustc [..] src/main.rs [..]` [FINISHED] release [optimized] target(s) in [..] [RUNNING] `[..]target/release/deps/foo-[..][EXE] hello --bench`", - ).with_stdout_contains("test bench_hello ... bench: [..]") + ) + .with_stdout_contains("test bench_hello ... bench: [..]") .run(); } @@ -239,7 +257,8 @@ fn many_similar_names() { pub fn foo() {} #[bench] fn lib_bench(_b: &mut test::Bencher) {} ", - ).file( + ) + .file( "src/main.rs", " #![feature(test)] @@ -250,7 +269,8 @@ fn many_similar_names() { fn main() {} #[bench] fn bin_bench(_b: &mut test::Bencher) { foo::foo() } ", - ).file( + ) + .file( "benches/foo.rs", r#" #![feature(test)] @@ -258,7 +278,8 @@ fn many_similar_names() { extern crate test; #[bench] fn bench_bench(_b: &mut test::Bencher) { foo::foo() } "#, - ).build(); + ) + .build(); p.cargo("bench") .with_stdout_contains("test bin_bench ... bench: 0 ns/iter (+/- 0)") @@ -293,7 +314,8 @@ fn cargo_bench_failing_test() { fn bench_hello(_b: &mut test::Bencher) { assert_eq!(hello(), "nope") }"#, - ).build(); + ) + .build(); p.cargo("build").run(); assert!(p.bin("foo").is_file()); @@ -308,9 +330,11 @@ fn cargo_bench_failing_test() { [COMPILING] foo v0.5.0 ([CWD])[..] [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_either_contains( + ) + .with_either_contains( "[..]thread '[..]' panicked at 'assertion failed: `(left == right)`[..]", - ).with_either_contains("[..]left: `\"hello\"`[..]") + ) + .with_either_contains("[..]left: `\"hello\"`[..]") .with_either_contains("[..]right: `\"nope\"`[..]") .with_either_contains("[..]src/main.rs:15[..]") .with_status(101) @@ -336,7 +360,8 @@ fn bench_with_lib_dep() { name = "baz" path = "src/main.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![cfg_attr(test, feature(test))] @@ -353,7 +378,8 @@ fn bench_with_lib_dep() { pub fn foo(){} #[bench] fn lib_bench(_b: &mut test::Bencher) {} "#, - ).file( + ) + .file( "src/main.rs", " #![feature(test)] @@ -367,7 +393,8 @@ fn bench_with_lib_dep() { #[bench] fn bin_bench(_b: &mut test::Bencher) {} ", - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -376,7 +403,8 @@ fn bench_with_lib_dep() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/baz-[..][EXE]", - ).with_stdout_contains("test lib_bench ... bench: [..]") + ) + .with_stdout_contains("test lib_bench ... bench: [..]") .with_stdout_contains("test bin_bench ... bench: [..]") .run(); } @@ -400,7 +428,8 @@ fn bench_with_deep_lib_dep() { [dependencies.foo] path = "../foo" "#, - ).file( + ) + .file( "src/lib.rs", " #![cfg_attr(test, feature(test))] @@ -413,7 +442,8 @@ fn bench_with_deep_lib_dep() { foo::foo(); } ", - ).build(); + ) + .build(); let _p2 = project() .file( "src/lib.rs", @@ -427,7 +457,8 @@ fn bench_with_deep_lib_dep() { #[bench] fn foo_bench(_b: &mut test::Bencher) {} ", - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -436,7 +467,8 @@ fn bench_with_deep_lib_dep() { [COMPILING] bar v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/bar-[..][EXE]", - ).with_stdout_contains("test bar_bench ... bench: [..]") + ) + .with_stdout_contains("test bar_bench ... bench: [..]") .run(); } @@ -459,7 +491,8 @@ fn external_bench_explicit() { name = "bench" path = "src/bench.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![cfg_attr(test, feature(test))] @@ -470,7 +503,8 @@ fn external_bench_explicit() { #[bench] fn internal_bench(_b: &mut test::Bencher) {} "#, - ).file( + ) + .file( "src/bench.rs", r#" #![feature(test)] @@ -481,7 +515,8 @@ fn external_bench_explicit() { #[bench] fn external_bench(_b: &mut test::Bencher) {} "#, - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -490,7 +525,8 @@ fn external_bench_explicit() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/bench-[..][EXE]", - ).with_stdout_contains("test internal_bench ... bench: [..]") + ) + .with_stdout_contains("test internal_bench ... bench: [..]") .with_stdout_contains("test external_bench ... bench: [..]") .run(); } @@ -514,7 +550,8 @@ fn external_bench_implicit() { #[bench] fn internal_bench(_b: &mut test::Bencher) {} "#, - ).file( + ) + .file( "benches/external.rs", r#" #![feature(test)] @@ -525,7 +562,8 @@ fn external_bench_implicit() { #[bench] fn external_bench(_b: &mut test::Bencher) {} "#, - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -534,7 +572,8 @@ fn external_bench_implicit() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/external-[..][EXE]", - ).with_stdout_contains("test internal_bench ... bench: [..]") + ) + .with_stdout_contains("test internal_bench ... bench: [..]") .with_stdout_contains("test external_bench ... bench: [..]") .run(); } @@ -559,7 +598,8 @@ fn bench_autodiscover_2015() { name = "bench_magic" required-features = ["magic"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "benches/bench_basic.rs", r#" @@ -571,7 +611,8 @@ fn bench_autodiscover_2015() { #[bench] fn bench_basic(_b: &mut test::Bencher) {} "#, - ).file( + ) + .file( "benches/bench_magic.rs", r#" #![feature(test)] @@ -582,7 +623,8 @@ fn bench_autodiscover_2015() { #[bench] fn bench_magic(_b: &mut test::Bencher) {} "#, - ).build(); + ) + .build(); p.cargo("bench bench_basic") .with_stderr( @@ -606,7 +648,8 @@ https://github.com/rust-lang/cargo/issues/5330 [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] ", - ).run(); + ) + .run(); } #[test] @@ -620,7 +663,8 @@ fn dont_run_examples() { .file( "examples/dont-run-me-i-will-fail.rs", r#"fn main() { panic!("Examples should not be run by 'cargo test'"); }"#, - ).build(); + ) + .build(); p.cargo("bench").run(); } @@ -641,7 +685,8 @@ fn pass_through_command_line() { #[bench] fn foo(_b: &mut test::Bencher) {} #[bench] fn bar(_b: &mut test::Bencher) {} ", - ).build(); + ) + .build(); p.cargo("bench bar") .with_stderr( @@ -649,14 +694,16 @@ fn pass_through_command_line() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bar ... bench: [..]") + ) + .with_stdout_contains("test bar ... bench: [..]") .run(); p.cargo("bench foo") .with_stderr( "[FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test foo ... bench: [..]") + ) + .with_stdout_contains("test foo ... bench: [..]") .run(); } @@ -681,7 +728,8 @@ fn cargo_bench_twice() { #[bench] fn dummy_bench(b: &mut test::Bencher) { } "#, - ).build(); + ) + .build(); for _ in 0..2 { p.cargo("bench").run(); @@ -708,7 +756,8 @@ fn lib_bin_same_name() { [[bin]] name = "foo" "#, - ).file( + ) + .file( "src/lib.rs", " #![cfg_attr(test, feature(test))] @@ -716,7 +765,8 @@ fn lib_bin_same_name() { extern crate test; #[bench] fn lib_bench(_b: &mut test::Bencher) {} ", - ).file( + ) + .file( "src/main.rs", " #![cfg_attr(test, feature(test))] @@ -728,7 +778,8 @@ fn lib_bin_same_name() { #[bench] fn bin_bench(_b: &mut test::Bencher) {} ", - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -737,7 +788,8 @@ fn lib_bin_same_name() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains_n("test [..] ... bench: [..]", 2) + ) + .with_stdout_contains_n("test [..] ... bench: [..]", 2) .run(); } @@ -764,7 +816,8 @@ fn lib_with_standard_name() { #[bench] fn foo_bench(_b: &mut test::Bencher) {} ", - ).file( + ) + .file( "benches/bench.rs", " #![feature(test)] @@ -774,7 +827,8 @@ fn lib_with_standard_name() { #[bench] fn bench(_b: &mut test::Bencher) { syntax::foo() } ", - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -783,7 +837,8 @@ fn lib_with_standard_name() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/syntax-[..][EXE] [RUNNING] target/release/deps/bench-[..][EXE]", - ).with_stdout_contains("test foo_bench ... bench: [..]") + ) + .with_stdout_contains("test foo_bench ... bench: [..]") .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -808,7 +863,8 @@ fn lib_with_standard_name2() { bench = false doctest = false "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -823,7 +879,8 @@ fn lib_with_standard_name2() { #[bench] fn bench(_b: &mut test::Bencher) { syntax::foo() } ", - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -831,7 +888,8 @@ fn lib_with_standard_name2() { [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/syntax-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -857,7 +915,8 @@ fn bench_dylib() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![cfg_attr(test, feature(test))] @@ -870,7 +929,8 @@ fn bench_dylib() { #[bench] fn foo(_b: &mut test::Bencher) {} "#, - ).file( + ) + .file( "benches/bench.rs", r#" #![feature(test)] @@ -880,7 +940,8 @@ fn bench_dylib() { #[bench] fn foo(_b: &mut test::Bencher) { the_foo::bar(); } "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -892,7 +953,8 @@ fn bench_dylib() { name = "bar" crate_type = ["dylib"] "#, - ).file("bar/src/lib.rs", "pub fn baz() {}") + ) + .file("bar/src/lib.rs", "pub fn baz() {}") .build(); p.cargo("bench -v") @@ -907,7 +969,8 @@ fn bench_dylib() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` [RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", - ).with_stdout_contains_n("test foo ... bench: [..]", 2) + ) + .with_stdout_contains_n("test foo ... bench: [..]", 2) .run(); p.root().move_into_the_past(); @@ -919,7 +982,8 @@ fn bench_dylib() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] `[..]target/release/deps/foo-[..][EXE] --bench` [RUNNING] `[..]target/release/deps/bench-[..][EXE] --bench`", - ).with_stdout_contains_n("test foo ... bench: [..]", 2) + ) + .with_stdout_contains_n("test foo ... bench: [..]", 2) .run(); } @@ -939,7 +1003,8 @@ fn bench_twice_with_build_cmd() { authors = [] build = "build.rs" "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file( "src/lib.rs", " @@ -949,7 +1014,8 @@ fn bench_twice_with_build_cmd() { #[bench] fn foo(_b: &mut test::Bencher) {} ", - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -957,14 +1023,16 @@ fn bench_twice_with_build_cmd() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test foo ... bench: [..]") + ) + .with_stdout_contains("test foo ... bench: [..]") .run(); p.cargo("bench") .with_stderr( "[FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test foo ... bench: [..]") + ) + .with_stdout_contains("test foo ... bench: [..]") .run(); } @@ -989,7 +1057,8 @@ fn bench_with_examples() { [[bench]] name = "testb1" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![cfg_attr(test, feature(test))] @@ -1009,7 +1078,8 @@ fn bench_with_examples() { f2(); } "#, - ).file( + ) + .file( "benches/testb1.rs", " #![feature(test)] @@ -1023,7 +1093,8 @@ fn bench_with_examples() { foo::f2(); } ", - ).file( + ) + .file( "examples/teste1.rs", r#" extern crate foo; @@ -1033,7 +1104,8 @@ fn bench_with_examples() { foo::f1(); } "#, - ).build(); + ) + .build(); p.cargo("bench -v") .with_stderr( @@ -1045,7 +1117,8 @@ fn bench_with_examples() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] `[CWD]/target/release/deps/foo-[..][EXE] --bench` [RUNNING] `[CWD]/target/release/deps/testb1-[..][EXE] --bench`", - ).with_stdout_contains("test bench_bench1 ... bench: [..]") + ) + .with_stdout_contains("test bench_bench1 ... bench: [..]") .with_stdout_contains("test bench_bench2 ... bench: [..]") .run(); } @@ -1074,7 +1147,8 @@ fn test_a_bench() { name = "b" test = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("benches/b.rs", "#[test] fn foo() {}") .build(); @@ -1084,7 +1158,8 @@ fn test_a_bench() { [COMPILING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/b-[..][EXE]", - ).with_stdout_contains("test foo ... ok") + ) + .with_stdout_contains("test foo ... ok") .run(); } @@ -1108,7 +1183,8 @@ fn test_bench_no_run() { #[bench] fn bench_baz(_: &mut Bencher) {} "#, - ).build(); + ) + .build(); p.cargo("bench --no-run") .with_stderr( @@ -1116,7 +1192,8 @@ fn test_bench_no_run() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1150,7 +1227,8 @@ fn test_bench_no_fail_fast() { fn bench_nope(_b: &mut test::Bencher) { assert_eq!("nope", hello()) }"#, - ).build(); + ) + .build(); p.cargo("bench --no-fail-fast -- --test-threads=1") .with_status(101) @@ -1183,7 +1261,8 @@ fn test_bench_multiple_packages() { [dependencies.baz] path = "../baz" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let _bar = project() @@ -1200,7 +1279,8 @@ fn test_bench_multiple_packages() { name = "bbar" test = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "benches/bbar.rs", r#" @@ -1212,7 +1292,8 @@ fn test_bench_multiple_packages() { #[bench] fn bench_bar(_b: &mut Bencher) {} "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") @@ -1228,7 +1309,8 @@ fn test_bench_multiple_packages() { name = "bbaz" test = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "benches/bbaz.rs", r#" @@ -1240,7 +1322,8 @@ fn test_bench_multiple_packages() { #[bench] fn bench_baz(_b: &mut Bencher) {} "#, - ).build(); + ) + .build(); p.cargo("bench -p bar -p baz") .with_stderr_contains("[RUNNING] target/release/deps/bbaz-[..][EXE]") @@ -1269,7 +1352,8 @@ fn bench_all_workspace() { [workspace] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "benches/foo.rs", r#" @@ -1281,7 +1365,8 @@ fn bench_all_workspace() { #[bench] fn bench_foo(_: &mut Bencher) -> () { () } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file( "bar/benches/bar.rs", @@ -1294,7 +1379,8 @@ fn bench_all_workspace() { #[bench] fn bench_bar(_: &mut Bencher) -> () { () } "#, - ).build(); + ) + .build(); p.cargo("bench --all") .with_stderr_contains("[RUNNING] target/release/deps/bar-[..][EXE]") @@ -1321,7 +1407,8 @@ fn bench_all_exclude() { [workspace] members = ["bar", "baz"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file( "bar/src/lib.rs", @@ -1335,18 +1422,21 @@ fn bench_all_exclude() { b.iter(|| {}); } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file( "baz/src/lib.rs", "#[test] pub fn baz() { break_the_build(); }", - ).build(); + ) + .build(); p.cargo("bench --all --exclude baz") .with_stdout_contains( "\ running 1 test test bar ... bench: [..] ns/iter (+/- [..])", - ).run(); + ) + .run(); } #[test] @@ -1362,7 +1452,8 @@ fn bench_all_virtual_manifest() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file( "bar/benches/bar.rs", @@ -1375,7 +1466,8 @@ fn bench_all_virtual_manifest() { #[bench] fn bench_bar(_: &mut Bencher) -> () { () } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") .file( "baz/benches/baz.rs", @@ -1388,7 +1480,8 @@ fn bench_all_virtual_manifest() { #[bench] fn bench_baz(_: &mut Bencher) -> () { () } "#, - ).build(); + ) + .build(); // The order in which bar and baz are built is not guaranteed p.cargo("bench --all") @@ -1417,7 +1510,8 @@ fn legacy_bench_name() { [[bench]] name = "bench" "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/bench.rs", r#" @@ -1429,14 +1523,16 @@ fn legacy_bench_name() { #[bench] fn bench_foo(_: &mut Bencher) -> () { () } "#, - ).build(); + ) + .build(); p.cargo("bench") .with_stderr_contains( "\ [WARNING] path `[..]src/bench.rs` was erroneously implicitly accepted for benchmark `bench`, please set bench.path in Cargo.toml", - ).run(); + ) + .run(); } #[test] @@ -1452,7 +1548,8 @@ fn bench_virtual_manifest_all_implied() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn foo() {}") .file( "bar/benches/bar.rs", @@ -1463,7 +1560,8 @@ fn bench_virtual_manifest_all_implied() { #[bench] fn bench_bar(_: &mut Bencher) -> () { () } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") .file( "baz/benches/baz.rs", @@ -1474,7 +1572,8 @@ fn bench_virtual_manifest_all_implied() { #[bench] fn bench_baz(_: &mut Bencher) -> () { () } "#, - ).build(); + ) + .build(); // The order in which bar and baz are built is not guaranteed @@ -1508,7 +1607,8 @@ fn json_artifact_includes_executable_for_benchmark() { .build(); p.cargo("bench --no-run --message-format=json") - .with_json(r#" + .with_json( + r#" { "executable": "[..]/foo/target/release/benchmark-[..][EXE]", "features": [], @@ -1525,6 +1625,7 @@ fn json_artifact_includes_executable_for_benchmark() { "src_path": "[..]/foo/benches/benchmark.rs" } } - "#) + "#, + ) .run(); } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 9d65e8e56d5..c89f7ba8fbc 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -2,7 +2,6 @@ use std::env; use std::fs::{self, File}; use std::io::prelude::*; -use cargo::util::paths::dylib_path_envvar; use crate::support::paths::{root, CargoPathExt}; use crate::support::registry::Package; use crate::support::ProjectBuilder; @@ -10,6 +9,7 @@ use crate::support::{ basic_bin_manifest, basic_lib_manifest, basic_manifest, is_nightly, rustc_host, sleep_ms, }; use crate::support::{main_file, project, Execs}; +use cargo::util::paths::dylib_path_envvar; #[test] fn cargo_compile_simple() { @@ -49,13 +49,15 @@ fn cargo_compile_incremental() { .env("CARGO_INCREMENTAL", "1") .with_stderr_contains( "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", - ).run(); + ) + .run(); p.cargo("test -v") .env("CARGO_INCREMENTAL", "1") .with_stderr_contains( "[RUNNING] `rustc [..] -C incremental=[..]/target/debug/incremental[..]`\n", - ).run(); + ) + .run(); } #[test] @@ -75,7 +77,8 @@ fn incremental_profile() { [profile.release] incremental = true "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v") @@ -109,7 +112,8 @@ fn incremental_config() { [build] incremental = false "#, - ).build(); + ) + .build(); p.cargo("build -v") .env_remove("CARGO_INCREMENTAL") @@ -159,7 +163,8 @@ fn cargo_compile_with_invalid_manifest() { Caused by: virtual manifests must be configured with [workspace] ", - ).run(); + ) + .run(); } #[test] @@ -171,7 +176,8 @@ fn cargo_compile_with_invalid_manifest2() { [project] foo = bar ", - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -185,7 +191,8 @@ Caused by: Caused by: invalid number at line 3 ", - ).run(); + ) + .run(); } #[test] @@ -204,7 +211,8 @@ Caused by: Caused by: invalid number at line 1 ", - ).run(); + ) + .run(); } #[test] @@ -225,7 +233,8 @@ fn cargo_compile_duplicate_build_targets() { [dependencies] "#, - ).file("src/main.rs", "#![allow(warnings)] fn main() {}") + ) + .file("src/main.rs", "#![allow(warnings)] fn main() {}") .build(); p.cargo("build") @@ -235,7 +244,8 @@ warning: file found to be present in multiple build targets: [..]main.rs [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -253,7 +263,8 @@ fn cargo_compile_with_invalid_version() { Caused by: Expected dot for key `package.version` ", - ).run(); + ) + .run(); } #[test] @@ -271,7 +282,8 @@ fn cargo_compile_with_empty_package_name() { Caused by: package name cannot be an empty string ", - ).run(); + ) + .run(); } #[test] @@ -289,7 +301,8 @@ fn cargo_compile_with_invalid_package_name() { Caused by: Invalid character `:` in package name: `foo::bar` ", - ).run(); + ) + .run(); } #[test] @@ -306,7 +319,8 @@ fn cargo_compile_with_invalid_bin_target_name() { [[bin]] name = "" "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -317,7 +331,8 @@ fn cargo_compile_with_invalid_bin_target_name() { Caused by: binary target names cannot be empty ", - ).run(); + ) + .run(); } #[test] @@ -334,7 +349,8 @@ fn cargo_compile_with_forbidden_bin_target_name() { [[bin]] name = "build" "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -345,7 +361,8 @@ fn cargo_compile_with_forbidden_bin_target_name() { Caused by: the binary target name `build` is forbidden ", - ).run(); + ) + .run(); } #[test] @@ -364,7 +381,8 @@ fn cargo_compile_with_bin_and_crate_type() { path = "src/foo.rs" crate-type = ["cdylib", "rlib"] "#, - ).file("src/foo.rs", "fn main() {}") + ) + .file("src/foo.rs", "fn main() {}") .build(); p.cargo("build") @@ -376,7 +394,8 @@ fn cargo_compile_with_bin_and_crate_type() { Caused by: the target `the_foo_bin` is a binary and can't have any crate-types set \ (currently \"cdylib, rlib\")", - ).run(); + ) + .run(); } #[test] @@ -395,7 +414,8 @@ fn cargo_compile_with_bin_and_proc() { path = "src/foo.rs" proc-macro = true "#, - ).file("src/foo.rs", "fn main() {}") + ) + .file("src/foo.rs", "fn main() {}") .build(); p.cargo("build") @@ -406,7 +426,8 @@ fn cargo_compile_with_bin_and_proc() { Caused by: the target `the_foo_bin` is a binary and can't have `proc-macro` set `true`", - ).run(); + ) + .run(); } #[test] @@ -423,7 +444,8 @@ fn cargo_compile_with_invalid_lib_target_name() { [lib] name = "" "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -434,7 +456,8 @@ fn cargo_compile_with_invalid_lib_target_name() { Caused by: library target names cannot be empty ", - ).run(); + ) + .run(); } #[test] @@ -450,7 +473,8 @@ fn cargo_compile_with_invalid_non_numeric_dep_version() { [dependencies] crossbeam = "y" "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -464,7 +488,8 @@ Caused by: Caused by: the given version requirement is invalid ", - ).run(); + ) + .run(); } #[test] @@ -491,7 +516,8 @@ fn cargo_compile_with_invalid_code() { [ERROR] Could not compile `foo`. To learn more, run the command again with --verbose.\n", - ).run(); + ) + .run(); assert!(p.root().join("Cargo.lock").is_file()); } @@ -511,7 +537,8 @@ fn cargo_compile_with_invalid_code_in_deps() { [dependencies.baz] path = "../baz" "#, - ).file("src/main.rs", "invalid rust code!") + ) + .file("src/main.rs", "invalid rust code!") .build(); let _bar = project() .at("bar") @@ -557,7 +584,8 @@ fn cargo_compile_with_warnings_in_a_dep_package() { name = "foo" "#, - ).file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file( "bar/src/bar.rs", @@ -568,7 +596,8 @@ fn cargo_compile_with_warnings_in_a_dep_package() { fn dead() {} "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr_contains("[..]function is never used: `dead`[..]") @@ -597,7 +626,8 @@ fn cargo_compile_with_nested_deps_inferred() { [[bin]] name = "foo" "#, - ).file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -610,7 +640,8 @@ fn cargo_compile_with_nested_deps_inferred() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" extern crate baz; @@ -619,7 +650,8 @@ fn cargo_compile_with_nested_deps_inferred() { baz::gimme() } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0")) .file( "baz/src/lib.rs", r#" @@ -627,7 +659,8 @@ fn cargo_compile_with_nested_deps_inferred() { "test passed".to_string() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); @@ -656,7 +689,8 @@ fn cargo_compile_with_nested_deps_correct_bin() { [[bin]] name = "foo" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -669,7 +703,8 @@ fn cargo_compile_with_nested_deps_correct_bin() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" extern crate baz; @@ -678,7 +713,8 @@ fn cargo_compile_with_nested_deps_correct_bin() { baz::gimme() } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0")) .file( "baz/src/lib.rs", r#" @@ -686,7 +722,8 @@ fn cargo_compile_with_nested_deps_correct_bin() { "test passed".to_string() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); @@ -712,7 +749,8 @@ fn cargo_compile_with_nested_deps_shorthand() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -729,7 +767,8 @@ fn cargo_compile_with_nested_deps_shorthand() { name = "bar" "#, - ).file( + ) + .file( "bar/src/bar.rs", r#" extern crate baz; @@ -738,7 +777,8 @@ fn cargo_compile_with_nested_deps_shorthand() { baz::gimme() } "#, - ).file("baz/Cargo.toml", &basic_lib_manifest("baz")) + ) + .file("baz/Cargo.toml", &basic_lib_manifest("baz")) .file( "baz/src/baz.rs", r#" @@ -746,7 +786,8 @@ fn cargo_compile_with_nested_deps_shorthand() { "test passed".to_string() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); @@ -777,7 +818,8 @@ fn cargo_compile_with_nested_deps_longhand() { name = "foo" "#, - ).file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -795,7 +837,8 @@ fn cargo_compile_with_nested_deps_longhand() { name = "bar" "#, - ).file( + ) + .file( "bar/src/bar.rs", r#" extern crate baz; @@ -804,7 +847,8 @@ fn cargo_compile_with_nested_deps_longhand() { baz::gimme() } "#, - ).file("baz/Cargo.toml", &basic_lib_manifest("baz")) + ) + .file("baz/Cargo.toml", &basic_lib_manifest("baz")) .file( "baz/src/baz.rs", r#" @@ -812,7 +856,8 @@ fn cargo_compile_with_nested_deps_longhand() { "test passed".to_string() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); @@ -845,7 +890,8 @@ fn cargo_compile_with_dep_name_mismatch() { path = "bar" "#, - ).file("src/bin/foo.rs", &main_file(r#""i am foo""#, &["bar"])) + ) + .file("src/bin/foo.rs", &main_file(r#""i am foo""#, &["bar"])) .file("bar/Cargo.toml", &basic_bin_manifest("bar")) .file("bar/src/bar.rs", &main_file(r#""i am bar""#, &[])) .build(); @@ -857,7 +903,8 @@ fn cargo_compile_with_dep_name_mismatch() { location searched: [CWD]/bar required by package `foo v0.0.1 ([CWD])` "#, - ).run(); + ) + .run(); } #[test] @@ -870,7 +917,8 @@ fn cargo_compile_with_filename() { extern crate foo; fn main() { println!("hello a.rs"); } "#, - ).file("examples/a.rs", r#"fn main() { println!("example"); }"#) + ) + .file("examples/a.rs", r#"fn main() { println!("example"); }"#) .build(); p.cargo("build --bin bin.rs") @@ -885,7 +933,8 @@ fn cargo_compile_with_filename() { [ERROR] no bin target named `a.rs` Did you mean `a`?", - ).run(); + ) + .run(); p.cargo("build --example example.rs") .with_status(101) @@ -899,7 +948,8 @@ Did you mean `a`?", [ERROR] no example target named `a.rs` Did you mean `a`?", - ).run(); + ) + .run(); } #[test] @@ -916,7 +966,8 @@ fn cargo_compile_path_with_offline() { [dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -946,7 +997,8 @@ fn cargo_compile_with_downloaded_dependency_with_offline() { [dependencies] present_dep = "1.2.3" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); } @@ -963,7 +1015,8 @@ fn cargo_compile_with_downloaded_dependency_with_offline() { [dependencies] present_dep = "1.2.3" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p2.cargo("build -Zoffline") @@ -973,7 +1026,8 @@ fn cargo_compile_with_downloaded_dependency_with_offline() { [COMPILING] present_dep v1.2.3 [COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -990,7 +1044,8 @@ fn cargo_compile_offline_not_try_update() { [dependencies] not_cached_dep = "1.2.5" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -Zoffline") @@ -1005,7 +1060,8 @@ As a reminder, you're using offline mode (-Z offline) \ which can sometimes cause surprising resolution failures, \ if this error is too confusing you may with to retry \ without the offline flag.", - ).run(); + ) + .run(); } #[test] @@ -1018,7 +1074,8 @@ fn compile_offline_without_maxvers_cached() { .file( "src/lib.rs", r#"pub fn get_version()->&'static str {"1.2.3"}"#, - ).publish(); + ) + .publish(); Package::new("present_dep", "1.2.5") .file("Cargo.toml", &basic_manifest("present_dep", "1.2.5")) @@ -1038,7 +1095,8 @@ fn compile_offline_without_maxvers_cached() { [dependencies] present_dep = "=1.2.3" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); } @@ -1054,14 +1112,16 @@ fn compile_offline_without_maxvers_cached() { [dependencies] present_dep = "1.2" "#, - ).file( + ) + .file( "src/main.rs", "\ extern crate present_dep; fn main(){ println!(\"{}\", present_dep::get_version()); }", - ).build(); + ) + .build(); p2.cargo("run -Zoffline") .masquerade_as_nightly_cargo() @@ -1071,7 +1131,8 @@ fn main(){ [COMPILING] foo v0.1.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] Running `[..]`", - ).with_stdout("1.2.3") + ) + .with_stdout("1.2.3") .run(); } @@ -1101,7 +1162,8 @@ fn incompatible_dependencies() { baz = "0.1.0" qux = "0.1.0" "#, - ).file("src/main.rs", "fn main(){}") + ) + .file("src/main.rs", "fn main(){}") .build(); p.cargo("build") @@ -1120,7 +1182,8 @@ all possible versions conflict with previously selected packages. ... which is depended on by `foo v0.0.1 ([..])` failed to select a version for `bad` which could resolve this conflict", - ).run(); + ) + .run(); } #[test] @@ -1145,7 +1208,8 @@ fn incompatible_dependencies_with_multi_semver() { baz = "0.1.0" bad = ">=1.0.1, <=2.0.0" "#, - ).file("src/main.rs", "fn main(){}") + ) + .file("src/main.rs", "fn main(){}") .build(); p.cargo("build") @@ -1167,7 +1231,8 @@ all possible versions conflict with previously selected packages. ... which is depended on by `foo v0.0.1 ([..])` failed to select a version for `bad` which could resolve this conflict", - ).run(); + ) + .run(); } #[test] @@ -1196,7 +1261,8 @@ fn compile_offline_while_transitive_dep_not_cached() { [dependencies] bar = "0.1.0" "#, - ).file("src/main.rs", "fn main(){}") + ) + .file("src/main.rs", "fn main(){}") .build(); // simulate download bar, but fail to download baz @@ -1217,7 +1283,8 @@ As a reminder, you're using offline mode (-Z offline) \ which can sometimes cause surprising resolution failures, \ if this error is too confusing you may with to retry \ without the offline flag.", - ).run(); + ) + .run(); } #[test] @@ -1234,7 +1301,8 @@ fn compile_path_dep_then_change_version() { [dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -1288,7 +1356,8 @@ fn cargo_default_env_metadata_env_var() { [dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "// hi") + ) + .file("src/lib.rs", "// hi") .file( "bar/Cargo.toml", r#" @@ -1301,7 +1370,8 @@ fn cargo_default_env_metadata_env_var() { name = "bar" crate_type = ["dylib"] "#, - ).file("bar/src/lib.rs", "// hello") + ) + .file("bar/src/lib.rs", "// hello") .build(); // No metadata on libbar since it's a dylib path dependency @@ -1326,7 +1396,8 @@ fn cargo_default_env_metadata_env_var() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX, - )).run(); + )) + .run(); p.cargo("clean").run(); @@ -1354,7 +1425,8 @@ fn cargo_default_env_metadata_env_var() { ", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX, - )).run(); + )) + .run(); } #[test] @@ -1371,7 +1443,8 @@ fn crate_env_vars() { repository = "http://example.com/repo.git" authors = ["wycats@example.com"] "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate foo; @@ -1403,7 +1476,8 @@ fn crate_env_vars() { assert_eq!(s, VERSION); } "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn version() -> String { @@ -1415,13 +1489,16 @@ fn crate_env_vars() { env!("CARGO_MANIFEST_DIR")) } "#, - ).build(); + ) + .build(); println!("build"); p.cargo("build -v").run(); println!("bin"); - p.process(&p.bin("foo")).with_stdout("0-5-1 @ alpha.1 in [CWD]").run(); + p.process(&p.bin("foo")) + .with_stdout("0-5-1 @ alpha.1 in [CWD]") + .run(); println!("test"); p.cargo("test -v").run(); @@ -1438,7 +1515,8 @@ fn crate_authors_env_vars() { version = "0.5.1-alpha.1" authors = ["wycats@example.com", "neikos@example.com"] "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate foo; @@ -1452,14 +1530,16 @@ fn crate_authors_env_vars() { assert_eq!(s, AUTHORS); } "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn authors() -> String { format!("{}", env!("CARGO_PKG_AUTHORS")) } "#, - ).build(); + ) + .build(); println!("build"); p.cargo("build -v").run(); @@ -1501,7 +1581,8 @@ fn crate_library_path_env_var() { "##, dylib_path_envvar() ), - ).build(); + ) + .build(); setenv_for_removing_empty_component(p.cargo("run")).run(); } @@ -1536,14 +1617,16 @@ fn many_crate_types_old_style_lib_location() { name = "foo" crate_type = ["rlib", "dylib"] "#, - ).file("src/foo.rs", "pub fn foo() {}") + ) + .file("src/foo.rs", "pub fn foo() {}") .build(); p.cargo("build") .with_stderr_contains( "\ [WARNING] path `[..]src/foo.rs` was erroneously implicitly accepted for library `foo`, please rename the file to `src/lib.rs` or set lib.path in Cargo.toml", - ).run(); + ) + .run(); assert!(p.root().join("target/debug/libfoo.rlib").is_file()); let fname = format!("{}foo{}", env::consts::DLL_PREFIX, env::consts::DLL_SUFFIX); @@ -1567,7 +1650,8 @@ fn many_crate_types_correct() { name = "foo" crate_type = ["rlib", "dylib"] "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .build(); p.cargo("build").run(); @@ -1596,7 +1680,8 @@ fn self_dependency() { name = "test" path = "src/test.rs" "#, - ).file("src/test.rs", "fn main() {}") + ) + .file("src/test.rs", "fn main() {}") .build(); p.cargo("build") .with_status(101) @@ -1604,7 +1689,8 @@ fn self_dependency() { "\ [ERROR] cyclic package dependency: package `test v0.0.0 ([CWD])` depends on itself. Cycle: package `test v0.0.0 ([CWD])`", - ).run(); + ) + .run(); } #[test] @@ -1638,7 +1724,8 @@ fn missing_lib_and_bin() { Caused by: no targets specified in the manifest either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present\n", - ).run(); + ) + .run(); } #[test] @@ -1661,7 +1748,8 @@ fn lto_build() { [profile.release] lto = true "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v --release") .with_stderr( @@ -1676,7 +1764,8 @@ fn lto_build() { -L dependency=[CWD]/target/release/deps` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1693,7 +1782,8 @@ fn verbose_build() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1711,7 +1801,8 @@ fn verbose_release_build() { -L dependency=[CWD]/target/release/deps` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1729,7 +1820,8 @@ fn verbose_release_build_deps() { [dependencies.foo] path = "foo" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -1743,7 +1835,8 @@ fn verbose_release_build_deps() { name = "foo" crate_type = ["dylib", "rlib"] "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build -v --release") .with_stderr(&format!( @@ -1770,7 +1863,8 @@ fn verbose_release_build_deps() { ", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX - )).run(); + )) + .run(); } #[test] @@ -1796,26 +1890,30 @@ fn explicit_examples() { name = "goodbye" path = "examples/ex-goodbye.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn get_hello() -> &'static str { "Hello" } pub fn get_goodbye() -> &'static str { "Goodbye" } pub fn get_world() -> &'static str { "World" } "#, - ).file( + ) + .file( "examples/ex-hello.rs", r#" extern crate foo; fn main() { println!("{}, {}!", foo::get_hello(), foo::get_world()); } "#, - ).file( + ) + .file( "examples/ex-goodbye.rs", r#" extern crate foo; fn main() { println!("{}, {}!", foo::get_goodbye(), foo::get_world()); } "#, - ).build(); + ) + .build(); p.cargo("test -v").run(); p.process(&p.bin("examples/hello")) @@ -1844,7 +1942,8 @@ fn non_existing_example() { [[example]] name = "hello" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("test -v") @@ -1855,7 +1954,8 @@ fn non_existing_example() { Caused by: can't find `hello` example, specify example.path", - ).run(); + ) + .run(); } #[test] @@ -1874,7 +1974,8 @@ fn non_existing_binary() { Caused by: can't find `foo` bin, specify bin.path", - ).run(); + ) + .run(); } #[test] @@ -1891,7 +1992,8 @@ fn legacy_binary_paths_warnings() { [[bin]] name = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/main.rs", "fn main() {}") .build(); @@ -1900,7 +2002,8 @@ fn legacy_binary_paths_warnings() { "\ [WARNING] path `[..]src/main.rs` was erroneously implicitly accepted for binary `bar`, please set bin.path in Cargo.toml", - ).run(); + ) + .run(); let p = project() .file( @@ -1914,7 +2017,8 @@ please set bin.path in Cargo.toml", [[bin]] name = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/bin/main.rs", "fn main() {}") .build(); @@ -1923,7 +2027,8 @@ please set bin.path in Cargo.toml", "\ [WARNING] path `[..]src/bin/main.rs` was erroneously implicitly accepted for binary `bar`, please set bin.path in Cargo.toml", - ).run(); + ) + .run(); let p = project() .file( @@ -1937,7 +2042,8 @@ please set bin.path in Cargo.toml", [[bin]] name = "bar" "#, - ).file("src/bar.rs", "fn main() {}") + ) + .file("src/bar.rs", "fn main() {}") .build(); p.cargo("build -v") @@ -1945,7 +2051,8 @@ please set bin.path in Cargo.toml", "\ [WARNING] path `[..]src/bar.rs` was erroneously implicitly accepted for binary `bar`, please set bin.path in Cargo.toml", - ).run(); + ) + .run(); } #[test] @@ -1958,7 +2065,8 @@ fn implicit_examples() { pub fn get_goodbye() -> &'static str { "Goodbye" } pub fn get_world() -> &'static str { "World" } "#, - ).file( + ) + .file( "examples/hello.rs", r#" extern crate foo; @@ -1966,7 +2074,8 @@ fn implicit_examples() { println!("{}, {}!", foo::get_hello(), foo::get_world()); } "#, - ).file( + ) + .file( "examples/goodbye.rs", r#" extern crate foo; @@ -1974,7 +2083,8 @@ fn implicit_examples() { println!("{}, {}!", foo::get_goodbye(), foo::get_world()); } "#, - ).build(); + ) + .build(); p.cargo("test").run(); p.process(&p.bin("examples/hello")) @@ -2000,7 +2110,8 @@ fn standard_build_no_ndebug() { } } "#, - ).build(); + ) + .build(); p.cargo("build").run(); p.process(&p.bin("foo")).with_stdout("slow\n").run(); @@ -2021,7 +2132,8 @@ fn release_build_ndebug() { } } "#, - ).build(); + ) + .build(); p.cargo("build --release").run(); p.process(&p.release_bin("foo")).with_stdout("fast\n").run(); @@ -2049,7 +2161,8 @@ fn deletion_causes_failure() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() {}") + ) + .file("src/main.rs", "extern crate bar; fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -2078,7 +2191,8 @@ fn lib_with_standard_name() { .file( "src/main.rs", "extern crate syntax; fn main() { syntax::foo() }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -2086,7 +2200,8 @@ fn lib_with_standard_name() { [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2104,7 +2219,8 @@ fn simple_staticlib() { name = "foo" crate-type = ["staticlib"] "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .build(); // env var is a test for #1381 @@ -2126,7 +2242,8 @@ fn staticlib_rlib_and_bin() { name = "foo" crate-type = ["staticlib", "rlib"] "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file("src/main.rs", "extern crate foo; fn main() { foo::foo(); }") .build(); @@ -2146,7 +2263,8 @@ fn opt_out_of_bin() { authors = [] version = "0.0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/main.rs", "bad syntax") .build(); p.cargo("build").run(); @@ -2167,7 +2285,8 @@ fn single_lib() { name = "foo" path = "src/bar.rs" "#, - ).file("src/bar.rs", "") + ) + .file("src/bar.rs", "") .build(); p.cargo("build").run(); } @@ -2185,7 +2304,8 @@ fn freshness_ignores_excluded() { build = "build.rs" exclude = ["src/b*.rs"] "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") .build(); foo.root().move_into_the_past(); @@ -2196,7 +2316,8 @@ fn freshness_ignores_excluded() { [COMPILING] foo v0.0.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // Smoke test to make sure it doesn't compile again println!("first pass"); @@ -2220,7 +2341,8 @@ fn rebuild_preserves_out_dir() { authors = [] build = 'build.rs' "#, - ).file( + ) + .file( "build.rs", r#" use std::env; @@ -2236,7 +2358,8 @@ fn rebuild_preserves_out_dir() { } } "#, - ).file("src/lib.rs", "pub fn bar() -> i32 { 1 }") + ) + .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") .build(); foo.root().move_into_the_past(); @@ -2247,7 +2370,8 @@ fn rebuild_preserves_out_dir() { [COMPILING] foo v0.0.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); File::create(&foo.root().join("src/bar.rs")).unwrap(); foo.cargo("build") @@ -2256,7 +2380,8 @@ fn rebuild_preserves_out_dir() { [COMPILING] foo v0.0.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2273,7 +2398,8 @@ fn dep_no_libs() { [dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "pub fn bar() -> i32 { 1 }") + ) + .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.0")) .file("bar/src/main.rs", "") .build(); @@ -2295,7 +2421,8 @@ fn recompile_space_in_name() { name = "foo" path = "src/my lib.rs" "#, - ).file("src/my lib.rs", "") + ) + .file("src/my lib.rs", "") .build(); foo.cargo("build").run(); foo.root().move_into_the_past(); @@ -2343,7 +2470,8 @@ Caused by: Caused by: expected an equals, found an identifier at line 1 ", - ).run(); + ) + .run(); } #[test] @@ -2369,14 +2497,17 @@ fn cargo_platform_specific_dependency() { "#, host = host ), - ).file("src/main.rs", "extern crate dep; fn main() { dep::dep() }") + ) + .file("src/main.rs", "extern crate dep; fn main() { dep::dep() }") .file( "tests/foo.rs", "extern crate dev; #[test] fn foo() { dev::dev() }", - ).file( + ) + .file( "build.rs", "extern crate build; fn main() { build::build(); }", - ).file("dep/Cargo.toml", &basic_manifest("dep", "0.5.0")) + ) + .file("dep/Cargo.toml", &basic_manifest("dep", "0.5.0")) .file("dep/src/lib.rs", "pub fn dep() {}") .file("build/Cargo.toml", &basic_manifest("build", "0.5.0")) .file("build/src/lib.rs", "pub fn build() {}") @@ -2405,12 +2536,14 @@ fn bad_platform_specific_dependency() { [target.wrong-target.dependencies.bar] path = "bar" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) .file( "bar/src/lib.rs", r#"extern crate baz; pub fn gimme() -> String { format!("") }"#, - ).build(); + ) + .build(); p.cargo("build").with_status(101).run(); } @@ -2430,12 +2563,14 @@ fn cargo_platform_specific_dependency_wrong_platform() { [target.non-existing-triplet.dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) .file( "bar/src/lib.rs", "invalid rust file, should not be compiled", - ).build(); + ) + .build(); p.cargo("build").run(); @@ -2466,7 +2601,8 @@ fn example_as_lib() { name = "ex" crate-type = ["lib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/ex.rs", "") .build(); @@ -2489,7 +2625,8 @@ fn example_as_rlib() { name = "ex" crate-type = ["rlib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/ex.rs", "") .build(); @@ -2512,7 +2649,8 @@ fn example_as_dylib() { name = "ex" crate-type = ["dylib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/ex.rs", "") .build(); @@ -2539,7 +2677,8 @@ fn example_as_proc_macro() { name = "ex" crate-type = ["proc-macro"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/ex.rs", "#![feature(proc_macro)]") .build(); @@ -2595,10 +2734,12 @@ fn transitive_dependencies_not_available() { [dependencies.aaaaa] path = "a" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bbbbb; extern crate aaaaa; fn main() {}", - ).file( + ) + .file( "a/Cargo.toml", r#" [package] @@ -2609,7 +2750,8 @@ fn transitive_dependencies_not_available() { [dependencies.bbbbb] path = "../b" "#, - ).file("a/src/lib.rs", "extern crate bbbbb;") + ) + .file("a/src/lib.rs", "extern crate bbbbb;") .file("b/Cargo.toml", &basic_manifest("bbbbb", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -2634,7 +2776,8 @@ fn cyclic_deps_rejected() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -2646,7 +2789,8 @@ fn cyclic_deps_rejected() { [dependencies.foo] path = ".." "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build -v") @@ -2673,7 +2817,8 @@ fn predictable_filenames() { name = "foo" crate-type = ["dylib", "rlib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v").run(); @@ -2708,7 +2853,8 @@ fn dashes_in_crate_name_bad() { [lib] name = "foo-bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/main.rs", "extern crate foo_bar; fn main() {}") .build(); @@ -2729,7 +2875,8 @@ fn rustc_env_var() { Caused by: [..] ", - ).run(); + ) + .run(); assert!(!p.bin("a").is_file()); } @@ -2838,7 +2985,8 @@ fn custom_target_dir_env() { [build] target-dir = "foo/target" "#, - ).unwrap(); + ) + .unwrap(); p.cargo("build").env("CARGO_TARGET_DIR", "bar/target").run(); assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); @@ -2867,7 +3015,8 @@ fn custom_target_dir_line_parameter() { [build] target-dir = "foo/target" "#, - ).unwrap(); + ) + .unwrap(); p.cargo("build --target-dir bar/target").run(); assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); @@ -2876,12 +3025,11 @@ fn custom_target_dir_line_parameter() { p.cargo("build --target-dir foobar/target") .env("CARGO_TARGET_DIR", "bar/target") .run(); - assert!( - p.root() - .join("foobar/target/debug") - .join(&exe_name) - .is_file() - ); + assert!(p + .root() + .join("foobar/target/debug") + .join(&exe_name) + .is_file()); assert!(p.root().join("bar/target/debug").join(&exe_name).is_file()); assert!(p.root().join("foo/target/debug").join(&exe_name).is_file()); assert!(p.root().join("target/debug").join(&exe_name).is_file()); @@ -2906,7 +3054,8 @@ fn build_multiple_packages() { [[bin]] name = "foo" "#, - ).file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + ) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) .file("d1/Cargo.toml", &basic_bin_manifest("d1")) .file("d1/src/lib.rs", "") .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }") @@ -2922,7 +3071,8 @@ fn build_multiple_packages() { name = "d2" doctest = false "#, - ).file("d2/src/main.rs", "fn main() { println!(\"d2\"); }") + ) + .file("d2/src/main.rs", "fn main() { println!(\"d2\"); }") .build(); p.cargo("build -p d1 -p d2 -p foo").run(); @@ -2963,7 +3113,8 @@ fn invalid_spec() { [[bin]] name = "foo" "#, - ).file("src/bin/foo.rs", &main_file(r#""i am foo""#, &[])) + ) + .file("src/bin/foo.rs", &main_file(r#""i am foo""#, &[])) .file("d1/Cargo.toml", &basic_bin_manifest("d1")) .file("d1/src/lib.rs", "") .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }") @@ -2991,7 +3142,8 @@ fn manifest_with_bom_is_ok() { version = \"0.0.1\" authors = [] ", - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v").run(); } @@ -3010,7 +3162,8 @@ fn panic_abort_compiles_with_panic_abort() { [profile.dev] panic = 'abort' "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") .with_stderr_contains("[..] -C panic=abort [..]") @@ -3036,7 +3189,8 @@ fn explicit_color_config_is_propagated_to_rustc() { [RUNNING] `rustc [..] --color never [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -3054,10 +3208,12 @@ fn compiler_json_error_format() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "build.rs", "fn main() { println!(\"cargo:rustc-cfg=xyz\") }", - ).file("src/main.rs", "fn main() { let unused = 92; }") + ) + .file("src/main.rs", "fn main() { let unused = 92; }") .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("bar/src/lib.rs", r#"fn dead() {}"#) .build(); @@ -3170,7 +3326,8 @@ fn compiler_json_error_format() { "fresh": false } "#, - ).run(); + ) + .run(); // With fresh build, we should repeat the artifacts, // but omit compiler warnings. @@ -3255,7 +3412,8 @@ fn compiler_json_error_format() { "fresh": true } "#, - ).run(); + ) + .run(); } #[test] @@ -3272,7 +3430,8 @@ fn wrong_message_format_option() { error: 'XML' isn't a valid value for '--message-format ' [possible values: human, json, short] ", - ).run(); + ) + .run(); } #[test] @@ -3321,7 +3480,8 @@ fn message_format_json_forward_stderr() { "fresh": false } "#, - ).run(); + ) + .run(); } #[test] @@ -3343,13 +3503,15 @@ fn no_warn_about_package_metadata() { [package.metadata.another] bar = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") .with_stderr( "[..] foo v0.0.1 ([..])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -3381,7 +3543,8 @@ fn build_all_workspace() { [workspace] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -3391,7 +3554,8 @@ fn build_all_workspace() { "[..] Compiling bar v0.1.0 ([..])\n\ [..] Compiling foo v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -3407,7 +3571,8 @@ fn build_all_exclude() { [workspace] members = ["bar", "baz"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) @@ -3436,7 +3601,8 @@ fn build_all_workspace_implicit_examples() { [workspace] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/bin/a.rs", "fn main() {}") .file("src/bin/b.rs", "fn main() {}") .file("examples/c.rs", "fn main() {}") @@ -3454,7 +3620,8 @@ fn build_all_workspace_implicit_examples() { "[..] Compiling bar v0.1.0 ([..])\n\ [..] Compiling foo v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); assert!(!p.bin("a").is_file()); assert!(!p.bin("b").is_file()); assert!(p.bin("examples/c").is_file()); @@ -3474,7 +3641,8 @@ fn build_all_virtual_manifest() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -3488,7 +3656,8 @@ fn build_all_virtual_manifest() { "[..] Compiling [..] v0.1.0 ([..])\n\ [..] Compiling [..] v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -3500,7 +3669,8 @@ fn build_virtual_manifest_all_implied() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -3514,7 +3684,8 @@ fn build_virtual_manifest_all_implied() { "[..] Compiling [..] v0.1.0 ([..])\n\ [..] Compiling [..] v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -3526,7 +3697,8 @@ fn build_virtual_manifest_one_project() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -3538,7 +3710,8 @@ fn build_virtual_manifest_one_project() { .with_stderr( "[..] Compiling [..] v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -3550,7 +3723,8 @@ fn build_all_virtual_manifest_implicit_examples() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") .file("bar/src/bin/a.rs", "fn main() {}") .file("bar/src/bin/b.rs", "fn main() {}") @@ -3572,7 +3746,8 @@ fn build_all_virtual_manifest_implicit_examples() { "[..] Compiling [..] v0.1.0 ([..])\n\ [..] Compiling [..] v0.1.0 ([..])\n\ [..] Finished dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); assert!(!p.bin("a").is_file()); assert!(!p.bin("b").is_file()); assert!(p.bin("examples/c").is_file()); @@ -3592,7 +3767,8 @@ fn build_all_member_dependency_same_name() { [workspace] members = ["a"] "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -3602,7 +3778,8 @@ fn build_all_member_dependency_same_name() { [dependencies] a = "0.1.0" "#, - ).file("a/src/lib.rs", "pub fn a() {}") + ) + .file("a/src/lib.rs", "pub fn a() {}") .build(); Package::new("a", "0.1.0").publish(); @@ -3615,7 +3792,8 @@ fn build_all_member_dependency_same_name() { [COMPILING] a v0.1.0\n\ [COMPILING] a v0.1.0 ([..])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -3633,11 +3811,13 @@ fn run_proper_binary() { [[bin]] name = "other" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "src/bin/main.rs", r#"fn main() { panic!("This should never be run."); }"#, - ).file("src/bin/other.rs", "fn main() {}") + ) + .file("src/bin/other.rs", "fn main() {}") .build(); p.cargo("run --bin other").run(); @@ -3669,7 +3849,8 @@ fn run_proper_alias_binary_from_src() { [[bin]] name = "bar" "#, - ).file("src/foo.rs", r#"fn main() { println!("foo"); }"#) + ) + .file("src/foo.rs", r#"fn main() { println!("foo"); }"#) .file("src/bar.rs", r#"fn main() { println!("bar"); }"#) .build(); @@ -3693,7 +3874,8 @@ fn run_proper_alias_binary_main_rs() { [[bin]] name = "bar" "#, - ).file("src/main.rs", r#"fn main() { println!("main"); }"#) + ) + .file("src/main.rs", r#"fn main() { println!("main"); }"#) .build(); p.cargo("build --all").run(); @@ -3708,7 +3890,8 @@ fn run_proper_binary_main_rs_as_foo() { .file( "src/foo.rs", r#" fn main() { panic!("This should never be run."); }"#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("run --bin foo").run(); @@ -3746,7 +3929,8 @@ fn cdylib_not_lifted() { [lib] crate-type = ["cdylib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -3779,7 +3963,8 @@ fn cdylib_final_outputs() { [lib] crate-type = ["cdylib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -3819,7 +4004,8 @@ fn deterministic_cfg_flags() { f_c = [] f_d = [] "#, - ).file( + ) + .file( "build.rs", r#" fn main() { @@ -3830,7 +4016,8 @@ fn deterministic_cfg_flags() { println!("cargo:rustc-cfg=cfg_e"); } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v") @@ -3844,7 +4031,8 @@ fn deterministic_cfg_flags() { --cfg[..]f_c[..]--cfg[..]f_d[..] \ --cfg cfg_a --cfg cfg_b --cfg cfg_c --cfg cfg_d --cfg cfg_e` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -3864,7 +4052,8 @@ fn explicit_bins_without_paths() { [[bin]] name = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/main.rs", "fn main() {}") .file("src/bin/bar.rs", "fn main() {}") .build(); @@ -3888,7 +4077,8 @@ fn no_bin_in_src_with_lib() { Caused by: can't find `foo` bin, specify bin.path", - ).run(); + ) + .run(); } #[test] @@ -3935,7 +4125,8 @@ fn inferred_bin_path() { name = "bar" # Note, no `path` key! "#, - ).file("src/bin/bar/main.rs", "fn main() {}") + ) + .file("src/bin/bar/main.rs", "fn main() {}") .build(); p.cargo("build").run(); @@ -3990,7 +4181,8 @@ fn target_edition() { [lib] edition = "2018" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") @@ -4000,7 +4192,8 @@ fn target_edition() { [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..]--edition=2018 [..] ", - ).run(); + ) + .run(); } #[test] @@ -4018,13 +4211,14 @@ fn target_edition_override() { [lib] edition = "2015" "#, - ).file( + ) + .file( "src/lib.rs", " pub fn async() {} pub fn try() {} pub fn await() {} - " + ", ) .build(); @@ -4072,7 +4266,8 @@ fn building_a_dependent_crate_witout_bin_should_fail() { [[bin]] name = "a_bin" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); let p = project() @@ -4086,7 +4281,8 @@ fn building_a_dependent_crate_witout_bin_should_fail() { [dependencies] testless = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -4110,13 +4306,12 @@ fn uplift_dsym_of_bin_on_mac() { p.cargo("build --bins --examples --tests").run(); assert!(p.bin("foo.dSYM").is_dir()); assert!(p.bin("b.dSYM").is_dir()); - assert!( - p.bin("b.dSYM") - .symlink_metadata() - .expect("read metadata from b.dSYM") - .file_type() - .is_symlink() - ); + assert!(p + .bin("b.dSYM") + .symlink_metadata() + .expect("read metadata from b.dSYM") + .file_type() + .is_symlink()); assert!(!p.bin("c.dSYM").is_dir()); assert!(!p.bin("d.dSYM").is_dir()); } @@ -4156,23 +4351,28 @@ fn build_filter_infer_profile() { .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \ --emit=dep-info,link[..]", - ).with_stderr_contains( + ) + .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ --emit=dep-info,link[..]", - ).run(); + ) + .run(); 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 \ --emit=dep-info,link -C debuginfo=2 [..]", - ).with_stderr_contains( + ) + .with_stderr_contains( "[RUNNING] `rustc --crate-name t1 tests/t1.rs --color never --emit=dep-info,link \ - -C debuginfo=2 [..]", - ).with_stderr_contains( + -C debuginfo=2 [..]", + ) + .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ --emit=dep-info,link -C debuginfo=2 [..]", - ).run(); + ) + .run(); p.root().join("target").rm_rf(); // Bench uses test profile without `--release`. @@ -4180,15 +4380,17 @@ fn build_filter_infer_profile() { .with_stderr_contains( "[RUNNING] `rustc --crate-name foo src/lib.rs --color never --crate-type lib \ --emit=dep-info,link -C debuginfo=2 [..]", - ).with_stderr_contains( + ) + .with_stderr_contains( "[RUNNING] `rustc --crate-name b1 benches/b1.rs --color never --emit=dep-info,link \ - -C debuginfo=2 [..]", + -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 \ --emit=dep-info,link -C debuginfo=2 [..]", - ).run(); + ) + .run(); } #[test] @@ -4196,17 +4398,24 @@ fn targets_selected_default() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("build -v") // bin - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ - --emit=dep-info,link[..]") + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ + --emit=dep-info,link[..]", + ) // bench - .with_stderr_does_not_contain("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C opt-level=3 --test [..]") + .with_stderr_does_not_contain( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C opt-level=3 --test [..]", + ) // unit test - .with_stderr_does_not_contain("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C debuginfo=2 --test [..]").run(); + .with_stderr_does_not_contain( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C debuginfo=2 --test [..]", + ) + .run(); } #[test] @@ -4214,13 +4423,18 @@ fn targets_selected_all() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("build -v --all-targets") // bin - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ - --emit=dep-info,link[..]") + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ + --emit=dep-info,link[..]", + ) // unit test - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C debuginfo=2 --test [..]").run(); + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C debuginfo=2 --test [..]", + ) + .run(); } #[test] @@ -4228,13 +4442,18 @@ fn all_targets_no_lib() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("build -v --all-targets") // bin - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ - --emit=dep-info,link[..]") + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ + --emit=dep-info,link[..]", + ) // unit test - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C debuginfo=2 --test [..]").run(); + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C debuginfo=2 --test [..]", + ) + .run(); } #[test] @@ -4251,7 +4470,8 @@ fn no_linkable_target() { [dependencies] the_lib = { path = "the_lib" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "the_lib/Cargo.toml", r#" @@ -4262,14 +4482,16 @@ fn no_linkable_target() { name = "the_lib" crate-type = ["staticlib"] "#, - ).file("the_lib/src/lib.rs", "pub fn foo() {}") + ) + .file("the_lib/src/lib.rs", "pub fn foo() {}") .build(); p.cargo("build") .with_stderr_contains( "\ [WARNING] The package `the_lib` provides no linkable [..] \ while compiling `foo`. [..] in `the_lib`'s Cargo.toml. [..]", - ).run(); + ) + .run(); } #[test] @@ -4287,7 +4509,8 @@ fn avoid_dev_deps() { [dev-dependencies] baz = "1.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").with_status(101).run(); @@ -4319,7 +4542,8 @@ fn target_filters_workspace() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_lib_manifest("a")) + ) + .file("a/Cargo.toml", &basic_lib_manifest("a")) .file("a/src/lib.rs", "") .file("a/examples/ex1.rs", "fn main() {}") .file("b/Cargo.toml", &basic_bin_manifest("b")) @@ -4334,7 +4558,8 @@ fn target_filters_workspace() { [ERROR] no example target named `ex` Did you mean `ex1`?", - ).run(); + ) + .run(); ws.cargo("build -v --lib") .with_status(0) @@ -4358,7 +4583,8 @@ fn target_filters_workspace_not_found() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_bin_manifest("a")) + ) + .file("a/Cargo.toml", &basic_bin_manifest("a")) .file("a/src/main.rs", "fn main() {}") .file("b/Cargo.toml", &basic_bin_manifest("b")) .file("b/src/main.rs", "fn main() {}") @@ -4420,14 +4646,16 @@ fn signal_display() { .build(); foo.cargo("build") - .with_stderr("\ + .with_stderr( + "\ [COMPILING] pm [..] [COMPILING] foo [..] [ERROR] Could not compile `foo`. Caused by: process didn't exit successfully: `rustc [..]` (signal: 6, SIGABRT: process abort signal) -") +", + ) .with_status(101) .run(); } diff --git a/tests/testsuite/build_auth.rs b/tests/testsuite/build_auth.rs index 9b849fdb51b..78d4c455539 100644 --- a/tests/testsuite/build_auth.rs +++ b/tests/testsuite/build_auth.rs @@ -4,10 +4,10 @@ use std::io::prelude::*; use std::net::TcpListener; use std::thread; -use bufstream::BufStream; -use git2; use crate::support::paths; use crate::support::{basic_manifest, project}; +use bufstream::BufStream; +use git2; // Test that HTTP auth is offered from `credential.helper` #[test] @@ -34,13 +34,15 @@ fn http_auth_offered() { WWW-Authenticate: Basic realm=\"wheee\"\r\n \r\n\ ", - ).unwrap(); + ) + .unwrap(); assert_eq!( req, vec![ "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Accept: */*", - ].into_iter() + ] + .into_iter() .map(|s| s.to_string()) .collect() ); @@ -54,14 +56,16 @@ fn http_auth_offered() { WWW-Authenticate: Basic realm=\"wheee\"\r\n \r\n\ ", - ).unwrap(); + ) + .unwrap(); assert_eq!( req, vec![ "GET /foo/bar/info/refs?service=git-upload-pack HTTP/1.1", "Authorization: Basic Zm9vOmJhcg==", "Accept: */*", - ].into_iter() + ] + .into_iter() .map(|s| s.to_string()) .collect() ); @@ -78,7 +82,8 @@ fn http_auth_offered() { println!("password=bar"); } "#, - ).build(); + ) + .build(); script.cargo("build -v").run(); let script = script.bin("script"); @@ -104,14 +109,16 @@ fn http_auth_offered() { "#, addr.port() ), - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file( ".cargo/config", "\ [net] retry = 0 ", - ).build(); + ) + .build(); // This is a "contains" check because the last error differs by platform, // may span multiple lines, and isn't relevant to this test. @@ -135,7 +142,8 @@ attempted to find username/password via `credential.helper`, but [..] Caused by: ", addr = addr - )).run(); + )) + .run(); t.join().ok().unwrap(); } @@ -167,21 +175,24 @@ fn https_something_happens() { "#, addr.port() ), - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file( ".cargo/config", "\ [net] retry = 0 ", - ).build(); + ) + .build(); p.cargo("build -v") .with_status(101) .with_stderr_contains(&format!( "[UPDATING] git repository `https://{addr}/foo/bar`", addr = addr - )).with_stderr_contains(&format!( + )) + .with_stderr_contains(&format!( "\ Caused by: {errmsg} @@ -196,7 +207,8 @@ Caused by: } else { "[..]SSL error: [..]" } - )).run(); + )) + .run(); t.join().ok().unwrap(); } @@ -225,7 +237,8 @@ fn ssh_something_happens() { "#, addr.port() ), - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build -v") @@ -233,11 +246,13 @@ fn ssh_something_happens() { .with_stderr_contains(&format!( "[UPDATING] git repository `ssh://{addr}/foo/bar`", addr = addr - )).with_stderr_contains( + )) + .with_stderr_contains( "\ Caused by: [..]failed to start SSH session: Failed getting banner[..] ", - ).run(); + ) + .run(); t.join().ok().unwrap(); } diff --git a/tests/testsuite/build_lib.rs b/tests/testsuite/build_lib.rs index bb714a8a777..00c256b610f 100644 --- a/tests/testsuite/build_lib.rs +++ b/tests/testsuite/build_lib.rs @@ -17,7 +17,8 @@ fn build_lib_only() { --out-dir [..] \ -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -49,12 +50,14 @@ fn build_with_relative_cargo_home_path() { "test-dependency" = { path = "src/test_dependency" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("src/test_dependency/src/lib.rs", r#" "#) .file( "src/test_dependency/Cargo.toml", &basic_manifest("test-dependency", "0.0.1"), - ).build(); + ) + .build(); p.cargo("build").env("CARGO_HOME", "./cargo_home/").run(); } diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs index cb019ae39f3..4fa915a8491 100644 --- a/tests/testsuite/build_plan.rs +++ b/tests/testsuite/build_plan.rs @@ -34,7 +34,8 @@ fn cargo_build_plan_simple() { ] } "#, - ).run(); + ) + .run(); assert!(!p.bin("foo").is_file()); } @@ -52,7 +53,8 @@ fn cargo_build_plan_single_dep() { [dependencies] bar = { path = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -61,7 +63,8 @@ fn cargo_build_plan_single_dep() { #[test] fn test() { foo(); } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); p.cargo("build --build-plan -Zunstable-options") @@ -109,7 +112,8 @@ fn cargo_build_plan_single_dep() { ] } "#, - ).run(); + ) + .run(); } #[test] @@ -125,7 +129,8 @@ fn cargo_build_plan_build_script() { authors = ["wycats@example.com"] build = "build.rs" "#, - ).file("src/main.rs", r#"fn main() {}"#) + ) + .file("src/main.rs", r#"fn main() {}"#) .file("build.rs", r#"fn main() {}"#) .build(); @@ -185,7 +190,8 @@ fn cargo_build_plan_build_script() { ] } "#, - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index 5e3d524e1aa..2ce7e5f0230 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -5,11 +5,11 @@ use std::io::prelude::*; use std::thread; use std::time::Duration; -use cargo::util::paths::remove_dir_all; use crate::support::paths::CargoPathExt; use crate::support::registry::Package; use crate::support::{basic_manifest, cross_compile, project}; use crate::support::{rustc_host, sleep_ms}; +use cargo::util::paths::remove_dir_all; #[test] fn custom_build_script_failed() { @@ -24,7 +24,8 @@ fn custom_build_script_failed() { authors = ["wycats@example.com"] build = "build.rs" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("build.rs", "fn main() { std::process::exit(101); }") .build(); p.cargo("build -v") @@ -36,7 +37,8 @@ fn custom_build_script_failed() { [RUNNING] `[..]/build-script-build` [ERROR] failed to run custom build command for `foo v0.5.0 ([CWD])` process didn't exit successfully: `[..]/build-script-build` (exit code: 101)", - ).run(); + ) + .run(); } #[test] @@ -57,7 +59,8 @@ fn custom_build_env_vars() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -71,7 +74,8 @@ fn custom_build_env_vars() { [features] foo = [] "#, - ).file("bar/src/lib.rs", "pub fn hello() {}"); + ) + .file("bar/src/lib.rs", "pub fn hello() {}"); let file_content = format!( r#" @@ -141,7 +145,8 @@ fn custom_build_env_var_rustc_linker() { "#, target ), - ).file( + ) + .file( "build.rs", r#" use std::env; @@ -150,7 +155,8 @@ fn custom_build_env_var_rustc_linker() { assert!(env::var("RUSTC_LINKER").unwrap().ends_with("/path/to/linker")); } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); // no crate type set => linker never called => build succeeds if and @@ -171,11 +177,13 @@ fn custom_build_script_wrong_rustc_flags() { authors = ["wycats@example.com"] build = "build.rs" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "build.rs", r#"fn main() { println!("cargo:rustc-flags=-aaa -bbb"); }"#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -183,7 +191,8 @@ fn custom_build_script_wrong_rustc_flags() { "\ [ERROR] Only `-l` and `-L` flags are allowed in build script of `foo v0.5.0 ([CWD])`: \ `-aaa -bbb`", - ).run(); + ) + .run(); } /* @@ -253,7 +262,8 @@ fn links_no_build_cmd() { authors = [] links = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -263,7 +273,8 @@ fn links_no_build_cmd() { [ERROR] package `foo v0.5.0 ([CWD])` specifies that it links to `a` but does \ not have a custom build script ", - ).run(); + ) + .run(); } #[test] @@ -283,7 +294,8 @@ fn links_duplicates() { [dependencies.a-sys] path = "a-sys" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "") .file( "a-sys/Cargo.toml", @@ -295,7 +307,8 @@ fn links_duplicates() { links = "a" build = "build.rs" "#, - ).file("a-sys/src/lib.rs", "") + ) + .file("a-sys/src/lib.rs", "") .file("a-sys/build.rs", "") .build(); @@ -329,7 +342,8 @@ fn links_duplicates_deep_dependency() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "") .file( "a/Cargo.toml", @@ -343,7 +357,8 @@ fn links_duplicates_deep_dependency() { [dependencies.a-sys] path = "a-sys" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file("a/build.rs", "") .file( "a/a-sys/Cargo.toml", @@ -355,7 +370,8 @@ fn links_duplicates_deep_dependency() { links = "a" build = "build.rs" "#, - ).file("a/a-sys/src/lib.rs", "") + ) + .file("a/a-sys/src/lib.rs", "") .file("a/a-sys/build.rs", "") .build(); @@ -390,7 +406,8 @@ fn overrides_and_links() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -402,7 +419,8 @@ fn overrides_and_links() { "baz"); } "#, - ).file( + ) + .file( ".cargo/config", &format!( r#" @@ -413,7 +431,8 @@ fn overrides_and_links() { "#, target ), - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -423,7 +442,8 @@ fn overrides_and_links() { links = "foo" build = "build.rs" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file("a/build.rs", "not valid rust code") .build(); @@ -438,7 +458,8 @@ fn overrides_and_links() { [RUNNING] `rustc --crate-name foo [..] -L foo -L bar` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -455,7 +476,8 @@ fn unused_overrides() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .file( ".cargo/config", @@ -468,7 +490,8 @@ fn unused_overrides() { "#, target ), - ).build(); + ) + .build(); p.cargo("build -v").run(); } @@ -488,7 +511,8 @@ fn links_passes_env_vars() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -498,7 +522,8 @@ fn links_passes_env_vars() { assert_eq!(env::var("DEP_FOO_BAR").unwrap(), "baz"); } "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -508,7 +533,8 @@ fn links_passes_env_vars() { links = "foo" build = "build.rs" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", r#" @@ -521,7 +547,8 @@ fn links_passes_env_vars() { println!("cargo:bar=baz"); } "#, - ).build(); + ) + .build(); p.cargo("build -v").run(); } @@ -538,7 +565,8 @@ fn only_rerun_build_script() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .build(); @@ -556,7 +584,8 @@ fn only_rerun_build_script() { [RUNNING] `rustc --crate-name foo [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -573,7 +602,8 @@ fn rebuild_continues_to_pass_env_vars() { links = "foo" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -584,7 +614,8 @@ fn rebuild_continues_to_pass_env_vars() { std::thread::sleep(Duration::from_millis(500)); } "#, - ).build(); + ) + .build(); a.root().move_into_the_past(); let p = project() @@ -603,7 +634,8 @@ fn rebuild_continues_to_pass_env_vars() { "#, a.root().display() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -613,7 +645,8 @@ fn rebuild_continues_to_pass_env_vars() { assert_eq!(env::var("DEP_FOO_BAR").unwrap(), "baz"); } "#, - ).build(); + ) + .build(); p.cargo("build -v").run(); p.root().move_into_the_past(); @@ -636,7 +669,8 @@ fn testing_and_such() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .build(); @@ -659,7 +693,8 @@ fn testing_and_such() { [RUNNING] `[..]/foo-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]`", - ).with_stdout_contains_n("running 0 tests", 2) + ) + .with_stdout_contains_n("running 0 tests", 2) .run(); println!("doc"); @@ -670,7 +705,8 @@ fn testing_and_such() { [RUNNING] `rustdoc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); File::create(&p.root().join("src/main.rs")) .unwrap() @@ -684,7 +720,8 @@ fn testing_and_such() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/foo[EXE]` ", - ).run(); + ) + .run(); } #[test] @@ -701,7 +738,8 @@ fn propagation_of_l_flags() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -715,11 +753,13 @@ fn propagation_of_l_flags() { [dependencies.b] path = "../b" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", r#"fn main() { println!("cargo:rustc-flags=-L bar"); }"#, - ).file( + ) + .file( "b/Cargo.toml", r#" [project] @@ -729,7 +769,8 @@ fn propagation_of_l_flags() { links = "foo" build = "build.rs" "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file("b/build.rs", "bad file") .file( ".cargo/config", @@ -740,7 +781,8 @@ fn propagation_of_l_flags() { "#, target ), - ).build(); + ) + .build(); p.cargo("build -v -j1") .with_stderr_contains( @@ -749,7 +791,8 @@ fn propagation_of_l_flags() { [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc --crate-name foo [..] -L bar -L foo` ", - ).run(); + ) + .run(); } #[test] @@ -766,7 +809,8 @@ fn propagation_of_l_flags_new() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -780,7 +824,8 @@ fn propagation_of_l_flags_new() { [dependencies.b] path = "../b" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", r#" @@ -788,7 +833,8 @@ fn propagation_of_l_flags_new() { println!("cargo:rustc-link-search=bar"); } "#, - ).file( + ) + .file( "b/Cargo.toml", r#" [project] @@ -798,7 +844,8 @@ fn propagation_of_l_flags_new() { links = "foo" build = "build.rs" "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file("b/build.rs", "bad file") .file( ".cargo/config", @@ -809,7 +856,8 @@ fn propagation_of_l_flags_new() { "#, target ), - ).build(); + ) + .build(); p.cargo("build -v -j1") .with_stderr_contains( @@ -818,7 +866,8 @@ fn propagation_of_l_flags_new() { [COMPILING] foo v0.5.0 ([CWD]) [RUNNING] `rustc --crate-name foo [..] -L bar -L foo` ", - ).run(); + ) + .run(); } #[test] @@ -835,7 +884,8 @@ fn build_deps_simple() { [build-dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", " @@ -843,7 +893,8 @@ fn build_deps_simple() { extern crate a; fn main() {} ", - ).file("a/Cargo.toml", &basic_manifest("a", "0.5.0")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.5.0")) .file("a/src/lib.rs", "") .build(); @@ -858,7 +909,8 @@ fn build_deps_simple() { [RUNNING] `rustc --crate-name foo [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -876,17 +928,20 @@ fn build_deps_not_for_normal() { [build-dependencies.aaaaa] path = "a" "#, - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate aaaaa;", - ).file( + ) + .file( "build.rs", " #[allow(unused_extern_crates)] extern crate aaaaa; fn main() {} ", - ).file("a/Cargo.toml", &basic_manifest("aaaaa", "0.5.0")) + ) + .file("a/Cargo.toml", &basic_manifest("aaaaa", "0.5.0")) .file("a/src/lib.rs", "") .build(); @@ -901,7 +956,8 @@ fn build_deps_not_for_normal() { Caused by: process didn't exit successfully: [..] ", - ).run(); + ) + .run(); } #[test] @@ -919,7 +975,8 @@ fn build_cmd_with_a_build_cmd() { [build-dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", " @@ -927,7 +984,8 @@ fn build_cmd_with_a_build_cmd() { extern crate a; fn main() {} ", - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -939,11 +997,13 @@ fn build_cmd_with_a_build_cmd() { [build-dependencies.b] path = "../b" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", "#[allow(unused_extern_crates)] extern crate b; fn main() {}", - ).file("b/Cargo.toml", &basic_manifest("b", "0.5.0")) + ) + .file("b/Cargo.toml", &basic_manifest("b", "0.5.0")) .file("b/src/lib.rs", "") .build(); @@ -974,7 +1034,8 @@ fn build_cmd_with_a_build_cmd() { -L [..]target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -989,7 +1050,8 @@ fn out_dir_is_preserved() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -1001,7 +1063,8 @@ fn out_dir_is_preserved() { File::create(Path::new(&out).join("foo")).unwrap(); } "#, - ).build(); + ) + .build(); // Make the file p.cargo("build -v").run(); @@ -1019,7 +1082,8 @@ fn out_dir_is_preserved() { File::open(&Path::new(&out).join("foo")).unwrap(); } "#, - ).unwrap(); + ) + .unwrap(); p.root().move_into_the_past(); p.cargo("build -v").run(); @@ -1043,7 +1107,8 @@ fn output_separate_lines() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -1052,7 +1117,8 @@ fn output_separate_lines() { println!("cargo:rustc-flags=-l static=foo"); } "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_status(101) .with_stderr_contains( @@ -1063,7 +1129,8 @@ fn output_separate_lines() { [RUNNING] `rustc --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ", - ).run(); + ) + .run(); } #[test] @@ -1078,7 +1145,8 @@ fn output_separate_lines_new() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -1087,7 +1155,8 @@ fn output_separate_lines_new() { println!("cargo:rustc-link-lib=static=foo"); } "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_status(101) .with_stderr_contains( @@ -1098,7 +1167,8 @@ fn output_separate_lines_new() { [RUNNING] `rustc --crate-name foo [..] -L foo -l static=foo` [ERROR] could not find native static library [..] ", - ).run(); + ) + .run(); } #[cfg(not(windows))] // FIXME(#867) @@ -1114,7 +1184,8 @@ fn code_generation() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "src/main.rs", r#" include!(concat!(env!("OUT_DIR"), "/hello.rs")); @@ -1123,7 +1194,8 @@ fn code_generation() { println!("{}", message()); } "#, - ).file( + ) + .file( "build.rs", r#" use std::env; @@ -1141,7 +1213,8 @@ fn code_generation() { ").unwrap(); } "#, - ).build(); + ) + .build(); p.cargo("run") .with_stderr( @@ -1149,7 +1222,8 @@ fn code_generation() { [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/foo`", - ).with_stdout("Hello, World!") + ) + .with_stdout("Hello, World!") .run(); p.cargo("test").run(); @@ -1167,13 +1241,15 @@ fn release_with_build_script() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" fn main() {} "#, - ).build(); + ) + .build(); p.cargo("build -v --release").run(); } @@ -1190,7 +1266,8 @@ fn build_script_only() { authors = [] build = "build.rs" "#, - ).file("build.rs", r#"fn main() {}"#) + ) + .file("build.rs", r#"fn main() {}"#) .build(); p.cargo("build -v") .with_status(101) @@ -1201,7 +1278,8 @@ fn build_script_only() { Caused by: no targets specified in the manifest either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present", - ).run(); + ) + .run(); } #[test] @@ -1222,7 +1300,8 @@ fn shared_dep_with_a_build_script() { [build-dependencies.b] path = "b" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .file( "a/Cargo.toml", @@ -1233,7 +1312,8 @@ fn shared_dep_with_a_build_script() { authors = [] build = "build.rs" "#, - ).file("a/build.rs", "fn main() {}") + ) + .file("a/build.rs", "fn main() {}") .file("a/src/lib.rs", "") .file( "b/Cargo.toml", @@ -1246,7 +1326,8 @@ fn shared_dep_with_a_build_script() { [dependencies.a] path = "../a" "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .build(); p.cargo("build -v").run(); } @@ -1266,7 +1347,8 @@ fn transitive_dep_host() { [build-dependencies.b] path = "b" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .file( "a/Cargo.toml", @@ -1278,7 +1360,8 @@ fn transitive_dep_host() { links = "foo" build = "build.rs" "#, - ).file("a/build.rs", "fn main() {}") + ) + .file("a/build.rs", "fn main() {}") .file("a/src/lib.rs", "") .file( "b/Cargo.toml", @@ -1295,7 +1378,8 @@ fn transitive_dep_host() { [dependencies.a] path = "../a" "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .build(); p.cargo("build").run(); } @@ -1312,7 +1396,8 @@ fn test_a_lib_with_a_build_command() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" include!(concat!(env!("OUT_DIR"), "/foo.rs")); @@ -1324,7 +1409,8 @@ fn test_a_lib_with_a_build_command() { assert_eq!(foo(), 1); } "#, - ).file( + ) + .file( "build.rs", r#" use std::env; @@ -1339,7 +1425,8 @@ fn test_a_lib_with_a_build_command() { ").unwrap(); } "#, - ).build(); + ) + .build(); p.cargo("test").run(); } @@ -1357,7 +1444,8 @@ fn test_dev_dep_build_script() { [dev-dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -1367,7 +1455,8 @@ fn test_dev_dep_build_script() { authors = [] build = "build.rs" "#, - ).file("a/build.rs", "fn main() {}") + ) + .file("a/build.rs", "fn main() {}") .file("a/src/lib.rs", "") .build(); @@ -1390,7 +1479,8 @@ fn build_script_with_dynamic_native_dependency() { name = "builder" crate-type = ["dylib"] "#, - ).file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") + ) + .file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") .build(); let foo = project() @@ -1406,7 +1496,8 @@ fn build_script_with_dynamic_native_dependency() { [build-dependencies.bar] path = "bar" "#, - ).file("build.rs", "extern crate bar; fn main() { bar::bar() }") + ) + .file("build.rs", "extern crate bar; fn main() { bar::bar() }") .file("src/lib.rs", "") .file( "bar/Cargo.toml", @@ -1417,7 +1508,8 @@ fn build_script_with_dynamic_native_dependency() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "bar/build.rs", r#" use std::env; @@ -1440,7 +1532,8 @@ fn build_script_with_dynamic_native_dependency() { println!("cargo:rustc-link-search=native={}", out_dir.display()); } "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" pub fn bar() { @@ -1450,7 +1543,8 @@ fn build_script_with_dynamic_native_dependency() { unsafe { foo() } } "#, - ).build(); + ) + .build(); build .cargo("build -v") @@ -1476,7 +1570,8 @@ fn profile_and_opt_level_set_correctly() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -1488,7 +1583,8 @@ fn profile_and_opt_level_set_correctly() { assert_eq!(env::var("DEBUG").unwrap(), "false"); } "#, - ).build(); + ) + .build(); p.cargo("bench").run(); } @@ -1505,7 +1601,8 @@ fn profile_debug_0() { [profile.dev] debug = 0 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -1517,7 +1614,8 @@ fn profile_debug_0() { assert_eq!(env::var("DEBUG").unwrap(), "false"); } "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -1536,7 +1634,8 @@ fn build_script_with_lto() { [profile.dev] lto = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .build(); p.cargo("build").run(); @@ -1560,19 +1659,22 @@ fn test_duplicate_deps() { [build-dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate bar; fn main() { bar::do_nothing() } "#, - ).file( + ) + .file( "build.rs", r#" extern crate bar; fn main() { bar::do_nothing() } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn do_nothing() {}") .build(); @@ -1591,11 +1693,13 @@ fn cfg_feedback() { authors = [] build = "build.rs" "#, - ).file("src/main.rs", "#[cfg(foo)] fn main() {}") + ) + .file("src/main.rs", "#[cfg(foo)] fn main() {}") .file( "build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#, - ).build(); + ) + .build(); p.cargo("build -v").run(); } @@ -1614,7 +1718,8 @@ fn cfg_override() { links = "a" build = "build.rs" "#, - ).file("src/main.rs", "#[cfg(foo)] fn main() {}") + ) + .file("src/main.rs", "#[cfg(foo)] fn main() {}") .file("build.rs", "") .file( ".cargo/config", @@ -1625,7 +1730,8 @@ fn cfg_override() { "#, target ), - ).build(); + ) + .build(); p.cargo("build -v").run(); } @@ -1642,10 +1748,12 @@ fn cfg_test() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#, - ).file( + ) + .file( "src/lib.rs", r#" /// @@ -1666,7 +1774,8 @@ fn cfg_test() { foo() } "#, - ).file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") + ) + .file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") .build(); p.cargo("test -v") .with_stderr( @@ -1682,7 +1791,8 @@ fn cfg_test() { [RUNNING] `[..]/test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", - ).with_stdout_contains("test test_foo ... ok") + ) + .with_stdout_contains("test test_foo ... ok") .with_stdout_contains("test test_bar ... ok") .with_stdout_contains_n("test [..] ... ok", 3) .run(); @@ -1703,10 +1813,12 @@ fn cfg_doc() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#, - ).file("src/lib.rs", "#[cfg(foo)] pub fn foo() {}") + ) + .file("src/lib.rs", "#[cfg(foo)] pub fn foo() {}") .file( "bar/Cargo.toml", r#" @@ -1716,10 +1828,12 @@ fn cfg_doc() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "bar/build.rs", r#"fn main() { println!("cargo:rustc-cfg=bar"); }"#, - ).file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") + ) + .file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") .build(); p.cargo("doc").run(); assert!(p.root().join("target/doc").is_dir()); @@ -1740,7 +1854,8 @@ fn cfg_override_test() { build = "build.rs" links = "a" "#, - ).file("build.rs", "") + ) + .file("build.rs", "") .file( ".cargo/config", &format!( @@ -1750,7 +1865,8 @@ fn cfg_override_test() { "#, rustc_host() ), - ).file( + ) + .file( "src/lib.rs", r#" /// @@ -1771,7 +1887,8 @@ fn cfg_override_test() { foo() } "#, - ).file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") + ) + .file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") .build(); p.cargo("test -v") .with_stderr( @@ -1785,7 +1902,8 @@ fn cfg_override_test() { [RUNNING] `[..]/test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --cfg foo[..]", - ).with_stdout_contains("test test_foo ... ok") + ) + .with_stdout_contains("test test_foo ... ok") .with_stdout_contains("test test_bar ... ok") .with_stdout_contains_n("test [..] ... ok", 3) .run(); @@ -1807,7 +1925,8 @@ fn cfg_override_doc() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( ".cargo/config", &format!( r#" @@ -1818,7 +1937,8 @@ fn cfg_override_doc() { "#, target = rustc_host() ), - ).file("build.rs", "") + ) + .file("build.rs", "") .file("src/lib.rs", "#[cfg(foo)] pub fn foo() {}") .file( "bar/Cargo.toml", @@ -1830,7 +1950,8 @@ fn cfg_override_doc() { build = "build.rs" links = "b" "#, - ).file("bar/build.rs", "") + ) + .file("bar/build.rs", "") .file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") .build(); p.cargo("doc").run(); @@ -1851,7 +1972,8 @@ fn env_build() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "src/main.rs", r#" const FOO: &'static str = env!("FOO"); @@ -1859,10 +1981,12 @@ fn env_build() { println!("{}", FOO); } "#, - ).file( + ) + .file( "build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#, - ).build(); + ) + .build(); p.cargo("build -v").run(); p.cargo("run -v").with_stdout("foo\n").run(); } @@ -1879,13 +2003,16 @@ fn env_test() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#, - ).file( + ) + .file( "src/lib.rs", r#"pub const FOO: &'static str = env!("FOO"); "#, - ).file( + ) + .file( "tests/test.rs", r#" extern crate foo; @@ -1895,7 +2022,8 @@ fn env_test() { assert_eq!("foo", foo::FOO); } "#, - ).build(); + ) + .build(); p.cargo("test -v") .with_stderr( "\ @@ -1910,7 +2038,8 @@ fn env_test() { [RUNNING] `[..]/test-[..][EXE]` [DOCTEST] foo [RUNNING] [..] --crate-name foo[..]", - ).with_stdout_contains_n("running 0 tests", 2) + ) + .with_stdout_contains_n("running 0 tests", 2) .with_stdout_contains("test test_foo ... ok") .run(); } @@ -1927,16 +2056,19 @@ fn env_doc() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "src/main.rs", r#" const FOO: &'static str = env!("FOO"); fn main() {} "#, - ).file( + ) + .file( "build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#, - ).build(); + ) + .build(); p.cargo("doc -v").run(); } @@ -1954,7 +2086,8 @@ fn flags_go_into_tests() { [dependencies] b = { path = "b" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("tests/foo.rs", "") .file( "b/Cargo.toml", @@ -1966,7 +2099,8 @@ fn flags_go_into_tests() { [dependencies] a = { path = "../a" } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -1976,7 +2110,8 @@ fn flags_go_into_tests() { authors = [] build = "build.rs" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", r#" @@ -1984,7 +2119,8 @@ fn flags_go_into_tests() { println!("cargo:rustc-link-search=test"); } "#, - ).build(); + ) + .build(); p.cargo("test -v --test=foo") .with_stderr( @@ -2000,7 +2136,8 @@ fn flags_go_into_tests() { [RUNNING] `rustc [..] tests/foo.rs [..] -L test[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/foo-[..][EXE]`", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); p.cargo("test -v -pb --lib") @@ -2011,7 +2148,8 @@ fn flags_go_into_tests() { [RUNNING] `rustc [..] b/src/lib.rs [..] -L test[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]/b-[..][EXE]`", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); } @@ -2030,7 +2168,8 @@ fn diamond_passes_args_only_once() { a = { path = "a" } b = { path = "b" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("tests/foo.rs", "") .file( "a/Cargo.toml", @@ -2043,7 +2182,8 @@ fn diamond_passes_args_only_once() { b = { path = "../b" } c = { path = "../c" } "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "b/Cargo.toml", r#" @@ -2054,7 +2194,8 @@ fn diamond_passes_args_only_once() { [dependencies] c = { path = "../c" } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file( "c/Cargo.toml", r#" @@ -2064,14 +2205,16 @@ fn diamond_passes_args_only_once() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "c/build.rs", r#" fn main() { println!("cargo:rustc-link-search=native=test"); } "#, - ).file("c/src/lib.rs", "") + ) + .file("c/src/lib.rs", "") .build(); p.cargo("build -v") @@ -2089,7 +2232,8 @@ fn diamond_passes_args_only_once() { [RUNNING] `[..]rlib -L native=test` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2106,7 +2250,8 @@ fn adding_an_override_invalidates() { links = "foo" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file(".cargo/config", "") .file( "build.rs", @@ -2115,7 +2260,8 @@ fn adding_an_override_invalidates() { println!("cargo:rustc-link-search=native=foo"); } "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_stderr( @@ -2126,7 +2272,8 @@ fn adding_an_override_invalidates() { [RUNNING] `rustc [..] -L native=foo` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); File::create(p.root().join(".cargo/config")) .unwrap() @@ -2137,8 +2284,10 @@ fn adding_an_override_invalidates() { rustc-link-search = [\"native=bar\"] ", target - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); p.cargo("build -v") .with_stderr( @@ -2147,7 +2296,8 @@ fn adding_an_override_invalidates() { [RUNNING] `rustc [..] -L native=bar` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2164,7 +2314,8 @@ fn changing_an_override_invalidates() { links = "foo" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", &format!( @@ -2174,7 +2325,8 @@ fn changing_an_override_invalidates() { ", target ), - ).file("build.rs", "") + ) + .file("build.rs", "") .build(); p.cargo("build -v") @@ -2184,7 +2336,8 @@ fn changing_an_override_invalidates() { [RUNNING] `rustc [..] -L native=foo` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); File::create(p.root().join(".cargo/config")) .unwrap() @@ -2195,8 +2348,10 @@ fn changing_an_override_invalidates() { rustc-link-search = [\"native=bar\"] ", target - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); p.cargo("build -v") .with_stderr( @@ -2205,7 +2360,8 @@ fn changing_an_override_invalidates() { [RUNNING] `rustc [..] -L native=bar` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2223,7 +2379,8 @@ fn fresh_builds_possible_with_link_libs() { links = "nativefoo" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", &format!( @@ -2235,7 +2392,8 @@ fn fresh_builds_possible_with_link_libs() { ", target ), - ).file("build.rs", "") + ) + .file("build.rs", "") .build(); p.cargo("build -v") @@ -2245,7 +2403,8 @@ fn fresh_builds_possible_with_link_libs() { [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build -v") .env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint=info") @@ -2254,7 +2413,8 @@ fn fresh_builds_possible_with_link_libs() { [FRESH] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2272,7 +2432,8 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() { links = "foo" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", &format!( @@ -2286,7 +2447,8 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() { ", target ), - ).file("build.rs", "") + ) + .file("build.rs", "") .build(); p.cargo("build -v") @@ -2296,7 +2458,8 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() { [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build -v") .env("RUST_LOG", "cargo::ops::cargo_rustc::fingerprint=info") @@ -2305,7 +2468,8 @@ fn fresh_builds_possible_with_multiple_metadata_overrides() { [FRESH] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2320,7 +2484,8 @@ fn rebuild_only_on_explicit_paths() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2329,7 +2494,8 @@ fn rebuild_only_on_explicit_paths() { println!("cargo:rerun-if-changed=bar"); } "#, - ).build(); + ) + .build(); p.cargo("build -v").run(); @@ -2343,7 +2509,8 @@ fn rebuild_only_on_explicit_paths() { [RUNNING] `rustc [..] src/lib.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); sleep_ms(1000); File::create(p.root().join("foo")).unwrap(); @@ -2360,7 +2527,8 @@ fn rebuild_only_on_explicit_paths() { [RUNNING] `rustc [..] src/lib.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); println!("run with2"); p.cargo("build -v") @@ -2369,7 +2537,8 @@ fn rebuild_only_on_explicit_paths() { [FRESH] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); sleep_ms(1000); @@ -2382,7 +2551,8 @@ fn rebuild_only_on_explicit_paths() { [FRESH] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // but changing dependent files does println!("run foo change"); @@ -2395,7 +2565,8 @@ fn rebuild_only_on_explicit_paths() { [RUNNING] `rustc [..] src/lib.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // .. as does deleting a file println!("run foo delete"); @@ -2408,7 +2579,8 @@ fn rebuild_only_on_explicit_paths() { [RUNNING] `rustc [..] src/lib.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2424,7 +2596,8 @@ fn doctest_receives_build_link_args() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -2435,7 +2608,8 @@ fn doctest_receives_build_link_args() { links = "bar" build = "build.rs" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", r#" @@ -2443,12 +2617,14 @@ fn doctest_receives_build_link_args() { println!("cargo:rustc-link-search=native=bar"); } "#, - ).build(); + ) + .build(); p.cargo("test -v") .with_stderr_contains( "[RUNNING] `rustdoc --test [..] --crate-name foo [..]-L native=bar[..]`", - ).run(); + ) + .run(); } #[test] @@ -2466,7 +2642,8 @@ fn please_respect_the_dag() { [dependencies] a = { path = 'a' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2474,7 +2651,8 @@ fn please_respect_the_dag() { println!("cargo:rustc-link-search=native=foo"); } "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -2484,7 +2662,8 @@ fn please_respect_the_dag() { links = "bar" build = "build.rs" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", r#" @@ -2492,7 +2671,8 @@ fn please_respect_the_dag() { println!("cargo:rustc-link-search=native=bar"); } "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_stderr_contains("[RUNNING] `rustc [..] -L native=foo -L native=bar[..]`") @@ -2511,7 +2691,8 @@ fn non_utf8_output() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#" use std::io::prelude::*; @@ -2528,7 +2709,8 @@ fn non_utf8_output() { out.write_all(b"\xff\xff\n").unwrap(); } "#, - ).file("src/main.rs", "#[cfg(foo)] fn main() {}") + ) + .file("src/main.rs", "#[cfg(foo)] fn main() {}") .build(); p.cargo("build -v").run(); @@ -2548,14 +2730,16 @@ fn custom_target_dir() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" [build] target-dir = 'test' "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -2564,7 +2748,8 @@ fn custom_target_dir() { authors = [] build = "build.rs" "#, - ).file("a/build.rs", "fn main() {}") + ) + .file("a/build.rs", "fn main() {}") .file("a/src/lib.rs", "") .build(); @@ -2588,10 +2773,12 @@ fn panic_abort_with_build_scripts() { [dependencies] a = { path = "a" } "#, - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate a;", - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file( "a/Cargo.toml", r#" @@ -2604,11 +2791,13 @@ fn panic_abort_with_build_scripts() { [build-dependencies] b = { path = "../b" } "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/build.rs", "#[allow(unused_extern_crates)] extern crate b; fn main() {}", - ).file( + ) + .file( "b/Cargo.toml", r#" [project] @@ -2616,7 +2805,8 @@ fn panic_abort_with_build_scripts() { version = "0.5.0" authors = [] "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .build(); p.cargo("build -v --release").run(); @@ -2640,7 +2830,8 @@ fn warnings_emitted() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2649,7 +2840,8 @@ fn warnings_emitted() { println!("cargo:warning=bar"); } "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_stderr( @@ -2662,7 +2854,8 @@ warning: bar [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2676,7 +2869,8 @@ fn warnings_hidden_for_upstream() { println!("cargo:warning=bar"); } "#, - ).file( + ) + .file( "Cargo.toml", r#" [project] @@ -2685,7 +2879,8 @@ fn warnings_hidden_for_upstream() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); let p = project() @@ -2700,7 +2895,8 @@ fn warnings_hidden_for_upstream() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") @@ -2717,7 +2913,8 @@ fn warnings_hidden_for_upstream() { [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2731,7 +2928,8 @@ fn warnings_printed_on_vv() { println!("cargo:warning=bar"); } "#, - ).file( + ) + .file( "Cargo.toml", r#" [project] @@ -2740,7 +2938,8 @@ fn warnings_printed_on_vv() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); let p = project() @@ -2755,7 +2954,8 @@ fn warnings_printed_on_vv() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -vv") @@ -2774,7 +2974,8 @@ warning: bar [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2789,7 +2990,8 @@ fn output_shows_on_vv() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2800,7 +3002,8 @@ fn output_shows_on_vv() { std::io::stdout().write_all(b"stdout\n").unwrap(); } "#, - ).build(); + ) + .build(); p.cargo("build -vv") .with_stdout("[foo 0.5.0] stdout") @@ -2813,7 +3016,8 @@ fn output_shows_on_vv() { [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2831,7 +3035,8 @@ fn links_with_dots() { build = "build.rs" links = "a.b" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2839,7 +3044,8 @@ fn links_with_dots() { println!("cargo:rustc-link-search=bar") } "#, - ).file( + ) + .file( ".cargo/config", &format!( r#" @@ -2848,7 +3054,8 @@ fn links_with_dots() { "#, target ), - ).build(); + ) + .build(); p.cargo("build -v") .with_stderr_contains("[RUNNING] `rustc --crate-name foo [..] [..] -L foo[..]`") @@ -2867,7 +3074,8 @@ fn rustc_and_rustdoc_set_correctly() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2878,7 +3086,8 @@ fn rustc_and_rustdoc_set_correctly() { assert_eq!(env::var("RUSTDOC").unwrap(), "rustdoc"); } "#, - ).build(); + ) + .build(); p.cargo("bench").run(); } @@ -2894,7 +3103,8 @@ fn cfg_env_vars_available() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -2909,7 +3119,8 @@ fn cfg_env_vars_available() { } } "#, - ).build(); + ) + .build(); p.cargo("bench").run(); } @@ -2928,14 +3139,16 @@ fn switch_features_rerun() { [features] foo = [] "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() { println!(include_str!(concat!(env!("OUT_DIR"), "/output"))); } "#, - ).file( + ) + .file( "build.rs", r#" use std::env; @@ -2955,7 +3168,8 @@ fn switch_features_rerun() { } } "#, - ).build(); + ) + .build(); p.cargo("run -v --features=foo").with_stdout("foo\n").run(); p.cargo("run -v").with_stdout("bar\n").run(); @@ -2974,14 +3188,16 @@ fn assume_build_script_when_build_rs_present() { } } "#, - ).file( + ) + .file( "build.rs", r#" fn main() { println!("cargo:rustc-cfg=foo"); } "#, - ).build(); + ) + .build(); p.cargo("run -v").run(); } @@ -2998,7 +3214,8 @@ fn if_build_set_to_false_dont_treat_build_rs_as_build_script() { authors = [] build = false "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() { @@ -3007,14 +3224,16 @@ fn if_build_set_to_false_dont_treat_build_rs_as_build_script() { } } "#, - ).file( + ) + .file( "build.rs", r#" fn main() { println!("cargo:rustc-cfg=foo"); } "#, - ).build(); + ) + .build(); p.cargo("run -v").run(); } @@ -3034,14 +3253,16 @@ fn deterministic_rustc_dependency_flags() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#" fn main() { println!("cargo:rustc-flags=-L native=test1"); } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); Package::new("dep2", "0.1.0") .file( @@ -3053,14 +3274,16 @@ fn deterministic_rustc_dependency_flags() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#" fn main() { println!("cargo:rustc-flags=-L native=test2"); } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); Package::new("dep3", "0.1.0") .file( @@ -3072,14 +3295,16 @@ fn deterministic_rustc_dependency_flags() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#" fn main() { println!("cargo:rustc-flags=-L native=test3"); } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); Package::new("dep4", "0.1.0") .file( @@ -3091,14 +3316,16 @@ fn deterministic_rustc_dependency_flags() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", r#" fn main() { println!("cargo:rustc-flags=-L native=test4"); } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); let p = project() @@ -3116,7 +3343,8 @@ fn deterministic_rustc_dependency_flags() { dep3 = "*" dep4 = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v") @@ -3125,7 +3353,8 @@ fn deterministic_rustc_dependency_flags() { [RUNNING] `rustc --crate-name foo [..] -L native=test1 -L native=test2 \ -L native=test3 -L native=test4` ", - ).run(); + ) + .run(); } #[test] @@ -3148,7 +3377,8 @@ fn links_duplicates_with_cycle() { [dev-dependencies] b = { path = "b" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "") .file( "a/Cargo.toml", @@ -3160,7 +3390,8 @@ fn links_duplicates_with_cycle() { links = "a" build = "build.rs" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file("a/build.rs", "") .file( "b/Cargo.toml", @@ -3173,7 +3404,8 @@ fn links_duplicates_with_cycle() { [dependencies] foo = { path = ".." } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .build(); p.cargo("build").with_status(101) @@ -3221,7 +3453,8 @@ fn _rename_with_link_search_path(cross: bool) { [lib] crate-type = ["cdylib"] "#, - ).file( + ) + .file( "src/lib.rs", "#[no_mangle] pub extern fn cargo_test_foo() {}", ); @@ -3264,7 +3497,8 @@ fn _rename_with_link_search_path(cross: bool) { dst.parent().unwrap().display()); } "#, - ).file( + ) + .file( "src/main.rs", r#" extern { @@ -3284,7 +3518,11 @@ fn _rename_with_link_search_path(cross: bool) { // original path in `p` so we want to make sure that it can't find it (hence // the deletion). let root = if cross { - p.root().join("target").join(cross_compile::alternate()).join("debug").join("deps") + p.root() + .join("target") + .join(cross_compile::alternate()) + .join("debug") + .join("deps") } else { p.root().join("target").join("debug").join("deps") }; @@ -3338,7 +3576,8 @@ fn _rename_with_link_search_path(cross: bool) { [FINISHED] [..] [RUNNING] [..] ", - ).run(); + ) + .run(); } #[test] @@ -3358,7 +3597,8 @@ fn optional_build_script_dep() { [build-dependencies] bar = { path = "bar", optional = true } "#, - ).file( + ) + .file( "build.rs", r#" #[cfg(feature = "bar")] @@ -3372,7 +3612,8 @@ fn optional_build_script_dep() { println!("cargo:rustc-env=FOO=0"); } "#, - ).file( + ) + .file( "src/main.rs", r#" #[cfg(feature = "bar")] @@ -3382,7 +3623,8 @@ fn optional_build_script_dep() { println!("{}", env!("FOO")); } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("bar/src/lib.rs", "pub fn bar() -> u32 { 1 }"); let p = p.build(); @@ -3407,7 +3649,8 @@ fn optional_build_dep_and_required_normal_dep() { [build-dependencies] bar = { path = "./bar" } "#, - ).file("build.rs", "extern crate bar; fn main() { bar::bar(); }") + ) + .file("build.rs", "extern crate bar; fn main() { bar::bar(); }") .file( "src/main.rs", r#" @@ -3423,7 +3666,8 @@ fn optional_build_dep_and_required_normal_dep() { } } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("bar/src/lib.rs", "pub fn bar() -> u32 { 1 }"); let p = p.build(); @@ -3435,7 +3679,8 @@ fn optional_build_dep_and_required_normal_dep() { [COMPILING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]foo[EXE]`", - ).run(); + ) + .run(); p.cargo("run --all-features") .with_stdout("1") @@ -3444,5 +3689,6 @@ fn optional_build_dep_and_required_normal_dep() { [COMPILING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]foo[EXE]`", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index ca4caf2111b..612ae44d613 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -14,7 +14,8 @@ fn rerun_if_env_changes() { println!("cargo:rerun-if-env-changed=FOO"); } "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -22,7 +23,8 @@ fn rerun_if_env_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .env("FOO", "bar") .with_stderr( @@ -30,7 +32,8 @@ fn rerun_if_env_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .env("FOO", "baz") .with_stderr( @@ -38,7 +41,8 @@ fn rerun_if_env_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .env("FOO", "baz") .with_stderr("[FINISHED] [..]") @@ -49,7 +53,8 @@ fn rerun_if_env_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -64,7 +69,8 @@ fn rerun_if_env_or_file_changes() { println!("cargo:rerun-if-changed=foo"); } "#, - ).file("foo", "") + ) + .file("foo", "") .build(); p.cargo("build") @@ -73,7 +79,8 @@ fn rerun_if_env_or_file_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .env("FOO", "bar") .with_stderr( @@ -81,7 +88,8 @@ fn rerun_if_env_or_file_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .env("FOO", "bar") .with_stderr("[FINISHED] [..]") @@ -95,5 +103,6 @@ fn rerun_if_env_or_file_changes() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index a2b98fe20bd..5c88e02453f 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -11,7 +11,8 @@ fn alias_incorrect_config_type() { [alias] b-cargo-test = 5 "#, - ).build(); + ) + .build(); p.cargo("b-cargo-test -v") .with_status(101) @@ -19,7 +20,8 @@ fn alias_incorrect_config_type() { "\ [ERROR] invalid configuration for key `alias.b-cargo-test` expected a list, but found a integer for [..]", - ).run(); + ) + .run(); } #[test] @@ -33,14 +35,16 @@ fn alias_config() { [alias] b-cargo-test = "build" "#, - ).build(); + ) + .build(); p.cargo("b-cargo-test -v") .with_stderr_contains( "\ [COMPILING] foo v0.5.0 [..] [RUNNING] `rustc --crate-name foo [..]", - ).run(); + ) + .run(); } #[test] @@ -55,14 +59,16 @@ fn recursive_alias() { b-cargo-test = "build" a-cargo-test = ["b-cargo-test", "-v"] "#, - ).build(); + ) + .build(); p.cargo("a-cargo-test") .with_stderr_contains( "\ [COMPILING] foo v0.5.0 [..] [RUNNING] `rustc --crate-name foo [..]", - ).run(); + ) + .run(); } #[test] @@ -76,7 +82,8 @@ fn alias_list_test() { [alias] b-cargo-test = ["build", "--release"] "#, - ).build(); + ) + .build(); p.cargo("b-cargo-test -v") .with_stderr_contains("[COMPILING] foo v0.5.0 [..]") @@ -95,7 +102,8 @@ fn alias_with_flags_config() { [alias] b-cargo-test = "build --release" "#, - ).build(); + ) + .build(); p.cargo("b-cargo-test -v") .with_stderr_contains("[COMPILING] foo v0.5.0 [..]") @@ -114,7 +122,8 @@ fn alias_cannot_shadow_builtin_command() { [alias] build = "fetch" "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -123,7 +132,8 @@ fn alias_cannot_shadow_builtin_command() { [COMPILING] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -137,7 +147,8 @@ fn alias_override_builtin_alias() { [alias] b = "run" "#, - ).build(); + ) + .build(); p.cargo("b") .with_stderr( @@ -146,7 +157,8 @@ fn alias_override_builtin_alias() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/foo[EXE]` ", - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/cargo_command.rs b/tests/testsuite/cargo_command.rs index c20b5f4be86..2676fb66787 100644 --- a/tests/testsuite/cargo_command.rs +++ b/tests/testsuite/cargo_command.rs @@ -4,11 +4,11 @@ use std::io::prelude::*; use std::path::{Path, PathBuf}; use std::str; -use cargo; use crate::support::cargo_process; use crate::support::paths::{self, CargoPathExt}; use crate::support::registry::Package; use crate::support::{basic_bin_manifest, basic_manifest, cargo_exe, project, Project}; +use cargo; #[cfg_attr(windows, allow(dead_code))] enum FakeKind<'a> { @@ -64,9 +64,13 @@ fn path() -> Vec { fn list_commands_with_descriptions() { let p = project().build(); p.cargo("--list") - .with_stdout_contains(" build Compile a local package and all of its dependencies") + .with_stdout_contains( + " build Compile a local package and all of its dependencies", + ) // assert read-manifest prints the right one-line description followed by another command, indented. - .with_stdout_contains(" read-manifest Print a JSON representation of a Cargo.toml manifest.") + .with_stdout_contains( + " read-manifest Print a JSON representation of a Cargo.toml manifest.", + ) .run(); } @@ -83,7 +87,10 @@ fn list_command_looks_at_path() { let mut path = path(); path.push(proj.root().join("path-test")); let path = env::join_paths(path.iter()).unwrap(); - let output = cargo_process("-v --list").env("PATH", &path).exec_with_output().unwrap(); + let output = cargo_process("-v --list") + .env("PATH", &path) + .exec_with_output() + .unwrap(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("\n 1 "), @@ -109,7 +116,10 @@ fn list_command_resolves_symlinks() { let mut path = path(); path.push(proj.root().join("path-test")); let path = env::join_paths(path.iter()).unwrap(); - let output = cargo_process("-v --list").env("PATH", &path).exec_with_output().unwrap(); + let output = cargo_process("-v --list") + .env("PATH", &path) + .exec_with_output() + .unwrap(); let output = str::from_utf8(&output.stdout).unwrap(); assert!( output.contains("\n 2 "), @@ -128,7 +138,8 @@ error: no such subcommand: `biuld` Did you mean `build`? ", - ).run(); + ) + .run(); // But, if we actually have `biuld`, it must work! // https://github.com/rust-lang/cargo/issues/5201 @@ -140,7 +151,8 @@ error: no such subcommand: `biuld` println!("Similar, but not identical to, build"); } "#, - ).publish(); + ) + .publish(); cargo_process("install cargo-biuld").run(); cargo_process("biuld") @@ -149,7 +161,8 @@ error: no such subcommand: `biuld` cargo_process("--list") .with_stdout_contains( " build Compile a local package and all of its dependencies\n", - ).with_stdout_contains(" biuld\n") + ) + .with_stdout_contains(" biuld\n") .run(); } @@ -163,7 +176,8 @@ fn find_closest_dont_correct_nonsense() { "[ERROR] no such subcommand: \ `there-is-no-way-that-there-is-a-command-close-to-this` ", - ).run(); + ) + .run(); } #[test] @@ -188,7 +202,8 @@ fn override_cargo_home() { email = "bar" git = false "#, - ).unwrap(); + ) + .unwrap(); cargo_process("new foo") .env("USER", "foo") @@ -252,7 +267,8 @@ fn cargo_subcommand_args() { println!("{:?}", args); } "#, - ).build(); + ) + .build(); p.cargo("build").run(); let cargo_foo_bin = p.bin("cargo-foo"); @@ -291,7 +307,8 @@ fn cargo_help_external_subcommand() { println!("fancy help output"); } }"#, - ).publish(); + ) + .publish(); cargo_process("install cargo-fake-help").run(); cargo_process("help fake-help") .with_stdout("fancy help output\n") @@ -303,7 +320,8 @@ fn explain() { cargo_process("--explain E0001") .with_stdout_contains( "This error suggests that the expression arm corresponding to the noted pattern", - ).run(); + ) + .run(); } // Test that the output of 'cargo -Z help' shows a different help screen with @@ -313,5 +331,6 @@ fn z_flags_help() { cargo_process("-Z help") .with_stdout_contains( " -Z unstable-options -- Allow the usage of unstable options such as --registry", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/cargo_features.rs b/tests/testsuite/cargo_features.rs index b38b0c3a538..aa1828b92f9 100644 --- a/tests/testsuite/cargo_features.rs +++ b/tests/testsuite/cargo_features.rs @@ -12,7 +12,8 @@ fn feature_required() { authors = [] im-a-teapot = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") .masquerade_as_nightly_cargo() @@ -29,7 +30,8 @@ Caused by: consider adding `cargo-features = [\"test-dummy-unstable\"]` to the manifest ", - ).run(); + ) + .run(); p.cargo("build") .with_status(101) @@ -47,7 +49,8 @@ this Cargo does not support nightly features, but if you switch to nightly channel you can add `cargo-features = [\"test-dummy-unstable\"]` to enable this feature ", - ).run(); + ) + .run(); } #[test] @@ -63,7 +66,8 @@ fn unknown_feature() { version = "0.0.1" authors = [] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") .with_status(101) @@ -74,7 +78,8 @@ error: failed to parse manifest at `[..]` Caused by: unknown cargo feature `foo` ", - ).run(); + ) + .run(); } #[test] @@ -90,7 +95,8 @@ fn stable_feature_warns() { version = "0.0.1" authors = [] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") .with_stderr( @@ -100,7 +106,8 @@ necessary to be listed in the manifest [COMPILING] a [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -117,7 +124,8 @@ fn nightly_feature_requires_nightly() { authors = [] im-a-teapot = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") .masquerade_as_nightly_cargo() @@ -126,7 +134,8 @@ fn nightly_feature_requires_nightly() { [COMPILING] a [..] [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .with_status(101) @@ -138,7 +147,8 @@ Caused by: the cargo feature `test-dummy-unstable` requires a nightly version of Cargo, \ but this is the `stable` channel ", - ).run(); + ) + .run(); } #[test] @@ -155,7 +165,8 @@ fn nightly_feature_requires_nightly_in_dep() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -167,7 +178,8 @@ fn nightly_feature_requires_nightly_in_dep() { authors = [] im-a-teapot = true "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build") .masquerade_as_nightly_cargo() @@ -177,7 +189,8 @@ fn nightly_feature_requires_nightly_in_dep() { [COMPILING] b [..] [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .with_status(101) @@ -195,7 +208,8 @@ Caused by: the cargo feature `test-dummy-unstable` requires a nightly version of Cargo, \ but this is the `stable` channel ", - ).run(); + ) + .run(); } #[test] @@ -212,7 +226,8 @@ fn cant_publish() { authors = [] im-a-teapot = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") .masquerade_as_nightly_cargo() @@ -221,7 +236,8 @@ fn cant_publish() { [COMPILING] a [..] [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build") .with_status(101) @@ -233,7 +249,8 @@ Caused by: the cargo feature `test-dummy-unstable` requires a nightly version of Cargo, \ but this is the `stable` channel ", - ).run(); + ) + .run(); } #[test] @@ -250,7 +267,8 @@ fn z_flags_rejected() { authors = [] im-a-teapot = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -Zprint-im-a-teapot") .with_status(101) @@ -271,7 +289,8 @@ fn z_flags_rejected() { [COMPILING] a [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -289,7 +308,8 @@ fn publish_allowed() { version = "0.0.1" authors = [] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("publish --index") .arg(publish::registry().to_string()) diff --git a/tests/testsuite/cfg.rs b/tests/testsuite/cfg.rs index 241e6aba2f8..36866cc27d8 100644 --- a/tests/testsuite/cfg.rs +++ b/tests/testsuite/cfg.rs @@ -1,10 +1,10 @@ use std::fmt; use std::str::FromStr; -use cargo::util::{Cfg, CfgExpr}; use crate::support::registry::Package; use crate::support::rustc_host; use crate::support::{basic_manifest, project}; +use cargo::util::{Cfg, CfgExpr}; macro_rules! c { ($a:ident) => { @@ -156,7 +156,8 @@ fn cfg_easy() { [target."cfg(windows)".dependencies] b = { path = 'b' } "#, - ).file("src/lib.rs", "extern crate b;") + ) + .file("src/lib.rs", "extern crate b;") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -181,7 +182,8 @@ fn dont_include() { "#, other_family ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -191,7 +193,8 @@ fn dont_include() { [COMPILING] a v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -214,10 +217,12 @@ fn works_through_the_registry() { [dependencies] bar = "0.1.0" "#, - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate bar;", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -231,7 +236,8 @@ fn works_through_the_registry() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -259,10 +265,12 @@ fn ignore_version_from_other_platform() { "#, this_family, other_family ), - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate bar;", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -274,7 +282,8 @@ fn ignore_version_from_other_platform() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -291,7 +300,8 @@ fn bad_target_spec() { [target.'cfg(4)'.dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -306,7 +316,8 @@ Caused by: Caused by: unexpected character in cfg `4`, [..] ", - ).run(); + ) + .run(); } #[test] @@ -323,7 +334,8 @@ fn bad_target_spec2() { [target.'cfg(bar =)'.dependencies] baz = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -338,7 +350,8 @@ Caused by: Caused by: expected a string, found nothing ", - ).run(); + ) + .run(); } #[test] @@ -369,7 +382,8 @@ fn multiple_match_ok() { "#, rustc_host() ), - ).file("src/lib.rs", "extern crate b;") + ) + .file("src/lib.rs", "extern crate b;") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -390,7 +404,8 @@ fn any_ok() { [target."cfg(any(windows, unix))".dependencies] b = { path = 'b' } "#, - ).file("src/lib.rs", "extern crate b;") + ) + .file("src/lib.rs", "extern crate b;") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -399,11 +414,7 @@ fn any_ok() { // https://github.com/rust-lang/cargo/issues/5313 #[test] -#[cfg(all( - target_arch = "x86_64", - target_os = "linux", - target_env = "gnu" -))] +#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))] fn cfg_looks_at_rustflags_for_target() { let p = project() .file( @@ -417,7 +428,8 @@ fn cfg_looks_at_rustflags_for_target() { [target.'cfg(with_b)'.dependencies] b = { path = 'b' } "#, - ).file( + ) + .file( "src/main.rs", r#" #[cfg(with_b)] @@ -425,7 +437,8 @@ fn cfg_looks_at_rustflags_for_target() { fn main() { b::foo(); } "#, - ).file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) + ) + .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "pub fn foo() {}") .build(); diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index c2bc8561378..c4d83244398 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -1,10 +1,10 @@ use std::fmt::{self, Write}; -use glob::glob; use crate::support::install::exe; use crate::support::paths::CargoPathExt; use crate::support::registry::Package; use crate::support::{basic_manifest, project}; +use glob::glob; #[test] fn check_success() { @@ -20,10 +20,12 @@ fn check_success() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }", - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -47,10 +49,12 @@ fn check_fail() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bar; fn main() { ::bar::baz(42); }", - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -74,7 +78,8 @@ fn custom_derive() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", r#" #[macro_use] @@ -92,7 +97,8 @@ fn main() { a.b(); } "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file( @@ -105,7 +111,8 @@ fn main() { [lib] proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate proc_macro; @@ -117,7 +124,8 @@ pub fn derive(_input: TokenStream) -> TokenStream { format!("impl B for A {{ fn b(&self) {{}} }}").parse().unwrap() } "#, - ).build(); + ) + .build(); foo.cargo("check").run(); } @@ -136,10 +144,12 @@ fn check_build() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }", - ).build(); + ) + .build(); let _bar = project() .at("bar") @@ -165,10 +175,12 @@ fn build_check() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }", - ).build(); + ) + .build(); let _bar = project() .at("bar") @@ -210,7 +222,8 @@ fn issue_3419() { [dependencies] rustc-serialize = "*" "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate rustc_serialize; @@ -219,7 +232,8 @@ fn issue_3419() { pub fn take() {} "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate rustc_serialize; @@ -233,7 +247,8 @@ fn issue_3419() { foo::take::(); } "#, - ).build(); + ) + .build(); Package::new("rustc-serialize", "1.0.0") .file( @@ -247,7 +262,8 @@ fn issue_3419() { -> Result where F: FnOnce(&mut Self) -> Result; } "#, - ).publish(); + ) + .publish(); p.cargo("check").run(); } @@ -269,7 +285,8 @@ fn dylib_check_preserves_build_cache() { [dependencies] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -278,7 +295,8 @@ fn dylib_check_preserves_build_cache() { [..]Compiling foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("check").run(); @@ -302,10 +320,12 @@ fn rustc_check() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }", - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -329,10 +349,12 @@ fn rustc_check_err() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", "extern crate bar; fn main() { ::bar::qux(); }", - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -359,7 +381,8 @@ fn check_all() { [dependencies] b = { path = "b" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("examples/a.rs", "fn main() {}") .file("tests/a.rs", "") .file("src/lib.rs", "") @@ -385,7 +408,8 @@ fn check_virtual_all_implied() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -449,7 +473,8 @@ fn check_unit_test_profile() { } } "#, - ).build(); + ) + .build(); foo.cargo("check").run(); foo.cargo("check --profile test") @@ -471,7 +496,8 @@ fn check_filters() { fn unused_unit_lib() {} } "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() {} @@ -481,7 +507,8 @@ fn check_filters() { fn unused_unit_bin() {} } "#, - ).file( + ) + .file( "tests/t1.rs", r#" fn unused_normal_t1() {} @@ -490,7 +517,8 @@ fn check_filters() { fn unused_unit_t1() {} } "#, - ).file( + ) + .file( "examples/ex1.rs", r#" fn main() {} @@ -500,7 +528,8 @@ fn check_filters() { fn unused_unit_ex1() {} } "#, - ).file( + ) + .file( "benches/b1.rs", r#" fn unused_normal_b1() {} @@ -509,7 +538,8 @@ fn check_filters() { fn unused_unit_b1() {} } "#, - ).build(); + ) + .build(); p.cargo("check") .with_stderr_contains("[..]unused_normal_lib[..]") @@ -615,12 +645,11 @@ fn check_artifacts() { p.cargo("check --example ex1").run(); assert!(!p.root().join("target/debug/libfoo.rmeta").is_file()); assert!(!p.root().join("target/debug/libfoo.rlib").is_file()); - assert!( - !p.root() - .join("target/debug/examples") - .join(exe("ex1")) - .is_file() - ); + assert!(!p + .root() + .join("target/debug/examples") + .join(exe("ex1")) + .is_file()); assert_glob("target/debug/deps/libfoo-*.rmeta", 1); assert_glob("target/debug/examples/libex1-*.rmeta", 1); @@ -647,7 +676,8 @@ src/lib.rs:1:27: error[E0308]: mismatched types error: aborting due to previous error error: Could not compile `foo`. ", - ).run(); + ) + .run(); } #[test] @@ -663,7 +693,8 @@ fn proc_macro() { [lib] proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate proc_macro; @@ -675,7 +706,8 @@ fn proc_macro() { "".parse().unwrap() } "#, - ).file( + ) + .file( "src/main.rs", r#" #[macro_use] @@ -686,7 +718,8 @@ fn proc_macro() { fn main() {} "#, - ).build(); + ) + .build(); p.cargo("check -v").env("RUST_LOG", "cargo=trace").run(); } diff --git a/tests/testsuite/clean.rs b/tests/testsuite/clean.rs index 7943a6f0f3a..81db081b951 100644 --- a/tests/testsuite/clean.rs +++ b/tests/testsuite/clean.rs @@ -54,7 +54,8 @@ fn clean_multiple_packages() { [[bin]] name = "foo" "#, - ).file("src/foo.rs", &main_file(r#""i am foo""#, &[])) + ) + .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) .file("d1/Cargo.toml", &basic_bin_manifest("d1")) .file("d1/src/main.rs", "fn main() { println!(\"d1\"); }") .file("d2/Cargo.toml", &basic_bin_manifest("d2")) @@ -99,7 +100,8 @@ fn clean_release() { [dependencies] a = { path = "a" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -116,7 +118,8 @@ fn clean_release() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").run(); @@ -140,7 +143,8 @@ fn clean_doc() { [dependencies] a = { path = "a" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -169,7 +173,8 @@ fn build_script() { authors = [] build = "build.rs" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "build.rs", r#" @@ -185,7 +190,8 @@ fn build_script() { } } "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build").env("FIRST", "1").run(); @@ -199,7 +205,8 @@ fn build_script() { [RUNNING] `rustc [..] src/main.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -208,7 +215,8 @@ fn clean_git() { project .file("Cargo.toml", &basic_manifest("dep", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -225,7 +233,8 @@ fn clean_git() { "#, git.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").run(); @@ -247,7 +256,8 @@ fn registry() { [dependencies] bar = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.1.0").publish(); @@ -270,7 +280,8 @@ fn clean_verbose() { [dependencies] bar = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.1.0").publish(); @@ -282,6 +293,7 @@ fn clean_verbose() { [REMOVING] [..] [REMOVING] [..] ", - ).run(); + ) + .run(); p.cargo("build").run(); } diff --git a/tests/testsuite/collisions.rs b/tests/testsuite/collisions.rs index dac33312e58..e3f744e8551 100644 --- a/tests/testsuite/collisions.rs +++ b/tests/testsuite/collisions.rs @@ -1,5 +1,5 @@ -use std::env; use crate::support::{basic_manifest, project}; +use std::env; #[test] fn collision_dylib() { diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index e2b43073aa5..90e7847807c 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -7,12 +7,12 @@ use std::thread; use std::time::Duration; use std::{env, str}; -use git2; use crate::support::cargo_process; use crate::support::git; -use crate::support::install::{cargo_home, assert_has_installed_exe}; +use crate::support::install::{assert_has_installed_exe, cargo_home}; use crate::support::registry::Package; use crate::support::{basic_manifest, execs, project}; +use git2; fn pkg(name: &str, vers: &str) { Package::new(name, vers) @@ -109,7 +109,8 @@ fn one_install_should_be_bad() { .with_status(101) .with_stderr_contains( "[ERROR] binary `foo[..]` already exists in destination as part of `[..]`", - ).run_output(&bad); + ) + .run_output(&bad); execs() .with_stderr_contains("warning: be sure to add `[..]` to your PATH [..]") .run_output(&good); @@ -140,7 +141,8 @@ fn multiple_registry_fetches() { [dependencies] bar = "*" "#, - ).file("a/src/main.rs", "fn main() {}") + ) + .file("a/src/main.rs", "fn main() {}") .file( "b/Cargo.toml", r#" @@ -152,7 +154,8 @@ fn multiple_registry_fetches() { [dependencies] bar = "*" "#, - ).file("b/src/main.rs", "fn main() {}"); + ) + .file("b/src/main.rs", "fn main() {}"); let p = p.build(); let mut a = p.cargo("build").cwd(p.root().join("a")).build_command(); @@ -171,18 +174,16 @@ fn multiple_registry_fetches() { execs().run_output(&b); let suffix = env::consts::EXE_SUFFIX; - assert!( - p.root() - .join("a/target/debug") - .join(format!("foo{}", suffix)) - .is_file() - ); - assert!( - p.root() - .join("b/target/debug") - .join(format!("bar{}", suffix)) - .is_file() - ); + assert!(p + .root() + .join("a/target/debug") + .join(format!("foo{}", suffix)) + .is_file()); + assert!(p + .root() + .join("b/target/debug") + .join(format!("bar{}", suffix)) + .is_file()); } #[test] @@ -191,7 +192,8 @@ fn git_same_repo_different_tags() { project .file("Cargo.toml", &basic_manifest("dep", "0.5.0")) .file("src/lib.rs", "pub fn tag1() {}") - }).unwrap(); + }) + .unwrap(); let repo = git2::Repository::open(&a.root()).unwrap(); git::tag(&repo, "tag1"); @@ -220,10 +222,12 @@ fn git_same_repo_different_tags() { "#, a.url() ), - ).file( + ) + .file( "a/src/main.rs", "extern crate dep; fn main() { dep::tag1(); }", - ).file( + ) + .file( "b/Cargo.toml", &format!( r#" @@ -237,7 +241,8 @@ fn git_same_repo_different_tags() { "#, a.url() ), - ).file( + ) + .file( "b/src/main.rs", "extern crate dep; fn main() { dep::tag2(); }", ); @@ -265,7 +270,8 @@ fn git_same_branch_different_revs() { project .file("Cargo.toml", &basic_manifest("dep", "0.5.0")) .file("src/lib.rs", "pub fn f1() {}") - }).unwrap(); + }) + .unwrap(); let p = project() .no_manifest() @@ -283,10 +289,12 @@ fn git_same_branch_different_revs() { "#, a.url() ), - ).file( + ) + .file( "a/src/main.rs", "extern crate dep; fn main() { dep::f1(); }", - ).file( + ) + .file( "b/Cargo.toml", &format!( r#" @@ -300,7 +308,8 @@ fn git_same_branch_different_revs() { "#, a.url() ), - ).file( + ) + .file( "b/src/main.rs", "extern crate dep; fn main() { dep::f2(); }", ); @@ -377,7 +386,8 @@ fn killing_cargo_releases_the_lock() { version = "0.0.0" build = "build.rs" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "build.rs", r#" @@ -449,14 +459,16 @@ fn debug_release_ok() { [COMPILING] foo v0.0.1 [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run_output(&a); + ) + .run_output(&a); execs() .with_stderr( "\ [COMPILING] foo v0.0.1 [..] [FINISHED] release [optimized] target(s) in [..] ", - ).run_output(&b); + ) + .run_output(&b); } #[test] @@ -465,13 +477,15 @@ fn no_deadlock_with_git_dependencies() { project .file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let dep2 = git::new("dep2", |project| { project .file("Cargo.toml", &basic_manifest("dep2", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -490,7 +504,8 @@ fn no_deadlock_with_git_dependencies() { dep1.url(), dep2.url() ), - ).file("src/main.rs", "fn main() { }"); + ) + .file("src/main.rs", "fn main() { }"); let p = p.build(); let n_concurrent_builds = 5; diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index 794ca8da9ac..bb8b334fd1c 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -1,3 +1,4 @@ +use crate::support::{lines_match, paths, project}; use cargo::core::{enable_nightly_features, Shell}; use cargo::util::config::{self, Config}; use cargo::util::toml::{self, VecStringOrBool as VSOB}; @@ -5,7 +6,6 @@ use cargo::CargoError; use std::borrow::Borrow; use std::collections; use std::fs; -use crate::support::{lines_match, paths, project}; #[test] fn read_env_vars_for_config() { @@ -19,7 +19,8 @@ fn read_env_vars_for_config() { version = "0.0.0" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -28,7 +29,8 @@ fn read_env_vars_for_config() { assert_eq!(env::var("NUM_JOBS").unwrap(), "100"); } "#, - ).build(); + ) + .build(); p.cargo("build").env("CARGO_BUILD_JOBS", "100").run(); } @@ -60,7 +62,8 @@ fn new_config(env: &[(&str, &str)]) -> Config { false, &None, &["advanced-env".into()], - ).unwrap(); + ) + .unwrap(); config } diff --git a/tests/testsuite/corrupt_git.rs b/tests/testsuite/corrupt_git.rs index a991f5794f2..f71f2ec65b5 100644 --- a/tests/testsuite/corrupt_git.rs +++ b/tests/testsuite/corrupt_git.rs @@ -1,9 +1,9 @@ use std::fs; use std::path::{Path, PathBuf}; -use cargo::util::paths as cargopaths; use crate::support::paths; use crate::support::{basic_manifest, git, project}; +use cargo::util::paths as cargopaths; #[test] fn deleting_database_files() { @@ -12,7 +12,8 @@ fn deleting_database_files() { project .file("Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let project = project .file( @@ -29,7 +30,8 @@ fn deleting_database_files() { "#, git_project.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); project.cargo("build").run(); @@ -69,7 +71,8 @@ fn deleting_checkout_files() { project .file("Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let project = project .file( @@ -86,7 +89,8 @@ fn deleting_checkout_files() { "#, git_project.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); project.cargo("build").run(); diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index 941c6d93529..686b284146e 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -17,7 +17,8 @@ fn simple_cross() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", &format!( r#" @@ -27,7 +28,8 @@ fn simple_cross() { "#, cross_compile::alternate() ), - ).file( + ) + .file( "src/main.rs", &format!( r#" @@ -38,7 +40,8 @@ fn simple_cross() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); let target = cross_compile::alternate(); p.cargo("build -v --target").arg(&target).run(); @@ -63,7 +66,8 @@ fn simple_cross_config() { "#, cross_compile::alternate() ), - ).file( + ) + .file( "Cargo.toml", r#" [package] @@ -72,7 +76,8 @@ fn simple_cross_config() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", &format!( r#" @@ -82,7 +87,8 @@ fn simple_cross_config() { "#, cross_compile::alternate() ), - ).file( + ) + .file( "src/main.rs", &format!( r#" @@ -93,7 +99,8 @@ fn simple_cross_config() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); let target = cross_compile::alternate(); p.cargo("build -v").run(); @@ -120,7 +127,8 @@ fn simple_deps() { [dependencies.bar] path = "../bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }") .build(); let _p2 = project() .at("bar") @@ -159,7 +167,8 @@ fn plugin_deps() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "src/main.rs", r#" #![feature(plugin)] @@ -169,7 +178,8 @@ fn plugin_deps() { assert_eq!(bar!(), baz::baz()); } "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file( @@ -184,7 +194,8 @@ fn plugin_deps() { name = "bar" plugin = true "#, - ).file( + ) + .file( "src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] @@ -209,7 +220,8 @@ fn plugin_deps() { MacEager::expr(cx.expr_lit(sp, LitKind::Int(1, LitIntType::Unsuffixed))) } "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") .file("Cargo.toml", &basic_manifest("baz", "0.0.1")) @@ -247,7 +259,8 @@ fn plugin_to_the_max() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "src/main.rs", r#" #![feature(plugin)] @@ -257,7 +270,8 @@ fn plugin_to_the_max() { assert_eq!(bar!(), baz::baz()); } "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file( @@ -275,7 +289,8 @@ fn plugin_to_the_max() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] @@ -304,7 +319,8 @@ fn plugin_to_the_max() { MacEager::expr(cx.expr_call(sp, cx.expr_path(path), vec![])) } "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") .file("Cargo.toml", &basic_manifest("baz", "0.0.1")) @@ -338,7 +354,8 @@ fn linker_and_ar() { "#, target ), - ).file("Cargo.toml", &basic_bin_manifest("foo")) + ) + .file("Cargo.toml", &basic_bin_manifest("foo")) .file( "src/foo.rs", &format!( @@ -350,7 +367,8 @@ fn linker_and_ar() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); p.cargo("build -v --target") .arg(&target) @@ -368,7 +386,8 @@ fn linker_and_ar() { -L dependency=[CWD]/target/debug/deps` ", target = target, - )).run(); + )) + .run(); } #[test] @@ -392,7 +411,8 @@ fn plugin_with_extra_dylib_dep() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", r#" #![feature(plugin)] @@ -400,7 +420,8 @@ fn plugin_with_extra_dylib_dep() { fn main() {} "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file( @@ -418,7 +439,8 @@ fn plugin_with_extra_dylib_dep() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] @@ -433,7 +455,8 @@ fn plugin_with_extra_dylib_dep() { println!("{}", baz::baz()); } "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") .file( @@ -448,7 +471,8 @@ fn plugin_with_extra_dylib_dep() { name = "baz" crate_type = ["dylib"] "#, - ).file("src/lib.rs", "pub fn baz() -> i32 { 1 }") + ) + .file("src/lib.rs", "pub fn baz() -> i32 { 1 }") .build(); let target = cross_compile::alternate(); @@ -473,7 +497,8 @@ fn cross_tests() { [[bin]] name = "bar" "#, - ).file( + ) + .file( "src/bin/bar.rs", &format!( r#" @@ -487,7 +512,8 @@ fn cross_tests() { "#, cross_compile::alternate_arch() ), - ).file( + ) + .file( "src/lib.rs", &format!( r#" @@ -497,7 +523,8 @@ fn cross_tests() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); let target = cross_compile::alternate(); p.cargo("test --target") @@ -509,7 +536,8 @@ fn cross_tests() { [RUNNING] target/{triple}/debug/deps/foo-[..][EXE] [RUNNING] target/{triple}/debug/deps/bar-[..][EXE]", triple = target - )).with_stdout_contains("test test_foo ... ok") + )) + .with_stdout_contains("test test_foo ... ok") .with_stdout_contains("test test ... ok") .run(); } @@ -529,10 +557,10 @@ fn no_cross_doctests() { //! assert!(true); //! ``` "#, - ).build(); + ) + .build(); - let host_output = - "\ + let host_output = "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] @@ -554,7 +582,8 @@ fn no_cross_doctests() { [DOCTEST] foo ", triple = target - )).run(); + )) + .run(); println!("c"); let target = cross_compile::alternate(); @@ -567,7 +596,8 @@ fn no_cross_doctests() { [RUNNING] target/{triple}/debug/deps/foo-[..][EXE] ", triple = target - )).run(); + )) + .run(); } #[test] @@ -588,7 +618,8 @@ fn simple_cargo_run() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); let target = cross_compile::alternate(); p.cargo("run --target").arg(&target).run(); @@ -611,7 +642,8 @@ fn cross_with_a_build_script() { authors = [] build = 'build.rs' "#, - ).file( + ) + .file( "build.rs", &format!( r#" @@ -636,7 +668,8 @@ fn cross_with_a_build_script() { "#, target ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v --target") @@ -650,7 +683,8 @@ fn cross_with_a_build_script() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", target = target, - )).run(); + )) + .run(); } #[test] @@ -676,21 +710,24 @@ fn build_script_needed_for_host_and_target() { [build-dependencies.d2] path = "d2" "#, - ).file( + ) + .file( "build.rs", r#" #[allow(unused_extern_crates)] extern crate d2; fn main() { d2::d2(); } "#, - ).file( + ) + .file( "src/main.rs", " #[allow(unused_extern_crates)] extern crate d1; fn main() { d1::d1(); } ", - ).file( + ) + .file( "d1/Cargo.toml", r#" [package] @@ -699,7 +736,8 @@ fn build_script_needed_for_host_and_target() { authors = [] build = 'build.rs' "#, - ).file("d1/src/lib.rs", "pub fn d1() {}") + ) + .file("d1/src/lib.rs", "pub fn d1() {}") .file( "d1/build.rs", r#" @@ -709,7 +747,8 @@ fn build_script_needed_for_host_and_target() { println!("cargo:rustc-flags=-L /path/to/{}", target); } "#, - ).file( + ) + .file( "d2/Cargo.toml", r#" [package] @@ -720,14 +759,16 @@ fn build_script_needed_for_host_and_target() { [dependencies.d1] path = "../d1" "#, - ).file( + ) + .file( "d2/src/lib.rs", " #[allow(unused_extern_crates)] extern crate d1; pub fn d2() { d1::d1(); } ", - ).build(); + ) + .build(); p.cargo("build -v --target") .arg(&target) @@ -741,17 +782,20 @@ fn build_script_needed_for_host_and_target() { .with_stderr_contains(&format!( "[RUNNING] `rustc [..] d2/src/lib.rs [..] -L /path/to/{host}`", host = host - )).with_stderr_contains("[COMPILING] foo v0.0.0 ([CWD])") + )) + .with_stderr_contains("[COMPILING] foo v0.0.0 ([CWD])") .with_stderr_contains(&format!( "[RUNNING] `rustc [..] build.rs [..] --out-dir [CWD]/target/debug/build/foo-[..] \ -L /path/to/{host}`", host = host - )).with_stderr_contains(&format!( + )) + .with_stderr_contains(&format!( "\ [RUNNING] `rustc [..] src/main.rs [..] --target {target} [..] \ -L /path/to/{target}`", target = target - )).run(); + )) + .run(); } #[test] @@ -772,7 +816,8 @@ fn build_deps_for_the_right_arch() { [dependencies.d2] path = "d2" "#, - ).file("src/main.rs", "extern crate d2; fn main() {}") + ) + .file("src/main.rs", "extern crate d2; fn main() {}") .file("d1/Cargo.toml", &basic_manifest("d1", "0.0.0")) .file("d1/src/lib.rs", "pub fn d1() {}") .file( @@ -787,7 +832,8 @@ fn build_deps_for_the_right_arch() { [build-dependencies.d1] path = "../d1" "#, - ).file("d2/build.rs", "extern crate d1; fn main() {}") + ) + .file("d2/build.rs", "extern crate d1; fn main() {}") .file("d2/src/lib.rs", "") .build(); @@ -814,7 +860,8 @@ fn build_script_only_host() { [build-dependencies.d1] path = "d1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("build.rs", "extern crate d1; fn main() {}") .file( "d1/Cargo.toml", @@ -825,7 +872,8 @@ fn build_script_only_host() { authors = [] build = "build.rs" "#, - ).file("d1/src/lib.rs", "pub fn d1() {}") + ) + .file("d1/src/lib.rs", "pub fn d1() {}") .file( "d1/build.rs", r#" @@ -837,7 +885,8 @@ fn build_script_only_host() { "bad: {:?}", env::var("OUT_DIR")); } "#, - ).build(); + ) + .build(); let target = cross_compile::alternate(); p.cargo("build -v --target").arg(&target).run(); @@ -862,7 +911,8 @@ fn plugin_build_script_right_arch() { name = "foo" plugin = true "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "") .build(); @@ -876,7 +926,8 @@ fn plugin_build_script_right_arch() { [RUNNING] `rustc [..] src/lib.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -900,14 +951,16 @@ fn build_script_with_platform_specific_dependencies() { [build-dependencies.d1] path = "d1" "#, - ).file( + ) + .file( "build.rs", " #[allow(unused_extern_crates)] extern crate d1; fn main() {} ", - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "d1/Cargo.toml", &format!( @@ -922,10 +975,12 @@ fn build_script_with_platform_specific_dependencies() { "#, host ), - ).file( + ) + .file( "d1/src/lib.rs", "#[allow(unused_extern_crates)] extern crate d2;", - ).file("d2/Cargo.toml", &basic_manifest("d2", "0.0.0")) + ) + .file("d2/Cargo.toml", &basic_manifest("d2", "0.0.0")) .file("d2/src/lib.rs", "") .build(); @@ -944,7 +999,8 @@ fn build_script_with_platform_specific_dependencies() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", target = target - )).run(); + )) + .run(); } #[test] @@ -971,7 +1027,8 @@ fn platform_specific_dependencies_do_not_leak() { [build-dependencies.d1] path = "d1" "#, - ).file("build.rs", "extern crate d1; fn main() {}") + ) + .file("build.rs", "extern crate d1; fn main() {}") .file("src/lib.rs", "") .file( "d1/Cargo.toml", @@ -987,7 +1044,8 @@ fn platform_specific_dependencies_do_not_leak() { "#, host ), - ).file("d1/src/lib.rs", "extern crate d2;") + ) + .file("d1/src/lib.rs", "extern crate d2;") .file("d1/Cargo.toml", &basic_manifest("d1", "0.0.0")) .file("d2/src/lib.rs", "") .build(); @@ -1027,7 +1085,8 @@ fn platform_specific_variables_reflected_in_build_scripts() { host = host, target = target ), - ).file( + ) + .file( "build.rs", &format!( r#" @@ -1050,7 +1109,8 @@ fn platform_specific_variables_reflected_in_build_scripts() { host = host, target = target ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "d1/Cargo.toml", r#" @@ -1061,7 +1121,8 @@ fn platform_specific_variables_reflected_in_build_scripts() { links = "d1" build = "build.rs" "#, - ).file("d1/build.rs", r#"fn main() { println!("cargo:val=1") }"#) + ) + .file("d1/build.rs", r#"fn main() { println!("cargo:val=1") }"#) .file("d1/src/lib.rs", "") .file( "d2/Cargo.toml", @@ -1073,7 +1134,8 @@ fn platform_specific_variables_reflected_in_build_scripts() { links = "d2" build = "build.rs" "#, - ).file("d2/build.rs", r#"fn main() { println!("cargo:val=1") }"#) + ) + .file("d2/build.rs", r#"fn main() { println!("cargo:val=1") }"#) .file("d2/src/lib.rs", "") .build(); @@ -1105,7 +1167,8 @@ fn cross_test_dylib() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar as the_bar; @@ -1115,7 +1178,8 @@ fn cross_test_dylib() { #[test] fn foo() { bar(); } "#, - ).file( + ) + .file( "tests/test.rs", r#" extern crate foo as the_foo; @@ -1123,7 +1187,8 @@ fn cross_test_dylib() { #[test] fn foo() { the_foo::bar(); } "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -1135,7 +1200,8 @@ fn cross_test_dylib() { name = "bar" crate_type = ["dylib"] "#, - ).file( + ) + .file( "bar/src/lib.rs", &format!( r#" @@ -1146,7 +1212,8 @@ fn cross_test_dylib() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); p.cargo("test --target") .arg(&target) @@ -1158,6 +1225,7 @@ fn cross_test_dylib() { [RUNNING] target/{arch}/debug/deps/foo-[..][EXE] [RUNNING] target/{arch}/debug/deps/test-[..][EXE]", arch = cross_compile::alternate() - )).with_stdout_contains_n("test foo ... ok", 2) + )) + .with_stdout_contains_n("test foo ... ok", 2) .run(); } diff --git a/tests/testsuite/cross_publish.rs b/tests/testsuite/cross_publish.rs index ffb3a0507a6..624d323c99c 100644 --- a/tests/testsuite/cross_publish.rs +++ b/tests/testsuite/cross_publish.rs @@ -2,8 +2,8 @@ use std::fs::File; use std::io::prelude::*; use std::path::PathBuf; -use flate2::read::GzDecoder; use crate::support::{cross_compile, project, publish}; +use flate2::read::GzDecoder; use tar::Archive; #[test] @@ -24,7 +24,8 @@ fn simple_cross_package() { description = "foo" repository = "bar" "#, - ).file( + ) + .file( "src/main.rs", &format!( r#" @@ -35,7 +36,8 @@ fn simple_cross_package() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); let target = cross_compile::alternate(); @@ -47,7 +49,8 @@ fn simple_cross_package() { Compiling foo v0.0.0 ([CWD]/target/package/foo-0.0.0) Finished dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // Check that the tarball contains the files let f = File::open(&p.root().join("target/package/foo-0.0.0.crate")).unwrap(); @@ -84,7 +87,8 @@ fn publish_with_target() { description = "foo" repository = "bar" "#, - ).file( + ) + .file( "src/main.rs", &format!( r#" @@ -95,7 +99,8 @@ fn publish_with_target() { "#, cross_compile::alternate_arch() ), - ).build(); + ) + .build(); let target = cross_compile::alternate(); @@ -112,5 +117,6 @@ fn publish_with_target() { Uploading foo v0.0.0 ([CWD]) ", registry = publish::registry_path().to_str().unwrap() - )).run(); + )) + .run(); } diff --git a/tests/testsuite/custom_target.rs b/tests/testsuite/custom_target.rs index 14f4b1ae783..d05661acad7 100644 --- a/tests/testsuite/custom_target.rs +++ b/tests/testsuite/custom_target.rs @@ -27,7 +27,8 @@ fn custom_target_minimal() { // Empty. } "#, - ).file( + ) + .file( "custom-target.json", r#" { @@ -41,7 +42,8 @@ fn custom_target_minimal() { "linker-flavor": "ld.lld" } "#, - ).build(); + ) + .build(); p.cargo("build --lib --target custom-target.json -v").run(); p.cargo("build --lib --target src/../custom-target.json -v") @@ -66,7 +68,8 @@ fn custom_target_dependency() { [dependencies] bar = { path = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", r#" #![feature(no_core)] @@ -83,7 +86,8 @@ fn custom_target_dependency() { #[lang = "freeze"] unsafe auto trait Freeze {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file( "bar/src/lib.rs", r#" @@ -104,7 +108,8 @@ fn custom_target_dependency() { // Empty. } "#, - ).file( + ) + .file( "custom-target.json", r#" { @@ -118,7 +123,8 @@ fn custom_target_dependency() { "linker-flavor": "ld.lld" } "#, - ).build(); + ) + .build(); p.cargo("build --lib --target custom-target.json -v").run(); } diff --git a/tests/testsuite/death.rs b/tests/testsuite/death.rs index 6c26e5f0238..78a20e9b458 100644 --- a/tests/testsuite/death.rs +++ b/tests/testsuite/death.rs @@ -66,7 +66,8 @@ fn ctrl_c_kills_everyone() { authors = [] build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", &format!( @@ -82,7 +83,8 @@ fn ctrl_c_kills_everyone() { "#, addr ), - ).build(); + ) + .build(); let mut cargo = p.cargo("build").build_command(); cargo diff --git a/tests/testsuite/dep_info.rs b/tests/testsuite/dep_info.rs index f273bc41eff..2f8b910f8ba 100644 --- a/tests/testsuite/dep_info.rs +++ b/tests/testsuite/dep_info.rs @@ -1,5 +1,5 @@ -use filetime::FileTime; use crate::support::{basic_bin_manifest, main_file, project}; +use filetime::FileTime; #[test] fn build_dep_info() { @@ -30,7 +30,8 @@ fn build_dep_info_lib() { name = "ex" crate-type = ["lib"] "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "") .file("examples/ex.rs", "") .build(); @@ -54,7 +55,8 @@ fn build_dep_info_rlib() { name = "ex" crate-type = ["rlib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/ex.rs", "") .build(); @@ -77,7 +79,8 @@ fn build_dep_info_dylib() { name = "ex" crate-type = ["dylib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/ex.rs", "") .build(); diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 1bd2a26504b..72f972264a4 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -93,10 +93,12 @@ fn simple() { [dependencies] bar = "0.1.0" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -105,7 +107,8 @@ fn simple() { [COMPILING] foo v0.1.0 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -128,10 +131,12 @@ fn simple_install() { [dependencies] foo = "0.0.1" "#, - ).file( + ) + .file( "src/main.rs", "extern crate foo; pub fn main() { foo::foo(); }", - ).build(); + ) + .build(); cargo_process("install bar") .with_stderr( @@ -142,7 +147,8 @@ fn simple_install() { Installing [..]bar[..] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); } #[test] @@ -166,10 +172,12 @@ fn simple_install_fail() { foo = "0.1.0" baz = "9.8.7" "#, - ).file( + ) + .file( "src/main.rs", "extern crate foo; pub fn main() { foo::foo(); }", - ).build(); + ) + .build(); cargo_process("install bar") .with_status(101) @@ -183,7 +191,8 @@ location searched: registry `https://github.com/rust-lang/crates.io-index` did you mean: bar, foo required by package `bar v0.1.0` ", - ).run(); + ) + .run(); } #[test] @@ -210,10 +219,12 @@ fn install_without_feature_dep() { [features] wantbaz = ["baz"] "#, - ).file( + ) + .file( "src/main.rs", "extern crate foo; pub fn main() { foo::foo(); }", - ).build(); + ) + .build(); cargo_process("install bar") .with_stderr( @@ -224,7 +235,8 @@ fn install_without_feature_dep() { Installing [..]bar[..] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); } #[test] @@ -245,10 +257,12 @@ fn not_there() { [dependencies] bar = "0.1.0" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -258,7 +272,8 @@ error: no matching package named `bar` found location searched: [..] required by package `foo v0.1.0 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -289,10 +304,12 @@ fn multiple() { [dependencies] bar = "0.1.0" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -301,7 +318,8 @@ fn multiple() { [COMPILING] foo v0.1.0 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -318,10 +336,12 @@ fn crates_io_then_directory() { [dependencies] bar = "0.1.0" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); let cksum = Package::new("bar", "0.1.0") .file("src/lib.rs", "pub fn bar() -> u32 { 0 }") @@ -337,7 +357,8 @@ fn crates_io_then_directory() { [COMPILING] foo v0.1.0 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); setup(); @@ -354,7 +375,8 @@ fn crates_io_then_directory() { [COMPILING] foo v0.1.0 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -371,7 +393,8 @@ fn crates_io_then_bad_checksum() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); Package::new("bar", "0.1.0").publish(); @@ -399,7 +422,8 @@ this could be indicative of a few possible errors: unable to verify that `bar v0.1.0` is the same as when the lockfile was generated ", - ).run(); + ) + .run(); } #[test] @@ -426,7 +450,8 @@ fn bad_file_checksum() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -441,7 +466,8 @@ directory sources are not intended to be edited, if modifications are \ required then it is recommended that [replace] is used with a forked copy of \ the source ", - ).run(); + ) + .run(); } #[test] @@ -469,7 +495,8 @@ fn only_dot_files_ok() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -501,7 +528,8 @@ fn random_files_ok() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -512,7 +540,8 @@ fn git_lock_file_doesnt_change() { let git = git::new("git", |p| { p.file("Cargo.toml", &basic_manifest("git", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); VendorPackage::new("git") .file("Cargo.toml", &basic_manifest("git", "0.5.0")) @@ -535,7 +564,8 @@ fn git_lock_file_doesnt_change() { "#, git.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -556,7 +586,8 @@ fn git_lock_file_doesnt_change() { directory = 'index' "#, git.url() - ).as_bytes() + ) + .as_bytes() )); p.cargo("build") @@ -566,7 +597,8 @@ fn git_lock_file_doesnt_change() { [COMPILING] [..] [FINISHED] [..] ", - ).run(); + ) + .run(); let mut lock2 = String::new(); t!(t!(File::open(p.root().join("Cargo.lock"))).read_to_string(&mut lock2)); @@ -593,7 +625,8 @@ fn git_override_requires_lockfile() { [dependencies] git = { git = 'https://example.com/' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let root = paths::root(); @@ -626,7 +659,8 @@ remove the source replacement configuration, generate a lock file, and then restore the source replacement configuration to continue the build ", - ).run(); + ) + .run(); } #[test] @@ -643,7 +677,8 @@ fn workspace_different_locations() { [dependencies] baz = "*" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .file("foo/vendor/baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("foo/vendor/baz/src/lib.rs", "") .file("foo/vendor/baz/.cargo-checksum.json", "{\"files\":{}}") @@ -657,7 +692,8 @@ fn workspace_different_locations() { [dependencies] baz = "*" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file( ".cargo/config", r#" @@ -670,7 +706,8 @@ fn workspace_different_locations() { [source.my-awesome-local-registry] directory = 'foo/vendor' "#, - ).build(); + ) + .build(); p.cargo("build").cwd(p.root().join("foo")).run(); p.cargo("build") @@ -681,7 +718,8 @@ fn workspace_different_locations() { [COMPILING] bar [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index c9a1f3ae2cb..2534d570242 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -1,13 +1,13 @@ +use crate::support; use std::fs::{self, File}; use std::io::Read; use std::str; -use crate::support; -use glob::glob; use crate::support::paths::CargoPathExt; use crate::support::registry::Package; use crate::support::{basic_lib_manifest, basic_manifest, git, project}; use crate::support::{is_nightly, rustc_host}; +use glob::glob; #[test] fn simple() { @@ -21,7 +21,8 @@ fn simple() { authors = [] build = "build.rs" "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "pub fn foo() {}") .build(); @@ -32,7 +33,8 @@ fn simple() { [..] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); assert!(p.root().join("target/doc/foo/index.html").is_file()); } @@ -52,7 +54,8 @@ fn doc_no_libs() { name = "foo" doc = false "#, - ).file("src/main.rs", "bad code") + ) + .file("src/main.rs", "bad code") .build(); p.cargo("doc").run(); @@ -68,7 +71,8 @@ fn doc_twice() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("doc").with_stdout("").run(); } @@ -87,7 +91,8 @@ fn doc_deps() { [dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "extern crate bar; pub fn foo() {}") + ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -100,7 +105,8 @@ fn doc_deps() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); assert!(p.root().join("target/doc/foo/index.html").is_file()); @@ -119,7 +125,8 @@ fn doc_deps() { .join("target/debug/deps/libbar-*.rmeta") .to_str() .unwrap() - ).unwrap() + ) + .unwrap() .count(), 1 ); @@ -148,7 +155,8 @@ fn doc_no_deps() { [dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "extern crate bar; pub fn foo() {}") + ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -160,7 +168,8 @@ fn doc_no_deps() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); assert!(p.root().join("target/doc/foo/index.html").is_file()); @@ -181,7 +190,8 @@ fn doc_only_bin() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "extern crate bar; pub fn foo() {}") + ) + .file("src/main.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -202,7 +212,8 @@ fn doc_multiple_targets_same_name_lib() { [workspace] members = ["foo", "bar"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -211,7 +222,8 @@ fn doc_multiple_targets_same_name_lib() { [lib] name = "foo_lib" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -221,7 +233,8 @@ fn doc_multiple_targets_same_name_lib() { [lib] name = "foo_lib" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("doc --all") @@ -241,7 +254,8 @@ fn doc_multiple_targets_same_name() { [workspace] members = ["foo", "bar"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -251,7 +265,8 @@ fn doc_multiple_targets_same_name() { name = "foo_lib" path = "src/foo_lib.rs" "#, - ).file("foo/src/foo_lib.rs", "") + ) + .file("foo/src/foo_lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -261,7 +276,8 @@ fn doc_multiple_targets_same_name() { [lib] name = "foo_lib" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("doc --all") @@ -283,7 +299,8 @@ fn doc_multiple_targets_same_name_bin() { [workspace] members = ["foo", "bar"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -292,7 +309,8 @@ fn doc_multiple_targets_same_name_bin() { [[bin]] name = "foo-cli" "#, - ).file("foo/src/foo-cli.rs", "") + ) + .file("foo/src/foo-cli.rs", "") .file( "bar/Cargo.toml", r#" @@ -302,7 +320,8 @@ fn doc_multiple_targets_same_name_bin() { [[bin]] name = "foo-cli" "#, - ).file("bar/src/foo-cli.rs", "") + ) + .file("bar/src/foo-cli.rs", "") .build(); p.cargo("doc --all") @@ -322,7 +341,8 @@ fn doc_multiple_targets_same_name_undoced() { [workspace] members = ["foo", "bar"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -331,7 +351,8 @@ fn doc_multiple_targets_same_name_undoced() { [[bin]] name = "foo-cli" "#, - ).file("foo/src/foo-cli.rs", "") + ) + .file("foo/src/foo-cli.rs", "") .file( "bar/Cargo.toml", r#" @@ -342,7 +363,8 @@ fn doc_multiple_targets_same_name_undoced() { name = "foo-cli" doc = false "#, - ).file("bar/src/foo-cli.rs", "") + ) + .file("bar/src/foo-cli.rs", "") .build(); p.cargo("doc --all").run(); @@ -360,13 +382,15 @@ fn doc_lib_bin_same_name_documents_lib() { foo::foo(); } "#, - ).file( + ) + .file( "src/lib.rs", r#" //! Library documentation pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("doc") .with_stderr( @@ -374,7 +398,8 @@ fn doc_lib_bin_same_name_documents_lib() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); let doc_file = p.root().join("target/doc/foo/index.html"); assert!(doc_file.is_file()); @@ -399,13 +424,15 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() { foo::foo(); } "#, - ).file( + ) + .file( "src/lib.rs", r#" //! Library documentation pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("doc --lib") .with_stderr( @@ -413,7 +440,8 @@ fn doc_lib_bin_same_name_documents_lib_when_requested() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); let doc_file = p.root().join("target/doc/foo/index.html"); assert!(doc_file.is_file()); @@ -438,13 +466,15 @@ fn doc_lib_bin_same_name_documents_named_bin_when_requested() { foo::foo(); } "#, - ).file( + ) + .file( "src/lib.rs", r#" //! Library documentation pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("doc --bin foo") .with_stderr( @@ -453,7 +483,8 @@ fn doc_lib_bin_same_name_documents_named_bin_when_requested() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); let doc_file = p.root().join("target/doc/foo/index.html"); assert!(doc_file.is_file()); @@ -478,13 +509,15 @@ fn doc_lib_bin_same_name_documents_bins_when_requested() { foo::foo(); } "#, - ).file( + ) + .file( "src/lib.rs", r#" //! Library documentation pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("doc --bins") .with_stderr( @@ -493,7 +526,8 @@ fn doc_lib_bin_same_name_documents_bins_when_requested() { [DOCUMENTING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/doc").is_dir()); let doc_file = p.root().join("target/doc/foo/index.html"); assert!(doc_file.is_file()); @@ -520,7 +554,8 @@ fn doc_dash_p() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "extern crate a;") + ) + .file("src/lib.rs", "extern crate a;") .file( "a/Cargo.toml", r#" @@ -532,7 +567,8 @@ fn doc_dash_p() { [dependencies.b] path = "../b" "#, - ).file("a/src/lib.rs", "extern crate b;") + ) + .file("a/src/lib.rs", "extern crate b;") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -545,7 +581,8 @@ fn doc_dash_p() { [DOCUMENTING] a v0.0.1 ([CWD]/a) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -578,15 +615,15 @@ fn doc_target() { pub static A: u32; } "#, - ).build(); + ) + .build(); p.cargo("doc --verbose --target").arg(TARGET).run(); assert!(p.root().join(&format!("target/{}/doc", TARGET)).is_dir()); - assert!( - p.root() - .join(&format!("target/{}/doc/foo/index.html", TARGET)) - .is_file() - ); + assert!(p + .root() + .join(&format!("target/{}/doc/foo/index.html", TARGET)) + .is_file()); } #[test] @@ -603,7 +640,8 @@ fn target_specific_not_documented() { [target.foo.dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "not rust") .build(); @@ -625,7 +663,8 @@ fn output_not_captured() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file( "a/src/lib.rs", @@ -635,7 +674,8 @@ fn output_not_captured() { /// ``` pub fn foo() {} ", - ).build(); + ) + .build(); p.cargo("doc") .without_status() @@ -663,7 +703,8 @@ fn target_specific_documented() { "#, rustc_host() ), - ).file( + ) + .file( "src/lib.rs", " extern crate a; @@ -671,14 +712,16 @@ fn target_specific_documented() { /// test pub fn foo() {} ", - ).file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file( "a/src/lib.rs", " /// test pub fn foo() {} ", - ).build(); + ) + .build(); p.cargo("doc").run(); } @@ -697,7 +740,8 @@ fn no_document_build_deps() { [build-dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file( "a/src/lib.rs", @@ -707,7 +751,8 @@ fn no_document_build_deps() { /// ``` pub fn foo() {} ", - ).build(); + ) + .build(); p.cargo("doc").run(); } @@ -724,7 +769,8 @@ fn doc_release() { [RUNNING] `rustdoc [..] src/lib.rs [..]` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -744,7 +790,8 @@ fn doc_multiple_deps() { [dependencies.baz] path = "baz" "#, - ).file("src/lib.rs", "extern crate bar; pub fn foo() {}") + ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) @@ -775,7 +822,8 @@ fn features() { [features] foo = ["bar/bar"] "#, - ).file("src/lib.rs", r#"#[cfg(feature = "foo")] pub fn foo() {}"#) + ) + .file("src/lib.rs", r#"#[cfg(feature = "foo")] pub fn foo() {}"#) .file( "bar/Cargo.toml", r#" @@ -787,17 +835,20 @@ fn features() { [features] bar = [] "#, - ).file( + ) + .file( "bar/build.rs", r#" fn main() { println!("cargo:rustc-cfg=bar"); } "#, - ).file( + ) + .file( "bar/src/lib.rs", r#"#[cfg(feature = "bar")] pub fn bar() {}"#, - ).build(); + ) + .build(); p.cargo("doc --features foo").run(); assert!(p.root().join("target/doc").is_dir()); assert!(p.root().join("target/doc/foo/fn.foo.html").is_file()); @@ -813,7 +864,8 @@ fn rerun_when_dir_removed() { /// dox pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("doc").run(); assert!(p.root().join("target/doc/foo/index.html").is_file()); @@ -833,7 +885,8 @@ fn document_only_lib() { /// dox pub fn foo() {} "#, - ).file( + ) + .file( "src/bin/bar.rs", r#" /// ``` @@ -842,7 +895,8 @@ fn document_only_lib() { pub fn foo() {} fn main() { foo(); } "#, - ).build(); + ) + .build(); p.cargo("doc --lib").run(); assert!(p.root().join("target/doc/foo/index.html").is_file()); } @@ -864,7 +918,8 @@ fn plugins_no_use_target() { [lib] proc-macro = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("doc --target=x86_64-unknown-openbsd -v").run(); } @@ -884,7 +939,8 @@ fn doc_all_workspace() { [workspace] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -906,7 +962,8 @@ fn doc_all_virtual_manifest() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -928,7 +985,8 @@ fn doc_virtual_manifest_all_implied() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -954,7 +1012,8 @@ fn doc_all_member_dependency_same_name() { [workspace] members = ["bar"] "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [project] @@ -964,7 +1023,8 @@ fn doc_all_member_dependency_same_name() { [dependencies] bar = "0.1.0" "#, - ).file("bar/src/lib.rs", "pub fn bar() {}") + ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); Package::new("bar", "0.1.0").publish(); @@ -984,7 +1044,8 @@ fn doc_workspace_open_help_message() { [workspace] members = ["foo", "bar"] "#, - ).file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) + ) + .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") @@ -998,10 +1059,12 @@ fn doc_workspace_open_help_message() { .with_stderr_contains( "error: Passing multiple packages and `open` \ is not supported.", - ).with_stderr_contains( + ) + .with_stderr_contains( "Please re-run this command with `-p ` \ where `` is one of the following:", - ).with_stderr_contains(" foo") + ) + .with_stderr_contains(" foo") .with_stderr_contains(" bar") .run(); } @@ -1016,7 +1079,8 @@ fn doc_workspace_open_different_library_and_package_names() { [workspace] members = ["foo"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -1025,7 +1089,8 @@ fn doc_workspace_open_different_library_and_package_names() { [lib] name = "foolib" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("doc --open") @@ -1045,7 +1110,8 @@ fn doc_workspace_open_binary() { [workspace] members = ["foo"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -1055,7 +1121,8 @@ fn doc_workspace_open_binary() { name = "foobin" path = "src/main.rs" "#, - ).file("foo/src/main.rs", "") + ) + .file("foo/src/main.rs", "") .build(); p.cargo("doc --open") @@ -1075,7 +1142,8 @@ fn doc_workspace_open_binary_and_library() { [workspace] members = ["foo"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -1087,7 +1155,8 @@ fn doc_workspace_open_binary_and_library() { name = "foobin" path = "src/main.rs" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .file("foo/src/main.rs", "") .build(); @@ -1116,7 +1185,8 @@ fn doc_edition() { authors = [] edition = "2018" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("doc -v") @@ -1148,7 +1218,8 @@ fn doc_target_edition() { [lib] edition = "2018" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("doc -v") @@ -1185,7 +1256,8 @@ fn issue_5345() { [target.'cfg(not(all(windows, target_arch = "x86")))'.dependencies] bar = "0.2" "#, - ).file("src/lib.rs", "extern crate bar;") + ) + .file("src/lib.rs", "extern crate bar;") .build(); Package::new("bar", "0.1.0").publish(); Package::new("bar", "0.2.0").publish(); @@ -1202,11 +1274,10 @@ fn doc_private_items() { foo.cargo("doc --document-private-items").run(); assert!(foo.root().join("target/doc").is_dir()); - assert!( - foo.root() - .join("target/doc/foo/private/index.html") - .is_file() - ); + assert!(foo + .root() + .join("target/doc/foo/private/index.html") + .is_file()); } #[test] @@ -1218,7 +1289,8 @@ fn doc_private_ws() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "fn p() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "fn p2() {}") @@ -1227,11 +1299,14 @@ fn doc_private_ws() { p.cargo("doc --all --bins --lib --document-private-items -v") .with_stderr_contains( "[RUNNING] `rustdoc [..] a/src/lib.rs [..]--document-private-items[..]", - ).with_stderr_contains( + ) + .with_stderr_contains( "[RUNNING] `rustdoc [..] b/src/lib.rs [..]--document-private-items[..]", - ).with_stderr_contains( + ) + .with_stderr_contains( "[RUNNING] `rustdoc [..] b/src/main.rs [..]--document-private-items[..]", - ).run(); + ) + .run(); } const BAD_INTRA_LINK_LIB: &str = r#" @@ -1250,7 +1325,8 @@ fn doc_cap_lints() { let a = git::new("a", |p| { p.file("Cargo.toml", &basic_lib_manifest("a")) .file("src/lib.rs", BAD_INTRA_LINK_LIB) - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1267,7 +1343,8 @@ fn doc_cap_lints() { "#, a.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("doc") @@ -1279,7 +1356,8 @@ fn doc_cap_lints() { [DOCUMENTING] foo v0.0.1 ([..]) [FINISHED] dev [..] ", - ).run(); + ) + .run(); p.root().join("target").rm_rf(); @@ -1288,7 +1366,8 @@ fn doc_cap_lints() { "\ [WARNING] `[bad_link]` cannot be resolved, ignoring it... ", - ).run(); + ) + .run(); } #[test] @@ -1317,7 +1396,8 @@ fn doc_message_format() { "target": "{...}" } "#, - ).run(); + ) + .run(); } #[test] @@ -1334,5 +1414,6 @@ fn short_message_format() { src/lib.rs:4:6: error: `[bad_link]` cannot be resolved, ignoring it... error: Could not document `foo`. ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/edition.rs b/tests/testsuite/edition.rs index ae9c2653ef5..5c6e0db36bb 100644 --- a/tests/testsuite/edition.rs +++ b/tests/testsuite/edition.rs @@ -18,7 +18,8 @@ fn edition_works_for_build_script() { [build-dependencies] a = { path = 'a' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -26,7 +27,8 @@ fn edition_works_for_build_script() { a::foo(); } "#, - ).file("a/Cargo.toml", &basic_lib_manifest("a")) + ) + .file("a/Cargo.toml", &basic_lib_manifest("a")) .file("a/src/lib.rs", "pub fn foo() {}") .build(); diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index beeb54544a2..7b0386723df 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -19,7 +19,8 @@ fn invalid1() { [features] bar = ["baz"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -31,7 +32,8 @@ fn invalid1() { Caused by: Feature `bar` includes `baz` which is neither a dependency nor another feature ", - ).run(); + ) + .run(); } #[test] @@ -51,7 +53,8 @@ fn invalid2() { [dependencies.bar] path = "foo" "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -63,7 +66,8 @@ fn invalid2() { Caused by: Features and dependencies cannot have the same name: `bar` ", - ).run(); + ) + .run(); } #[test] @@ -83,7 +87,8 @@ fn invalid3() { [dependencies.baz] path = "foo" "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -96,7 +101,8 @@ Caused by: Feature `bar` depends on `baz` which is not an optional dependency. Consider adding `optional = true` to the dependency ", - ).run(); + ) + .run(); } #[test] @@ -114,7 +120,8 @@ fn invalid4() { path = "bar" features = ["bar"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -131,7 +138,8 @@ the package `foo` depends on `bar`, with features: `bar` but `bar` does not have failed to select a version for `bar` which could resolve this conflict", - ).run(); + ) + .run(); p.change_file("Cargo.toml", &basic_manifest("foo", "0.0.1")); @@ -156,7 +164,8 @@ fn invalid5() { path = "bar" optional = true "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -168,7 +177,8 @@ fn invalid5() { Caused by: Dev-dependencies are not allowed to be optional: `bar` ", - ).run(); + ) + .run(); } #[test] @@ -185,7 +195,8 @@ fn invalid6() { [features] foo = ["bar/baz"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build --features foo") @@ -197,7 +208,8 @@ fn invalid6() { Caused by: Feature `foo` requires a feature of `bar` which is not a dependency ", - ).run(); + ) + .run(); } #[test] @@ -215,7 +227,8 @@ fn invalid7() { foo = ["bar/baz"] bar = [] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build --features foo") @@ -227,7 +240,8 @@ fn invalid7() { Caused by: Feature `foo` requires a feature of `bar` which is not a dependency ", - ).run(); + ) + .run(); } #[test] @@ -245,7 +259,8 @@ fn invalid8() { path = "bar" features = ["foo/bar"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -270,7 +285,8 @@ fn invalid9() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -299,7 +315,8 @@ fn invalid10() { path = "bar" features = ["baz"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -311,7 +328,8 @@ fn invalid10() { [dependencies.baz] path = "baz" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("bar/baz/src/lib.rs", "") .build(); @@ -343,13 +361,15 @@ fn no_transitive_dep_feature_requirement() { [features] default = ["derived/bar/qux"] "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate derived; fn main() { derived::test(); } "#, - ).file( + ) + .file( "derived/Cargo.toml", r#" [package] @@ -360,7 +380,8 @@ fn no_transitive_dep_feature_requirement() { [dependencies.bar] path = "../bar" "#, - ).file("derived/src/lib.rs", "extern crate bar; pub use bar::test;") + ) + .file("derived/src/lib.rs", "extern crate bar; pub use bar::test;") .file( "bar/Cargo.toml", r#" @@ -372,13 +393,15 @@ fn no_transitive_dep_feature_requirement() { [features] qux = [] "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #[cfg(feature = "qux")] pub fn test() { print!("test"); } "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) .with_stderr("[ERROR] feature names may not contain slashes: `bar/qux`") @@ -400,7 +423,8 @@ fn no_feature_doesnt_build() { path = "bar" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[cfg(feature = "bar")] @@ -410,7 +434,8 @@ fn no_feature_doesnt_build() { #[cfg(not(feature = "bar"))] fn main() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -420,7 +445,8 @@ fn no_feature_doesnt_build() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.process(&p.bin("foo")).with_stdout("").run(); p.cargo("build --features bar") @@ -430,7 +456,8 @@ fn no_feature_doesnt_build() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.process(&p.bin("foo")).with_stdout("bar\n").run(); } @@ -452,7 +479,8 @@ fn default_feature_pulled_in() { path = "bar" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[cfg(feature = "bar")] @@ -462,7 +490,8 @@ fn default_feature_pulled_in() { #[cfg(not(feature = "bar"))] fn main() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -473,7 +502,8 @@ fn default_feature_pulled_in() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.process(&p.bin("foo")).with_stdout("bar\n").run(); p.cargo("build --no-default-features") @@ -482,7 +512,8 @@ fn default_feature_pulled_in() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.process(&p.bin("foo")).with_stdout("").run(); } @@ -500,7 +531,8 @@ fn cyclic_feature() { [features] default = ["default"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -524,7 +556,8 @@ fn cyclic_feature2() { foo = ["bar"] bar = ["foo"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").with_stdout("").run(); @@ -559,7 +592,8 @@ fn groups_on_groups_on_groups() { path = "baz" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -568,7 +602,8 @@ fn groups_on_groups_on_groups() { extern crate baz; fn main() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -582,7 +617,8 @@ fn groups_on_groups_on_groups() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -604,7 +640,8 @@ fn many_cli_features() { path = "baz" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -613,7 +650,8 @@ fn many_cli_features() { extern crate baz; fn main() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -628,7 +666,8 @@ fn many_cli_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -649,7 +688,8 @@ fn union_features() { path = "d2" features = ["f2"] "#, - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -660,7 +700,8 @@ fn union_features() { d2::f2(); } "#, - ).file( + ) + .file( "d1/Cargo.toml", r#" [package] @@ -676,7 +717,8 @@ fn union_features() { features = ["f1"] optional = true "#, - ).file("d1/src/lib.rs", "") + ) + .file("d1/src/lib.rs", "") .file( "d2/Cargo.toml", r#" @@ -689,13 +731,15 @@ fn union_features() { f1 = [] f2 = [] "#, - ).file( + ) + .file( "d2/src/lib.rs", r#" #[cfg(feature = "f1")] pub fn f1() {} #[cfg(feature = "f2")] pub fn f2() {} "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -705,7 +749,8 @@ fn union_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -723,7 +768,8 @@ fn many_features_no_rebuilds() { path = "a" features = ["fall"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "a/Cargo.toml", r#" @@ -737,7 +783,8 @@ fn many_features_no_rebuilds() { ftest2 = [] fall = ["ftest", "ftest2"] "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build") @@ -747,7 +794,8 @@ fn many_features_no_rebuilds() { [COMPILING] b v0.1.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.root().move_into_the_past(); p.cargo("build -v") @@ -757,7 +805,8 @@ fn many_features_no_rebuilds() { [FRESH] b v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } // Tests that all cmd lines work with `--features ""` @@ -786,7 +835,8 @@ fn transitive_features() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::baz(); }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz(); }") .file( "bar/Cargo.toml", r#" @@ -798,10 +848,12 @@ fn transitive_features() { [features] baz = [] "#, - ).file( + ) + .file( "bar/src/lib.rs", r#"#[cfg(feature = "baz")] pub fn baz() {}"#, - ).build(); + ) + .build(); p.cargo("build --features foo").run(); } @@ -830,7 +882,8 @@ fn everything_in_the_lockfile() { path = "d3" optional = true "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "d1/Cargo.toml", r#" @@ -842,7 +895,8 @@ fn everything_in_the_lockfile() { [features] f1 = [] "#, - ).file("d1/src/lib.rs", "") + ) + .file("d1/src/lib.rs", "") .file("d2/Cargo.toml", &basic_manifest("d2", "0.0.2")) .file("d2/src/lib.rs", "") .file( @@ -856,7 +910,8 @@ fn everything_in_the_lockfile() { [features] f3 = [] "#, - ).file("d3/src/lib.rs", "") + ) + .file("d3/src/lib.rs", "") .build(); p.cargo("fetch").run(); @@ -895,7 +950,8 @@ fn no_rebuild_when_frobbing_default_feature() { a = { path = "a" } b = { path = "b" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "b/Cargo.toml", r#" @@ -907,7 +963,8 @@ fn no_rebuild_when_frobbing_default_feature() { [dependencies] a = { path = "../a", features = ["f1"], default-features = false } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -920,7 +977,8 @@ fn no_rebuild_when_frobbing_default_feature() { default = ["f1"] f1 = [] "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -943,7 +1001,8 @@ fn unions_work_with_no_default_features() { a = { path = "a" } b = { path = "b" } "#, - ).file("src/lib.rs", "extern crate a; pub fn foo() { a::a(); }") + ) + .file("src/lib.rs", "extern crate a; pub fn foo() { a::a(); }") .file( "b/Cargo.toml", r#" @@ -955,7 +1014,8 @@ fn unions_work_with_no_default_features() { [dependencies] a = { path = "../a", features = [], default-features = false } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -968,7 +1028,8 @@ fn unions_work_with_no_default_features() { default = ["f1"] f1 = [] "#, - ).file("a/src/lib.rs", r#"#[cfg(feature = "f1")] pub fn a() {}"#) + ) + .file("a/src/lib.rs", r#"#[cfg(feature = "f1")] pub fn a() {}"#) .build(); p.cargo("build").run(); @@ -992,7 +1053,8 @@ fn optional_and_dev_dep() { [dev-dependencies] foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "") .build(); @@ -1003,7 +1065,8 @@ fn optional_and_dev_dep() { [COMPILING] test v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1023,10 +1086,12 @@ fn activating_feature_activates_dep() { [features] a = ["foo/a"] "#, - ).file( + ) + .file( "src/lib.rs", "extern crate foo; pub fn bar() { foo::bar(); }", - ).file( + ) + .file( "foo/Cargo.toml", r#" [package] @@ -1037,7 +1102,8 @@ fn activating_feature_activates_dep() { [features] a = [] "#, - ).file("foo/src/lib.rs", r#"#[cfg(feature = "a")] pub fn bar() {}"#) + ) + .file("foo/src/lib.rs", r#"#[cfg(feature = "a")] pub fn bar() {}"#) .build(); p.cargo("build --features a -v").run(); @@ -1057,13 +1123,15 @@ fn dep_feature_in_cmd_line() { [dependencies.derived] path = "derived" "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate derived; fn main() { derived::test(); } "#, - ).file( + ) + .file( "derived/Cargo.toml", r#" [package] @@ -1078,7 +1146,8 @@ fn dep_feature_in_cmd_line() { default = [] derived-feat = ["bar/some-feat"] "#, - ).file("derived/src/lib.rs", "extern crate bar; pub use bar::test;") + ) + .file("derived/src/lib.rs", "extern crate bar; pub use bar::test;") .file( "bar/Cargo.toml", r#" @@ -1090,13 +1159,15 @@ fn dep_feature_in_cmd_line() { [features] some-feat = [] "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #[cfg(feature = "some-feat")] pub fn test() { print!("test"); } "#, - ).build(); + ) + .build(); // The foo project requires that feature "some-feat" in "bar" is enabled. // Building without any features enabled should fail: @@ -1138,7 +1209,8 @@ fn all_features_flag_enables_all_features() { path = "baz" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[cfg(feature = "foo")] @@ -1155,7 +1227,8 @@ fn all_features_flag_enables_all_features() { bar(); } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("baz/src/lib.rs", "pub fn baz() {}") .build(); @@ -1181,7 +1254,8 @@ fn many_cli_features_comma_delimited() { path = "baz" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -1190,7 +1264,8 @@ fn many_cli_features_comma_delimited() { extern crate baz; fn main() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -1204,7 +1279,8 @@ fn many_cli_features_comma_delimited() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1234,7 +1310,8 @@ fn many_cli_features_comma_and_space_delimited() { path = "bap" optional = true "#, - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -1247,7 +1324,8 @@ fn many_cli_features_comma_and_space_delimited() { extern crate bap; fn main() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("baz/src/lib.rs", "pub fn baz() {}") @@ -1268,7 +1346,8 @@ fn many_cli_features_comma_and_space_delimited() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1290,7 +1369,8 @@ fn combining_features_and_package() { [dependencies] dep = "1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -1301,13 +1381,15 @@ fn combining_features_and_package() { [features] main = [] "#, - ).file( + ) + .file( "bar/src/main.rs", r#" #[cfg(feature = "main")] fn main() {} "#, - ).build(); + ) + .build(); p.cargo("build -Z package-features --all --features main") .masquerade_as_nightly_cargo() @@ -1315,7 +1397,8 @@ fn combining_features_and_package() { .with_stderr_contains( "\ [ERROR] cannot specify features for more than one package", - ).run(); + ) + .run(); p.cargo("build -Z package-features --package dep --features main") .masquerade_as_nightly_cargo() @@ -1323,21 +1406,24 @@ fn combining_features_and_package() { .with_stderr_contains( "\ [ERROR] cannot specify features for packages outside of workspace", - ).run(); + ) + .run(); p.cargo("build -Z package-features --package dep --all-features") .masquerade_as_nightly_cargo() .with_status(101) .with_stderr_contains( "\ [ERROR] cannot specify features for packages outside of workspace", - ).run(); + ) + .run(); p.cargo("build -Z package-features --package dep --no-default-features") .masquerade_as_nightly_cargo() .with_status(101) .with_stderr_contains( "\ [ERROR] cannot specify features for packages outside of workspace", - ).run(); + ) + .run(); p.cargo("build -Z package-features --all --all-features") .masquerade_as_nightly_cargo() @@ -1364,7 +1450,8 @@ fn namespaced_invalid_feature() { [features] bar = ["baz"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -1377,7 +1464,8 @@ fn namespaced_invalid_feature() { Caused by: Feature `bar` includes `baz` which is not defined as a feature ", - ).run(); + ) + .run(); } #[test] @@ -1397,7 +1485,8 @@ fn namespaced_invalid_dependency() { [features] bar = ["crate:baz"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -1410,7 +1499,8 @@ fn namespaced_invalid_dependency() { Caused by: Feature `bar` includes `crate:baz` which is not a known dependency ", - ).run(); + ) + .run(); } #[test] @@ -1433,7 +1523,8 @@ fn namespaced_non_optional_dependency() { [dependencies] baz = "0.1" "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build") @@ -1447,7 +1538,8 @@ Caused by: Feature `bar` includes `crate:baz` which is not an optional dependency. Consider adding `optional = true` to the dependency ", - ).run(); + ) + .run(); } #[test] @@ -1470,7 +1562,8 @@ fn namespaced_implicit_feature() { [dependencies] baz = { version = "0.1", optional = true } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").masquerade_as_nightly_cargo().run(); @@ -1496,7 +1589,8 @@ fn namespaced_shadowed_dep() { [dependencies] baz = { version = "0.1", optional = true } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr( @@ -1531,7 +1625,8 @@ fn namespaced_shadowed_non_optional() { [dependencies] baz = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr( @@ -1567,7 +1662,8 @@ fn namespaced_implicit_non_optional() { [dependencies] baz = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").masquerade_as_nightly_cargo().with_status(101).with_stderr( @@ -1602,7 +1698,8 @@ fn namespaced_same_name() { [dependencies] baz = { version = "0.1", optional = true } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").masquerade_as_nightly_cargo().run(); @@ -1630,7 +1727,8 @@ fn only_dep_is_optional() { [dev-dependencies] bar = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").run(); @@ -1652,7 +1750,8 @@ fn all_features_all_crates() { [workspace] members = ['bar'] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -1664,7 +1763,8 @@ fn all_features_all_crates() { [features] foo = [] "#, - ).file("bar/src/main.rs", "#[cfg(feature = \"foo\")] fn main() {}") + ) + .file("bar/src/main.rs", "#[cfg(feature = \"foo\")] fn main() {}") .build(); p.cargo("build --all-features --all").run(); @@ -1748,9 +1848,10 @@ fn warn_if_default_features() { [features] default-features = ["bar"] - "# - ).file("src/main.rs", "fn main() {}") - .file("bar/Cargo.toml",&basic_manifest("bar", "0.0.1")) + "#, + ) + .file("src/main.rs", "fn main() {}") + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); diff --git a/tests/testsuite/fetch.rs b/tests/testsuite/fetch.rs index b453b95d2a4..d285e916d2a 100644 --- a/tests/testsuite/fetch.rs +++ b/tests/testsuite/fetch.rs @@ -49,7 +49,8 @@ fn fetch_all_platform_dependencies_when_no_target_is_given() { host = host, target = target ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("fetch") @@ -95,7 +96,8 @@ fn fetch_platform_specific_dependencies() { host = host, target = target ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("fetch --target") diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index 280d02724e6..4d898b65007 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -23,7 +23,8 @@ fn do_not_fix_broken_builds() { let _x: u32 = "a"; } "#, - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") @@ -43,7 +44,8 @@ fn fix_broken_if_requested() { foo(1); } "#, - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs --broken-code") .env("__CARGO_FIX_YOLO", "1") @@ -61,7 +63,8 @@ fn broken_fixes_backed_out() { version = '0.1.0' [workspace] "#, - ).file( + ) + .file( "foo/src/main.rs", r##" use std::env; @@ -94,7 +97,8 @@ fn broken_fixes_backed_out() { process::exit(status.code().unwrap_or(2)); } "##, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -102,7 +106,8 @@ fn broken_fixes_backed_out() { version = '0.1.0' [workspace] "#, - ).file("bar/build.rs", "fn main() {}") + ) + .file("bar/build.rs", "fn main() {}") .file( "bar/src/lib.rs", r#" @@ -111,7 +116,8 @@ fn broken_fixes_backed_out() { drop(x); } "#, - ).build(); + ) + .build(); // Build our rustc shim p.cargo("build").cwd(p.root().join("foo")).run(); @@ -140,7 +146,8 @@ fn broken_fixes_backed_out() { https://github.com/rust-lang/cargo/issues\n\ quoting the full output of this command we'd be very appreciative!\ ", - ).with_stderr_does_not_contain("[..][FIXING][..]") + ) + .with_stderr_does_not_contain("[..][FIXING][..]") .run(); } @@ -159,7 +166,8 @@ fn fix_path_deps() { [workspace] "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -169,7 +177,8 @@ fn fix_path_deps() { x } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file( "bar/src/lib.rs", r#" @@ -178,7 +187,8 @@ fn fix_path_deps() { x } "#, - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs -p foo -p bar") .env("__CARGO_FIX_YOLO", "1") @@ -191,7 +201,8 @@ fn fix_path_deps() { [FIXING] src/lib.rs (1 fix) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -210,7 +221,8 @@ fn do_not_fix_non_relevant_deps() { [workspace] "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file( "bar/src/lib.rs", @@ -220,7 +232,8 @@ fn do_not_fix_non_relevant_deps() { x } "#, - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") @@ -254,7 +267,8 @@ fn prepare_for_2018() { let x = ::foo::FOO; } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo v0.0.1 ([..]) @@ -268,10 +282,9 @@ fn prepare_for_2018() { println!("{}", p.read_file("src/lib.rs")); assert!(p.read_file("src/lib.rs").contains("use crate::foo::FOO;")); - assert!( - p.read_file("src/lib.rs") - .contains("let x = crate::foo::FOO;") - ); + assert!(p + .read_file("src/lib.rs") + .contains("let x = crate::foo::FOO;")); } #[test] @@ -295,7 +308,8 @@ fn local_paths() { foo(); } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo v0.0.1 ([..]) @@ -331,7 +345,8 @@ fn upgrade_extern_crate() { [dependencies] bar = { path = 'bar' } "#, - ).file( + ) + .file( "src/lib.rs", r#" #![warn(rust_2018_idioms)] @@ -344,7 +359,8 @@ fn upgrade_extern_crate() { bar(); } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -383,7 +399,8 @@ fn specify_rustflags() { let x = ::foo::FOO; } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo v0.0.1 ([..]) @@ -422,7 +439,8 @@ fn fixes_extra_mut() { x } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo v0.0.1 ([..]) @@ -448,7 +466,8 @@ fn fixes_two_missing_ampersands() { x + y } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo v0.0.1 ([..]) @@ -473,7 +492,8 @@ fn tricky() { x + y } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo v0.0.1 ([..]) @@ -496,7 +516,8 @@ fn preserve_line_endings() { fn add(a: &u32) -> u32 { a + 1 }\r\n\ pub fn foo() -> u32 { let mut x = 3; add(&x) }\r\n\ ", - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") @@ -513,7 +534,8 @@ fn fix_deny_warnings() { #![deny(warnings)] pub fn foo() { let mut x = 3; drop(x); } ", - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") @@ -535,7 +557,8 @@ fn fix_deny_warnings_but_not_others() { fn bar() {} ", - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") @@ -557,7 +580,8 @@ fn fix_two_files() { x } ", - ).file( + ) + .file( "src/bar.rs", " pub fn foo() -> u32 { @@ -566,7 +590,8 @@ fn fix_two_files() { } ", - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs") .env("__CARGO_FIX_YOLO", "1") @@ -589,31 +614,34 @@ fn fixes_missing_ampersand() { #[test] pub fn foo2() { let mut x = 3; drop(x); } "#, - ).file( + ) + .file( "tests/a.rs", r#" #[test] pub fn foo() { let mut x = 3; drop(x); } "#, - ).file("examples/foo.rs", "fn main() { let mut x = 3; drop(x); }") + ) + .file("examples/foo.rs", "fn main() { let mut x = 3; drop(x); }") .file("build.rs", "fn main() { let mut x = 3; drop(x); }") .build(); p.cargo("fix --all-targets --allow-no-vcs") - .env("__CARGO_FIX_YOLO", "1") - .with_stdout("") - .with_stderr_contains("[COMPILING] foo v0.0.1 ([..])") - .with_stderr_contains("[FIXING] build.rs (1 fix)") - // Don't assert number of fixes for this one, as we don't know if we're - // fixing it once or twice! We run this all concurrently, and if we - // compile (and fix) in `--test` mode first, we get two fixes. Otherwise - // we'll fix one non-test thing, and then fix another one later in - // test mode. - .with_stderr_contains("[FIXING] src/lib.rs[..]") - .with_stderr_contains("[FIXING] src/main.rs (1 fix)") - .with_stderr_contains("[FIXING] examples/foo.rs (1 fix)") - .with_stderr_contains("[FIXING] tests/a.rs (1 fix)") - .with_stderr_contains("[FINISHED] [..]").run(); + .env("__CARGO_FIX_YOLO", "1") + .with_stdout("") + .with_stderr_contains("[COMPILING] foo v0.0.1 ([..])") + .with_stderr_contains("[FIXING] build.rs (1 fix)") + // Don't assert number of fixes for this one, as we don't know if we're + // fixing it once or twice! We run this all concurrently, and if we + // compile (and fix) in `--test` mode first, we get two fixes. Otherwise + // we'll fix one non-test thing, and then fix another one later in + // test mode. + .with_stderr_contains("[FIXING] src/lib.rs[..]") + .with_stderr_contains("[FIXING] src/main.rs (1 fix)") + .with_stderr_contains("[FIXING] examples/foo.rs (1 fix)") + .with_stderr_contains("[FIXING] tests/a.rs (1 fix)") + .with_stderr_contains("[FINISHED] [..]") + .run(); p.cargo("build").run(); p.cargo("test").run(); } @@ -633,13 +661,15 @@ fn fix_features() { [workspace] "#, - ).file( + ) + .file( "src/lib.rs", r#" #[cfg(feature = "bar")] pub fn foo() -> u32 { let mut x = 3; x } "#, - ).build(); + ) + .build(); p.cargo("fix --allow-no-vcs").run(); p.cargo("build").run(); @@ -669,7 +699,8 @@ fn warns_if_no_vcs_detected() { error: no VCS found for this package and `cargo fix` can potentially perform \ destructive changes; if you'd like to suppress this error pass `--allow-no-vcs`\ ", - ).run(); + ) + .run(); p.cargo("fix --allow-no-vcs").run(); } @@ -699,7 +730,8 @@ commit the changes to these files: ", - ).run(); + ) + .run(); p.cargo("fix --allow-dirty").run(); } @@ -733,7 +765,8 @@ commit the changes to these files: ", - ).run(); + ) + .run(); p.cargo("fix --allow-staged").run(); } @@ -795,7 +828,8 @@ fn prepare_for_and_enable() { version = '0.1.0' edition = '2018' "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let stderr = "\ @@ -836,7 +870,8 @@ fn fix_overlapping() { } } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo [..] @@ -867,7 +902,8 @@ fn fix_idioms() { version = '0.1.0' edition = '2018' "#, - ).file( + ) + .file( "src/lib.rs", r#" use std::any::Any; @@ -875,7 +911,8 @@ fn fix_idioms() { let _x: Box = Box::new(3); } "#, - ).build(); + ) + .build(); let stderr = "\ [CHECKING] foo [..] @@ -1025,7 +1062,8 @@ fn doesnt_rebuild_dependencies() { [workspace] "#, - ).file("src/lib.rs", "extern crate bar;") + ) + .file("src/lib.rs", "extern crate bar;") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") .build(); @@ -1033,20 +1071,24 @@ fn doesnt_rebuild_dependencies() { p.cargo("fix --allow-no-vcs -p foo") .env("__CARGO_FIX_YOLO", "1") .with_stdout("") - .with_stderr("\ + .with_stderr( + "\ [CHECKING] bar v0.1.0 ([..]) [CHECKING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -") +", + ) .run(); p.cargo("fix --allow-no-vcs -p foo") .env("__CARGO_FIX_YOLO", "1") .with_stdout("") - .with_stderr("\ + .with_stderr( + "\ [CHECKING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -") +", + ) .run(); } @@ -1109,11 +1151,13 @@ fn only_warn_for_relevant_crates() { .build(); p.cargo("fix --allow-no-vcs --edition") - .with_stderr("\ + .with_stderr( + "\ [CHECKING] a v0.1.0 ([..]) [CHECKING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -") +", + ) .run(); } @@ -1131,7 +1175,8 @@ fn fix_to_broken_code() { version = '0.1.0' [workspace] "#, - ).file( + ) + .file( "foo/src/main.rs", r##" use std::env; @@ -1161,7 +1206,8 @@ fn fix_to_broken_code() { process::exit(status.code().unwrap_or(2)); } "##, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -1169,11 +1215,10 @@ fn fix_to_broken_code() { version = '0.1.0' [workspace] "#, - ).file("bar/build.rs", "fn main() {}") - .file( - "bar/src/lib.rs", - "pub fn foo() { let mut x = 3; drop(x); }", - ).build(); + ) + .file("bar/build.rs", "fn main() {}") + .file("bar/src/lib.rs", "pub fn foo() { let mut x = 3; drop(x); }") + .build(); // Build our rustc shim p.cargo("build").cwd(p.root().join("foo")).run(); @@ -1185,5 +1230,8 @@ fn fix_to_broken_code() { .with_status(101) .run(); - assert_eq!(p.read_file("bar/src/lib.rs"), "pub fn foo() { let x = 3; drop(x); }"); + assert_eq!( + p.read_file("bar/src/lib.rs"), + "pub fn foo() { let x = 3; drop(x); }" + ); } diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 7b959d4443d..74daba86518 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -19,7 +19,8 @@ fn modifying_and_moving() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stdout("").run(); p.root().move_into_the_past(); @@ -35,7 +36,8 @@ fn modifying_and_moving() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); fs::rename(&p.root().join("src/a.rs"), &p.root().join("src/b.rs")).unwrap(); p.cargo("build").with_status(101).run(); @@ -57,7 +59,8 @@ fn modify_only_some_files() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("test").run(); sleep_ms(1000); @@ -83,7 +86,8 @@ fn modify_only_some_files() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.bin("foo").is_file()); } @@ -103,7 +107,8 @@ fn rebuild_sub_package_then_while_package() { [dependencies.b] path = "b" "#, - ).file("src/lib.rs", "extern crate a; extern crate b;") + ) + .file("src/lib.rs", "extern crate a; extern crate b;") .file( "a/Cargo.toml", r#" @@ -114,7 +119,8 @@ fn rebuild_sub_package_then_while_package() { [dependencies.b] path = "../b" "#, - ).file("a/src/lib.rs", "extern crate b;") + ) + .file("a/src/lib.rs", "extern crate b;") .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -150,7 +156,8 @@ fn changing_lib_features_caches_targets() { [features] foo = [] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -159,7 +166,8 @@ fn changing_lib_features_caches_targets() { [..]Compiling foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build --features foo") .with_stderr( @@ -167,7 +175,8 @@ fn changing_lib_features_caches_targets() { [..]Compiling foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); /* Targets should be cached from the first build */ @@ -196,7 +205,8 @@ fn changing_profiles_caches_targets() { [profile.dev] panic = "abort" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -205,7 +215,8 @@ fn changing_profiles_caches_targets() { [..]Compiling foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("test") .with_stderr( @@ -215,7 +226,8 @@ fn changing_profiles_caches_targets() { [RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] [DOCTEST] foo ", - ).run(); + ) + .run(); /* Targets should be cached from the first build */ @@ -230,7 +242,8 @@ fn changing_profiles_caches_targets() { [RUNNING] target[..]debug[..]deps[..]foo-[..][EXE] [DOCTEST] foo ", - ).run(); + ) + .run(); } #[test] @@ -244,7 +257,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [build] target-dir = "./target" "#, - ).file( + ) + .file( "dep_crate/Cargo.toml", r#" [package] @@ -255,7 +269,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [features] ftest = [] "#, - ).file( + ) + .file( "dep_crate/src/lib.rs", r#" #[cfg(feature = "ftest")] @@ -267,7 +282,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { println!("ftest off") } "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [package] @@ -278,7 +294,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [dependencies] dep_crate = {path = "../dep_crate", features = []} "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "a/src/main.rs", r#" @@ -288,7 +305,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { yo(); } "#, - ).file( + ) + .file( "b/Cargo.toml", r#" [package] @@ -299,7 +317,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [dependencies] dep_crate = {path = "../dep_crate", features = ["ftest"]} "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file( "b/src/main.rs", r#" @@ -309,7 +328,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { yo(); } "#, - ).build(); + ) + .build(); /* Build and rebuild a/. Ensure dep_crate only builds once */ p.cargo("run") @@ -322,7 +342,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/a[EXE]` ", - ).run(); + ) + .run(); p.cargo("clean -p a").cwd(p.root().join("a")).run(); p.cargo("run") .cwd(p.root().join("a")) @@ -333,7 +354,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/a[EXE]` ", - ).run(); + ) + .run(); /* Build and rebuild b/. Ensure dep_crate only builds once */ p.cargo("run") @@ -346,7 +368,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/b[EXE]` ", - ).run(); + ) + .run(); p.cargo("clean -p b").cwd(p.root().join("b")).run(); p.cargo("run") .cwd(p.root().join("b")) @@ -357,7 +380,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/b[EXE]` ", - ).run(); + ) + .run(); /* Build a/ package again. If we cache different feature dep builds correctly, * this should not cause a rebuild of dep_crate */ @@ -371,7 +395,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/a[EXE]` ", - ).run(); + ) + .run(); /* Build b/ package again. If we cache different feature dep builds correctly, * this should not cause a rebuild */ @@ -385,7 +410,8 @@ fn changing_bin_paths_common_target_features_caches_targets() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/b[EXE]` ", - ).run(); + ) + .run(); } #[test] @@ -402,7 +428,8 @@ fn changing_bin_features_caches_targets() { [features] foo = [] "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() { @@ -410,7 +437,8 @@ fn changing_bin_features_caches_targets() { println!("{}", msg); } "#, - ).build(); + ) + .build(); // Windows has a problem with replacing a binary that was just executed. // Unlinking it will succeed, but then attempting to immediately replace @@ -429,7 +457,8 @@ fn changing_bin_features_caches_targets() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); foo_proc("off1").with_stdout("feature off").run(); p.cargo("build --features foo") @@ -438,7 +467,8 @@ fn changing_bin_features_caches_targets() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); foo_proc("on1").with_stdout("feature on").run(); /* Targets should be cached from the first build */ @@ -448,7 +478,8 @@ fn changing_bin_features_caches_targets() { "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); foo_proc("off2").with_stdout("feature off").run(); p.cargo("build --features foo") @@ -456,7 +487,8 @@ fn changing_bin_features_caches_targets() { "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); foo_proc("on2").with_stdout("feature on").run(); } @@ -471,7 +503,8 @@ fn rebuild_tests_if_lib_changes() { #[test] fn test() { foo::foo(); } "#, - ).build(); + ) + .build(); p.cargo("build").run(); p.cargo("test").run(); @@ -499,7 +532,8 @@ fn no_rebuild_transitive_target_deps() { [dev-dependencies] b = { path = "b" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("tests/foo.rs", "") .file( "a/Cargo.toml", @@ -512,7 +546,8 @@ fn no_rebuild_transitive_target_deps() { [target.foo.dependencies] c = { path = "../c" } "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .file( "b/Cargo.toml", r#" @@ -524,7 +559,8 @@ fn no_rebuild_transitive_target_deps() { [dependencies] c = { path = "../c" } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file("c/Cargo.toml", &basic_manifest("c", "0.0.1")) .file("c/src/lib.rs", "") .build(); @@ -538,7 +574,8 @@ fn no_rebuild_transitive_target_deps() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -555,7 +592,8 @@ fn rerun_if_changed_in_dep() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -565,14 +603,16 @@ fn rerun_if_changed_in_dep() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "a/build.rs", r#" fn main() { println!("cargo:rerun-if-changed=build.rs"); } "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -593,7 +633,8 @@ fn same_build_dir_cached_packages() { [dependencies] b = { path = "../b" } "#, - ).file("a1/src/lib.rs", "") + ) + .file("a1/src/lib.rs", "") .file( "a2/Cargo.toml", r#" @@ -604,7 +645,8 @@ fn same_build_dir_cached_packages() { [dependencies] b = { path = "../b" } "#, - ).file("a2/src/lib.rs", "") + ) + .file("a2/src/lib.rs", "") .file( "b/Cargo.toml", r#" @@ -615,7 +657,8 @@ fn same_build_dir_cached_packages() { [dependencies] c = { path = "../c" } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file( "c/Cargo.toml", r#" @@ -626,7 +669,8 @@ fn same_build_dir_cached_packages() { [dependencies] d = { path = "../d" } "#, - ).file("c/src/lib.rs", "") + ) + .file("c/src/lib.rs", "") .file("d/Cargo.toml", &basic_manifest("d", "0.0.1")) .file("d/src/lib.rs", "") .file( @@ -635,7 +679,8 @@ fn same_build_dir_cached_packages() { [build] target-dir = "./target" "#, - ).build(); + ) + .build(); p.cargo("build") .cwd(p.root().join("a1")) @@ -648,7 +693,8 @@ fn same_build_dir_cached_packages() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", dir = p.url().to_file_path().unwrap().to_str().unwrap() - )).run(); + )) + .run(); p.cargo("build") .cwd(p.root().join("a2")) .with_stderr( @@ -656,7 +702,8 @@ fn same_build_dir_cached_packages() { [COMPILING] a2 v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -673,7 +720,8 @@ fn no_rebuild_if_build_artifacts_move_backwards_in_time() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -702,7 +750,8 @@ fn rebuild_if_build_artifacts_move_forward_in_time() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -720,7 +769,8 @@ fn rebuild_if_build_artifacts_move_forward_in_time() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -735,14 +785,16 @@ fn rebuild_if_environment_changes() { version = "0.0.1" authors = [] "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() { println!("{}", env!("CARGO_PKG_DESCRIPTION")); } "#, - ).build(); + ) + .build(); p.cargo("run") .with_stdout("old desc") @@ -752,7 +804,8 @@ fn rebuild_if_environment_changes() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/foo[EXE]` ", - ).run(); + ) + .run(); File::create(&p.root().join("Cargo.toml")) .unwrap() @@ -764,7 +817,8 @@ fn rebuild_if_environment_changes() { version = "0.0.1" authors = [] "#, - ).unwrap(); + ) + .unwrap(); p.cargo("run") .with_stdout("new desc") @@ -774,7 +828,8 @@ fn rebuild_if_environment_changes() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/foo[EXE]` ", - ).run(); + ) + .run(); } #[test] @@ -791,7 +846,8 @@ fn no_rebuild_when_rename_dir() { [dependencies] foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("foo/Cargo.toml", &basic_manifest("foo", "0.0.1")) .file("foo/src/lib.rs", "") .build(); @@ -828,7 +884,8 @@ fn unused_optional_dep() { baz = { path = "baz" } registry1 = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -840,7 +897,8 @@ fn unused_optional_dep() { [dev-dependencies] registry2 = "*" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file( "baz/Cargo.toml", r#" @@ -852,7 +910,8 @@ fn unused_optional_dep() { [dependencies] registry3 = { version = "*", optional = true } "#, - ).file("baz/src/lib.rs", "") + ) + .file("baz/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -876,7 +935,8 @@ fn path_dev_dep_registry_updates() { [dependencies] bar = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -891,7 +951,8 @@ fn path_dev_dep_registry_updates() { [dev-dependencies] baz = { path = "../baz"} "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file( "baz/Cargo.toml", r#" @@ -903,7 +964,8 @@ fn path_dev_dep_registry_updates() { [dependencies] registry2 = "*" "#, - ).file("baz/src/lib.rs", "") + ) + .file("baz/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -921,7 +983,8 @@ fn change_panic_mode() { [profile.dev] panic = 'abort' "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.1")) .file("bar/src/lib.rs", "") .file( @@ -938,7 +1001,8 @@ fn change_panic_mode() { [dependencies] bar = { path = '../bar' } "#, - ).file("baz/src/lib.rs", "extern crate bar;") + ) + .file("baz/src/lib.rs", "extern crate bar;") .build(); p.cargo("build -p bar").run(); @@ -961,7 +1025,8 @@ fn dont_rebuild_based_on_plugins() { [dependencies] proc-macro-thing = { path = 'proc-macro-thing' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "proc-macro-thing/Cargo.toml", r#" @@ -975,7 +1040,8 @@ fn dont_rebuild_based_on_plugins() { [dependencies] qux = { path = '../qux' } "#, - ).file("proc-macro-thing/src/lib.rs", "") + ) + .file("proc-macro-thing/src/lib.rs", "") .file( "baz/Cargo.toml", r#" @@ -986,7 +1052,8 @@ fn dont_rebuild_based_on_plugins() { [dependencies] qux = { path = '../qux' } "#, - ).file("baz/src/main.rs", "fn main() {}") + ) + .file("baz/src/main.rs", "fn main() {}") .file("qux/Cargo.toml", &basic_manifest("qux", "0.1.1")) .file("qux/src/lib.rs", "") .build(); @@ -1014,7 +1081,8 @@ fn reuse_workspace_lib() { [dependencies] baz = { path = 'baz' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.1")) .file("baz/src/lib.rs", "") .build(); @@ -1027,7 +1095,8 @@ fn reuse_workspace_lib() { [RUNNING] `rustc[..] --test [..]` [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/generate_lockfile.rs b/tests/testsuite/generate_lockfile.rs index cfe0253e6d8..d494dd93244 100644 --- a/tests/testsuite/generate_lockfile.rs +++ b/tests/testsuite/generate_lockfile.rs @@ -30,7 +30,8 @@ fn adding_and_removing_packages() { [dependencies.bar] path = "bar" "#, - ).unwrap(); + ) + .unwrap(); p.cargo("generate-lockfile").run(); let lock2 = p.read_lockfile(); assert_ne!(lock1, lock2); @@ -56,7 +57,8 @@ fn adding_and_removing_packages() { authors = [] version = "0.0.1" "#, - ).unwrap(); + ) + .unwrap(); p.cargo("generate-lockfile").run(); let lock4 = p.read_lockfile(); assert_eq!(lock1, lock4); @@ -78,7 +80,8 @@ fn no_index_update() { [dependencies] serde = "1.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("generate-lockfile") @@ -189,7 +192,8 @@ fn duplicate_entries_in_lockfile() { [dependencies] common = {path="common"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let common_toml = &basic_manifest("common", "0.0.1"); @@ -212,7 +216,8 @@ fn duplicate_entries_in_lockfile() { common = {path="common"} a = {path="../a"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let _common_in_b = ProjectBuilder::new(paths::root().join("b/common")) @@ -227,5 +232,6 @@ fn duplicate_entries_in_lockfile() { "[..]package collision in the lockfile: packages common [..] and \ common [..] are different, but only one can be written to \ lockfile unambiguously", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 38cc48469cf..9ed1345f80d 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -10,8 +10,8 @@ use std::thread; use crate::support::paths::{self, CargoPathExt}; use crate::support::sleep_ms; -use crate::support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; use crate::support::Project; +use crate::support::{basic_lib_manifest, basic_manifest, git, main_file, path2url, project}; #[test] fn cargo_compile_simple_git_dep() { @@ -27,7 +27,8 @@ fn cargo_compile_simple_git_dep() { } "#, ) - }).unwrap(); + }) + .unwrap(); let project = project .file( @@ -46,10 +47,12 @@ fn cargo_compile_simple_git_dep() { "#, git_project.url() ), - ).file( + ) + .file( "src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); let git_root = git_project.root(); @@ -62,7 +65,8 @@ fn cargo_compile_simple_git_dep() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", path2url(&git_root), path2url(&git_root), - )).run(); + )) + .run(); assert!(project.bin("foo").is_file()); @@ -87,7 +91,8 @@ fn cargo_compile_forbird_git_httpsrepo_offline() { [dependencies.dep1] git = 'https://github.com/some_user/dep1.git' "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build -Zoffline").masquerade_as_nightly_cargo().with_status(101). @@ -112,7 +117,8 @@ fn cargo_compile_offline_with_cached_git_dep() { pub static COOL_STR:&str = "cached git repo rev1"; "#, ) - }).unwrap(); + }) + .unwrap(); let repo = git2::Repository::open(&git_project.root()).unwrap(); let rev1 = repo.revparse_single("HEAD").unwrap().id(); @@ -144,7 +150,8 @@ fn cargo_compile_offline_with_cached_git_dep() { git_project.url(), rev1 ), - ).file("src/main.rs", "fn main(){}") + ) + .file("src/main.rs", "fn main(){}") .build(); prj.cargo("build").run(); @@ -163,8 +170,10 @@ fn cargo_compile_offline_with_cached_git_dep() { "#, git_project.url(), rev2 - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); prj.cargo("build").run(); } @@ -182,10 +191,12 @@ fn cargo_compile_offline_with_cached_git_dep() { "#, git_project.url() ), - ).file( + ) + .file( "src/main.rs", &main_file(r#""hello from {}", dep1::COOL_STR"#, &["dep1"]), - ).build(); + ) + .build(); let git_root = git_project.root(); @@ -197,7 +208,8 @@ fn cargo_compile_offline_with_cached_git_dep() { [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", path2url(git_root), - )).run(); + )) + .run(); assert!(p.bin("foo").is_file()); @@ -220,10 +232,14 @@ fn cargo_compile_offline_with_cached_git_dep() { "#, git_project.url(), rev1 - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); - p.cargo("build -Zoffline").masquerade_as_nightly_cargo().run(); + p.cargo("build -Zoffline") + .masquerade_as_nightly_cargo() + .run(); p.process(&p.bin("foo")) .with_stdout("hello from cached git repo rev1\n") .run(); @@ -243,7 +259,8 @@ fn cargo_compile_git_dep_branch() { } "#, ) - }).unwrap(); + }) + .unwrap(); // Make a new branch based on the current HEAD commit let repo = git2::Repository::open(&git_project.root()).unwrap(); @@ -270,10 +287,12 @@ fn cargo_compile_git_dep_branch() { "#, git_project.url() ), - ).file( + ) + .file( "src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); let git_root = git_project.root(); @@ -286,7 +305,8 @@ fn cargo_compile_git_dep_branch() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", path2url(&git_root), path2url(&git_root), - )).run(); + )) + .run(); assert!(project.bin("foo").is_file()); @@ -310,7 +330,8 @@ fn cargo_compile_git_dep_tag() { } "#, ) - }).unwrap(); + }) + .unwrap(); // Make a tag corresponding to the current HEAD let repo = git2::Repository::open(&git_project.root()).unwrap(); @@ -321,7 +342,8 @@ fn cargo_compile_git_dep_tag() { &repo.signature().unwrap(), "make a new tag", false, - ).unwrap(); + ) + .unwrap(); let project = project .file( @@ -341,10 +363,12 @@ fn cargo_compile_git_dep_tag() { "#, git_project.url() ), - ).file( + ) + .file( "src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); let git_root = git_project.root(); @@ -357,7 +381,8 @@ fn cargo_compile_git_dep_tag() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", path2url(&git_root), path2url(&git_root), - )).run(); + )) + .run(); assert!(project.bin("foo").is_file()); @@ -391,7 +416,8 @@ fn cargo_compile_with_nested_paths() { name = "dep1" "#, - ).file( + ) + .file( "src/dep1.rs", r#" extern crate dep2; @@ -400,7 +426,8 @@ fn cargo_compile_with_nested_paths() { dep2::hello() } "#, - ).file("vendor/dep2/Cargo.toml", &basic_lib_manifest("dep2")) + ) + .file("vendor/dep2/Cargo.toml", &basic_lib_manifest("dep2")) .file( "vendor/dep2/src/dep2.rs", r#" @@ -409,7 +436,8 @@ fn cargo_compile_with_nested_paths() { } "#, ) - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -433,10 +461,12 @@ fn cargo_compile_with_nested_paths() { "#, git_project.url() ), - ).file( + ) + .file( "src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); p.cargo("build").run(); @@ -457,8 +487,10 @@ fn cargo_compile_with_malformed_nested_paths() { "hello world" } "#, - ).file("vendor/dep2/Cargo.toml", "!INVALID!") - }).unwrap(); + ) + .file("vendor/dep2/Cargo.toml", "!INVALID!") + }) + .unwrap(); let p = project() .file( @@ -482,10 +514,12 @@ fn cargo_compile_with_malformed_nested_paths() { "#, git_project.url() ), - ).file( + ) + .file( "src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); p.cargo("build").run(); @@ -506,7 +540,8 @@ fn cargo_compile_with_meta_package() { "this is dep1" } "#, - ).file("dep2/Cargo.toml", &basic_lib_manifest("dep2")) + ) + .file("dep2/Cargo.toml", &basic_lib_manifest("dep2")) .file( "dep2/src/dep2.rs", r#" @@ -515,7 +550,8 @@ fn cargo_compile_with_meta_package() { } "#, ) - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -545,13 +581,15 @@ fn cargo_compile_with_meta_package() { git_project.url(), git_project.url() ), - ).file( + ) + .file( "src/foo.rs", &main_file( r#""{} {}", dep1::hello(), dep2::hello()"#, &["dep1", "dep2"], ), - ).build(); + ) + .build(); p.cargo("build").run(); @@ -587,10 +625,12 @@ fn cargo_compile_with_short_ssh_git() { "#, url ), - ).file( + ) + .file( "src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -603,7 +643,8 @@ Caused by: invalid url `{}`: relative URL without a base ", url - )).run(); + )) + .run(); } #[test] @@ -612,7 +653,8 @@ fn two_revs_same_deps() { project .file("Cargo.toml", &basic_manifest("bar", "0.0.0")) .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") - }).unwrap(); + }) + .unwrap(); let repo = git2::Repository::open(&bar.root()).unwrap(); let rev1 = repo.revparse_single("HEAD").unwrap().id(); @@ -645,7 +687,8 @@ fn two_revs_same_deps() { bar.url(), rev1 ), - ).file( + ) + .file( "src/main.rs", r#" extern crate bar; @@ -656,7 +699,8 @@ fn two_revs_same_deps() { assert_eq!(baz::baz(), 2); } "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") @@ -676,13 +720,15 @@ fn two_revs_same_deps() { bar.url(), rev2 ), - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; pub fn baz() -> i32 { bar::bar() } "#, - ).build(); + ) + .build(); foo.cargo("build -v").run(); assert!(foo.bin("foo").is_file()); @@ -695,7 +741,8 @@ fn recompilation() { project .file("Cargo.toml", &basic_lib_manifest("bar")) .file("src/bar.rs", "pub fn bar() {}") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -715,7 +762,8 @@ fn recompilation() { "#, git_project.url() ), - ).file("src/main.rs", &main_file(r#""{:?}", bar::bar()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{:?}", bar::bar()"#, &["bar"])) .build(); // First time around we should compile both foo and bar @@ -728,7 +776,8 @@ fn recompilation() { in [..]\n", git_project.url(), git_project.url(), - )).run(); + )) + .run(); // Don't recompile the second time p.cargo("build").with_stdout("").run(); @@ -745,7 +794,8 @@ fn recompilation() { .with_stderr(&format!( "[UPDATING] git repository `{}`", git_project.url() - )).run(); + )) + .run(); p.cargo("build").with_stdout("").run(); @@ -766,7 +816,8 @@ fn recompilation() { [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ ", git_project.url() - )).run(); + )) + .run(); println!("going for the last compile"); p.cargo("build") .with_stderr(&format!( @@ -775,7 +826,8 @@ fn recompilation() { [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", git_project.url(), - )).run(); + )) + .run(); // Make sure clean only cleans one dep p.cargo("clean -p foo").with_stdout("").run(); @@ -783,8 +835,9 @@ fn recompilation() { .with_stderr( "[COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ - in [..]" - ).run(); + in [..]", + ) + .run(); } #[test] @@ -793,7 +846,8 @@ fn update_with_shared_deps() { project .file("Cargo.toml", &basic_lib_manifest("bar")) .file("src/bar.rs", "pub fn bar() {}") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -809,7 +863,8 @@ fn update_with_shared_deps() { [dependencies.dep2] path = "dep2" "#, - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -818,7 +873,8 @@ fn update_with_shared_deps() { extern crate dep2; fn main() {} "#, - ).file( + ) + .file( "dep1/Cargo.toml", &format!( r#" @@ -833,7 +889,8 @@ fn update_with_shared_deps() { "#, git_project.url() ), - ).file("dep1/src/lib.rs", "") + ) + .file("dep1/src/lib.rs", "") .file( "dep2/Cargo.toml", &format!( @@ -849,7 +906,8 @@ fn update_with_shared_deps() { "#, git_project.url() ), - ).file("dep2/src/lib.rs", "") + ) + .file("dep2/src/lib.rs", "") .build(); // First time around we should compile both foo and bar @@ -863,7 +921,8 @@ fn update_with_shared_deps() { [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", git = git_project.url(), - )).run(); + )) + .run(); // Modify a file manually, and commit it File::create(&git_project.root().join("src/bar.rs")) @@ -893,7 +952,8 @@ fn update_with_shared_deps() { Caused by: revspec '0.1.2' not found; [..] ", - ).run(); + ) + .run(); // Specifying a precise rev to the old rev shouldn't actually update // anything because we already have the rev in the db. @@ -911,7 +971,8 @@ Caused by: [UPDATING] bar v0.5.0 ([..]) -> #[..]\n\ ", git_project.url() - )).run(); + )) + .run(); // Make sure we still only compile one version of the git repo println!("build"); @@ -924,14 +985,16 @@ Caused by: [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", git = git_project.url(), - )).run(); + )) + .run(); // We should be able to update transitive deps p.cargo("update -p bar") .with_stderr(&format!( "[UPDATING] git repository `{}`", git_project.url() - )).run(); + )) + .run(); } #[test] @@ -939,7 +1002,8 @@ fn dep_with_submodule() { let project = project(); let git_project = git::new("dep1", |project| { project.file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) - }).unwrap(); + }) + .unwrap(); let git_project2 = git::new("dep2", |project| project.file("lib.rs", "pub fn dep() {}")).unwrap(); @@ -965,10 +1029,12 @@ fn dep_with_submodule() { "#, git_project.url() ), - ).file( + ) + .file( "src/lib.rs", "extern crate dep1; pub fn foo() { dep1::dep() }", - ).build(); + ) + .build(); project .cargo("build") @@ -978,7 +1044,8 @@ fn dep_with_submodule() { [COMPILING] dep1 [..] [COMPILING] foo [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -986,7 +1053,8 @@ fn dep_with_bad_submodule() { let project = project(); let git_project = git::new("dep1", |project| { project.file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) - }).unwrap(); + }) + .unwrap(); let git_project2 = git::new("dep2", |project| project.file("lib.rs", "pub fn dep() {}")).unwrap(); @@ -1008,7 +1076,8 @@ fn dep_with_bad_submodule() { None, Some("something something"), None, - ).unwrap(); + ) + .unwrap(); let p = project .file( @@ -1027,10 +1096,12 @@ fn dep_with_bad_submodule() { "#, git_project.url() ), - ).file( + ) + .file( "src/lib.rs", "extern crate dep1; pub fn foo() { dep1::dep() }", - ).build(); + ) + .build(); let expected = format!( "\ @@ -1062,12 +1133,14 @@ fn two_deps_only_update_one() { project .file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let git2 = git::new("dep2", |project| { project .file("Cargo.toml", &basic_manifest("dep2", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project .file( @@ -1088,7 +1161,8 @@ fn two_deps_only_update_one() { git1.url(), git2.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); fn oid_to_short_sha(oid: git2::Oid) -> String { @@ -1111,7 +1185,8 @@ fn two_deps_only_update_one() { [COMPILING] [..] v0.5.0 ([..])\n\ [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - ).run(); + ) + .run(); File::create(&git1.root().join("src/lib.rs")) .unwrap() @@ -1128,7 +1203,8 @@ fn two_deps_only_update_one() { [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ ", git1.url() - )).run(); + )) + .run(); } #[test] @@ -1137,7 +1213,8 @@ fn stale_cached_version() { project .file("Cargo.toml", &basic_manifest("bar", "0.0.0")) .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") - }).unwrap(); + }) + .unwrap(); // Update the git database in the cache with the current state of the git // repo @@ -1156,14 +1233,16 @@ fn stale_cached_version() { "#, bar.url() ), - ).file( + ) + .file( "src/main.rs", r#" extern crate bar; fn main() { assert_eq!(bar::bar(), 1) } "#, - ).build(); + ) + .build(); foo.cargo("build").run(); foo.process(&foo.bin("foo")).run(); @@ -1201,8 +1280,10 @@ fn stale_cached_version() { "#, url = bar.url(), hash = rev - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); // Now build! foo.cargo("build") @@ -1214,7 +1295,8 @@ fn stale_cached_version() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", bar = bar.url(), - )).run(); + )) + .run(); foo.process(&foo.bin("foo")).run(); } @@ -1223,15 +1305,18 @@ fn dep_with_changed_submodule() { let project = project(); let git_project = git::new("dep1", |project| { project.file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) - }).unwrap(); + }) + .unwrap(); let git_project2 = git::new("dep2", |project| { project.file("lib.rs", "pub fn dep() -> &'static str { \"project2\" }") - }).unwrap(); + }) + .unwrap(); let git_project3 = git::new("dep3", |project| { project.file("lib.rs", "pub fn dep() -> &'static str { \"project3\" }") - }).unwrap(); + }) + .unwrap(); let repo = git2::Repository::open(&git_project.root()).unwrap(); let mut sub = git::add_submodule(&repo, &git_project2.url().to_string(), Path::new("src")); @@ -1251,13 +1336,15 @@ fn dep_with_changed_submodule() { "#, git_project.url() ), - ).file( + ) + .file( "src/main.rs", " extern crate dep1; pub fn main() { println!(\"{}\", dep1::dep()) } ", - ).build(); + ) + .build(); println!("first run"); p.cargo("run") @@ -1268,7 +1355,8 @@ fn dep_with_changed_submodule() { [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n\ [RUNNING] `target/debug/foo[EXE]`\n", - ).with_stdout("project2\n") + ) + .with_stdout("project2\n") .run(); File::create(&git_project.root().join(".gitmodules")) @@ -1277,8 +1365,10 @@ fn dep_with_changed_submodule() { format!( "[submodule \"src\"]\n\tpath = src\n\turl={}", git_project3.url() - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); // Sync the submodule and reset it to the new remote. sub.sync().unwrap(); @@ -1310,7 +1400,8 @@ fn dep_with_changed_submodule() { [UPDATING] dep1 v0.5.0 ([..]) -> #[..]\n\ ", git_project.url() - )).run(); + )) + .run(); println!("last run"); p.cargo("run") @@ -1320,7 +1411,8 @@ fn dep_with_changed_submodule() { [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n\ [RUNNING] `target/debug/foo[EXE]`\n", - ).with_stdout("project3\n") + ) + .with_stdout("project3\n") .run(); } @@ -1335,7 +1427,8 @@ fn dev_deps_with_testing() { pub fn gimme() -> &'static str { "zoidberg" } "#, ) - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1354,7 +1447,8 @@ fn dev_deps_with_testing() { "#, p2.url() ), - ).file( + ) + .file( "src/main.rs", r#" fn main() {} @@ -1365,7 +1459,8 @@ fn dev_deps_with_testing() { #[test] fn foo() { bar::gimme(); } } "#, - ).build(); + ) + .build(); // Generate a lockfile which did not use `bar` to compile, but had to update // `bar` to generate the lockfile @@ -1377,7 +1472,8 @@ fn dev_deps_with_testing() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", bar = p2.url() - )).run(); + )) + .run(); // Make sure we use the previous resolution of `bar` instead of updating it // a second time. @@ -1388,7 +1484,8 @@ fn dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test tests::foo ... ok") + ) + .with_stdout_contains("test tests::foo ... ok") .run(); } @@ -1405,10 +1502,12 @@ fn git_build_cmd_freshness() { authors = [] build = "build.rs" "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") .file(".gitignore", "src/bar.rs") - }).unwrap(); + }) + .unwrap(); foo.root().move_into_the_past(); sleep_ms(1000); @@ -1419,7 +1518,8 @@ fn git_build_cmd_freshness() { [COMPILING] foo v0.0.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // Smoke test to make sure it doesn't compile again println!("first pass"); @@ -1442,7 +1542,8 @@ fn git_name_not_always_needed() { pub fn gimme() -> &'static str { "zoidberg" } "#, ) - }).unwrap(); + }) + .unwrap(); let repo = git2::Repository::open(&p2.root()).unwrap(); let mut cfg = repo.config().unwrap(); @@ -1464,7 +1565,8 @@ fn git_name_not_always_needed() { "#, p2.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); // Generate a lockfile which did not use `bar` to compile, but had to update @@ -1477,7 +1579,8 @@ fn git_name_not_always_needed() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", bar = p2.url() - )).run(); + )) + .run(); } #[test] @@ -1486,7 +1589,8 @@ fn git_repo_changing_no_rebuild() { project .file("Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") - }).unwrap(); + }) + .unwrap(); // Lock p1 to the first rev in the git repo let p1 = project() @@ -1505,7 +1609,8 @@ fn git_repo_changing_no_rebuild() { "#, bar.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("build.rs", "fn main() {}") .build(); p1.root().move_into_the_past(); @@ -1518,7 +1623,8 @@ fn git_repo_changing_no_rebuild() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", bar = bar.url() - )).run(); + )) + .run(); // Make a commit to lock p2 to a different rev File::create(&bar.root().join("src/lib.rs")) @@ -1545,7 +1651,8 @@ fn git_repo_changing_no_rebuild() { "#, bar.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p2.cargo("build") .with_stderr(&format!( @@ -1556,7 +1663,8 @@ fn git_repo_changing_no_rebuild() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", bar = bar.url() - )).run(); + )) + .run(); // And now for the real test! Make sure that p1 doesn't get rebuilt // even though the git repo has changed. @@ -1585,7 +1693,8 @@ fn git_dep_build_cmd() { name = "foo" "#, - ).file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/foo.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -1600,12 +1709,14 @@ fn git_dep_build_cmd() { name = "bar" path = "src/bar.rs" "#, - ).file( + ) + .file( "bar/src/bar.rs.in", r#" pub fn gimme() -> i32 { 0 } "#, - ).file( + ) + .file( "bar/build.rs", r#" use std::fs; @@ -1614,7 +1725,8 @@ fn git_dep_build_cmd() { } "#, ) - }).unwrap(); + }) + .unwrap(); p.root().join("bar").move_into_the_past(); @@ -1639,7 +1751,8 @@ fn fetch_downloads() { project .file("Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1655,13 +1768,15 @@ fn fetch_downloads() { "#, bar.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("fetch") .with_stderr(&format!( "[UPDATING] git repository `{url}`", url = bar.url() - )).run(); + )) + .run(); p.cargo("fetch").with_stdout("").run(); } @@ -1672,7 +1787,8 @@ fn warnings_in_git_dep() { project .file("Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("src/lib.rs", "fn unused() {}") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1688,7 +1804,8 @@ fn warnings_in_git_dep() { "#, bar.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build") @@ -1699,7 +1816,8 @@ fn warnings_in_git_dep() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", bar.url(), bar.url(), - )).run(); + )) + .run(); } #[test] @@ -1708,12 +1826,14 @@ fn update_ambiguous() { project .file("Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let bar2 = git::new("bar2", |project| { project .file("Cargo.toml", &basic_manifest("bar", "0.6.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let baz = git::new("baz", |project| { project .file( @@ -1730,8 +1850,10 @@ fn update_ambiguous() { "#, bar2.url() ), - ).file("src/lib.rs", "") - }).unwrap(); + ) + .file("src/lib.rs", "") + }) + .unwrap(); let p = project() .file( @@ -1750,7 +1872,8 @@ fn update_ambiguous() { bar1.url(), baz.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("generate-lockfile").run(); @@ -1765,7 +1888,8 @@ following: bar:0.[..].0 bar:0.[..].0 ", - ).run(); + ) + .run(); } #[test] @@ -1776,7 +1900,8 @@ fn update_one_dep_in_repo_with_many_deps() { .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.5.0")) .file("a/src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1795,7 +1920,8 @@ fn update_one_dep_in_repo_with_many_deps() { bar.url(), bar.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("generate-lockfile").run(); @@ -1810,7 +1936,8 @@ fn switch_deps_does_not_update_transitive() { project .file("Cargo.toml", &basic_manifest("transitive", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let dep1 = git::new("dep1", |project| { project .file( @@ -1827,8 +1954,10 @@ fn switch_deps_does_not_update_transitive() { "#, transitive.url() ), - ).file("src/lib.rs", "") - }).unwrap(); + ) + .file("src/lib.rs", "") + }) + .unwrap(); let dep2 = git::new("dep2", |project| { project .file( @@ -1845,8 +1974,10 @@ fn switch_deps_does_not_update_transitive() { "#, transitive.url() ), - ).file("src/lib.rs", "") - }).unwrap(); + ) + .file("src/lib.rs", "") + }) + .unwrap(); let p = project() .file( @@ -1862,7 +1993,8 @@ fn switch_deps_does_not_update_transitive() { "#, dep1.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build") @@ -1877,7 +2009,8 @@ fn switch_deps_does_not_update_transitive() { ", dep1.url(), transitive.url() - )).run(); + )) + .run(); // Update the dependency to point to the second repository, but this // shouldn't update the transitive dependency which is the same. @@ -1894,8 +2027,10 @@ fn switch_deps_does_not_update_transitive() { git = '{}' "#, dep2.url() - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); p.cargo("build") .with_stderr(&format!( @@ -1906,7 +2041,8 @@ fn switch_deps_does_not_update_transitive() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", dep2.url() - )).run(); + )) + .run(); } #[test] @@ -1924,10 +2060,12 @@ fn update_one_source_updates_all_packages_in_that_git_source() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.5.0")) .file("a/src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1943,7 +2081,8 @@ fn update_one_source_updates_all_packages_in_that_git_source() { "#, dep.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").run(); @@ -1979,12 +2118,14 @@ fn switch_sources() { project .file("Cargo.toml", &basic_manifest("a", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let a2 = git::new("a2", |project| { project .file("Cargo.toml", &basic_manifest("a", "0.5.1")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -1997,7 +2138,8 @@ fn switch_sources() { [dependencies.b] path = "b" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "b/Cargo.toml", &format!( @@ -2011,7 +2153,8 @@ fn switch_sources() { "#, a1.url() ), - ).file("b/src/lib.rs", "pub fn main() {}") + ) + .file("b/src/lib.rs", "pub fn main() {}") .build(); p.cargo("build") @@ -2023,7 +2166,8 @@ fn switch_sources() { [COMPILING] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); File::create(&p.root().join("b/Cargo.toml")) .unwrap() @@ -2038,8 +2182,10 @@ fn switch_sources() { git = '{}' "#, a2.url() - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); p.cargo("build") .with_stderr( @@ -2050,7 +2196,8 @@ fn switch_sources() { [COMPILING] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2066,10 +2213,12 @@ fn dont_require_submodules_are_checked_out() { authors = [] build = "build.rs" "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "") .file("a/foo", "") - }).unwrap(); + }) + .unwrap(); let git2 = git::new("dep2", |p| p).unwrap(); let repo = git2::Repository::open(&git1.root()).unwrap(); @@ -2090,7 +2239,8 @@ fn doctest_same_name() { let a2 = git::new("a2", |p| { p.file("Cargo.toml", &basic_manifest("a", "0.5.0")) .file("src/lib.rs", "pub fn a2() {}") - }).unwrap(); + }) + .unwrap(); let a1 = git::new("a1", |p| { p.file( @@ -2106,8 +2256,10 @@ fn doctest_same_name() { "#, a2.url() ), - ).file("src/lib.rs", "extern crate a; pub fn a1() {}") - }).unwrap(); + ) + .file("src/lib.rs", "extern crate a; pub fn a1() {}") + }) + .unwrap(); let p = project() .file( @@ -2124,13 +2276,15 @@ fn doctest_same_name() { "#, a1.url() ), - ).file( + ) + .file( "src/lib.rs", r#" #[macro_use] extern crate a; "#, - ).build(); + ) + .build(); p.cargo("test -v").run(); } @@ -2144,7 +2298,8 @@ fn lints_are_suppressed() { use std::option; ", ) - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -2161,7 +2316,8 @@ fn lints_are_suppressed() { "#, a.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -2172,7 +2328,8 @@ fn lints_are_suppressed() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2185,7 +2342,8 @@ fn denied_lints_are_allowed() { use std::option; ", ) - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -2202,7 +2360,8 @@ fn denied_lints_are_allowed() { "#, a.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -2213,7 +2372,8 @@ fn denied_lints_are_allowed() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2221,7 +2381,8 @@ fn add_a_git_dep() { let git = git::new("git", |p| { p.file("Cargo.toml", &basic_manifest("git", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -2239,7 +2400,8 @@ fn add_a_git_dep() { "#, git.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -2260,8 +2422,10 @@ fn add_a_git_dep() { git = {{ git = '{}' }} "#, git.url() - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); p.cargo("build").run(); } @@ -2273,7 +2437,8 @@ fn two_at_rev_instead_of_tag() { .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("git2", "0.5.0")) .file("a/src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); // Make a tag corresponding to the current HEAD let repo = git2::Repository::open(&git.root()).unwrap(); @@ -2284,7 +2449,8 @@ fn two_at_rev_instead_of_tag() { &repo.signature().unwrap(), "make a new tag", false, - ).unwrap(); + ) + .unwrap(); let p = project() .file( @@ -2302,7 +2468,8 @@ fn two_at_rev_instead_of_tag() { "#, git.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("generate-lockfile").run(); @@ -2326,7 +2493,8 @@ fn include_overrides_gitignore() { [build-dependencies] filetime = "0.1" "#, - ).file( + ) + .file( ".gitignore", r#" target @@ -2335,7 +2503,8 @@ fn include_overrides_gitignore() { src/incl.rs src/not_incl.rs "#, - ).file( + ) + .file( "tango-build.rs", r#" extern crate filetime; @@ -2359,14 +2528,16 @@ fn include_overrides_gitignore() { } } "#, - ).file("src/lib.rs", "mod not_incl; mod incl;") + ) + .file("src/lib.rs", "mod not_incl; mod incl;") .file( "src/mod.md", r#" (The content of this file does not matter since we are not doing real codegen.) "#, ) - }).unwrap(); + }) + .unwrap(); println!("build 1: all is new"); p.cargo("build -v") @@ -2385,7 +2556,8 @@ fn include_overrides_gitignore() { [RUNNING] `rustc --crate-name reduction src/lib.rs --crate-type lib [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); println!("build 2: nothing changed; file timestamps reset by build script"); p.cargo("build -v") @@ -2396,7 +2568,8 @@ fn include_overrides_gitignore() { [FRESH] reduction [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); println!("build 3: touch `src/not_incl.rs`; expect build script *not* re-run"); sleep_ms(1000); @@ -2411,7 +2584,8 @@ fn include_overrides_gitignore() { [RUNNING] `rustc --crate-name reduction src/lib.rs --crate-type lib [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // This final case models the bug from rust-lang/cargo#4135: an // explicitly included file should cause a build-script re-run, @@ -2430,7 +2604,8 @@ fn include_overrides_gitignore() { [RUNNING] `rustc --crate-name reduction src/lib.rs --crate-type lib [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2453,7 +2628,8 @@ fn invalid_git_dependency_manifest() { name = "dep1" "#, - ).file( + ) + .file( "src/dep1.rs", r#" pub fn hello() -> &'static str { @@ -2461,7 +2637,8 @@ fn invalid_git_dependency_manifest() { } "#, ) - }).unwrap(); + }) + .unwrap(); let project = project .file( @@ -2480,10 +2657,12 @@ fn invalid_git_dependency_manifest() { "#, git_project.url() ), - ).file( + ) + .file( "src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ).build(); + ) + .build(); let git_root = git_project.root(); @@ -2507,7 +2686,8 @@ fn invalid_git_dependency_manifest() { duplicate key: `categories` for key `project`", path2url(&git_root), path2url(&git_root), - )).run(); + )) + .run(); } #[test] @@ -2515,7 +2695,8 @@ fn failed_submodule_checkout() { let project = project(); let git_project = git::new("dep1", |project| { project.file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) - }).unwrap(); + }) + .unwrap(); let git_project2 = git::new("dep2", |project| project.file("lib.rs", "")).unwrap(); @@ -2567,7 +2748,8 @@ fn failed_submodule_checkout() { "#, git_project.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); project @@ -2601,7 +2783,8 @@ fn use_the_cli() { project .file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let project = project .file( @@ -2618,14 +2801,16 @@ fn use_the_cli() { "#, git_project.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", " [net] git-fetch-with-cli = true ", - ).build(); + ) + .build(); let stderr = "\ [UPDATING] git repository `[..]` @@ -2646,16 +2831,19 @@ fn templatedir_doesnt_cause_problems() { project .file("Cargo.toml", &basic_manifest("dep2", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let git_project = git::new("dep1", |project| { project .file("Cargo.toml", &basic_manifest("dep1", "0.5.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( "Cargo.toml", - &format!(r#" + &format!( + r#" [project] name = "fo" version = "0.5.0" @@ -2663,24 +2851,32 @@ fn templatedir_doesnt_cause_problems() { [dependencies] dep1 = {{ git = '{}' }} - "#, git_project.url()), - ).file("src/main.rs", "fn main() {}") + "#, + git_project.url() + ), + ) + .file("src/main.rs", "fn main() {}") .build(); File::create(paths::home().join(".gitconfig")) .unwrap() .write_all( - &format!(r#" + &format!( + r#" [init] templatedir = {} - "#, git_project2.url() - .to_file_path() - .unwrap() - .to_str() - .unwrap() - .replace("\\", "/") - ).as_bytes(), - ).unwrap(); + "#, + git_project2 + .url() + .to_file_path() + .unwrap() + .to_str() + .unwrap() + .replace("\\", "/") + ) + .as_bytes(), + ) + .unwrap(); p.cargo("build").run(); } diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index f9c36cbd10a..378cadc89ca 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -1,7 +1,7 @@ +use crate::support; use std::env; use std::fs::{self, File}; use std::io::prelude::*; -use crate::support; use crate::support::{paths, Execs}; @@ -39,11 +39,9 @@ fn simple_bin() { assert!(paths::root().join("foo/src/main.rs").is_file()); cargo_process("build").cwd(&path).run(); - assert!( - paths::root() - .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) - .is_file() - ); + assert!(paths::root() + .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) + .is_file()); } #[test] @@ -183,7 +181,8 @@ fn multibin_project_name_clash() { foo.rs cannot automatically generate Cargo.toml as the main target would be ambiguous ", - ).run(); + ) + .run(); assert!(!paths::root().join("foo/Cargo.toml").is_file()); } @@ -265,7 +264,8 @@ fn invalid_dir_name() { [ERROR] Invalid character `.` in crate name: `foo.bar` use --name to override crate name ", - ).run(); + ) + .run(); assert!(!foo.join("Cargo.toml").is_file()); } @@ -283,7 +283,8 @@ fn reserved_name() { [ERROR] The name `test` cannot be used as a crate name\n\ use --name to override crate name ", - ).run(); + ) + .run(); assert!(!test.join("Cargo.toml").is_file()); } @@ -502,7 +503,8 @@ fn unknown_flags() { .with_status(1) .with_stderr_contains( "error: Found argument '--flag' which wasn't expected, or isn't valid in this context", - ).run(); + ) + .run(); } #[cfg(not(windows))] @@ -513,5 +515,6 @@ fn no_filename() { .with_stderr( "[ERROR] cannot auto-detect package name from path \"/\" ; use --name to override" .to_string(), - ).run(); + ) + .run(); } diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 4a697c6d86b..90917f69e6c 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -1,14 +1,14 @@ +use crate::support; use std::fs::{self, File, OpenOptions}; use std::io::prelude::*; -use crate::support; -use git2; use crate::support::cross_compile; use crate::support::git; use crate::support::install::{assert_has_installed_exe, assert_has_not_installed_exe, cargo_home}; use crate::support::paths; use crate::support::registry::Package; use crate::support::{basic_manifest, cargo_process, project}; +use git2; fn pkg(name: &str, vers: &str) { Package::new(name, vers) @@ -16,7 +16,8 @@ fn pkg(name: &str, vers: &str) { .file( "src/main.rs", &format!("extern crate {}; fn main() {{}}", name), - ).publish(); + ) + .publish(); } #[test] @@ -35,7 +36,8 @@ fn simple() { [INSTALLING] [CWD]/home/.cargo/bin/foo[EXE] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); assert_has_installed_exe(cargo_home(), "foo"); cargo_process("uninstall foo") @@ -71,7 +73,8 @@ error: could not find `baz` in registry `[..]` warning: be sure to add `[..]` to your PATH to be able to run the installed binaries error: some crates failed to install ", - ).run(); + ) + .run(); assert_has_installed_exe(cargo_home(), "foo"); assert_has_installed_exe(cargo_home(), "bar"); @@ -82,7 +85,8 @@ error: some crates failed to install [REMOVING] [CWD]/home/.cargo/bin/bar[EXE] [SUMMARY] Successfully uninstalled foo, bar! ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); assert_has_not_installed_exe(cargo_home(), "bar"); @@ -108,7 +112,8 @@ fn pick_max_version() { [INSTALLING] [CWD]/home/.cargo/bin/foo[EXE] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); assert_has_installed_exe(cargo_home(), "foo"); } @@ -136,7 +141,8 @@ fn missing() { [UPDATING] [..] index [ERROR] could not find `bar` in registry `[..]` ", - ).run(); + ) + .run(); } #[test] @@ -149,7 +155,8 @@ fn bad_version() { [UPDATING] [..] index [ERROR] could not find `foo` in registry `[..]` with version `=0.2.0` ", - ).run(); + ) + .run(); } #[test] @@ -166,7 +173,8 @@ Caused by: Caused by: [..] (os error [..]) ", - ).run(); + ) + .run(); } #[test] @@ -189,8 +197,10 @@ fn install_location_precedence() { root = '{}' ", t3.display() - ).as_bytes(), - ).unwrap(); + ) + .as_bytes(), + ) + .unwrap(); println!("install --root"); @@ -237,7 +247,8 @@ fn install_path() { [ERROR] binary `foo[..]` already exists in destination as part of `foo v0.0.1 [..]` Add --force to overwrite ", - ).run(); + ) + .run(); } #[test] @@ -257,7 +268,8 @@ fn multiple_crates_error() { [UPDATING] git repository [..] [ERROR] multiple packages with binaries found: bar, foo ", - ).run(); + ) + .run(); } #[test] @@ -286,14 +298,23 @@ fn multiple_crates_select() { #[test] fn multiple_crates_git_all() { let p = git::repo(&paths::root().join("foo")) - .file("Cargo.toml", r#"\ + .file( + "Cargo.toml", + r#"\ [workspace] members = ["bin1", "bin2"] -"#) +"#, + ) .file("bin1/Cargo.toml", &basic_manifest("bin1", "0.1.0")) .file("bin2/Cargo.toml", &basic_manifest("bin2", "0.1.0")) - .file("bin1/src/main.rs", r#"fn main() { println!("Hello, world!"); }"#) - .file("bin2/src/main.rs", r#"fn main() { println!("Hello, world!"); }"#) + .file( + "bin1/src/main.rs", + r#"fn main() { println!("Hello, world!"); }"#, + ) + .file( + "bin2/src/main.rs", + r#"fn main() { println!("Hello, world!"); }"#, + ) .build(); cargo_process(&format!("install --git {} bin1 bin2", p.url().to_string())).run(); @@ -313,7 +334,8 @@ fn multiple_crates_auto_binaries() { [dependencies] bar = { path = "a" } "#, - ).file("src/main.rs", "extern crate bar; fn main() {}") + ) + .file("src/main.rs", "extern crate bar; fn main() {}") .file("a/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("a/src/lib.rs", "") .build(); @@ -336,7 +358,8 @@ fn multiple_crates_auto_examples() { [dependencies] bar = { path = "a" } "#, - ).file("src/lib.rs", "extern crate bar;") + ) + .file("src/lib.rs", "extern crate bar;") .file( "examples/foo.rs", " @@ -344,7 +367,8 @@ fn multiple_crates_auto_examples() { extern crate foo; fn main() {} ", - ).file("a/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("a/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("a/src/lib.rs", "") .build(); @@ -369,7 +393,8 @@ fn no_binaries_or_examples() { [dependencies] bar = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("a/src/lib.rs", "") .build(); @@ -397,7 +422,8 @@ fn no_binaries() { [INSTALLING] foo [..] [ERROR] specified package has no binaries ", - ).run(); + ) + .run(); } #[test] @@ -432,7 +458,8 @@ fn install_twice() { binary `foo-bin2[..]` already exists in destination as part of `foo v0.0.1 ([..])` Add --force to overwrite ", - ).run(); + ) + .run(); } #[test] @@ -457,7 +484,8 @@ fn install_force() { [REPLACING] [CWD]/home/.cargo/bin/foo[EXE] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); cargo_process("install --list") .with_stdout( @@ -465,7 +493,8 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina foo v0.2.0 ([..]): foo[..] ", - ).run(); + ) + .run(); } #[test] @@ -495,7 +524,8 @@ fn install_force_partial_overlap() { [REPLACING] [CWD]/home/.cargo/bin/foo-bin2[EXE] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); cargo_process("install --list") .with_stdout( @@ -506,7 +536,8 @@ foo v0.2.0 ([..]): foo-bin2[..] foo-bin3[..] ", - ).run(); + ) + .run(); } #[test] @@ -535,7 +566,8 @@ fn install_force_bin() { [REPLACING] [CWD]/home/.cargo/bin/foo-bin2[EXE] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); cargo_process("install --list") .with_stdout( @@ -545,7 +577,8 @@ foo v0.0.1 ([..]): foo v0.2.0 ([..]): foo-bin2[..] ", - ).run(); + ) + .run(); } #[test] @@ -565,7 +598,8 @@ Caused by: To learn more, run the command again with --verbose. ", - ).run(); + ) + .run(); } #[test] @@ -587,7 +621,8 @@ fn git_repo() { [INSTALLING] [CWD]/home/.cargo/bin/foo[EXE] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); assert_has_installed_exe(cargo_home(), "foo"); assert_has_installed_exe(cargo_home(), "foo"); } @@ -610,7 +645,8 @@ bar v0.2.1: foo v0.0.1: foo[..] ", - ).run(); + ) + .run(); } #[test] @@ -623,7 +659,8 @@ fn list_error() { foo v0.0.1: foo[..] ", - ).run(); + ) + .run(); let mut worldfile_path = cargo_home(); worldfile_path.push(".crates.toml"); let mut worldfile = OpenOptions::new() @@ -644,7 +681,8 @@ Caused by: Caused by: unexpected character[..] ", - ).run(); + ) + .run(); } #[test] @@ -717,7 +755,8 @@ fn installs_from_cwd_by_default() { package in current working directory is deprecated, \ use `cargo install --path .` instead. \ Use `cargo build` if you want to simply build the package.", - ).run(); + ) + .run(); assert_has_installed_exe(cargo_home(), "foo"); } @@ -740,7 +779,8 @@ fn installs_from_cwd_with_2018_warnings() { authors = [] edition = "2018" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("install") @@ -751,7 +791,8 @@ fn installs_from_cwd_with_2018_warnings() { package in current working directory is no longer supported, \ use `cargo install --path .` instead. \ Use `cargo build` if you want to simply build the package.", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); } @@ -767,7 +808,8 @@ fn uninstall_cwd() { [INSTALLING] {home}/bin/foo[EXE] warning: be sure to add `{home}/bin` to your PATH to be able to run the installed binaries", home = cargo_home().display(), - )).run(); + )) + .run(); assert_has_installed_exe(cargo_home(), "foo"); p.cargo("uninstall") @@ -776,7 +818,8 @@ warning: be sure to add `{home}/bin` to your PATH to be able to run the installe "\ [REMOVING] {home}/bin/foo[EXE]", home = cargo_home().display() - )).run(); + )) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); } @@ -789,7 +832,8 @@ fn uninstall_cwd_not_installed() { .with_stderr( "\ error: package `foo v0.0.1 ([CWD])` is not installed", - ).run(); + ) + .run(); } #[test] @@ -809,7 +853,8 @@ fn uninstall_cwd_no_project() { Caused by: {err_msg} (os error 2)", err_msg = err_msg, - )).run(); + )) + .run(); } #[test] @@ -825,7 +870,8 @@ fn do_not_rebuilds_on_local_install() { [INSTALLING] [..] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); assert!(p.build_dir().exists()); assert!(p.release_bin("foo").exists()); @@ -861,7 +907,8 @@ fn git_with_lockfile() { [dependencies] bar = { path = "bar" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "fn main() {}") .file( @@ -876,7 +923,8 @@ fn git_with_lockfile() { name = "bar" version = "0.1.0" "#, - ).build(); + ) + .build(); cargo_process("install --git") .arg(p.url().to_string()) @@ -923,7 +971,8 @@ fn use_path_workspace() { [workspace] members = ["baz"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "baz/Cargo.toml", r#" @@ -935,7 +984,8 @@ fn use_path_workspace() { [dependencies] foo = "1" "#, - ).file("baz/src/lib.rs", "") + ) + .file("baz/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -960,7 +1010,8 @@ fn dev_dependencies_no_check() { [dev-dependencies] baz = "1.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").with_status(101).run(); @@ -982,7 +1033,8 @@ fn dev_dependencies_lock_file_untouched() { [dev-dependencies] bar = { path = "a" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("a/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("a/src/lib.rs", "") .build(); @@ -1050,7 +1102,8 @@ fn not_both_vers_and_version() { error: The argument '--version ' was provided more than once, \ but cannot be used multiple times ", - ).run(); + ) + .run(); } #[test] @@ -1065,7 +1118,8 @@ warning: the `--vers` provided, `0.1`, is not a valid semver version historically Cargo treated this as a semver version requirement accidentally and will continue to do so, but this behavior will be removed eventually ", - ).run(); + ) + .run(); } #[test] @@ -1093,7 +1147,8 @@ error: package id specification `bar` matched no packages [SUMMARY] Successfully uninstalled foo! Failed to uninstall bar (see error(s) above). error: some packages failed to uninstall ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); assert_has_not_installed_exe(cargo_home(), "bar"); @@ -1130,7 +1185,8 @@ fn install_respects_lock_file() { .file( "src/main.rs", "extern crate foo; extern crate bar; fn main() {}", - ).file( + ) + .file( "Cargo.lock", r#" [[package]] @@ -1145,7 +1201,8 @@ dependencies = [ "bar 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] "#, - ).publish(); + ) + .publish(); cargo_process("install foo").run(); } @@ -1160,7 +1217,8 @@ fn lock_file_path_deps_ok() { .file( "src/main.rs", "extern crate foo; extern crate bar; fn main() {}", - ).file( + ) + .file( "Cargo.lock", r#" [[package]] @@ -1174,7 +1232,8 @@ dependencies = [ "bar 0.1.0", ] "#, - ).publish(); + ) + .publish(); cargo_process("install foo").run(); } @@ -1187,7 +1246,8 @@ fn install_empty_argument() { .with_status(1) .with_stderr_contains( "[ERROR] The argument '...' requires a value but none was supplied", - ).run(); + ) + .run(); } #[test] @@ -1207,19 +1267,15 @@ fn git_repo_replace() { path.push(".cargo/.crates.toml"); assert_ne!(old_rev, new_rev); - assert!( - fs::read_to_string(path.clone()) - .unwrap() - .contains(&format!("{}", old_rev)) - ); + assert!(fs::read_to_string(path.clone()) + .unwrap() + .contains(&format!("{}", old_rev))); cargo_process("install --force --git") .arg(p.url().to_string()) .run(); - assert!( - fs::read_to_string(path) - .unwrap() - .contains(&format!("{}", new_rev)) - ); + assert!(fs::read_to_string(path) + .unwrap() + .contains(&format!("{}", new_rev))); } #[test] @@ -1238,7 +1294,8 @@ fn workspace_uses_workspace_target_dir() { [dependencies] bar = { path = 'bar' } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}") .build(); @@ -1252,7 +1309,8 @@ fn workspace_uses_workspace_target_dir() { [INSTALLING] [..] warning: be sure to add `[..]` to your PATH to be able to run the installed binaries ", - ).run(); + ) + .run(); } #[test] @@ -1281,10 +1339,12 @@ fn install_global_cargo_config() { let config = cargo_home().join("config"); let mut toml = fs::read_to_string(&config).unwrap_or(String::new()); - toml.push_str(r#" + toml.push_str( + r#" [build] target = 'nonexistent' - "#); + "#, + ); fs::write(&config, toml).unwrap(); cargo_process("install bar") diff --git a/tests/testsuite/jobserver.rs b/tests/testsuite/jobserver.rs index b436ce813d5..efdd6373270 100644 --- a/tests/testsuite/jobserver.rs +++ b/tests/testsuite/jobserver.rs @@ -45,7 +45,8 @@ fn jobserver_exists() { // a little too complicated for a test... } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -76,7 +77,8 @@ fn makes_jobserver_used() { d2 = { path = "d2" } d3 = { path = "d3" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "d1/Cargo.toml", r#" @@ -86,7 +88,8 @@ fn makes_jobserver_used() { authors = [] build = "../dbuild.rs" "#, - ).file("d1/src/lib.rs", "") + ) + .file("d1/src/lib.rs", "") .file( "d2/Cargo.toml", r#" @@ -96,7 +99,8 @@ fn makes_jobserver_used() { authors = [] build = "../dbuild.rs" "#, - ).file("d2/src/lib.rs", "") + ) + .file("d2/src/lib.rs", "") .file( "d3/Cargo.toml", r#" @@ -106,7 +110,8 @@ fn makes_jobserver_used() { authors = [] build = "../dbuild.rs" "#, - ).file("d3/src/lib.rs", "") + ) + .file("d3/src/lib.rs", "") .file( "dbuild.rs", r#" @@ -121,13 +126,15 @@ fn makes_jobserver_used() { stream.read_to_end(&mut v).unwrap(); } "#, - ).file( + ) + .file( "Makefile", "\ all: \t+$(CARGO) build ", - ).build(); + ) + .build(); let l = TcpListener::bind("127.0.0.1:0").unwrap(); let addr = l.local_addr().unwrap(); @@ -176,7 +183,8 @@ fn jobserver_and_j() { all: \t+$(CARGO) build -j2 ", - ).build(); + ) + .build(); p.process(make) .env("CARGO", cargo_exe()) @@ -188,5 +196,6 @@ with an external jobserver in its environment, ignoring the `-j` parameter [COMPILING] [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/local_registry.rs b/tests/testsuite/local_registry.rs index b876190655e..dda4197874f 100644 --- a/tests/testsuite/local_registry.rs +++ b/tests/testsuite/local_registry.rs @@ -40,10 +40,12 @@ fn simple() { [dependencies] bar = "0.0.1" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -53,7 +55,8 @@ fn simple() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); p.cargo("test").run(); } @@ -79,10 +82,12 @@ fn multiple_versions() { [dependencies] bar = "*" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -92,7 +97,8 @@ fn multiple_versions() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); Package::new("bar", "0.2.0") .local(true) @@ -129,7 +135,8 @@ fn multiple_names() { bar = "*" baz = "*" "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -139,7 +146,8 @@ fn multiple_names() { baz::baz(); } "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -151,7 +159,8 @@ fn multiple_names() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -180,7 +189,8 @@ fn interdependent() { bar = "*" baz = "*" "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -190,7 +200,8 @@ fn interdependent() { baz::baz(); } "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -202,7 +213,8 @@ fn interdependent() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -226,7 +238,8 @@ fn path_dep_rewritten() { [dependencies] bar = { path = "bar", version = "*" } "#, - ).file("src/lib.rs", "extern crate bar; pub fn baz() {}") + ) + .file("src/lib.rs", "extern crate bar; pub fn baz() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .publish(); @@ -244,7 +257,8 @@ fn path_dep_rewritten() { bar = "*" baz = "*" "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -254,7 +268,8 @@ fn path_dep_rewritten() { baz::baz(); } "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -266,7 +281,8 @@ fn path_dep_rewritten() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -284,7 +300,8 @@ fn invalid_dir_bad() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -295,7 +312,8 @@ fn invalid_dir_bad() { [source.my-awesome-local-directory] local-registry = '/path/to/nowhere' "#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) @@ -312,7 +330,8 @@ Caused by: Caused by: local registry path is not a directory: [..]path[..]to[..]nowhere ", - ).run(); + ) + .run(); } #[test] @@ -337,7 +356,8 @@ fn different_directory_replacing_the_registry_is_bad() { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); // Generate a lock file against the crates.io registry @@ -369,7 +389,8 @@ this could be indicative of a few possible errors: unable to verify that `bar v0.0.1` is the same as when the lockfile was generated ", - ).run(); + ) + .run(); } #[test] @@ -403,10 +424,12 @@ fn crates_io_registry_url_is_optional() { [dependencies] bar = "0.0.1" "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -416,7 +439,8 @@ fn crates_io_registry_url_is_optional() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); p.cargo("test").run(); } diff --git a/tests/testsuite/lockfile_compat.rs b/tests/testsuite/lockfile_compat.rs index 4a1f034388d..5b36eda436b 100644 --- a/tests/testsuite/lockfile_compat.rs +++ b/tests/testsuite/lockfile_compat.rs @@ -54,7 +54,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("Cargo.lock", old_lockfile) .build(); @@ -103,7 +104,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("Cargo.lock", &old_lockfile) .build(); @@ -133,7 +135,8 @@ fn totally_wild_checksums_works() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "Cargo.lock", r#" @@ -160,9 +163,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" p.cargo("build").run(); let lock = p.read_lockfile(); - assert!( - lock.starts_with( - r#" + assert!(lock.starts_with( + r#" [[package]] name = "bar" version = "0.1.0" @@ -176,9 +178,9 @@ dependencies = [ ] [metadata] -"#.trim() - ) - ); +"# + .trim() + )); } #[test] @@ -197,7 +199,8 @@ fn wrong_checksum_is_an_error() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "Cargo.lock", r#" @@ -236,7 +239,8 @@ this could be indicative of a few possible errors: unable to verify that `bar v0.1.0` is the same as when the lockfile was generated ", - ).run(); + ) + .run(); } // If the checksum is unlisted in the lockfile (e.g. ) yet we can @@ -258,7 +262,8 @@ fn unlisted_checksum_is_bad_if_we_calculate() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "Cargo.lock", r#" @@ -297,7 +302,8 @@ this could be indicative of a few possible situations: * the lock file is corrupt ", - ).run(); + ) + .run(); } // If the checksum is listed in the lockfile yet we cannot calculate it (e.g. @@ -307,7 +313,8 @@ fn listed_checksum_bad_if_we_cannot_compute() { let git = git::new("bar", |p| { p.file("Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( @@ -324,7 +331,8 @@ fn listed_checksum_bad_if_we_cannot_compute() { "#, git.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "Cargo.lock", &format!( @@ -367,7 +375,8 @@ this could be indicative of a few possible situations: unable to verify that `bar v0.1.0 ([..])` is the same as when the lockfile was generated ", - ).run(); + ) + .run(); } #[test] @@ -386,7 +395,8 @@ fn current_lockfile_format() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", ""); + ) + .file("src/lib.rs", ""); let p = p.build(); p.cargo("build").run(); @@ -445,7 +455,8 @@ dependencies = [ [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("Cargo.lock", lockfile); let p = p.build(); @@ -472,7 +483,8 @@ fn locked_correct_error() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", ""); + ) + .file("src/lib.rs", ""); let p = p.build(); p.cargo("build --locked") @@ -482,5 +494,6 @@ fn locked_correct_error() { [UPDATING] `[..]` index error: the lock file [CWD]/Cargo.lock needs to be updated but --locked was passed to prevent this ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/login.rs b/tests/testsuite/login.rs index e9d20a4fa40..443f4ea02fc 100644 --- a/tests/testsuite/login.rs +++ b/tests/testsuite/login.rs @@ -1,11 +1,11 @@ use std::fs::{self, File}; use std::io::prelude::*; -use cargo::core::Shell; -use cargo::util::config::Config; use crate::support::cargo_process; use crate::support::install::cargo_home; use crate::support::registry::registry; +use cargo::core::Shell; +use cargo::util::config::Config; use toml; const TOKEN: &str = "test-token"; diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index cab299af4ee..a1e0d8dded4 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -2,16 +2,8 @@ #![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))] #![cfg_attr(feature = "cargo-clippy", allow(explicit_iter_loop))] - -use cargo; -use filetime; - -use git2; - -use hex; #[macro_use] extern crate lazy_static; -use libc; #[macro_use] extern crate proptest; #[macro_use] @@ -19,11 +11,6 @@ extern crate serde_derive; #[macro_use] extern crate serde_json; -use toml; - -#[cfg(windows)] -extern crate winapi; - #[macro_use] mod support; diff --git a/tests/testsuite/metabuild.rs b/tests/testsuite/metabuild.rs index 5a183f5b4eb..1231ac3e2bd 100644 --- a/tests/testsuite/metabuild.rs +++ b/tests/testsuite/metabuild.rs @@ -1,10 +1,10 @@ -use glob::glob; -use serde_json; -use std::str; use crate::support::{ basic_lib_manifest, basic_manifest, is_coarse_mtime, project, registry::Package, rustc_host, Project, }; +use glob::glob; +use serde_json; +use std::str; #[test] fn metabuild_gated() { @@ -17,7 +17,8 @@ fn metabuild_gated() { version = "0.0.1" metabuild = ["mb"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -32,7 +33,8 @@ Caused by: consider adding `cargo-features = [\"metabuild\"]` to the manifest ", - ).run(); + ) + .run(); } fn basic_project() -> Project { @@ -50,22 +52,26 @@ fn basic_project() -> Project { mb = {path="mb"} mb-other = {path="mb-other"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("mb/Cargo.toml", &basic_lib_manifest("mb")) .file( "mb/src/lib.rs", r#"pub fn metabuild() { println!("Hello mb"); }"#, - ).file( + ) + .file( "mb-other/Cargo.toml", r#" [package] name = "mb-other" version = "0.0.1" "#, - ).file( + ) + .file( "mb-other/src/lib.rs", r#"pub fn metabuild() { println!("Hello mb-other"); }"#, - ).build() + ) + .build() } #[test] @@ -93,13 +99,15 @@ fn metabuild_error_both() { [build-dependencies] mb = {path="mb"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", r#"fn main() {}"#) .file("mb/Cargo.toml", &basic_lib_manifest("mb")) .file( "mb/src/lib.rs", r#"pub fn metabuild() { println!("Hello mb"); }"#, - ).build(); + ) + .build(); p.cargo("build -vv") .masquerade_as_nightly_cargo() @@ -111,7 +119,8 @@ error: failed to parse manifest at [..] Caused by: cannot specify both `metabuild` and `build` ", - ).run(); + ) + .run(); } #[test] @@ -126,7 +135,8 @@ fn metabuild_missing_dep() { version = "0.0.1" metabuild = "mb" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -vv") @@ -138,7 +148,8 @@ error: failed to parse manifest at [..] Caused by: metabuild package `mb` must be specified in `build-dependencies`", - ).run(); + ) + .run(); } #[test] @@ -156,12 +167,14 @@ fn metabuild_optional_dep() { [build-dependencies] mb = {path="mb", optional=true} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("mb/Cargo.toml", &basic_lib_manifest("mb")) .file( "mb/src/lib.rs", r#"pub fn metabuild() { println!("Hello mb"); }"#, - ).build(); + ) + .build(); p.cargo("build -vv") .masquerade_as_nightly_cargo() @@ -190,7 +203,8 @@ fn metabuild_lib_name() { [build-dependencies] mb = {path="mb"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "mb/Cargo.toml", r#" @@ -200,10 +214,12 @@ fn metabuild_lib_name() { [lib] name = "other" "#, - ).file( + ) + .file( "mb/src/lib.rs", r#"pub fn metabuild() { println!("Hello mb"); }"#, - ).build(); + ) + .build(); p.cargo("build -vv") .masquerade_as_nightly_cargo() @@ -235,12 +251,14 @@ fn metabuild_fresh() { [build-dependencies] mb = {path="mb"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("mb/Cargo.toml", &basic_lib_manifest("mb")) .file( "mb/src/lib.rs", r#"pub fn metabuild() { println!("Hello mb"); }"#, - ).build(); + ) + .build(); p.cargo("build -vv") .masquerade_as_nightly_cargo() @@ -256,7 +274,8 @@ fn metabuild_fresh() { [FRESH] foo [..] [FINISHED] dev [..] ", - ).run(); + ) + .run(); } #[test] @@ -275,7 +294,8 @@ fn metabuild_links() { [build-dependencies] mb = {path="mb"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("mb/Cargo.toml", &basic_lib_manifest("mb")) .file( "mb/src/lib.rs", @@ -284,7 +304,8 @@ fn metabuild_links() { Ok("cat".to_string())); println!("Hello mb"); }"#, - ).build(); + ) + .build(); p.cargo("build -vv") .masquerade_as_nightly_cargo() @@ -308,12 +329,14 @@ fn metabuild_override() { [build-dependencies] mb = {path="mb"} "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("mb/Cargo.toml", &basic_lib_manifest("mb")) .file( "mb/src/lib.rs", r#"pub fn metabuild() { panic!("should not run"); }"#, - ).file( + ) + .file( ".cargo/config", &format!( r#" @@ -322,7 +345,8 @@ fn metabuild_override() { "#, rustc_host() ), - ).build(); + ) + .build(); p.cargo("build -vv").masquerade_as_nightly_cargo().run(); } @@ -336,7 +360,8 @@ fn metabuild_workspace() { [workspace] members = ["member1", "member2"] "#, - ).file( + ) + .file( "member1/Cargo.toml", r#" cargo-features = ["metabuild"] @@ -349,7 +374,8 @@ fn metabuild_workspace() { mb1 = {path="../../mb1"} mb2 = {path="../../mb2"} "#, - ).file("member1/src/lib.rs", "") + ) + .file("member1/src/lib.rs", "") .file( "member2/Cargo.toml", r#" @@ -362,7 +388,8 @@ fn metabuild_workspace() { [build-dependencies] mb1 = {path="../../mb1"} "#, - ).file("member2/src/lib.rs", "") + ) + .file("member2/src/lib.rs", "") .build(); project() @@ -507,7 +534,8 @@ fn metabuild_build_plan() { ] } "#, - ).run(); + ) + .run(); assert_eq!( glob( @@ -515,7 +543,8 @@ fn metabuild_build_plan() { .join("target/.metabuild/metabuild-foo-*.rs") .to_str() .unwrap() - ).unwrap() + ) + .unwrap() .count(), 1 ); @@ -532,7 +561,8 @@ fn metabuild_two_versions() { [workspace] members = ["member1", "member2"] "#, - ).file( + ) + .file( "member1/Cargo.toml", r#" cargo-features = ["metabuild"] @@ -544,7 +574,8 @@ fn metabuild_two_versions() { [build-dependencies] mb = {path="../../mb1"} "#, - ).file("member1/src/lib.rs", "") + ) + .file("member1/src/lib.rs", "") .file( "member2/Cargo.toml", r#" @@ -557,7 +588,8 @@ fn metabuild_two_versions() { [build-dependencies] mb = {path="../../mb2"} "#, - ).file("member2/src/lib.rs", "") + ) + .file("member2/src/lib.rs", "") .build(); project().at("mb1") @@ -596,7 +628,8 @@ fn metabuild_two_versions() { .join("target/.metabuild/metabuild-member?-*.rs") .to_str() .unwrap() - ).unwrap() + ) + .unwrap() .count(), 2 ); @@ -609,7 +642,8 @@ fn metabuild_external_dependency() { .file( "src/lib.rs", r#"pub fn metabuild() { println!("Hello mb"); }"#, - ).publish(); + ) + .publish(); Package::new("dep", "1.0.0") .file( "Cargo.toml", @@ -623,7 +657,8 @@ fn metabuild_external_dependency() { [build-dependencies] mb = "1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build_dep("mb", "1.0.0") .publish(); @@ -637,7 +672,8 @@ fn metabuild_external_dependency() { [dependencies] dep = "1.0" "#, - ).file("src/lib.rs", "extern crate dep;") + ) + .file("src/lib.rs", "extern crate dep;") .build(); p.cargo("build -vv") @@ -651,7 +687,8 @@ fn metabuild_external_dependency() { .join("target/.metabuild/metabuild-dep-*.rs") .to_str() .unwrap() - ).unwrap() + ) + .unwrap() .count(), 1 ); diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index e624b1f1948..d46e4129441 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -64,7 +64,8 @@ fn cargo_metadata_simple() { "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -93,7 +94,8 @@ version = "0.5.0" [lib] crate-type = ["lib", "staticlib"] "#, - ).build(); + ) + .build(); p.cargo("metadata") .with_json( @@ -151,7 +153,8 @@ crate-type = ["lib", "staticlib"] "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -170,7 +173,8 @@ default = ["default_feat"] default_feat = [] optional_feat = [] "#, - ).build(); + ) + .build(); p.cargo("metadata") .with_json( @@ -235,7 +239,8 @@ optional_feat = [] "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -258,7 +263,8 @@ fn cargo_metadata_with_deps_and_version() { [dependencies] bar = "*" "#, - ).build(); + ) + .build(); Package::new("baz", "0.0.1").publish(); Package::new("bar", "0.0.1").dep("baz", "0.0.1").publish(); @@ -425,7 +431,8 @@ fn cargo_metadata_with_deps_and_version() { "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -443,7 +450,8 @@ version = "0.1.0" [[example]] name = "ex" "#, - ).build(); + ) + .build(); p.cargo("metadata") .with_json( @@ -504,7 +512,8 @@ name = "ex" "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -523,7 +532,8 @@ version = "0.1.0" name = "ex" crate-type = ["rlib", "dylib"] "#, - ).build(); + ) + .build(); p.cargo("metadata") .with_json( @@ -584,7 +594,8 @@ crate-type = ["rlib", "dylib"] "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -596,7 +607,8 @@ fn workspace_metadata() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_lib_manifest("bar")) + ) + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .file("baz/Cargo.toml", &basic_lib_manifest("baz")) .file("baz/src/lib.rs", "") @@ -690,7 +702,8 @@ fn workspace_metadata() { "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -702,7 +715,8 @@ fn workspace_metadata_no_deps() { [workspace] members = ["bar", "baz"] "#, - ).file("bar/Cargo.toml", &basic_lib_manifest("bar")) + ) + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .file("baz/Cargo.toml", &basic_lib_manifest("baz")) .file("baz/src/lib.rs", "") @@ -780,7 +794,8 @@ fn workspace_metadata_no_deps() { "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -795,7 +810,8 @@ fn cargo_metadata_with_invalid_manifest() { Caused by: virtual manifests must be configured with [workspace]", - ).run(); + ) + .run(); } const MANIFEST_OUTPUT: &str = r#" @@ -875,7 +891,8 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_parent_relative() { .with_stderr( "[ERROR] the manifest-path must be \ a path to a Cargo.toml file", - ).run(); + ) + .run(); } #[test] @@ -892,7 +909,8 @@ fn cargo_metadata_no_deps_path_to_cargo_toml_parent_absolute() { .with_stderr( "[ERROR] the manifest-path must be \ a path to a Cargo.toml file", - ).run(); + ) + .run(); } #[test] @@ -921,7 +939,8 @@ fn cargo_metadata_bad_version() { error: '2' isn't a valid value for '--format-version ' [possible values: 1] ", - ).run(); + ) + .run(); } #[test] @@ -939,7 +958,8 @@ fn multiple_features() { a = [] b = [] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("metadata --features").arg("a b").run(); @@ -963,7 +983,8 @@ fn package_metadata() { [package.metadata.bar] baz = "quux" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("metadata --no-deps") @@ -1010,7 +1031,8 @@ fn package_metadata() { "version": 1, "workspace_root": "[..]/foo" }"#, - ).run(); + ) + .run(); } #[test] @@ -1022,7 +1044,8 @@ fn cargo_metadata_path_to_cargo_toml_project() { [workspace] members = ["bar"] "#, - ).file("bar/Cargo.toml", &basic_lib_manifest("bar")) + ) + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .build(); @@ -1091,7 +1114,8 @@ fn cargo_metadata_path_to_cargo_toml_project() { "workspace_root": "[..]" } "#, - ).run(); + ) + .run(); } #[test] @@ -1109,7 +1133,8 @@ fn package_edition_2018() { authors = ["wycats@example.com"] edition = "2018" "#, - ).build(); + ) + .build(); p.cargo("metadata") .masquerade_as_nightly_cargo() .with_json( @@ -1170,7 +1195,8 @@ fn package_edition_2018() { "workspace_root": "[..]" } "#, - ).run(); + ) + .run(); } #[test] @@ -1192,7 +1218,8 @@ fn target_edition_2018() { [lib] edition = "2018" "#, - ).build(); + ) + .build(); p.cargo("metadata") .masquerade_as_nightly_cargo() .with_json( @@ -1264,7 +1291,8 @@ fn target_edition_2018() { "workspace_root": "[..]" } "#, - ).run(); + ) + .run(); } #[test] @@ -1287,7 +1315,8 @@ fn rename_dependency() { bar = { version = "0.1.0" } baz = { version = "0.2.0", package = "bar" } "#, - ).file("src/lib.rs", "extern crate bar; extern crate baz;") + ) + .file("src/lib.rs", "extern crate bar; extern crate baz;") .build(); p.cargo("metadata") @@ -1458,5 +1487,6 @@ fn rename_dependency() { ], "workspace_root": "[..]" }"#, - ).run(); + ) + .run(); } diff --git a/tests/testsuite/net_config.rs b/tests/testsuite/net_config.rs index b8a03324750..3b72251279b 100644 --- a/tests/testsuite/net_config.rs +++ b/tests/testsuite/net_config.rs @@ -14,7 +14,8 @@ fn net_retry_loads_from_config() { [dependencies.bar] git = "https://127.0.0.1:11/foo/bar" "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file( ".cargo/config", r#" @@ -23,14 +24,16 @@ fn net_retry_loads_from_config() { [http] timeout=1 "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_status(101) .with_stderr_contains( "[WARNING] spurious network error \ (1 tries remaining): [..]", - ).run(); + ) + .run(); } #[test] @@ -47,13 +50,15 @@ fn net_retry_git_outputs_warning() { [dependencies.bar] git = "https://127.0.0.1:11/foo/bar" "#, - ).file( + ) + .file( ".cargo/config", r#" [http] timeout=1 "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("build -v -j 1") @@ -61,6 +66,7 @@ fn net_retry_git_outputs_warning() { .with_stderr_contains( "[WARNING] spurious network error \ (2 tries remaining): [..]", - ).with_stderr_contains("[WARNING] spurious network error (1 tries remaining): [..]") + ) + .with_stderr_contains("[WARNING] spurious network error (1 tries remaining): [..]") .run(); } diff --git a/tests/testsuite/new.rs b/tests/testsuite/new.rs index 1781332a9f6..ae6faa49691 100644 --- a/tests/testsuite/new.rs +++ b/tests/testsuite/new.rs @@ -57,11 +57,9 @@ fn simple_bin() { assert!(paths::root().join("foo/src/main.rs").is_file()); cargo_process("build").cwd(&paths::root().join("foo")).run(); - assert!( - paths::root() - .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) - .is_file() - ); + assert!(paths::root() + .join(&format!("foo/target/debug/foo{}", env::consts::EXE_SUFFIX)) + .is_file()); } #[test] @@ -75,7 +73,9 @@ fn both_lib_and_bin() { #[test] fn simple_git() { - cargo_process("new --lib foo --edition 2015").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()); @@ -95,7 +95,8 @@ fn no_argument() { error: The following required arguments were not provided: ", - ).run(); + ) + .run(); } #[test] @@ -107,7 +108,8 @@ fn existing() { .with_stderr( "[ERROR] destination `[CWD]/foo` already exists\n\n\ Use `cargo init` to initialize the directory", - ).run(); + ) + .run(); } #[test] @@ -118,7 +120,8 @@ fn invalid_characters() { "\ [ERROR] Invalid character `.` in crate name: `foo.rs` use --name to override crate name", - ).run(); + ) + .run(); } #[test] @@ -129,7 +132,8 @@ fn reserved_name() { "\ [ERROR] The name `test` cannot be used as a crate name\n\ use --name to override crate name", - ).run(); + ) + .run(); } #[test] @@ -140,7 +144,8 @@ fn reserved_binary_name() { "\ [ERROR] The name `incremental` cannot be used as a crate name\n\ use --name to override crate name", - ).run(); + ) + .run(); } #[test] @@ -151,7 +156,8 @@ fn keyword_name() { "\ [ERROR] The name `pub` cannot be used as a crate name\n\ use --name to override crate name", - ).run(); + ) + .run(); } #[test] @@ -323,7 +329,8 @@ fn author_prefers_cargo() { email = "new-bar" vcs = "none" "#, - ).unwrap(); + ) + .unwrap(); cargo_process("new foo").env("USER", "foo").run(); @@ -367,7 +374,8 @@ fn git_prefers_command_line() { name = "foo" email = "bar" "#, - ).unwrap(); + ) + .unwrap(); cargo_process("new foo --vcs git").env("USER", "foo").run(); assert!(paths::root().join("foo/.gitignore").exists()); @@ -386,16 +394,12 @@ fn subpackage_no_git() { .env("USER", "foo") .run(); - assert!( - !paths::root() - .join("foo/components/subcomponent/.git") - .is_file() - ); - assert!( - !paths::root() - .join("foo/components/subcomponent/.gitignore") - .is_file() - ); + assert!(!paths::root() + .join("foo/components/subcomponent/.git") + .is_file()); + assert!(!paths::root() + .join("foo/components/subcomponent/.gitignore") + .is_file()); } #[test] @@ -414,16 +418,12 @@ fn subpackage_git_with_gitignore() { .env("USER", "foo") .run(); - assert!( - paths::root() - .join("foo/components/subcomponent/.git") - .is_dir() - ); - assert!( - paths::root() - .join("foo/components/subcomponent/.gitignore") - .is_file() - ); + assert!(paths::root() + .join("foo/components/subcomponent/.git") + .is_dir()); + assert!(paths::root() + .join("foo/components/subcomponent/.gitignore") + .is_file()); } #[test] @@ -436,16 +436,12 @@ fn subpackage_git_with_vcs_arg() { .env("USER", "foo") .run(); - assert!( - paths::root() - .join("foo/components/subcomponent/.git") - .is_dir() - ); - assert!( - paths::root() - .join("foo/components/subcomponent/.gitignore") - .is_file() - ); + assert!(paths::root() + .join("foo/components/subcomponent/.git") + .is_dir()); + assert!(paths::root() + .join("foo/components/subcomponent/.gitignore") + .is_file()); } #[test] @@ -454,7 +450,8 @@ fn unknown_flags() { .with_status(1) .with_stderr_contains( "error: Found argument '--flag' which wasn't expected, or isn't valid in this context", - ).run(); + ) + .run(); } #[test] @@ -493,9 +490,7 @@ fn new_with_edition_2018() { #[test] fn new_default_edition() { - cargo_process("new foo") - .env("USER", "foo") - .run(); + 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\"")); } diff --git a/tests/testsuite/out_dir.rs b/tests/testsuite/out_dir.rs index c06e86dd5b6..b8a9ac88697 100644 --- a/tests/testsuite/out_dir.rs +++ b/tests/testsuite/out_dir.rs @@ -36,13 +36,15 @@ fn static_library_with_debug() { [lib] crate-type = ["staticlib"] "#, - ).file( + ) + .file( "src/lib.rs", r#" #[no_mangle] pub extern "C" fn foo() { println!("Hello, World!") } "#, - ).build(); + ) + .build(); p.cargo("build -Z unstable-options --out-dir out") .masquerade_as_nightly_cargo() @@ -69,13 +71,15 @@ fn dynamic_library_with_debug() { [lib] crate-type = ["cdylib"] "#, - ).file( + ) + .file( "src/lib.rs", r#" #[no_mangle] pub extern "C" fn foo() { println!("Hello, World!") } "#, - ).build(); + ) + .build(); p.cargo("build -Z unstable-options --out-dir out") .masquerade_as_nightly_cargo() @@ -102,12 +106,14 @@ fn rlib_with_debug() { [lib] crate-type = ["rlib"] "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn foo() { println!("Hello, World!") } "#, - ).build(); + ) + .build(); p.cargo("build -Z unstable-options --out-dir out") .masquerade_as_nightly_cargo() @@ -136,7 +142,8 @@ fn include_only_the_binary_from_the_current_package() { [dependencies] utils = { path = "./utils" } "#, - ).file("src/lib.rs", "extern crate utils;") + ) + .file("src/lib.rs", "extern crate utils;") .file( "src/main.rs", r#" @@ -146,7 +153,8 @@ fn include_only_the_binary_from_the_current_package() { println!("Hello, World!") } "#, - ).file("utils/Cargo.toml", &basic_manifest("utils", "0.0.1")) + ) + .file("utils/Cargo.toml", &basic_manifest("utils", "0.0.1")) .file("utils/src/lib.rs", "") .build(); @@ -187,7 +195,8 @@ fn replaces_artifacts() { p.process( &p.root() .join(&format!("out/foo{}", env::consts::EXE_SUFFIX)), - ).with_stdout("foo") + ) + .with_stdout("foo") .run(); sleep_ms(1000); @@ -199,7 +208,8 @@ fn replaces_artifacts() { p.process( &p.root() .join(&format!("out/foo{}", env::consts::EXE_SUFFIX)), - ).with_stdout("bar") + ) + .with_stdout("bar") .run(); } diff --git a/tests/testsuite/overrides.rs b/tests/testsuite/overrides.rs index e5490566b48..1d1d6b45d9e 100644 --- a/tests/testsuite/overrides.rs +++ b/tests/testsuite/overrides.rs @@ -30,10 +30,12 @@ fn override_simple() { "#, bar.url() ), - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -44,7 +46,8 @@ fn override_simple() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -64,7 +67,8 @@ fn missing_version() { [replace] bar = { git = 'https://example.com' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -76,7 +80,8 @@ error: failed to parse manifest at `[..]` Caused by: replacements must specify a version to replace, but `[..]bar` does not ", - ).run(); + ) + .run(); } #[test] @@ -96,7 +101,8 @@ fn invalid_semver_version() { [replace] "bar:*" = { git = 'https://example.com' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -108,7 +114,8 @@ error: failed to parse manifest at `[..]` Caused by: replacements must specify a valid semver version to replace, but `bar:*` does not ", - ).run(); + ) + .run(); } #[test] @@ -131,7 +138,8 @@ fn different_version() { [replace] "bar:0.1.0" = "0.2.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -143,7 +151,8 @@ error: failed to parse manifest at `[..]` Caused by: replacements cannot specify a version requirement, but found one for [..] ", - ).run(); + ) + .run(); } #[test] @@ -177,7 +186,8 @@ fn transitive() { "#, foo.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -192,7 +202,8 @@ fn transitive() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stdout("").run(); } @@ -224,10 +235,12 @@ fn persists_across_rebuilds() { "#, foo.url() ), - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -238,7 +251,8 @@ fn persists_across_rebuilds() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stdout("").run(); } @@ -268,10 +282,12 @@ fn replace_registry_with_path() { [replace] "bar:0.1.0" = { path = "../bar" } "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -281,7 +297,8 @@ fn replace_registry_with_path() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -295,7 +312,8 @@ fn use_a_spec_to_select() { .file( "src/lib.rs", "extern crate baz; pub fn bar() { baz::baz3(); }", - ).publish(); + ) + .publish(); let foo = git::repo(&paths::root().join("override")) .file("Cargo.toml", &basic_manifest("baz", "0.2.0")) @@ -321,7 +339,8 @@ fn use_a_spec_to_select() { "#, foo.url() ), - ).file( + ) + .file( "src/lib.rs", " extern crate bar; @@ -332,7 +351,8 @@ fn use_a_spec_to_select() { bar::bar(); } ", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -348,7 +368,8 @@ fn use_a_spec_to_select() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -368,7 +389,8 @@ fn override_adds_some_deps() { [dependencies] baz = "0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let p = project() @@ -389,7 +411,8 @@ fn override_adds_some_deps() { "#, foo.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -404,7 +427,8 @@ fn override_adds_some_deps() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stdout("").run(); @@ -416,13 +440,15 @@ fn override_adds_some_deps() { [UPDATING] git repository `file://[..]` [UPDATING] `[ROOT][..]` index ", - ).run(); + ) + .run(); p.cargo("update -p https://github.com/rust-lang/crates.io-index#bar") .with_stderr( "\ [UPDATING] `[ROOT][..]` index ", - ).run(); + ) + .run(); p.cargo("build").with_stdout("").run(); } @@ -446,7 +472,8 @@ fn locked_means_locked_yes_no_seriously_i_mean_locked() { [dependencies] baz = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let p = project() @@ -468,7 +495,8 @@ fn locked_means_locked_yes_no_seriously_i_mean_locked() { "#, foo.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -504,7 +532,8 @@ fn override_wrong_name() { "#, foo.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -517,7 +546,8 @@ error: no matching package for override `[..]baz:0.1.0` found location searched: file://[..] version required: = 0.1.0 ", - ).run(); + ) + .run(); } #[test] @@ -546,7 +576,8 @@ fn override_with_nothing() { "#, foo.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -563,7 +594,8 @@ Caused by: Caused by: Could not find Cargo.toml in `[..]` ", - ).run(); + ) + .run(); } #[test] @@ -580,7 +612,8 @@ fn override_wrong_version() { [replace] "bar:0.1.0" = { git = 'https://example.com', version = '0.2.0' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -592,7 +625,8 @@ error: failed to parse manifest at `[..]` Caused by: replacements cannot specify a version requirement, but found one for `[..]bar:0.1.0` ", - ).run(); + ) + .run(); } #[test] @@ -625,7 +659,8 @@ fn multiple_specs() { "#, bar.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -641,7 +676,8 @@ error: overlapping replacement specifications found: both specifications match: bar v0.1.0 ", - ).run(); + ) + .run(); } #[test] @@ -671,7 +707,8 @@ fn test_override_dep() { "#, bar.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("test -p bar") @@ -683,7 +720,8 @@ Please re-run this command with [..] [..]#bar:0.1.0 [..]#bar:0.1.0 ", - ).run(); + ) + .run(); } #[test] @@ -713,7 +751,8 @@ fn update() { "#, bar.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("generate-lockfile").run(); @@ -723,7 +762,8 @@ fn update() { [UPDATING] `[..]` index [UPDATING] git repository `[..]` ", - ).run(); + ) + .run(); } // foo -> near -> far @@ -744,7 +784,8 @@ fn no_override_self() { [dependencies] far = { path = "../far" } "#, - ).file("near/src/lib.rs", "#![no_std] pub extern crate far;") + ) + .file("near/src/lib.rs", "#![no_std] pub extern crate far;") .build(); let p = project() @@ -765,7 +806,8 @@ fn no_override_self() { "#, deps.url() ), - ).file("src/lib.rs", "#![no_std] pub extern crate near;") + ) + .file("src/lib.rs", "#![no_std] pub extern crate near;") .build(); p.cargo("build --verbose").run(); @@ -788,7 +830,8 @@ fn broken_path_override_warns() { [dependencies] a = { path = "a1" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a1/Cargo.toml", r#" @@ -800,7 +843,8 @@ fn broken_path_override_warns() { [dependencies] bar = "0.1" "#, - ).file("a1/src/lib.rs", "") + ) + .file("a1/src/lib.rs", "") .file( "a2/Cargo.toml", r#" @@ -812,7 +856,8 @@ fn broken_path_override_warns() { [dependencies] bar = "0.2" "#, - ).file("a2/src/lib.rs", "") + ) + .file("a2/src/lib.rs", "") .file(".cargo/config", r#"paths = ["a2"]"#) .build(); @@ -842,7 +887,8 @@ https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#overridin [COMPILING] [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -874,7 +920,8 @@ fn override_an_override() { "chrono:0.2.0" = { path = "chrono" } "serde:0.8.0" = { path = "serde" } "#, - ).file( + ) + .file( "Cargo.lock", r#" [[package]] @@ -913,7 +960,8 @@ fn override_an_override() { name = "serde" version = "0.8.0" "#, - ).file( + ) + .file( "src/lib.rs", " extern crate chrono; @@ -924,7 +972,8 @@ fn override_an_override() { serde::serde08_override(); } ", - ).file( + ) + .file( "chrono/Cargo.toml", r#" [package] @@ -935,7 +984,8 @@ fn override_an_override() { [dependencies] serde = "< 0.9" "#, - ).file( + ) + .file( "chrono/src/lib.rs", " extern crate serde; @@ -943,7 +993,8 @@ fn override_an_override() { serde::serde07(); } ", - ).file("serde/Cargo.toml", &basic_manifest("serde", "0.8.0")) + ) + .file("serde/Cargo.toml", &basic_manifest("serde", "0.8.0")) .file("serde/src/lib.rs", "pub fn serde08_override() {}") .build(); @@ -967,7 +1018,8 @@ fn overriding_nonexistent_no_spurious() { [dependencies] baz = { path = "baz" } "#, - ).file("src/lib.rs", "pub fn bar() {}") + ) + .file("src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/lib.rs", "pub fn baz() {}") .build(); @@ -991,7 +1043,8 @@ fn overriding_nonexistent_no_spurious() { "#, url = bar.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -1001,7 +1054,8 @@ fn overriding_nonexistent_no_spurious() { [WARNING] package replacement is not used: [..]baz:0.1.0 [FINISHED] [..] ", - ).with_stdout("") + ) + .with_stdout("") .run(); } @@ -1019,7 +1073,8 @@ fn no_warnings_when_replace_is_used_in_another_workspace_member() { [replace] "bar:0.1.0" = { path = "local_bar" }"#, - ).file( + ) + .file( "first_crate/Cargo.toml", r#" [package] @@ -1029,11 +1084,13 @@ fn no_warnings_when_replace_is_used_in_another_workspace_member() { [dependencies] bar = "0.1.0" "#, - ).file("first_crate/src/lib.rs", "") + ) + .file("first_crate/src/lib.rs", "") .file( "second_crate/Cargo.toml", &basic_manifest("second_crate", "0.1.0"), - ).file("second_crate/src/lib.rs", "") + ) + .file("second_crate/src/lib.rs", "") .file("local_bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("local_bar/src/lib.rs", "") .build(); @@ -1047,7 +1104,8 @@ fn no_warnings_when_replace_is_used_in_another_workspace_member() { [COMPILING] bar v0.1.0 ([..]) [COMPILING] first_crate v0.1.0 ([..]) [FINISHED] [..]", - ).run(); + ) + .run(); p.cargo("build") .cwd(p.root().join("second_crate")) @@ -1056,7 +1114,8 @@ fn no_warnings_when_replace_is_used_in_another_workspace_member() { "\ [COMPILING] second_crate v0.1.0 ([..]) [FINISHED] [..]", - ).run(); + ) + .run(); } #[test] @@ -1076,7 +1135,8 @@ fn override_to_path_dep() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -1088,7 +1148,8 @@ fn override_to_path_dep() { [dependencies] baz = { path = "baz" } "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("bar/baz/src/lib.rs", "") .file(".cargo/config", r#"paths = ["bar"]"#) @@ -1117,7 +1178,8 @@ fn replace_to_path_dep() { [replace] "bar:0.1.0" = { path = "bar" } "#, - ).file("src/lib.rs", "extern crate bar;") + ) + .file("src/lib.rs", "extern crate bar;") .file( "bar/Cargo.toml", r#" @@ -1129,10 +1191,12 @@ fn replace_to_path_dep() { [dependencies] baz = { path = "baz" } "#, - ).file( + ) + .file( "bar/src/lib.rs", "extern crate baz; pub fn bar() { baz::baz(); }", - ).file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) + ) + .file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("bar/baz/src/lib.rs", "pub fn baz() {}") .build(); @@ -1155,7 +1219,8 @@ fn paths_ok_with_optional() { [dependencies] bar = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -1167,7 +1232,8 @@ fn paths_ok_with_optional() { [dependencies] baz = { version = "0.1", optional = true } "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file( "bar2/Cargo.toml", r#" @@ -1179,7 +1245,8 @@ fn paths_ok_with_optional() { [dependencies] baz = { version = "0.1", optional = true } "#, - ).file("bar2/src/lib.rs", "") + ) + .file("bar2/src/lib.rs", "") .file(".cargo/config", r#"paths = ["bar2"]"#) .build(); @@ -1190,7 +1257,8 @@ fn paths_ok_with_optional() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -1209,7 +1277,8 @@ fn paths_add_optional_bad() { [dependencies] bar = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") .file( @@ -1223,7 +1292,8 @@ fn paths_add_optional_bad() { [dependencies] baz = { version = "0.1", optional = true } "#, - ).file("bar2/src/lib.rs", "") + ) + .file("bar2/src/lib.rs", "") .file(".cargo/config", r#"paths = ["bar2"]"#) .build(); @@ -1233,7 +1303,8 @@ fn paths_add_optional_bad() { warning: path override for crate `bar` has altered the original list of dependencies; the dependency on `baz` was either added or\ ", - ).run(); + ) + .run(); } #[test] @@ -1259,7 +1330,8 @@ fn override_with_default_feature() { [replace] 'bar:0.1.0' = { path = "bar" } "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }") .file( "bar/Cargo.toml", r#" @@ -1271,13 +1343,15 @@ fn override_with_default_feature() { [features] default = [] "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #[cfg(feature = "default")] pub fn bar() {} "#, - ).file( + ) + .file( "another2/Cargo.toml", r#" [package] @@ -1288,7 +1362,8 @@ fn override_with_default_feature() { [dependencies] bar = { version = "0.1", default-features = false } "#, - ).file("another2/src/lib.rs", "") + ) + .file("another2/src/lib.rs", "") .build(); p.cargo("run").run(); @@ -1313,7 +1388,8 @@ fn override_plus_dep() { [replace] 'bar:0.1.0' = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -1325,7 +1401,8 @@ fn override_plus_dep() { [dependencies] foo = { path = ".." } "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("build") diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index dc3fe5c28c6..34a707c271f 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -3,17 +3,19 @@ use std::fs::File; use std::io::prelude::*; use std::path::{Path, PathBuf}; -use flate2::read::GzDecoder; -use git2; use crate::support::registry::Package; use crate::support::{basic_manifest, git, is_nightly, path2url, paths, project, registry}; use crate::support::{cargo_process, sleep_ms}; +use flate2::read::GzDecoder; +use git2; use tar::Archive; #[test] fn simple() { let p = project() - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" [project] name = "foo" version = "0.0.1" @@ -21,7 +23,8 @@ fn simple() { exclude = ["*.txt"] license = "MIT" description = "foo" - "#) + "#, + ) .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("src/bar.txt", "") // should be ignored when packaging .build(); @@ -36,7 +39,8 @@ See [..] [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout( @@ -44,7 +48,8 @@ See [..] Cargo.toml src/main.rs ", - ).run(); + ) + .run(); p.cargo("package").with_stdout("").run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -80,7 +85,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); let p = project() .file( @@ -92,7 +98,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. authors = [] license = "MIT" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("package") .with_stderr( @@ -104,7 +111,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); let p = project() .file( @@ -118,7 +126,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. description = "foo" repository = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("package") .with_stderr( @@ -128,7 +137,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -154,7 +164,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [ARCHIVING] [..] [ARCHIVING] .cargo_vcs_info.json ", - ).run(); + ) + .run(); let f = File::open(&repo.root().join("target/package/foo-0.0.1.crate")).unwrap(); let mut rdr = GzDecoder::new(f); @@ -194,7 +205,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [ARCHIVING] src/lib.rs [ARCHIVING] .cargo_vcs_info.json ", - ).run(); + ) + .run(); } #[test] @@ -211,7 +223,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -232,12 +245,14 @@ fn vcs_file_collision() { repository = "foo" exclude = ["*.no-existe"] "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() {} "#, - ).file(".cargo_vcs_info.json", "foo") + ) + .file(".cargo_vcs_info.json", "foo") .build(); p.cargo("package") .arg("--no-verify") @@ -247,7 +262,8 @@ fn vcs_file_collision() { [ERROR] Invalid inclusion of reserved file name .cargo_vcs_info.json \ in package source ", - ).run(); + ) + .run(); } #[test] @@ -266,7 +282,8 @@ fn path_dependency_no_version() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") .build(); @@ -280,14 +297,17 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [ERROR] all path dependencies must have a version specified when packaging. dependency `bar` does not specify a version. ", - ).run(); + ) + .run(); } #[test] fn exclude() { let root = paths::root().join("exclude"); let repo = git::repo(&root) - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" [project] name = "foo" version = "0.0.1" @@ -319,7 +339,8 @@ fn exclude() { "dir_deep_4/*", # CHANGING (packaged -> ignored) "dir_deep_5/**", # CHANGING (packaged -> ignored) ] - "#) + "#, + ) .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("bar.txt", "") .file("src/bar.txt", "") @@ -389,7 +410,8 @@ See [..] [ARCHIVING] [..] [ARCHIVING] .cargo_vcs_info.json ", - ).run(); + ) + .run(); assert!(repo.root().join("target/package/foo-0.0.1.crate").is_file()); @@ -417,21 +439,25 @@ some_dir/file_deep_4 some_dir/file_deep_5 src/main.rs ", - ).run(); + ) + .run(); } #[test] fn include() { let root = paths::root().join("include"); let repo = git::repo(&root) - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" [project] name = "foo" version = "0.0.1" authors = [] exclude = ["*.txt"] include = ["foo.txt", "**/*.rs", "Cargo.toml"] - "#) + "#, + ) .file("foo.txt", "") .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("src/bar.txt", "") // should be ignored when packaging @@ -449,7 +475,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [ARCHIVING] [..] [ARCHIVING] .cargo_vcs_info.json ", - ).run(); + ) + .run(); } #[test] @@ -477,11 +504,14 @@ fn package_git_submodule() { description = "foo" repository = "foo" "#, - ).file("src/lib.rs", "pub fn foo() {}") - }).unwrap(); + ) + .file("src/lib.rs", "pub fn foo() {}") + }) + .unwrap(); let library = git::new("bar", |library| { library.no_manifest().file("Makefile", "all:") - }).unwrap(); + }) + .unwrap(); let repository = git2::Repository::open(&project.root()).unwrap(); let url = path2url(library.root()).to_string(); @@ -494,9 +524,11 @@ fn package_git_submodule() { &repository.revparse_single("HEAD").unwrap(), git2::ResetType::Hard, None, - ).unwrap(); + ) + .unwrap(); - project.cargo("package --no-verify -v") + project + .cargo("package --no-verify -v") .with_stderr_contains("[ARCHIVING] bar/Makefile") .run(); } @@ -520,7 +552,8 @@ fn no_duplicates_from_modified_tracked_files() { Cargo.toml src/main.rs ", - ).run(); + ) + .run(); } #[test] @@ -555,7 +588,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .with_stdout( @@ -563,7 +597,8 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. Cargo.toml src[..]main.rs ", - ).run(); + ) + .run(); p.cargo("package").with_stdout("").run(); let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -605,7 +640,8 @@ See [..] Caused by: cannot package a filename with a special character `:`: src/:foo ", - ).run(); + ) + .run(); } #[test] @@ -640,7 +676,8 @@ See [..] [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // Check that the tarball contains the added file let f = File::open(&p.root().join("target/package/foo-0.0.1.crate")).unwrap(); @@ -674,7 +711,8 @@ fn broken_symlink() { homepage = 'foo' repository = 'foo' "#, - ).file("src/main.rs", r#"fn main() { println!("hello"); }"#) + ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); t!(fs::symlink("nowhere", &p.root().join("src/foo.rs"))); @@ -690,7 +728,8 @@ Caused by: Caused by: [..] ", - ).run(); + ) + .run(); } #[test] @@ -711,7 +750,8 @@ fn do_not_package_if_repository_is_dirty() { homepage = "foo" repository = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); // Modify Cargo.toml without committing the change. @@ -741,7 +781,8 @@ Cargo.toml to proceed despite this, pass the `--allow-dirty` flag ", - ).run(); + ) + .run(); } #[test] @@ -775,7 +816,8 @@ fn generated_manifest() { ghi = "1.0" abc = "1.0" "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") .build(); @@ -861,7 +903,8 @@ fn ignore_workspace_specifier() { [dependencies] bar = { path = "bar", version = "0.1" } "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file( "bar/Cargo.toml", r#" @@ -871,7 +914,8 @@ fn ignore_workspace_specifier() { authors = [] workspace = ".." "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("package --no-verify") @@ -930,7 +974,8 @@ fn package_two_kinds_of_deps() { other = "1.0" other1 = { version = "1.0" } "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .build(); p.cargo("package --no-verify").run(); @@ -949,18 +994,23 @@ fn test_edition() { authors = [] edition = "2018" "#, - ).file("src/lib.rs", r#" "#) + ) + .file("src/lib.rs", r#" "#) .build(); - p.cargo("build -v").masquerade_as_nightly_cargo() + p.cargo("build -v") + .masquerade_as_nightly_cargo() .without_status() // passes on nightly, fails on stable, b/c --edition is nightly-only // --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("\ + .with_stderr_contains( + "\ [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..]--edition=2018 [..] -").run(); +", + ) + .run(); } #[test] @@ -983,7 +1033,8 @@ fn edition_with_metadata() { [package.metadata.docs.rs] features = ["foobar"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("package").run(); @@ -1001,7 +1052,8 @@ fn test_edition_malformed() { authors = [] edition = "chicken" "#, - ).file("src/lib.rs", r#" "#) + ) + .file("src/lib.rs", r#" "#) .build(); p.cargo("build -v") @@ -1015,8 +1067,10 @@ Caused by: Caused by: supported edition values are `2015` or `2018`, but `chicken` is unknown -".to_string(), - ).run(); +" + .to_string(), + ) + .run(); } #[test] @@ -1035,7 +1089,8 @@ fn package_lockfile() { description = "foo" publish-lockfile = true "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("package") @@ -1049,7 +1104,8 @@ See [..] [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.root().join("target/package/foo-0.0.1.crate").is_file()); p.cargo("package -l") .masquerade_as_nightly_cargo() @@ -1059,7 +1115,8 @@ Cargo.lock Cargo.toml src/main.rs ", - ).run(); + ) + .run(); p.cargo("package") .masquerade_as_nightly_cargo() .with_stdout("") @@ -1106,7 +1163,8 @@ fn package_lockfile_git_repo() { repository = "foo" publish-lockfile = true "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("package -l") .masquerade_as_nightly_cargo() @@ -1117,7 +1175,8 @@ Cargo.lock Cargo.toml src/main.rs ", - ).run(); + ) + .run(); } #[test] @@ -1136,7 +1195,8 @@ fn no_lock_file_with_library() { description = "foo" publish-lockfile = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("package").masquerade_as_nightly_cargo().run(); @@ -1162,7 +1222,8 @@ fn lock_file_and_workspace() { [workspace] members = ["foo"] "#, - ).file( + ) + .file( "foo/Cargo.toml", r#" cargo-features = ["publish-lockfile"] @@ -1175,7 +1236,8 @@ fn lock_file_and_workspace() { description = "foo" publish-lockfile = true "#, - ).file("foo/src/main.rs", "fn main() {}") + ) + .file("foo/src/main.rs", "fn main() {}") .build(); p.cargo("package") @@ -1210,7 +1272,8 @@ fn do_not_package_if_src_was_modified() { file.write_all(b"Hello, world of generated files.").expect("failed to write"); } "#, - ).build(); + ) + .build(); if cfg!(target_os = "macos") { // MacOS has 1s resolution filesystem. @@ -1230,7 +1293,8 @@ Caused by: Build scripts should not modify anything outside of OUT_DIR. Modified file: [..]src/generated.txt To proceed despite this, pass the `--no-verify` flag.", - ).run(); + ) + .run(); p.cargo("package --no-verify").run(); } diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index 07eda0c05c3..dc101b85117 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -14,7 +14,8 @@ fn replace() { .file( "src/lib.rs", "extern crate bar; pub fn baz() { bar::bar(); }", - ).dep("bar", "0.1.0") + ) + .dep("bar", "0.1.0") .publish(); let p = project() @@ -33,7 +34,8 @@ fn replace() { [patch.crates-io] bar = { path = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", " extern crate bar; @@ -43,7 +45,8 @@ fn replace() { baz::baz(); } ", - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -58,7 +61,8 @@ fn replace() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); } @@ -82,10 +86,12 @@ fn nonexistent() { [patch.crates-io] bar = { path = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -97,7 +103,8 @@ fn nonexistent() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); } @@ -126,10 +133,12 @@ fn patch_git() { "#, bar.url() ), - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -141,7 +150,8 @@ fn patch_git() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); } @@ -172,10 +182,12 @@ fn patch_to_git() { "#, bar.url() ), - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }", - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -186,7 +198,8 @@ fn patch_to_git() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); } @@ -209,7 +222,8 @@ fn unused() { [patch.crates-io] bar = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.2.0")) .file("bar/src/lib.rs", "not rust code") .build(); @@ -224,7 +238,8 @@ fn unused() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); // unused patch should be in the lock file @@ -269,7 +284,8 @@ fn unused_git() { "#, foo.url() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -283,7 +299,8 @@ fn unused_git() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); } @@ -303,7 +320,8 @@ fn add_patch() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", r#""#) .build(); @@ -318,7 +336,8 @@ fn add_patch() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); t!(t!(File::create(p.root().join("Cargo.toml"))).write_all( @@ -343,7 +362,8 @@ fn add_patch() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); } @@ -363,7 +383,8 @@ fn add_ignored_patch() { [dependencies] bar = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.1")) .file("bar/src/lib.rs", r#""#) .build(); @@ -378,7 +399,8 @@ fn add_ignored_patch() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build").with_stderr("[FINISHED] [..]").run(); t!(t!(File::create(p.root().join("Cargo.toml"))).write_all( @@ -421,7 +443,8 @@ fn new_minor() { [patch.crates-io] bar = { path = 'bar' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.1")) .file("bar/src/lib.rs", r#""#) .build(); @@ -434,7 +457,8 @@ fn new_minor() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -456,7 +480,8 @@ fn transitive_new_minor() { [patch.crates-io] baz = { path = 'baz' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -468,7 +493,8 @@ fn transitive_new_minor() { [dependencies] baz = '0.1.0' "#, - ).file("bar/src/lib.rs", r#""#) + ) + .file("bar/src/lib.rs", r#""#) .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.1")) .file("baz/src/lib.rs", r#""#) .build(); @@ -482,7 +508,8 @@ fn transitive_new_minor() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -504,7 +531,8 @@ fn new_major() { [patch.crates-io] bar = { path = 'bar' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.2.0")) .file("bar/src/lib.rs", r#""#) .build(); @@ -517,7 +545,8 @@ fn new_major() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); Package::new("bar", "0.2.0").publish(); p.cargo("update").run(); @@ -546,7 +575,8 @@ fn new_major() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -568,7 +598,8 @@ fn transitive_new_major() { [patch.crates-io] baz = { path = 'baz' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -580,7 +611,8 @@ fn transitive_new_major() { [dependencies] baz = '0.2.0' "#, - ).file("bar/src/lib.rs", r#""#) + ) + .file("bar/src/lib.rs", r#""#) .file("baz/Cargo.toml", &basic_manifest("baz", "0.2.0")) .file("baz/src/lib.rs", r#""#) .build(); @@ -594,7 +626,8 @@ fn transitive_new_major() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -618,7 +651,8 @@ fn remove_patch() { foo = { path = 'foo' } bar = { path = 'bar' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", r#""#) .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) @@ -649,7 +683,8 @@ fn remove_patch() { [patch.crates-io] bar = { path = 'bar' } "#, - ).unwrap(); + ) + .unwrap(); p.cargo("build").run(); let mut lock_file2 = String::new(); File::open(p.root().join("Cargo.lock")) @@ -687,7 +722,8 @@ fn non_crates_io() { [patch.some-other-source] bar = { path = 'bar' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", r#""#) .build(); @@ -701,7 +737,8 @@ error: failed to parse manifest at `[..]` Caused by: invalid url `some-other-source`: relative URL without a base ", - ).run(); + ) + .run(); } #[test] @@ -720,7 +757,8 @@ fn replace_with_crates_io() { [patch.crates-io] bar = "0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", r#""#) .build(); @@ -736,7 +774,8 @@ Caused by: patch for `bar` in `[..]` points to the same source, but patches must point \ to different sources ", - ).run(); + ) + .run(); } #[test] @@ -753,7 +792,8 @@ fn patch_in_virtual() { [patch.crates-io] bar = { path = "bar" } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", r#""#) .file( "foo/Cargo.toml", @@ -766,7 +806,8 @@ fn patch_in_virtual() { [dependencies] bar = "0.1" "#, - ).file("foo/src/lib.rs", r#""#) + ) + .file("foo/src/lib.rs", r#""#) .build(); p.cargo("build").run(); @@ -801,7 +842,8 @@ fn patch_depends_on_another_patch() { bar = { path = "bar" } baz = { path = "baz" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.1")) .file("bar/src/lib.rs", r#""#) .file( @@ -815,7 +857,8 @@ fn patch_depends_on_another_patch() { [dependencies] bar = "0.1" "#, - ).file("baz/src/lib.rs", r#""#) + ) + .file("baz/src/lib.rs", r#""#) .build(); p.cargo("build").run(); @@ -837,7 +880,8 @@ fn replace_prerelease() { [patch.crates-io] baz = { path = "./baz" } "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [project] @@ -848,10 +892,12 @@ fn replace_prerelease() { [dependencies] baz = "1.1.0-pre.1" "#, - ).file( + ) + .file( "bar/src/main.rs", "extern crate baz; fn main() { baz::baz() }", - ).file( + ) + .file( "baz/Cargo.toml", r#" [project] @@ -860,7 +906,8 @@ fn replace_prerelease() { authors = [] [workspace] "#, - ).file("baz/src/lib.rs", "pub fn baz() {}") + ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); p.cargo("build").run(); diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index fbb80c27937..01c605307c1 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -25,7 +25,8 @@ fn cargo_compile_with_nested_deps_shorthand() { version = "0.5.0" path = "bar" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -44,7 +45,8 @@ fn cargo_compile_with_nested_deps_shorthand() { name = "bar" "#, - ).file( + ) + .file( "bar/src/bar.rs", r#" extern crate baz; @@ -53,7 +55,8 @@ fn cargo_compile_with_nested_deps_shorthand() { baz::gimme() } "#, - ).file("bar/baz/Cargo.toml", &basic_lib_manifest("baz")) + ) + .file("bar/baz/Cargo.toml", &basic_lib_manifest("baz")) .file( "bar/baz/src/baz.rs", r#" @@ -61,7 +64,8 @@ fn cargo_compile_with_nested_deps_shorthand() { "test passed".to_string() } "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -70,7 +74,8 @@ fn cargo_compile_with_nested_deps_shorthand() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); assert!(p.bin("foo").is_file()); @@ -84,7 +89,8 @@ fn cargo_compile_with_nested_deps_shorthand() { "[COMPILING] baz v0.5.0 ([CWD]/bar/baz)\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); println!("building foo"); p.cargo("build -p foo") .with_stderr( @@ -92,7 +98,8 @@ fn cargo_compile_with_nested_deps_shorthand() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -115,7 +122,8 @@ fn cargo_compile_with_root_dev_deps() { [[bin]] name = "foo" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .build(); let _p2 = project() .at("bar") @@ -127,7 +135,8 @@ fn cargo_compile_with_root_dev_deps() { "zoidberg" } "#, - ).build(); + ) + .build(); p.cargo("build").with_status(101).run(); } @@ -152,7 +161,8 @@ fn cargo_compile_with_root_dev_deps_with_testing() { [[bin]] name = "foo" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .build(); let _p2 = project() .at("bar") @@ -164,7 +174,8 @@ fn cargo_compile_with_root_dev_deps_with_testing() { "zoidberg" } "#, - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -173,7 +184,8 @@ fn cargo_compile_with_root_dev_deps_with_testing() { [COMPILING] [..] v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); } @@ -194,7 +206,8 @@ fn cargo_compile_with_transitive_dev_deps() { version = "0.5.0" path = "bar" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -212,14 +225,16 @@ fn cargo_compile_with_transitive_dev_deps() { name = "bar" "#, - ).file( + ) + .file( "bar/src/bar.rs", r#" pub fn gimme() -> &'static str { "zoidberg" } "#, - ).build(); + ) + .build(); p.cargo("build") .with_stderr( @@ -227,7 +242,8 @@ fn cargo_compile_with_transitive_dev_deps() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n", - ).run(); + ) + .run(); assert!(p.bin("foo").is_file()); @@ -249,7 +265,8 @@ fn no_rebuild_dependency() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/bar.rs", "pub fn bar() {}") .build(); @@ -260,7 +277,8 @@ fn no_rebuild_dependency() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); sleep_ms(1000); p.change_file( @@ -277,7 +295,8 @@ fn no_rebuild_dependency() { [COMPILING] foo v0.5.0 ([..])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -295,7 +314,8 @@ fn deep_dependencies_trigger_rebuild() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") .file( "bar/Cargo.toml", r#" @@ -310,10 +330,12 @@ fn deep_dependencies_trigger_rebuild() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "bar/src/bar.rs", "extern crate baz; pub fn bar() { baz::baz() }", - ).file("baz/Cargo.toml", &basic_lib_manifest("baz")) + ) + .file("baz/Cargo.toml", &basic_lib_manifest("baz")) .file("baz/src/baz.rs", "pub fn baz() {}") .build(); p.cargo("build") @@ -323,7 +345,8 @@ fn deep_dependencies_trigger_rebuild() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); p.cargo("build").with_stdout("").run(); // Make sure an update to baz triggers a rebuild of bar @@ -342,7 +365,8 @@ fn deep_dependencies_trigger_rebuild() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); // Make sure an update to bar doesn't trigger baz File::create(&p.root().join("bar/src/bar.rs")) @@ -352,7 +376,8 @@ fn deep_dependencies_trigger_rebuild() { extern crate baz; pub fn bar() { println!("hello!"); baz::baz(); } "#, - ).unwrap(); + ) + .unwrap(); sleep_ms(1000); p.cargo("build") .with_stderr( @@ -360,7 +385,8 @@ fn deep_dependencies_trigger_rebuild() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -380,7 +406,8 @@ fn no_rebuild_two_deps() { [dependencies.baz] path = "baz" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") .file( "bar/Cargo.toml", r#" @@ -395,7 +422,8 @@ fn no_rebuild_two_deps() { [dependencies.baz] path = "../baz" "#, - ).file("bar/src/bar.rs", "pub fn bar() {}") + ) + .file("bar/src/bar.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_lib_manifest("baz")) .file("baz/src/baz.rs", "pub fn baz() {}") .build(); @@ -406,7 +434,8 @@ fn no_rebuild_two_deps() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); assert!(p.bin("foo").is_file()); p.cargo("build").with_stdout("").run(); assert!(p.bin("foo").is_file()); @@ -429,7 +458,8 @@ fn nested_deps_recompile() { version = "0.5.0" path = "src/bar" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file("src/bar/Cargo.toml", &basic_lib_manifest("bar")) .file("src/bar/src/bar.rs", "pub fn gimme() -> i32 { 92 }") .build(); @@ -440,7 +470,8 @@ fn nested_deps_recompile() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); sleep_ms(1000); File::create(&p.root().join("src/main.rs")) @@ -454,7 +485,8 @@ fn nested_deps_recompile() { "[COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); } #[test] @@ -473,7 +505,8 @@ fn error_message_for_missing_manifest() { path = "src/bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/bar/not-a-manifest", "") .build(); @@ -492,7 +525,8 @@ Caused by: Caused by: [..] (os error [..]) ", - ).run(); + ) + .run(); } #[test] @@ -525,7 +559,8 @@ fn override_relative() { "#, bar.root().display() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v").run(); } @@ -558,7 +593,8 @@ fn override_self() { "#, bar.root().display() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/main.rs", "fn main() {}") .build(); @@ -580,7 +616,8 @@ fn override_path_dep() { [dependencies.p2] path = "../p2" "#, - ).file("p1/src/lib.rs", "") + ) + .file("p1/src/lib.rs", "") .file("p2/Cargo.toml", &basic_manifest("p2", "0.5.0")) .file("p2/src/lib.rs", "") .build(); @@ -593,7 +630,8 @@ fn override_path_dep() { bar.root().join("p1").display(), bar.root().join("p2").display() ), - ).file( + ) + .file( "Cargo.toml", &format!( r#" @@ -609,7 +647,8 @@ fn override_path_dep() { "#, bar.root().join("p2").display() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v").run(); @@ -632,7 +671,8 @@ fn path_dep_build_cmd() { version = "0.5.0" path = "bar" "#, - ).file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) + ) + .file("src/main.rs", &main_file(r#""{}", bar::gimme()"#, &["bar"])) .file( "bar/Cargo.toml", r#" @@ -647,7 +687,8 @@ fn path_dep_build_cmd() { name = "bar" path = "src/bar.rs" "#, - ).file( + ) + .file( "bar/build.rs", r#" use std::fs; @@ -655,7 +696,8 @@ fn path_dep_build_cmd() { fs::copy("src/bar.rs.in", "src/bar.rs").unwrap(); } "#, - ).file("bar/src/bar.rs.in", "pub fn gimme() -> i32 { 0 }") + ) + .file("bar/src/bar.rs.in", "pub fn gimme() -> i32 { 0 }") .build(); p.root().join("bar").move_into_the_past(); @@ -665,7 +707,8 @@ fn path_dep_build_cmd() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n", - ).run(); + ) + .run(); assert!(p.bin("foo").is_file()); @@ -685,7 +728,8 @@ fn path_dep_build_cmd() { [COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in \ [..]\n", - ).run(); + ) + .run(); p.process(&p.bin("foo")).with_stdout("1\n").run(); } @@ -708,13 +752,15 @@ fn dev_deps_no_rebuild_lib() { name = "foo" doctest = false "#, - ).file( + ) + .file( "src/lib.rs", r#" #[cfg(test)] #[allow(unused_extern_crates)] extern crate bar; #[cfg(not(test))] pub fn foo() { env!("FOO"); } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); p.cargo("build") @@ -723,7 +769,8 @@ fn dev_deps_no_rebuild_lib() { "[COMPILING] foo v0.5.0 ([CWD])\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) \ in [..]\n", - ).run(); + ) + .run(); p.cargo("test") .with_stderr( @@ -732,7 +779,8 @@ fn dev_deps_no_rebuild_lib() { [COMPILING] [..] v0.5.0 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); } @@ -751,7 +799,8 @@ fn custom_target_no_rebuild() { [workspace] members = ["a", "b"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.5.0")) .file("a/src/lib.rs", "") .file( @@ -764,7 +813,8 @@ fn custom_target_no_rebuild() { [dependencies] a = { path = "../a" } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .build(); p.cargo("build") .with_stderr( @@ -773,7 +823,8 @@ fn custom_target_no_rebuild() { [COMPILING] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); t!(fs::rename( p.root().join("target"), @@ -786,7 +837,8 @@ fn custom_target_no_rebuild() { [COMPILING] b v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -803,7 +855,8 @@ fn override_and_depend() { [dependencies] a2 = { path = "../a2" } "#, - ).file("a/a1/src/lib.rs", "") + ) + .file("a/a1/src/lib.rs", "") .file("a/a2/Cargo.toml", &basic_manifest("a2", "0.5.0")) .file("a/a2/src/lib.rs", "") .file( @@ -817,7 +870,8 @@ fn override_and_depend() { a1 = { path = "../a/a1" } a2 = { path = "../a/a2" } "#, - ).file("b/src/lib.rs", "") + ) + .file("b/src/lib.rs", "") .file("b/.cargo/config", r#"paths = ["../a"]"#) .build(); p.cargo("build") @@ -829,7 +883,8 @@ fn override_and_depend() { [COMPILING] b v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -840,7 +895,8 @@ fn missing_path_dependency() { .file( ".cargo/config", r#"paths = ["../whoa-this-does-not-exist"]"#, - ).build(); + ) + .build(); p.cargo("build") .with_status(101) .with_stderr( @@ -854,7 +910,8 @@ Caused by: Caused by: [..] (os error [..]) ", - ).run(); + ) + .run(); } #[test] @@ -875,7 +932,8 @@ fn invalid_path_dep_in_workspace_with_lockfile() { [dependencies] foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -887,7 +945,8 @@ fn invalid_path_dep_in_workspace_with_lockfile() { [dependencies] bar = "*" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); // Generate a lock file @@ -906,7 +965,8 @@ fn invalid_path_dep_in_workspace_with_lockfile() { [dependencies] bar = { path = "" } "#, - ).unwrap(); + ) + .unwrap(); // Make sure we get a nice error. In the past this actually stack // overflowed! @@ -919,7 +979,8 @@ location searched: [..] did you mean: foo required by package `foo v0.5.0 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -938,7 +999,8 @@ fn workspace_produces_rlib() { [dependencies] foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("foo/Cargo.toml", &basic_manifest("foo", "0.5.0")) .file("foo/src/lib.rs", "") .build(); @@ -963,7 +1025,8 @@ fn thin_lto_works() { [profile.release] lto = 'thin' "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build --release -v") @@ -973,5 +1036,6 @@ fn thin_lto_works() { [RUNNING] `rustc [..] -C lto=thin [..]` [FINISHED] [..] ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs index 8d93961b59b..bd58ebc6bd5 100644 --- a/tests/testsuite/plugins.rs +++ b/tests/testsuite/plugins.rs @@ -22,7 +22,8 @@ fn plugin_to_the_max() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/main.rs", r#" #![feature(plugin)] @@ -31,7 +32,8 @@ fn plugin_to_the_max() { fn main() { foo_lib::foo(); } "#, - ).file( + ) + .file( "src/foo_lib.rs", r#" #![feature(plugin)] @@ -39,7 +41,8 @@ fn plugin_to_the_max() { pub fn foo() {} "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file( @@ -57,7 +60,8 @@ fn plugin_to_the_max() { [dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] @@ -72,7 +76,8 @@ fn plugin_to_the_max() { println!("{}", baz::baz()); } "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") .file( @@ -87,7 +92,8 @@ fn plugin_to_the_max() { name = "baz" crate_type = ["dylib"] "#, - ).file("src/lib.rs", "pub fn baz() -> i32 { 1 }") + ) + .file("src/lib.rs", "pub fn baz() -> i32 { 1 }") .build(); foo.cargo("build").run(); @@ -114,7 +120,8 @@ fn plugin_with_dynamic_native_dependency() { name = "builder" crate-type = ["dylib"] "#, - ).file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") + ) + .file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") .build(); let foo = project() @@ -129,7 +136,8 @@ fn plugin_with_dynamic_native_dependency() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "src/main.rs", r#" #![feature(plugin)] @@ -137,7 +145,8 @@ fn plugin_with_dynamic_native_dependency() { fn main() {} "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -150,7 +159,8 @@ fn plugin_with_dynamic_native_dependency() { name = "bar" plugin = true "#, - ).file( + ) + .file( "bar/build.rs", r#" use std::env; @@ -173,7 +183,8 @@ fn plugin_with_dynamic_native_dependency() { println!("cargo:rustc-flags=-L {}", out_dir.display()); } "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] @@ -190,7 +201,8 @@ fn plugin_with_dynamic_native_dependency() { unsafe { foo() } } "#, - ).build(); + ) + .build(); build.cargo("build").run(); @@ -215,7 +227,8 @@ fn plugin_integration() { plugin = true doctest = false "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "") .file("tests/it_works.rs", "") .build(); @@ -237,7 +250,8 @@ fn doctest_a_plugin() { [dependencies] bar = { path = "bar" } "#, - ).file("src/lib.rs", "#[macro_use] extern crate bar;") + ) + .file("src/lib.rs", "#[macro_use] extern crate bar;") .file( "bar/Cargo.toml", r#" @@ -250,7 +264,8 @@ fn doctest_a_plugin() { name = "bar" plugin = true "#, - ).file("bar/src/lib.rs", "pub fn bar() {}") + ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); p.cargo("test -v").run(); @@ -273,7 +288,8 @@ fn native_plugin_dependency_with_custom_ar_linker() { [lib] plugin = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let bar = project() @@ -289,7 +305,8 @@ fn native_plugin_dependency_with_custom_ar_linker() { [dependencies.foo] path = "../foo" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", &format!( @@ -300,7 +317,8 @@ fn native_plugin_dependency_with_custom_ar_linker() { "#, target ), - ).build(); + ) + .build(); bar.cargo("build --verbose") .with_status(101) @@ -310,7 +328,8 @@ fn native_plugin_dependency_with_custom_ar_linker() { [RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]` [ERROR] [..]linker[..] ", - ).run(); + ) + .run(); } #[test] @@ -334,7 +353,8 @@ fn panic_abort_plugins() { [dependencies] bar = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -346,13 +366,15 @@ fn panic_abort_plugins() { [lib] plugin = true "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #![feature(rustc_private)] extern crate syntax; "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -379,7 +401,8 @@ fn shared_panic_abort_plugins() { bar = { path = "bar" } baz = { path = "baz" } "#, - ).file("src/lib.rs", "extern crate baz;") + ) + .file("src/lib.rs", "extern crate baz;") .file( "bar/Cargo.toml", r#" @@ -394,14 +417,16 @@ fn shared_panic_abort_plugins() { [dependencies] baz = { path = "../baz" } "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #![feature(rustc_private)] extern crate syntax; extern crate baz; "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("baz/src/lib.rs", "") .build(); diff --git a/tests/testsuite/proc_macro.rs b/tests/testsuite/proc_macro.rs index c42a996e8e8..acf14dee108 100644 --- a/tests/testsuite/proc_macro.rs +++ b/tests/testsuite/proc_macro.rs @@ -15,7 +15,8 @@ fn probe_cfg_before_crate_type_discovery() { [target.'cfg(not(stage300))'.dependencies.noop] path = "../noop" "#, - ).file( + ) + .file( "src/main.rs", r#" #[macro_use] @@ -26,7 +27,8 @@ fn probe_cfg_before_crate_type_discovery() { fn main() {} "#, - ).build(); + ) + .build(); let _noop = project() .at("noop") .file( @@ -40,7 +42,8 @@ fn probe_cfg_before_crate_type_discovery() { [lib] proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate proc_macro; @@ -51,7 +54,8 @@ fn probe_cfg_before_crate_type_discovery() { "".parse().unwrap() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -70,7 +74,8 @@ fn noop() { [dependencies.noop] path = "../noop" "#, - ).file( + ) + .file( "src/main.rs", r#" #[macro_use] @@ -81,7 +86,8 @@ fn noop() { fn main() {} "#, - ).build(); + ) + .build(); let _noop = project() .at("noop") .file( @@ -95,7 +101,8 @@ fn noop() { [lib] proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate proc_macro; @@ -106,7 +113,8 @@ fn noop() { "".parse().unwrap() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); p.cargo("build").run(); @@ -126,7 +134,8 @@ fn impl_and_derive() { [dependencies.transmogrify] path = "../transmogrify" "#, - ).file( + ) + .file( "src/main.rs", r#" #[macro_use] @@ -145,7 +154,8 @@ fn impl_and_derive() { println!("{:?}", x); } "#, - ).build(); + ) + .build(); let _transmogrify = project() .at("transmogrify") .file( @@ -159,7 +169,8 @@ fn impl_and_derive() { [lib] proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate proc_macro; @@ -183,7 +194,8 @@ fn impl_and_derive() { ".parse().unwrap() } "#, - ).build(); + ) + .build(); p.cargo("build").run(); p.cargo("run").with_stdout("X { success: true }").run(); @@ -208,7 +220,8 @@ fn plugin_and_proc_macro() { plugin = true proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] @@ -228,7 +241,8 @@ fn plugin_and_proc_macro() { input } "#, - ).build(); + ) + .build(); let msg = " lib.plugin and lib.proc-macro cannot both be true"; p.cargo("build") @@ -250,7 +264,8 @@ fn proc_macro_doctest() { [lib] proc-macro = true "#, - ).file( + ) + .file( "src/lib.rs", r#" #![crate_type = "proc-macro"] @@ -272,7 +287,8 @@ fn a() { assert!(true); } "#, - ).build(); + ) + .build(); foo.cargo("test") .with_stdout_contains("test a ... ok") diff --git a/tests/testsuite/profile_config.rs b/tests/testsuite/profile_config.rs index 53c63e41727..8a46cff70a5 100644 --- a/tests/testsuite/profile_config.rs +++ b/tests/testsuite/profile_config.rs @@ -11,14 +11,16 @@ fn profile_config_gated() { [profile.dev] debug = 1 "#, - ).build(); + ) + .build(); p.cargo("build -v") .with_stderr_contains( "\ [WARNING] profiles in config files require `-Z config-profile` command-line option ", - ).with_stderr_contains("[..]-C debuginfo=2[..]") + ) + .with_stderr_contains("[..]-C debuginfo=2[..]") .run(); } @@ -34,7 +36,8 @@ fn profile_config_validate_warnings() { name = "foo" version = "0.0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" @@ -53,7 +56,8 @@ fn profile_config_validate_warnings() { [profile.dev.overrides.bar] bad-key-bar = true "#, - ).build(); + ) + .build(); p.cargo("build -Z config-profile") .masquerade_as_nightly_cargo() @@ -67,7 +71,8 @@ fn profile_config_validate_warnings() { [COMPILING] foo [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -81,13 +86,15 @@ fn profile_config_error_paths() { [profile.dev] opt-level = 3 "#, - ).file( + ) + .file( paths::home().join(".cargo/config"), r#" [profile.dev] rpath = "foo" "#, - ).build(); + ) + .build(); p.cargo("build -Z config-profile") .masquerade_as_nightly_cargo() @@ -99,7 +106,8 @@ fn profile_config_error_paths() { Caused by: error in [..].cargo/config: `profile.dev.rpath` expected true/false, but found a string ", - ).run(); + ) + .run(); } #[test] @@ -114,14 +122,16 @@ fn profile_config_validate_errors() { name = "foo" version = "0.0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" [profile.dev.overrides.foo] panic = "abort" "#, - ).build(); + ) + .build(); p.cargo("build -Z config-profile") .masquerade_as_nightly_cargo() @@ -136,7 +146,8 @@ Caused by: Caused by: `panic` may not be specified in a profile override. ", - ).run(); + ) + .run(); } #[test] @@ -150,7 +161,8 @@ fn profile_config_syntax_errors() { [profile.dev] codegen-units = "foo" "#, - ).build(); + ) + .build(); p.cargo("build -Z config-profile") .masquerade_as_nightly_cargo() @@ -162,7 +174,8 @@ fn profile_config_syntax_errors() { Caused by: error in [..].cargo/config: `profile.dev.codegen-units` expected an integer, but found a string ", - ).run(); + ) + .run(); } #[test] @@ -180,7 +193,8 @@ fn profile_config_override_spec_multiple() { [dependencies] bar = { path = "bar" } "#, - ).file( + ) + .file( ".cargo/config", r#" [profile.dev.overrides.bar] @@ -189,7 +203,8 @@ fn profile_config_override_spec_multiple() { [profile.dev.overrides."bar:0.5.0"] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -199,7 +214,8 @@ fn profile_config_override_spec_multiple() { name = "bar" version = "0.5.0" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); // Unfortunately this doesn't tell you which file, hopefully it's not too @@ -211,7 +227,8 @@ fn profile_config_override_spec_multiple() { "\ [ERROR] multiple profile overrides in profile `dev` match package `bar v0.5.0 ([..])` found profile override specs: bar, bar:0.5.0", - ).run(); + ) + .run(); } #[test] @@ -234,7 +251,8 @@ fn profile_config_all_options() { panic = "abort" incremental = true "#, - ).build(); + ) + .build(); p.cargo("build --release -v -Z config-profile") .masquerade_as_nightly_cargo() @@ -251,7 +269,8 @@ fn profile_config_all_options() { -C rpath [..] [FINISHED] release [optimized + debuginfo] [..] ", - ).run(); + ) + .run(); } #[test] @@ -276,7 +295,8 @@ fn profile_config_override_precedence() { [profile.dev.overrides.bar] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "bar/Cargo.toml", r#" @@ -286,14 +306,16 @@ fn profile_config_override_precedence() { name = "bar" version = "0.0.1" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file( ".cargo/config", r#" [profile.dev.overrides.bar] opt-level = 2 "#, - ).build(); + ) + .build(); p.cargo("build -v -Z config-profile") .masquerade_as_nightly_cargo() @@ -304,7 +326,8 @@ fn profile_config_override_precedence() { [COMPILING] foo [..] [RUNNING] `rustc --crate-name foo [..]-C codegen-units=2 [..] [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -319,14 +342,16 @@ fn profile_config_no_warn_unknown_override() { name = "foo" version = "0.0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( ".cargo/config", r#" [profile.dev.overrides.bar] codegen-units = 4 "#, - ).build(); + ) + .build(); p.cargo("build -Z config-profile") .masquerade_as_nightly_cargo() @@ -345,13 +370,15 @@ fn profile_config_mixed_types() { [profile.dev] opt-level = 3 "#, - ).file( + ) + .file( paths::home().join(".cargo/config"), r#" [profile.dev] opt-level = 's' "#, - ).build(); + ) + .build(); p.cargo("build -v -Z config-profile") .masquerade_as_nightly_cargo() diff --git a/tests/testsuite/profile_overrides.rs b/tests/testsuite/profile_overrides.rs index 74e00ef4f2b..fde44a4a637 100644 --- a/tests/testsuite/profile_overrides.rs +++ b/tests/testsuite/profile_overrides.rs @@ -14,7 +14,8 @@ fn profile_override_gated() { [profile.dev.build-override] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -29,7 +30,8 @@ Caused by: consider adding `cargo-features = [\"profile-overrides\"]` to the manifest ", - ).run(); + ) + .run(); let p = project() .file( @@ -43,7 +45,8 @@ consider adding `cargo-features = [\"profile-overrides\"]` to the manifest [profile.dev.overrides."*"] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -58,7 +61,8 @@ Caused by: consider adding `cargo-features = [\"profile-overrides\"]` to the manifest ", - ).run(); + ) + .run(); } #[test] @@ -83,7 +87,8 @@ fn profile_override_basic() { [profile.dev.overrides.bar] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .build(); @@ -96,7 +101,8 @@ fn profile_override_basic() { [COMPILING] foo [..] [RUNNING] `rustc --crate-name foo [..] -C opt-level=1 [..]` [FINISHED] dev [optimized + debuginfo] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -123,7 +129,8 @@ fn profile_override_warnings() { [profile.dev.overrides."bar:1.2.3"] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .build(); @@ -159,7 +166,8 @@ fn profile_override_dev_release_only() { [profile.test.overrides.bar] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .build(); @@ -172,7 +180,8 @@ fn profile_override_dev_release_only() { Caused by: Profile overrides may only be specified for `dev` or `release` profile, not `test`. ", - ).run(); + ) + .run(); } #[test] @@ -212,7 +221,8 @@ fn profile_override_bad_settings() { "#, snippet ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .build(); @@ -248,10 +258,11 @@ fn profile_override_hierarchy() { [profile.dev.build-override] codegen-units = 4 - "#) - + "#, + ) // m1 - .file("m1/Cargo.toml", + .file( + "m1/Cargo.toml", r#" [package] name = "m1" @@ -260,12 +271,13 @@ fn profile_override_hierarchy() { [dependencies] m2 = { path = "../m2" } dep = { path = "../../dep" } - "#) + "#, + ) .file("m1/src/lib.rs", "extern crate m2; extern crate dep;") .file("m1/build.rs", "fn main() {}") - // m2 - .file("m2/Cargo.toml", + .file( + "m2/Cargo.toml", r#" [package] name = "m2" @@ -277,10 +289,13 @@ fn profile_override_hierarchy() { [build-dependencies] m3 = { path = "../m3" } dep = { path = "../../dep" } - "#) + "#, + ) .file("m2/src/lib.rs", "extern crate m3;") - .file("m2/build.rs", "extern crate m3; extern crate dep; fn main() {}") - + .file( + "m2/build.rs", + "extern crate m3; extern crate dep; fn main() {}", + ) // m3 .file("m3/Cargo.toml", &basic_lib_manifest("m3")) .file("m3/src/lib.rs", "") @@ -343,7 +358,8 @@ fn profile_override_spec_multiple() { [profile.dev.overrides."bar:0.5.0"] opt-level = 3 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file("bar/src/lib.rs", "") .build(); @@ -355,7 +371,8 @@ fn profile_override_spec_multiple() { "\ [ERROR] multiple profile overrides in profile `dev` match package `bar v0.5.0 ([..])` found profile override specs: bar, bar:0.5.0", - ).run(); + ) + .run(); } #[test] @@ -374,10 +391,11 @@ fn profile_override_spec() { [profile.dev.overrides."dep:2.0.0"] codegen-units = 2 - "#) - + "#, + ) // m1 - .file("m1/Cargo.toml", + .file( + "m1/Cargo.toml", r#" [package] name = "m1" @@ -385,11 +403,12 @@ fn profile_override_spec() { [dependencies] dep = { path = "../../dep1" } - "#) + "#, + ) .file("m1/src/lib.rs", "extern crate dep;") - // m2 - .file("m2/Cargo.toml", + .file( + "m2/Cargo.toml", r#" [package] name = "m2" @@ -397,9 +416,9 @@ fn profile_override_spec() { [dependencies] dep = {path = "../../dep2" } - "#) + "#, + ) .file("m2/src/lib.rs", "extern crate dep;") - .build(); project() diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 4406cc3da18..a1f3e6c30ba 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -38,7 +38,9 @@ fn all_target_project() -> Project { .file("examples/ex1.rs", "extern crate foo; fn main() {}") .file("tests/test1.rs", "extern crate foo;") .file("benches/bench1.rs", "extern crate foo;") - .file("build.rs", r#" + .file( + "build.rs", + r#" extern crate bdep; fn main() { eprintln!("foo custom build PROFILE={} DEBUG={} OPT_LEVEL={}", @@ -47,21 +49,23 @@ fn all_target_project() -> Project { std::env::var("OPT_LEVEL").unwrap(), ); } - "#) - + "#, + ) // bar package .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") - // bdep package - .file("bdep/Cargo.toml", r#" + .file( + "bdep/Cargo.toml", + r#" [package] name = "bdep" version = "0.0.1" [dependencies] bar = { path = "../bar" } - "#) + "#, + ) .file("bdep/src/lib.rs", "extern crate bar;") .build() } @@ -96,7 +100,8 @@ fn profile_selection_build() { [FRESH] foo [..] [FINISHED] dev [unoptimized + debuginfo] [..] ", - ).run(); + ) + .run(); } #[test] @@ -126,7 +131,8 @@ fn profile_selection_build_release() { [FRESH] foo [..] [FINISHED] release [optimized] [..] ", - ).run(); + ) + .run(); } #[test] @@ -187,7 +193,8 @@ fn profile_selection_build_all_targets() { [FRESH] foo [..] [FINISHED] dev [unoptimized + debuginfo] [..] ", - ).run(); + ) + .run(); } #[test] @@ -251,7 +258,8 @@ fn profile_selection_build_all_targets_release() { [FRESH] foo [..] [FINISHED] release [optimized] [..] ", - ).run(); + ) + .run(); } #[test] @@ -315,7 +323,8 @@ fn profile_selection_test() { [DOCTEST] foo [RUNNING] `rustdoc --test [..] ", - ).run(); + ) + .run(); } #[test] @@ -379,7 +388,8 @@ fn profile_selection_test_release() { [DOCTEST] foo [RUNNING] `rustdoc --test [..] ", - ).run(); + ) + .run(); } #[test] @@ -438,7 +448,8 @@ fn profile_selection_bench() { [RUNNING] `[..]/deps/foo-[..] --bench` [RUNNING] `[..]/deps/bench1-[..] --bench` ", - ).run(); + ) + .run(); } #[test] @@ -508,7 +519,8 @@ fn profile_selection_check_all_targets() { [FRESH] foo [..] [FINISHED] dev [unoptimized + debuginfo] [..] ", - ).run(); + ) + .run(); } #[test] @@ -554,7 +566,8 @@ fn profile_selection_check_all_targets_release() { [FRESH] foo [..] [FINISHED] release [optimized] [..] ", - ).run(); + ) + .run(); } #[test] @@ -616,7 +629,8 @@ fn profile_selection_check_all_targets_test() { [FRESH] foo [..] [FINISHED] dev [unoptimized + debuginfo] [..] ", - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/profiles.rs b/tests/testsuite/profiles.rs index 3bc78b615b8..a06a4975fe4 100644 --- a/tests/testsuite/profiles.rs +++ b/tests/testsuite/profiles.rs @@ -20,7 +20,8 @@ fn profile_overrides() { debug = false rpath = true "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") .with_stderr( @@ -36,7 +37,8 @@ fn profile_overrides() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -54,7 +56,8 @@ fn opt_level_override_0() { [profile.dev] opt-level = 0 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") .with_stderr( @@ -68,7 +71,8 @@ fn opt_level_override_0() { -L dependency=[CWD]/target/debug/deps` [FINISHED] [..] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -85,7 +89,8 @@ fn debug_override_1() { [profile.dev] debug = 1 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") .with_stderr( @@ -99,7 +104,8 @@ fn debug_override_1() { -L dependency=[CWD]/target/debug/deps` [FINISHED] [..] target(s) in [..] ", - ).run(); + ) + .run(); } fn check_opt_level_override(profile_level: &str, rustc_level: &str) { @@ -119,7 +125,8 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { "#, level = profile_level ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") .with_stderr(&format!( @@ -136,7 +143,8 @@ fn check_opt_level_override(profile_level: &str, rustc_level: &str) { [FINISHED] [..] target(s) in [..] ", level = rustc_level - )).run(); + )) + .run(); } #[test] @@ -175,7 +183,8 @@ fn top_level_overrides_deps() { [dependencies.foo] path = "foo" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -193,7 +202,8 @@ fn top_level_overrides_deps() { name = "foo" crate_type = ["dylib", "rlib"] "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build -v --release") .with_stderr(&format!( @@ -223,7 +233,8 @@ fn top_level_overrides_deps() { ", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX - )).run(); + )) + .run(); } #[test] @@ -243,7 +254,8 @@ fn profile_in_non_root_manifest_triggers_a_warning() { [profile.dev] debug = false "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -256,7 +268,8 @@ fn profile_in_non_root_manifest_triggers_a_warning() { [profile.dev] opt-level = 1 "#, - ).file("bar/src/main.rs", "fn main() {}") + ) + .file("bar/src/main.rs", "fn main() {}") .build(); p.cargo("build -v") @@ -269,7 +282,8 @@ workspace: [..] [COMPILING] bar v0.1.0 ([..]) [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -285,7 +299,8 @@ fn profile_in_virtual_manifest_works() { opt-level = 1 debug = false "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -295,7 +310,8 @@ fn profile_in_virtual_manifest_works() { authors = [] workspace = ".." "#, - ).file("bar/src/main.rs", "fn main() {}") + ) + .file("bar/src/main.rs", "fn main() {}") .build(); p.cargo("build -v") @@ -305,7 +321,8 @@ fn profile_in_virtual_manifest_works() { [COMPILING] bar v0.1.0 ([..]) [RUNNING] `rustc [..]` [FINISHED] dev [optimized] target(s) in [..]", - ).run(); + ) + .run(); } #[test] @@ -324,7 +341,8 @@ fn profile_panic_test_bench() { [profile.bench] panic = "abort" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") @@ -333,7 +351,8 @@ fn profile_panic_test_bench() { [WARNING] `panic` setting is ignored for `test` profile [WARNING] `panic` setting is ignored for `bench` profile ", - ).run(); + ) + .run(); } #[test] @@ -349,7 +368,8 @@ fn profile_doc_deprecated() { [profile.doc] opt-level = 0 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build") diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index a9b4aab568d..05bbdfb6788 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -2,10 +2,10 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::io::SeekFrom; -use flate2::read::GzDecoder; use crate::support::git::repo; use crate::support::paths; use crate::support::{basic_manifest, project, publish}; +use flate2::read::GzDecoder; use tar::Archive; #[test] @@ -23,7 +23,8 @@ fn simple() { license = "MIT" description = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --no-verify --index") @@ -37,7 +38,8 @@ See [..] [UPLOADING] foo v0.0.1 ([CWD]) ", reg = publish::registry_path().to_str().unwrap() - )).run(); + )) + .run(); let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap(); // Skip the metadata payload and the size of the tarball @@ -96,7 +98,8 @@ fn old_token_location() { license = "MIT" description = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --no-verify --index") @@ -110,7 +113,8 @@ See [..] [UPLOADING] foo v0.0.1 ([CWD]) ", reg = publish::registry_path().to_str().unwrap() - )).run(); + )) + .run(); let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap(); // Skip the metadata payload and the size of the tarball @@ -162,7 +166,8 @@ fn simple_with_host() { license = "MIT" description = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --no-verify --host") @@ -185,7 +190,8 @@ See [..] [UPLOADING] foo v0.0.1 ([CWD]) ", reg = publish::registry_path().to_str().unwrap() - )).run(); + )) + .run(); let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap(); // Skip the metadata payload and the size of the tarball @@ -237,7 +243,8 @@ fn simple_with_index_and_host() { license = "MIT" description = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --no-verify --index") @@ -262,7 +269,8 @@ See [..] [UPLOADING] foo v0.0.1 ([CWD]) ", reg = publish::registry_path().to_str().unwrap() - )).run(); + )) + .run(); let mut f = File::open(&publish::upload_path().join("api/v1/crates/new")).unwrap(); // Skip the metadata payload and the size of the tarball @@ -315,7 +323,8 @@ fn git_deps() { [dependencies.foo] git = "git://path/to/nowhere" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish -v --no-verify --index") @@ -330,7 +339,8 @@ specify a crates.io version as a dependency or pull it into this \ repository and specify it with a path and version\n\ (crate `foo` has repository path `git://path/to/nowhere`)\ ", - ).run(); + ) + .run(); } #[test] @@ -351,7 +361,8 @@ fn path_dependency_no_version() { [dependencies.bar] path = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); @@ -365,7 +376,8 @@ fn path_dependency_no_version() { [ERROR] all path dependencies must have a version specified when publishing. dependency `bar` does not specify a version ", - ).run(); + ) + .run(); } #[test] @@ -384,7 +396,8 @@ fn unpublishable_crate() { description = "foo" publish = false "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --index") @@ -395,7 +408,8 @@ fn unpublishable_crate() { [ERROR] some crates cannot be published. `foo` is marked as unpublishable ", - ).run(); + ) + .run(); } #[test] @@ -417,7 +431,8 @@ fn dont_publish_dirty() { homepage = "foo" repository = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --index") @@ -433,7 +448,8 @@ bar to proceed despite this, pass the `--allow-dirty` flag ", - ).run(); + ) + .run(); } #[test] @@ -456,7 +472,8 @@ fn publish_clean() { homepage = "foo" repository = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --index") @@ -484,7 +501,8 @@ fn publish_in_sub_repo() { homepage = "foo" repository = "foo" "#, - ).file("bar/src/main.rs", "fn main() {}") + ) + .file("bar/src/main.rs", "fn main() {}") .build(); p.cargo("publish") @@ -514,7 +532,8 @@ fn publish_when_ignored() { homepage = "foo" repository = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file(".gitignore", "baz") .build(); @@ -544,7 +563,8 @@ fn ignore_when_crate_ignored() { homepage = "foo" repository = "foo" "#, - ).nocommit_file("bar/src/main.rs", "fn main() {}"); + ) + .nocommit_file("bar/src/main.rs", "fn main() {}"); p.cargo("publish") .cwd(p.root().join("bar")) .arg("--index") @@ -572,7 +592,8 @@ fn new_crate_rejected() { homepage = "foo" repository = "foo" "#, - ).nocommit_file("src/main.rs", "fn main() {}"); + ) + .nocommit_file("src/main.rs", "fn main() {}"); p.cargo("publish --index") .arg(publish::registry().to_string()) .with_status(101) @@ -594,7 +615,8 @@ fn dry_run() { license = "MIT" description = "foo" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --dry-run --index") @@ -611,7 +633,8 @@ See [..] [UPLOADING] foo v0.0.1 ([CWD]) [WARNING] aborting upload due to dry run ", - ).run(); + ) + .run(); // Ensure the API request wasn't actually made assert!(!publish::upload_path().join("api/v1/crates/new").exists()); @@ -635,7 +658,8 @@ fn block_publish_feature_not_enabled() { "test" ] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --registry alternative -Zunstable-options") @@ -653,7 +677,8 @@ Caused by: consider adding `cargo-features = [\"alternative-registries\"]` to the manifest ", - ).run(); + ) + .run(); } #[test] @@ -676,7 +701,8 @@ fn registry_not_in_publish_list() { "test" ] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish") @@ -690,7 +716,8 @@ fn registry_not_in_publish_list() { [ERROR] some crates cannot be published. `foo` is marked as unpublishable ", - ).run(); + ) + .run(); } #[test] @@ -711,7 +738,8 @@ fn publish_empty_list() { description = "foo" publish = [] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --registry alternative -Zunstable-options") @@ -722,7 +750,8 @@ fn publish_empty_list() { [ERROR] some crates cannot be published. `foo` is marked as unpublishable ", - ).run(); + ) + .run(); } #[test] @@ -747,7 +776,8 @@ fn publish_allowed_registry() { homepage = "foo" publish = ["alternative"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --registry alternative -Zunstable-options") @@ -773,7 +803,8 @@ fn block_publish_no_registry() { description = "foo" publish = [] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish --registry alternative -Zunstable-options") @@ -784,5 +815,6 @@ fn block_publish_no_registry() { [ERROR] some crates cannot be published. `foo` is marked as unpublishable ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/read_manifest.rs b/tests/testsuite/read_manifest.rs index 82f9e201833..670da18f67c 100644 --- a/tests/testsuite/read_manifest.rs +++ b/tests/testsuite/read_manifest.rs @@ -70,7 +70,8 @@ fn cargo_read_manifest_path_to_cargo_toml_parent_relative() { .with_stderr( "[ERROR] the manifest-path must be \ a path to a Cargo.toml file", - ).run(); + ) + .run(); } #[test] @@ -87,7 +88,8 @@ fn cargo_read_manifest_path_to_cargo_toml_parent_absolute() { .with_stderr( "[ERROR] the manifest-path must be \ a path to a Cargo.toml file", - ).run(); + ) + .run(); } #[test] @@ -97,7 +99,5 @@ fn cargo_read_manifest_cwd() { .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) .build(); - p.cargo("read-manifest") - .with_json(MANIFEST_OUTPUT) - .run(); + p.cargo("read-manifest").with_json(MANIFEST_OUTPUT).run(); } diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 6f130221d91..2570f6fecbc 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -2,12 +2,12 @@ use std::fs::{self, File}; use std::io::prelude::*; use std::path::PathBuf; -use cargo::util::paths::remove_dir_all; use crate::support::cargo_process; use crate::support::git; use crate::support::paths::{self, CargoPathExt}; -use crate::support::registry::{self, Package, Dependency}; +use crate::support::registry::{self, Dependency, Package}; use crate::support::{basic_manifest, project}; +use cargo::util::paths::remove_dir_all; use url::Url; fn registry_path() -> PathBuf { @@ -31,7 +31,8 @@ fn simple() { [dependencies] bar = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").publish(); @@ -47,7 +48,8 @@ fn simple() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", reg = registry::registry_path().to_str().unwrap() - )).run(); + )) + .run(); p.cargo("clean").run(); @@ -59,7 +61,8 @@ fn simple() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -76,7 +79,8 @@ fn deps() { [dependencies] bar = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").publish(); @@ -95,7 +99,8 @@ fn deps() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", reg = registry::registry_path().to_str().unwrap() - )).run(); + )) + .run(); } #[test] @@ -114,7 +119,8 @@ fn nonexistent() { [dependencies] nonexistent = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build") @@ -126,7 +132,8 @@ error: no matching package named `nonexistent` found location searched: registry [..] required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -145,7 +152,8 @@ fn wrong_case() { [dependencies] Init = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); // #5678 to make this work @@ -159,7 +167,8 @@ location searched: registry [..] did you mean: init required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -178,7 +187,8 @@ fn mis_hyphenated() { [dependencies] mis_hyphenated = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); // #2775 to make this work @@ -192,7 +202,8 @@ location searched: registry [..] did you mean: mis-hyphenated required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -209,7 +220,8 @@ fn wrong_version() { [dependencies] foo = ">= 1.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("foo", "0.0.1").publish(); @@ -224,7 +236,8 @@ error: failed to select a version for the requirement `foo = \">= 1.0.0\"` location searched: `[..]` index (which is replacing registry `[..]`) required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); Package::new("foo", "0.0.3").publish(); Package::new("foo", "0.0.4").publish(); @@ -238,7 +251,8 @@ error: failed to select a version for the requirement `foo = \">= 1.0.0\"` location searched: `[..]` index (which is replacing registry `[..]`) required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -255,7 +269,8 @@ fn bad_cksum() { [dependencies] bad-cksum = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); let pkg = Package::new("bad-cksum", "0.0.1"); @@ -274,7 +289,8 @@ fn bad_cksum() { Caused by: failed to verify the checksum of `bad-cksum v0.0.1 (registry `[ROOT][..]`)` ", - ).run(); + ) + .run(); } #[test] @@ -293,7 +309,8 @@ fn update_registry() { [dependencies] notyet = ">= 0.0.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build") @@ -304,7 +321,8 @@ error: no matching package named `notyet` found location searched: registry `[..]` required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); Package::new("notyet", "0.0.1").publish(); @@ -319,7 +337,8 @@ required by package `foo v0.0.1 ([..])` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", reg = registry::registry_path().to_str().unwrap() - )).run(); + )) + .run(); } #[test] @@ -342,7 +361,8 @@ fn package_with_path_deps() { version = "0.0.1" path = "notyet" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("notyet/Cargo.toml", &basic_manifest("notyet", "0.0.1")) .file("notyet/src/lib.rs", "") .build(); @@ -358,7 +378,8 @@ Caused by: location searched: registry [..] required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); Package::new("notyet", "0.0.1").publish(); @@ -374,7 +395,8 @@ required by package `foo v0.0.1 ([..])` [COMPILING] foo v0.0.1 ([CWD][..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -391,7 +413,8 @@ fn lockfile_locks() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").publish(); @@ -406,7 +429,8 @@ fn lockfile_locks() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); p.root().move_into_the_past(); Package::new("bar", "0.0.2").publish(); @@ -428,7 +452,8 @@ fn lockfile_locks_transitively() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").publish(); @@ -446,7 +471,8 @@ fn lockfile_locks_transitively() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); p.root().move_into_the_past(); Package::new("baz", "0.0.2").publish(); @@ -469,7 +495,8 @@ fn yanks_are_not_used() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").publish(); @@ -492,7 +519,8 @@ fn yanks_are_not_used() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -509,7 +537,8 @@ fn relying_on_a_yank_is_bad() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").publish(); @@ -526,7 +555,8 @@ error: failed to select a version for the requirement `baz = \"= 0.0.2\"` required by package `bar v0.0.1` ... which is depended on by `foo [..]` ", - ).run(); + ) + .run(); } #[test] @@ -543,7 +573,8 @@ fn yanks_in_lockfiles_are_ok() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").publish(); @@ -564,7 +595,8 @@ error: no matching package named `bar` found location searched: registry [..] required by package `foo v0.0.1 ([..])` ", - ).run(); + ) + .run(); } #[test] @@ -581,7 +613,8 @@ fn update_with_lockfile_if_packages_missing() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.0.1").publish(); @@ -597,7 +630,8 @@ fn update_with_lockfile_if_packages_missing() { [DOWNLOADED] bar v0.0.1 (registry `[ROOT][..]`) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -614,7 +648,8 @@ fn update_lockfile() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); println!("0.0.1"); @@ -631,7 +666,8 @@ fn update_lockfile() { [UPDATING] `[..]` index [UPDATING] bar v0.0.1 -> v0.0.2 ", - ).run(); + ) + .run(); println!("0.0.2 build"); p.cargo("build") @@ -643,7 +679,8 @@ fn update_lockfile() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); println!("0.0.3 update"); p.cargo("update -p bar") @@ -652,7 +689,8 @@ fn update_lockfile() { [UPDATING] `[..]` index [UPDATING] bar v0.0.2 -> v0.0.3 ", - ).run(); + ) + .run(); println!("0.0.3 build"); p.cargo("build") @@ -664,7 +702,8 @@ fn update_lockfile() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); println!("new dependencies update"); Package::new("bar", "0.0.4").dep("spam", "0.2.5").publish(); @@ -676,7 +715,8 @@ fn update_lockfile() { [UPDATING] bar v0.0.3 -> v0.0.4 [ADDING] spam v0.2.5 ", - ).run(); + ) + .run(); println!("new dependencies update"); Package::new("bar", "0.0.5").publish(); @@ -687,7 +727,8 @@ fn update_lockfile() { [UPDATING] bar v0.0.4 -> v0.0.5 [REMOVING] spam v0.2.5 ", - ).run(); + ) + .run(); } #[test] @@ -704,7 +745,8 @@ fn update_offline() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("update -Zoffline") .masquerade_as_nightly_cargo() @@ -727,7 +769,8 @@ fn dev_dependency_not_used() { [dependencies] bar = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("baz", "0.0.1").publish(); @@ -743,7 +786,8 @@ fn dev_dependency_not_used() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -778,7 +822,8 @@ fn bad_license_file() { description = "bar" repository = "baz" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("publish -v --index") .arg(registry().to_string()) @@ -801,7 +846,8 @@ fn updating_a_dep() { [dependencies.a] path = "a" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "a/Cargo.toml", r#" @@ -813,7 +859,8 @@ fn updating_a_dep() { [dependencies] bar = "*" "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); Package::new("bar", "0.0.1").publish(); @@ -829,7 +876,8 @@ fn updating_a_dep() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); t!(t!(File::create(&p.root().join("a/Cargo.toml"))).write_all( br#" @@ -856,7 +904,8 @@ fn updating_a_dep() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -873,7 +922,8 @@ fn git_and_registry_dep() { [dependencies] a = "0.0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); let p = project() .file( @@ -893,7 +943,8 @@ fn git_and_registry_dep() { "#, b.url() ), - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("a", "0.0.1").publish(); @@ -911,7 +962,8 @@ fn git_and_registry_dep() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); p.root().move_into_the_past(); println!("second"); @@ -934,7 +986,8 @@ fn update_publish_then_update() { [dependencies] a = "0.1.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("a", "0.1.0").publish(); p.cargo("build").run(); @@ -961,7 +1014,8 @@ fn update_publish_then_update() { [dependencies] a = "0.1.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p2.cargo("build").run(); registry.rm_rf(); @@ -984,7 +1038,8 @@ fn update_publish_then_update() { [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -1001,7 +1056,8 @@ fn fetch_downloads() { [dependencies] a = "0.1.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("a", "0.1.0").publish(); @@ -1013,7 +1069,8 @@ fn fetch_downloads() { [DOWNLOADING] crates ... [DOWNLOADED] a v0.1.0 (registry [..]) ", - ).run(); + ) + .run(); } #[test] @@ -1030,7 +1087,8 @@ fn update_transitive_dependency() { [dependencies] a = "0.1.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("a", "0.1.0").dep("b", "*").publish(); @@ -1046,7 +1104,8 @@ fn update_transitive_dependency() { [UPDATING] `[..]` index [UPDATING] b v0.1.0 -> v0.1.1 ", - ).run(); + ) + .run(); p.cargo("build") .with_stderr( @@ -1058,7 +1117,8 @@ fn update_transitive_dependency() { [COMPILING] foo v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -1075,7 +1135,8 @@ fn update_backtracking_ok() { [dependencies] webdriver = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("webdriver", "0.1.0") @@ -1105,7 +1166,8 @@ fn update_backtracking_ok() { [UPDATING] hyper v0.6.5 -> v0.6.6 [UPDATING] openssl v0.1.0 -> v0.1.1 ", - ).run(); + ) + .run(); } #[test] @@ -1124,7 +1186,8 @@ fn update_multiple_packages() { b = "*" c = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("a", "0.1.0").publish(); @@ -1144,7 +1207,8 @@ fn update_multiple_packages() { [UPDATING] a v0.1.0 -> v0.1.1 [UPDATING] b v0.1.0 -> v0.1.1 ", - ).run(); + ) + .run(); p.cargo("update -pb -pc") .with_stderr( @@ -1152,7 +1216,8 @@ fn update_multiple_packages() { [UPDATING] `[..]` index [UPDATING] c v0.1.0 -> v0.1.1 ", - ).run(); + ) + .run(); p.cargo("build") .with_stderr_contains("[DOWNLOADED] a v0.1.1 (registry `[ROOT][..]`)") @@ -1180,7 +1245,8 @@ fn bundled_crate_in_registry() { bar = "0.1" baz = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("bar", "0.1.0").publish(); @@ -1197,7 +1263,8 @@ fn bundled_crate_in_registry() { [dependencies] bar = { path = "bar", version = "0.1.0" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "") .publish(); @@ -1219,7 +1286,8 @@ fn update_same_prefix_oh_my_how_was_this_a_bug() { [dependencies] foo = "0.1" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("foobar", "0.2.0").publish(); @@ -1245,7 +1313,8 @@ fn use_semver() { [dependencies] foo = "1.2.3-alpha.0" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("foo", "1.2.3-alpha.0").publish(); @@ -1271,7 +1340,8 @@ fn only_download_relevant() { [dependencies] baz = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("foo", "0.1.0").publish(); @@ -1288,7 +1358,8 @@ fn only_download_relevant() { [COMPILING] bar v0.5.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s ", - ).run(); + ) + .run(); } #[test] @@ -1305,7 +1376,8 @@ fn resolve_and_backtracking() { [dependencies] foo = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("foo", "0.1.1") @@ -1330,7 +1402,8 @@ fn upstream_warnings_on_extra_verbose() { [dependencies] foo = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("foo", "0.1.0") @@ -1356,7 +1429,8 @@ fn disallow_network() { [dependencies] foo = "*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build --frozen") @@ -1371,7 +1445,8 @@ Caused by: Caused by: attempting to make an HTTP request, but --frozen was specified ", - ).run(); + ) + .run(); } #[test] @@ -1388,7 +1463,8 @@ fn add_dep_dont_update_registry() { [dependencies] baz = { path = "baz" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "baz/Cargo.toml", r#" @@ -1400,7 +1476,8 @@ fn add_dep_dont_update_registry() { [dependencies] remote = "0.3" "#, - ).file("baz/src/lib.rs", "") + ) + .file("baz/src/lib.rs", "") .build(); Package::new("remote", "0.3.4").publish(); @@ -1426,7 +1503,8 @@ fn add_dep_dont_update_registry() { [COMPILING] bar v0.5.0 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -1443,7 +1521,8 @@ fn bump_version_dont_update_registry() { [dependencies] baz = { path = "baz" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "baz/Cargo.toml", r#" @@ -1455,7 +1534,8 @@ fn bump_version_dont_update_registry() { [dependencies] remote = "0.3" "#, - ).file("baz/src/lib.rs", "") + ) + .file("baz/src/lib.rs", "") .build(); Package::new("remote", "0.3.4").publish(); @@ -1480,7 +1560,8 @@ fn bump_version_dont_update_registry() { [COMPILING] bar v0.6.0 ([..]) [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -1497,7 +1578,8 @@ fn old_version_req() { [dependencies] remote = "0.2*" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("remote", "0.2.0").publish(); @@ -1532,7 +1614,8 @@ this warning. [COMPILING] [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -1549,7 +1632,8 @@ fn old_version_req_upstream() { [dependencies] remote = "0.3" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); Package::new("remote", "0.3.0") @@ -1564,7 +1648,8 @@ fn old_version_req_upstream() { [dependencies] bar = "0.2*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .publish(); Package::new("bar", "0.2.0").publish(); @@ -1588,7 +1673,8 @@ this warning. [COMPILING] [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -1607,7 +1693,8 @@ fn toml_lies_but_index_is_truth() { [dependencies] foo = "0.1.0" "#, - ).file("src/lib.rs", "extern crate foo;") + ) + .file("src/lib.rs", "extern crate foo;") .publish(); let p = project() @@ -1622,7 +1709,8 @@ fn toml_lies_but_index_is_truth() { [dependencies] bar = "0.3" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -v").run(); @@ -1634,7 +1722,8 @@ fn vv_prints_warnings() { .file( "src/lib.rs", "#![deny(warnings)] fn foo() {} // unused function", - ).publish(); + ) + .publish(); let p = project() .file( @@ -1648,7 +1737,8 @@ fn vv_prints_warnings() { [dependencies] foo = "0.2" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -vv").run(); @@ -1672,7 +1762,8 @@ fn bad_and_or_malicious_packages_rejected() { [dependencies] foo = "0.2" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build -vv") @@ -1690,7 +1781,8 @@ Caused by: Caused by: [..] contains a file at \"foo-0.1.0/src/lib.rs\" which isn't under \"foo-0.2.0\" ", - ).run(); + ) + .run(); } #[test] @@ -1710,7 +1802,8 @@ fn git_init_templatedir_missing() { [dependencies] foo = "0.2" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build").run(); @@ -1723,7 +1816,8 @@ fn git_init_templatedir_missing() { [init] templatedir = nowhere "#, - ).unwrap(); + ) + .unwrap(); p.cargo("build").run(); p.cargo("build").run(); @@ -1738,7 +1832,11 @@ fn rename_deps_and_features() { .file("src/lib.rs", "pub fn f2() {}") .publish(); Package::new("bar", "0.2.0") - .add_dep(Dependency::new("foo01", "0.1.0").package("foo").optional(true)) + .add_dep( + Dependency::new("foo01", "0.1.0") + .package("foo") + .optional(true), + ) .add_dep(Dependency::new("foo02", "0.2.0").package("foo")) .feature("another", &["foo01"]) .file( @@ -1769,7 +1867,8 @@ fn rename_deps_and_features() { [dependencies] bar = "0.2" "#, - ).file( + ) + .file( "src/main.rs", " extern crate bar; diff --git a/tests/testsuite/rename_deps.rs b/tests/testsuite/rename_deps.rs index cc75e5ee0ab..8a7f0e264b6 100644 --- a/tests/testsuite/rename_deps.rs +++ b/tests/testsuite/rename_deps.rs @@ -21,7 +21,8 @@ fn rename_dependency() { bar = { version = "0.1.0" } baz = { version = "0.2.0", package = "bar" } "#, - ).file("src/lib.rs", "extern crate bar; extern crate baz;") + ) + .file("src/lib.rs", "extern crate bar; extern crate baz;") .build(); p.cargo("build").run(); @@ -41,7 +42,8 @@ fn rename_with_different_names() { [dependencies] baz = { path = "bar", package = "bar" } "#, - ).file("src/lib.rs", "extern crate baz;") + ) + .file("src/lib.rs", "extern crate baz;") .file( "bar/Cargo.toml", r#" @@ -53,7 +55,8 @@ fn rename_with_different_names() { [lib] name = "random_name" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -97,7 +100,8 @@ fn lots_of_names() { "#, g.url() ), - ).file( + ) + .file( "src/lib.rs", " extern crate foo; @@ -114,7 +118,8 @@ fn lots_of_names() { foo4::foo4(); } ", - ).file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) + ) + .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "pub fn foo4() {}") .build(); @@ -140,10 +145,12 @@ fn rename_and_patch() { [patch.crates-io] foo = { path = "foo" } "#, - ).file( + ) + .file( "src/lib.rs", "extern crate bar; pub fn foo() { bar::foo(); }", - ).file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) + ) + .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "pub fn foo() {}") .build(); @@ -168,7 +175,8 @@ fn rename_twice() { [build-dependencies] foo = { version = "0.1" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") @@ -181,7 +189,8 @@ fn rename_twice() { 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 ", - ).run(); + ) + .run(); } #[test] @@ -200,7 +209,8 @@ fn rename_affects_fingerprint() { [dependencies] foo = { version = "0.1", package = "foo" } "#, - ).file("src/lib.rs", "extern crate foo;") + ) + .file("src/lib.rs", "extern crate foo;") .build(); p.cargo("build -v").run(); @@ -218,9 +228,7 @@ fn rename_affects_fingerprint() { "#, ); - p.cargo("build -v") - .with_status(101) - .run(); + p.cargo("build -v").with_status(101).run(); } #[test] @@ -240,13 +248,15 @@ fn can_run_doc_tests() { bar = { version = "0.1.0" } baz = { version = "0.2.0", package = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", " extern crate bar; extern crate baz; ", - ).build(); + ) + .build(); foo.cargo("test -v") .with_stderr_contains( @@ -258,7 +268,8 @@ fn can_run_doc_tests() { --extern baz=[CWD]/target/debug/deps/libbar-[..].rlib \ [..]` ", - ).run(); + ) + .run(); } #[test] @@ -279,7 +290,8 @@ fn features_still_work() { p1 = { path = 'a', features = ['b'] } p2 = { path = 'b' } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -291,7 +303,8 @@ fn features_still_work() { [dependencies] b = { version = "0.1", package = "foo", optional = true } "#, - ).file("a/src/lib.rs", "extern crate b;") + ) + .file("a/src/lib.rs", "extern crate b;") .file( "b/Cargo.toml", r#" @@ -306,7 +319,8 @@ fn features_still_work() { [features] default = ['b'] "#, - ).file("b/src/lib.rs", "extern crate b;") + ) + .file("b/src/lib.rs", "extern crate b;") .build(); p.cargo("build -v").run(); @@ -332,7 +346,8 @@ fn features_not_working() { [features] default = ['p1'] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("p1", "0.1.0")) .build(); @@ -345,7 +360,8 @@ error: failed to parse manifest at `[..]` Caused by: Feature `default` includes `p1` which is neither a dependency nor another feature ", - ).run(); + ) + .run(); } #[test] @@ -367,6 +383,5 @@ fn rename_with_dash() { .file("a/src/lib.rs", "") .build(); - p.cargo("build") - .run(); + p.cargo("build").run(); } diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 9818257d273..01c9bf9d823 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -1,4 +1,4 @@ -use crate::support::install::{cargo_home, assert_has_installed_exe, assert_has_not_installed_exe}; +use crate::support::install::{assert_has_installed_exe, assert_has_not_installed_exe, cargo_home}; use crate::support::is_nightly; use crate::support::project; @@ -21,7 +21,8 @@ fn build_bin_default_features() { name = "foo" required-features = ["a"] "#, - ).file( + ) + .file( "src/main.rs", r#" extern crate foo; @@ -33,7 +34,8 @@ fn build_bin_default_features() { fn main() {} "#, - ).file("src/lib.rs", r#"#[cfg(feature = "a")] pub fn foo() {}"#) + ) + .file("src/lib.rs", r#"#[cfg(feature = "a")] pub fn foo() {}"#) .build(); p.cargo("build").run(); @@ -51,7 +53,8 @@ fn build_bin_default_features() { error: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); } #[test] @@ -72,7 +75,8 @@ fn build_bin_arg_features() { name = "foo" required-features = ["a"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("build --features a").run(); @@ -106,7 +110,8 @@ fn build_bin_multiple_required_features() { path = "src/foo_2.rs" required-features = ["a"] "#, - ).file("src/foo_1.rs", "fn main() {}") + ) + .file("src/foo_1.rs", "fn main() {}") .file("src/foo_2.rs", "fn main() {}") .build(); @@ -142,7 +147,8 @@ fn build_example_default_features() { name = "foo" required-features = ["a"] "#, - ).file("examples/foo.rs", "fn main() {}") + ) + .file("examples/foo.rs", "fn main() {}") .build(); p.cargo("build --example=foo").run(); @@ -155,7 +161,8 @@ fn build_example_default_features() { error: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); } #[test] @@ -176,7 +183,8 @@ fn build_example_arg_features() { name = "foo" required-features = ["a"] "#, - ).file("examples/foo.rs", "fn main() {}") + ) + .file("examples/foo.rs", "fn main() {}") .build(); p.cargo("build --example=foo --features a").run(); @@ -208,7 +216,8 @@ fn build_example_multiple_required_features() { name = "foo_2" required-features = ["a"] "#, - ).file("examples/foo_1.rs", "fn main() {}") + ) + .file("examples/foo_1.rs", "fn main() {}") .file("examples/foo_2.rs", "fn main() {}") .build(); @@ -219,7 +228,8 @@ fn build_example_multiple_required_features() { error: target `foo_1` in package `foo` requires the features: `b`, `c` Consider enabling them by passing e.g. `--features=\"b c\"` ", - ).run(); + ) + .run(); p.cargo("build --example=foo_2").run(); assert!(!p.bin("examples/foo_1").is_file()); @@ -238,7 +248,8 @@ Consider enabling them by passing e.g. `--features=\"b c\"` error: target `foo_1` in package `foo` requires the features: `b`, `c` Consider enabling them by passing e.g. `--features=\"b c\"` ", - ).run(); + ) + .run(); p.cargo("build --example=foo_2 --no-default-features") .with_status(101) .with_stderr( @@ -246,7 +257,8 @@ Consider enabling them by passing e.g. `--features=\"b c\"` error: target `foo_2` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); } #[test] @@ -268,7 +280,8 @@ fn test_default_features() { name = "foo" required-features = ["a"] "#, - ).file("tests/foo.rs", "#[test]\nfn test() {}") + ) + .file("tests/foo.rs", "#[test]\nfn test() {}") .build(); p.cargo("test") @@ -277,7 +290,8 @@ fn test_default_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); p.cargo("test --no-default-features") @@ -290,7 +304,8 @@ fn test_default_features() { "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); p.cargo("test --test=foo --no-default-features") @@ -300,7 +315,8 @@ fn test_default_features() { error: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); } #[test] @@ -321,7 +337,8 @@ fn test_arg_features() { name = "foo" required-features = ["a"] "#, - ).file("tests/foo.rs", "#[test]\nfn test() {}") + ) + .file("tests/foo.rs", "#[test]\nfn test() {}") .build(); p.cargo("test --features a") @@ -330,7 +347,8 @@ fn test_arg_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); } @@ -359,7 +377,8 @@ fn test_multiple_required_features() { name = "foo_2" required-features = ["a"] "#, - ).file("tests/foo_1.rs", "#[test]\nfn test() {}") + ) + .file("tests/foo_1.rs", "#[test]\nfn test() {}") .file("tests/foo_2.rs", "#[test]\nfn test() {}") .build(); @@ -369,7 +388,8 @@ fn test_multiple_required_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo_2-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); p.cargo("test --features c") @@ -379,7 +399,8 @@ fn test_multiple_required_features() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo_1-[..][EXE] [RUNNING] target/debug/deps/foo_2-[..][EXE]", - ).with_stdout_contains_n("test test ... ok", 2) + ) + .with_stdout_contains_n("test test ... ok", 2) .run(); p.cargo("test --no-default-features") @@ -411,7 +432,8 @@ fn bench_default_features() { name = "foo" required-features = ["a"] "#, - ).file( + ) + .file( "benches/foo.rs", r#" #![feature(test)] @@ -420,7 +442,8 @@ fn bench_default_features() { #[bench] fn bench(_: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -428,7 +451,8 @@ fn bench_default_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); p.cargo("bench --no-default-features") @@ -441,7 +465,8 @@ fn bench_default_features() { "\ [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); p.cargo("bench --bench=foo --no-default-features") @@ -451,7 +476,8 @@ fn bench_default_features() { error: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); } #[test] @@ -476,7 +502,8 @@ fn bench_arg_features() { name = "foo" required-features = ["a"] "#, - ).file( + ) + .file( "benches/foo.rs", r#" #![feature(test)] @@ -485,7 +512,8 @@ fn bench_arg_features() { #[bench] fn bench(_: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench --features a") .with_stderr( @@ -493,7 +521,8 @@ fn bench_arg_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -526,7 +555,8 @@ fn bench_multiple_required_features() { name = "foo_2" required-features = ["a"] "#, - ).file( + ) + .file( "benches/foo_1.rs", r#" #![feature(test)] @@ -535,7 +565,8 @@ fn bench_multiple_required_features() { #[bench] fn bench(_: &mut test::Bencher) { }"#, - ).file( + ) + .file( "benches/foo_2.rs", r#" #![feature(test)] @@ -544,7 +575,8 @@ fn bench_multiple_required_features() { #[bench] fn bench(_: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); p.cargo("bench") .with_stderr( @@ -552,7 +584,8 @@ fn bench_multiple_required_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo_2-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); p.cargo("bench --features c") @@ -562,7 +595,8 @@ fn bench_multiple_required_features() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo_1-[..][EXE] [RUNNING] target/release/deps/foo_2-[..][EXE]", - ).with_stdout_contains_n("test bench ... bench: [..]", 2) + ) + .with_stdout_contains_n("test bench ... bench: [..]", 2) .run(); p.cargo("bench --no-default-features") @@ -594,7 +628,8 @@ fn install_default_features() { name = "foo" required-features = ["a"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("examples/foo.rs", "fn main() {}") .build(); @@ -610,7 +645,8 @@ fn install_default_features() { [FINISHED] release [optimized] target(s) in [..] [ERROR] no binaries are available for install using the selected features ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); p.cargo("install --path . --bin=foo").run(); @@ -629,7 +665,8 @@ Caused by: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); p.cargo("install --path . --example=foo").run(); @@ -648,7 +685,8 @@ Caused by: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); } @@ -670,7 +708,8 @@ fn install_arg_features() { name = "foo" required-features = ["a"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); p.cargo("install --features a").run(); @@ -705,7 +744,8 @@ fn install_multiple_required_features() { path = "src/foo_2.rs" required-features = ["a"] "#, - ).file("src/foo_1.rs", "fn main() {}") + ) + .file("src/foo_1.rs", "fn main() {}") .file("src/foo_2.rs", "fn main() {}") .build(); @@ -727,7 +767,8 @@ fn install_multiple_required_features() { [FINISHED] release [optimized] target(s) in [..] [ERROR] no binaries are available for install using the selected features ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo_1"); assert_has_not_installed_exe(cargo_home(), "foo_2"); } @@ -762,7 +803,8 @@ fn dep_feature_in_toml() { name = "foo" required-features = ["bar/a"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("examples/foo.rs", "fn main() {}") .file("tests/foo.rs", "#[test]\nfn test() {}") .file( @@ -774,7 +816,8 @@ fn dep_feature_in_toml() { #[bench] fn bench(_: &mut test::Bencher) { }"#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [project] @@ -785,7 +828,8 @@ fn dep_feature_in_toml() { [features] a = [] "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -805,7 +849,8 @@ fn dep_feature_in_toml() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); // bench @@ -817,7 +862,8 @@ fn dep_feature_in_toml() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -857,7 +903,8 @@ fn dep_feature_in_cmd_line() { name = "foo" required-features = ["bar/a"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("examples/foo.rs", "fn main() {}") .file("tests/foo.rs", "#[test]\nfn test() {}") .file( @@ -869,7 +916,8 @@ fn dep_feature_in_cmd_line() { #[bench] fn bench(_: &mut test::Bencher) { }"#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [project] @@ -880,7 +928,8 @@ fn dep_feature_in_cmd_line() { [features] a = [] "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -893,7 +942,8 @@ fn dep_feature_in_cmd_line() { error: target `foo` in package `foo` requires the features: `bar/a` Consider enabling them by passing e.g. `--features=\"bar/a\"` ", - ).run(); + ) + .run(); p.cargo("build --bin=foo --features bar/a").run(); assert!(p.bin("foo").is_file()); @@ -906,7 +956,8 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` error: target `foo` in package `foo` requires the features: `bar/a` Consider enabling them by passing e.g. `--features=\"bar/a\"` ", - ).run(); + ) + .run(); p.cargo("build --example=foo --features bar/a").run(); assert!(p.bin("examples/foo").is_file()); @@ -923,7 +974,8 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); // bench @@ -940,7 +992,8 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("test bench ... bench: [..]") + ) + .with_stdout_contains("test bench ... bench: [..]") .run(); } @@ -953,7 +1006,8 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` [FINISHED] release [optimized] target(s) in [..] [ERROR] no binaries are available for install using the selected features ", - ).run(); + ) + .run(); assert_has_not_installed_exe(cargo_home(), "foo"); p.cargo("install --features bar/a").run(); @@ -980,7 +1034,8 @@ fn test_skips_compiling_bin_with_missing_required_features() { path = "src/bin/foo.rs" required-features = ["a"] "#, - ).file("src/bin/foo.rs", "extern crate bar; fn main() {}") + ) + .file("src/bin/foo.rs", "extern crate bar; fn main() {}") .file("tests/foo.rs", "") .file("benches/foo.rs", "") .build(); @@ -991,7 +1046,8 @@ fn test_skips_compiling_bin_with_missing_required_features() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); p.cargo("test --features a -j 1") @@ -1000,7 +1056,8 @@ fn test_skips_compiling_bin_with_missing_required_features() { "\ [COMPILING] foo v0.0.1 ([CWD]) error[E0463]: can't find crate for `bar`", - ).run(); + ) + .run(); if is_nightly() { p.cargo("bench") @@ -1009,7 +1066,8 @@ error[E0463]: can't find crate for `bar`", [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); p.cargo("bench --features a -j 1") @@ -1018,7 +1076,8 @@ error[E0463]: can't find crate for `bar`", "\ [COMPILING] foo v0.0.1 ([CWD]) error[E0463]: can't find crate for `bar`", - ).run(); + ) + .run(); } } @@ -1041,7 +1100,8 @@ fn run_default() { name = "foo" required-features = ["a"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/main.rs", "extern crate foo; fn main() {}") .build(); @@ -1052,7 +1112,8 @@ fn run_default() { error: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` ", - ).run(); + ) + .run(); p.cargo("run --features a").run(); } @@ -1083,7 +1144,8 @@ fn run_default_multiple_required_features() { path = "src/foo2.rs" required-features = ["b"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/foo1.rs", "extern crate foo; fn main() {}") .file("src/foo2.rs", "extern crate foo; fn main() {}") .build(); @@ -1094,5 +1156,6 @@ fn run_default_multiple_required_features() { "\ error: `cargo run` requires that a package only have one executable; \ use the `--bin` option to specify which one to run\navailable binaries: foo1, foo2", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/resolve.rs b/tests/testsuite/resolve.rs index bec2d6f358f..74211f6581f 100644 --- a/tests/testsuite/resolve.rs +++ b/tests/testsuite/resolve.rs @@ -1088,23 +1088,23 @@ fn incomplete_information_skiping_3() { // minimized bug found in: // https://github.com/rust-lang/cargo/commit/003c29b0c71e5ea28fbe8e72c148c755c9f3f8d9 let input = vec![ - pkg!{("to_yank", "3.0.3")}, - pkg!{("to_yank", "3.3.0")}, - pkg!{("to_yank", "3.3.1")}, - pkg!{("a", "3.3.0") => [ + pkg! {("to_yank", "3.0.3")}, + pkg! {("to_yank", "3.3.0")}, + pkg! {("to_yank", "3.3.1")}, + pkg! {("a", "3.3.0") => [ dep_req("to_yank", "=3.0.3"), ] }, - pkg!{("a", "3.3.2") => [ + pkg! {("a", "3.3.2") => [ dep_req("to_yank", "<=3.3.0"), ] }, - pkg!{("b", "0.1.3") => [ + pkg! {("b", "0.1.3") => [ dep_req("a", "=3.3.0"), ] }, - pkg!{("b", "2.0.2") => [ + pkg! {("b", "2.0.2") => [ dep_req("to_yank", "3.3.0"), dep("a"), ] }, - pkg!{("b", "2.3.3") => [ + pkg! {("b", "2.3.3") => [ dep_req("to_yank", "3.3.0"), dep_req("a", "=3.3.0"), ] }, diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index 968734b15f1..1c42512285e 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -1,6 +1,6 @@ -use cargo::util::paths::dylib_path_envvar; use crate::support; use crate::support::{basic_bin_manifest, basic_lib_manifest, project, Project}; +use cargo::util::paths::dylib_path_envvar; #[test] fn simple() { @@ -14,7 +14,8 @@ fn simple() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/foo[EXE]`", - ).with_stdout("hello") + ) + .with_stdout("hello") .run(); assert!(p.bin("foo").is_file()); } @@ -51,7 +52,8 @@ fn quiet_and_verbose_config() { [term] verbose = true "#, - ).file("src/main.rs", r#"fn main() { println!("hello"); }"#) + ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); p.cargo("run -q").run(); @@ -68,7 +70,8 @@ fn simple_with_args() { assert_eq!(std::env::args().nth(2).unwrap(), "world"); } "#, - ).build(); + ) + .build(); p.cargo("run hello world").run(); } @@ -126,7 +129,8 @@ fn no_main_file() { .with_stderr( "[ERROR] a bin target must be available \ for `cargo run`\n", - ).run(); + ) + .run(); } #[test] @@ -144,7 +148,8 @@ fn too_many_bins() { "[ERROR] `cargo run` requires that a package only \ have one executable; use the `--bin` option \ to specify which one to run\navailable binaries: [..]\n", - ).run(); + ) + .run(); // Using [..] here because the order is not stable p.cargo("run") @@ -155,7 +160,8 @@ fn too_many_bins() { Use the `--bin` option to specify a binary, or (on \ nightly) the `default-run` manifest key.\ \navailable binaries: [..]\n", - ).run(); + ) + .run(); } #[test] @@ -169,14 +175,16 @@ fn specify_name() { extern crate foo; fn main() { println!("hello a.rs"); } "#, - ).file( + ) + .file( "src/bin/b.rs", r#" #[allow(unused_extern_crates)] extern crate foo; fn main() { println!("hello b.rs"); } "#, - ).build(); + ) + .build(); p.cargo("run --bin a -v") .with_stderr( @@ -186,7 +194,8 @@ fn specify_name() { [RUNNING] `rustc [..] src/bin/a.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/a[EXE]`", - ).with_stdout("hello a.rs") + ) + .with_stdout("hello a.rs") .run(); p.cargo("run --bin b -v") @@ -196,7 +205,8 @@ fn specify_name() { [RUNNING] `rustc [..] src/bin/b.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/b[EXE]`", - ).with_stdout("hello b.rs") + ) + .with_stdout("hello b.rs") .run(); } @@ -214,7 +224,8 @@ fn specify_default_run() { authors = [] default-run = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/bin/a.rs", r#"fn main() { println!("hello A"); }"#) .file("src/bin/b.rs", r#"fn main() { println!("hello B"); }"#) .build(); @@ -247,7 +258,8 @@ fn bogus_default_run() { authors = [] default-run = "b" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("src/bin/a.rs", r#"fn main() { println!("hello A"); }"#) .build(); @@ -270,7 +282,8 @@ fn default_run_unstable() { authors = [] default-run = "a" "#, - ).file("src/bin/a.rs", r#"fn main() { println!("hello A"); }"#) + ) + .file("src/bin/a.rs", r#"fn main() { println!("hello A"); }"#) .build(); p.cargo("run") @@ -288,7 +301,8 @@ this Cargo does not support nightly features, but if you switch to nightly channel you can add `cargo-features = ["default-run"]` to enable this feature "#, - ).run(); + ) + .run(); p.cargo("run") .masquerade_as_nightly_cargo() @@ -304,7 +318,8 @@ Caused by: consider adding `cargo-features = ["default-run"]` to the manifest "#, - ).run(); + ) + .run(); } #[test] @@ -321,7 +336,8 @@ fn run_example() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/examples/a[EXE]`", - ).with_stdout("example") + ) + .with_stdout("example") .run(); } @@ -339,7 +355,8 @@ fn run_library_example() { name = "bar" crate_type = ["lib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/bar.rs", "fn foo() {}") .build(); @@ -405,13 +422,15 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option) rust_edition = rust_edition, autoexamples = autoexamples ), - ).file("examples/a.rs", r#"fn main() { println!("example"); }"#) + ) + .file("examples/a.rs", r#"fn main() { println!("example"); }"#) .file( "examples/do_magic.rs", r#" fn main() { println!("magic example"); } "#, - ).build() + ) + .build() } #[test] @@ -442,7 +461,8 @@ For more information on this warning you can consult https://github.com/rust-lang/cargo/issues/5330 error: no example target named `a` ", - ).run(); + ) + .run(); } #[test] @@ -458,7 +478,8 @@ fn run_example_autodiscover_2015_with_autoexamples_enabled() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/examples/a[EXE]`", - ).with_stdout("example") + ) + .with_stdout("example") .run(); } @@ -488,7 +509,8 @@ fn run_example_autodiscover_2018() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/examples/a[EXE]`", - ).with_stdout("example") + ) + .with_stdout("example") .run(); } @@ -502,7 +524,7 @@ fn autobins_disables() { name = "foo" version = "0.0.1" autobins = false - "# + "#, ) .file("src/lib.rs", "pub mod bin;") .file("src/bin/mod.rs", "// empty") @@ -526,7 +548,8 @@ fn run_bins() { .with_status(1) .with_stderr_contains( "error: Found argument '--bins' which wasn't expected, or isn't valid in this context", - ).run(); + ) + .run(); } #[test] @@ -539,7 +562,8 @@ fn run_with_filename() { extern crate foo; fn main() { println!("hello a.rs"); } "#, - ).file("examples/a.rs", r#"fn main() { println!("example"); }"#) + ) + .file("examples/a.rs", r#"fn main() { println!("example"); }"#) .build(); p.cargo("run --bin bin.rs") @@ -554,7 +578,8 @@ fn run_with_filename() { [ERROR] no bin target named `a.rs` Did you mean `a`?", - ).run(); + ) + .run(); p.cargo("run --example example.rs") .with_status(101) @@ -568,7 +593,8 @@ Did you mean `a`?", [ERROR] no example target named `a.rs` Did you mean `a`?", - ).run(); + ) + .run(); } #[test] @@ -584,7 +610,8 @@ fn either_name_or_example() { "[ERROR] `cargo run` can run at most one \ executable, but multiple were \ specified", - ).run(); + ) + .run(); } #[test] @@ -594,7 +621,8 @@ fn one_bin_multiple_examples() { .file( "src/bin/main.rs", r#"fn main() { println!("hello main.rs"); }"#, - ).file("examples/a.rs", r#"fn main() { println!("hello a.rs"); }"#) + ) + .file("examples/a.rs", r#"fn main() { println!("hello a.rs"); }"#) .file("examples/b.rs", r#"fn main() { println!("hello b.rs"); }"#) .build(); @@ -604,7 +632,8 @@ fn one_bin_multiple_examples() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/main[EXE]`", - ).with_stdout("hello main.rs") + ) + .with_stdout("hello main.rs") .run(); } @@ -623,7 +652,8 @@ fn example_with_release_flag() { version = "*" path = "bar" "#, - ).file( + ) + .file( "examples/a.rs", r#" extern crate bar; @@ -637,7 +667,8 @@ fn example_with_release_flag() { bar::baz(); } "#, - ).file("bar/Cargo.toml", &basic_lib_manifest("bar")) + ) + .file("bar/Cargo.toml", &basic_lib_manifest("bar")) .file( "bar/src/bar.rs", r#" @@ -649,7 +680,8 @@ fn example_with_release_flag() { } } "#, - ).build(); + ) + .build(); p.cargo("run -v --release --example a") .with_stderr( @@ -672,11 +704,13 @@ fn example_with_release_flag() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] `target/release/examples/a[EXE]` ", - ).with_stdout( + ) + .with_stdout( "\ fast1 fast2", - ).run(); + ) + .run(); p.cargo("run -v --example a") .with_stderr( @@ -699,11 +733,13 @@ fast2", [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `target/debug/examples/a[EXE]` ", - ).with_stdout( + ) + .with_stdout( "\ slow1 slow2", - ).run(); + ) + .run(); } #[test] @@ -720,10 +756,12 @@ fn run_dylib_dep() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "src/main.rs", r#"extern crate bar; fn main() { bar::bar(); }"#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -735,7 +773,8 @@ fn run_dylib_dep() { name = "bar" crate-type = ["dylib"] "#, - ).file("bar/src/lib.rs", "pub fn bar() {}") + ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); p.cargo("run hello world").run(); @@ -749,7 +788,8 @@ fn release_works() { r#" fn main() { if cfg!(debug_assertions) { panic!() } } "#, - ).build(); + ) + .build(); p.cargo("run --release") .with_stderr( @@ -758,7 +798,8 @@ fn release_works() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] `target/release/foo[EXE]` ", - ).run(); + ) + .run(); assert!(p.release_bin("foo").is_file()); } @@ -776,7 +817,8 @@ fn run_bin_different_name() { [[bin]] name = "bar" "#, - ).file("src/bar.rs", "fn main() {}") + ) + .file("src/bar.rs", "fn main() {}") .build(); p.cargo("run").run(); @@ -796,7 +838,8 @@ fn dashes_are_forwarded() { assert_eq!(s[4], "b"); } "#, - ).build(); + ) + .build(); p.cargo("run -- -- a -- b").run(); } @@ -816,7 +859,8 @@ fn run_from_executable_folder() { "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n\ [RUNNING] `./foo[EXE]`", - ).with_stdout("hello") + ) + .with_stdout("hello") .run(); } @@ -842,7 +886,8 @@ fn run_with_library_paths() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", &format!( r##" @@ -854,7 +899,8 @@ fn run_with_library_paths() { dir1.display(), dir2.display() ), - ).file( + ) + .file( "src/main.rs", &format!( r##" @@ -869,7 +915,8 @@ fn run_with_library_paths() { dir1.display(), dir2.display() ), - ).build(); + ) + .build(); p.cargo("run").run(); } @@ -897,7 +944,8 @@ fn library_paths_sorted_alphabetically() { authors = [] build = "build.rs" "#, - ).file( + ) + .file( "build.rs", &format!( r##" @@ -911,7 +959,8 @@ fn library_paths_sorted_alphabetically() { dir2.display(), dir3.display() ), - ).file( + ) + .file( "src/main.rs", &format!( r##" @@ -926,7 +975,8 @@ fn library_paths_sorted_alphabetically() { "##, dylib_path_envvar() ), - ).build(); + ) + .build(); p.cargo("run").run(); } @@ -966,7 +1016,8 @@ fn run_multiple_packages() { [[bin]] name = "foo" "#, - ).file("foo/src/foo.rs", "fn main() { println!(\"foo\"); }") + ) + .file("foo/src/foo.rs", "fn main() { println!(\"foo\"); }") .file("foo/d1/Cargo.toml", &basic_bin_manifest("d1")) .file("foo/d1/src/lib.rs", "") .file("foo/d1/src/main.rs", "fn main() { println!(\"d1\"); }") @@ -1017,7 +1068,8 @@ fn explicit_bin_with_args() { assert_eq!(std::env::args().nth(2).unwrap(), "world"); } "#, - ).build(); + ) + .build(); p.cargo("run --bin foo hello world").run(); } @@ -1031,7 +1083,8 @@ fn run_workspace() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_bin_manifest("a")) + ) + .file("a/Cargo.toml", &basic_bin_manifest("a")) .file("a/src/main.rs", r#"fn main() {println!("run-a");}"#) .file("b/Cargo.toml", &basic_bin_manifest("b")) .file("b/src/main.rs", r#"fn main() {println!("run-b");}"#) @@ -1043,7 +1096,8 @@ fn run_workspace() { "\ [ERROR] `cargo run` requires that a package only have one executable[..] available binaries: a, b", - ).run(); + ) + .run(); p.cargo("run --bin a") .with_status(0) .with_stdout("run-a") @@ -1059,7 +1113,8 @@ fn default_run_workspace() { [workspace] members = ["a", "b"] "#, - ).file( + ) + .file( "a/Cargo.toml", r#" cargo-features = ["default-run"] @@ -1069,7 +1124,8 @@ fn default_run_workspace() { version = "0.0.1" default-run = "a" "#, - ).file("a/src/main.rs", r#"fn main() {println!("run-a");}"#) + ) + .file("a/src/main.rs", r#"fn main() {println!("run-a");}"#) .file("b/Cargo.toml", &basic_bin_manifest("b")) .file("b/src/main.rs", r#"fn main() {println!("run-b");}"#) .build(); diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index dbdf8516e59..5df915e5e2c 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -22,7 +22,8 @@ fn build_lib_for_foo() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -44,7 +45,8 @@ fn lib() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -74,7 +76,8 @@ fn build_main_and_allow_unstable_options() { ", name = "foo", version = "0.0.1" - )).run(); + )) + .run(); } #[test] @@ -148,7 +151,8 @@ fn build_with_args_to_one_of_multiple_tests() { -C debug-assertions [..]--test[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -165,7 +169,8 @@ fn build_foo_with_bar_dependency() { [dependencies.bar] path = "../bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") .build(); let _bar = project() .at("bar") @@ -182,7 +187,8 @@ fn build_foo_with_bar_dependency() { [RUNNING] `[..] -C debuginfo=2 -C debug-assertions [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -199,7 +205,8 @@ fn build_only_bar_dependency() { [dependencies.bar] path = "../bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") .build(); let _bar = project() .at("bar") @@ -214,7 +221,8 @@ fn build_only_bar_dependency() { [RUNNING] `rustc --crate-name bar [..] --color never --crate-type lib [..] -C debug-assertions [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -222,17 +230,24 @@ fn targets_selected_default() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("rustc -v") // bin - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ - --emit=dep-info,link[..]") + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ + --emit=dep-info,link[..]", + ) // bench - .with_stderr_does_not_contain("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C opt-level=3 --test [..]") + .with_stderr_does_not_contain( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C opt-level=3 --test [..]", + ) // unit test - .with_stderr_does_not_contain("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C debuginfo=2 --test [..]").run(); + .with_stderr_does_not_contain( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C debuginfo=2 --test [..]", + ) + .run(); } #[test] @@ -240,13 +255,18 @@ fn targets_selected_all() { let p = project().file("src/main.rs", "fn main() {}").build(); p.cargo("rustc -v --all-targets") // bin - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ - --emit=dep-info,link[..]") + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --crate-type bin \ + --emit=dep-info,link[..]", + ) // unit test - .with_stderr_contains("\ - [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ - -C debuginfo=2 --test [..]").run(); + .with_stderr_contains( + "\ + [RUNNING] `rustc --crate-name foo src/main.rs --color never --emit=dep-info,link \ + -C debuginfo=2 --test [..]", + ) + .run(); } #[test] @@ -266,7 +286,8 @@ fn fail_with_multiple_packages() { [dependencies.baz] path = "../baz" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .build(); let _bar = project() @@ -279,7 +300,8 @@ fn fail_with_multiple_packages() { if cfg!(flag = "1") { println!("Yeah from bar!"); } } "#, - ).build(); + ) + .build(); let _baz = project() .at("baz") @@ -291,7 +313,8 @@ fn fail_with_multiple_packages() { if cfg!(flag = "1") { println!("Yeah from baz!"); } } "#, - ).build(); + ) + .build(); foo.cargo("rustc -v -p bar -p baz") .with_status(1) @@ -300,7 +323,8 @@ fn fail_with_multiple_packages() { error: The argument '--package ' was provided more than once, \ but cannot be used multiple times ", - ).run(); + ) + .run(); } #[test] @@ -317,7 +341,8 @@ fn rustc_with_other_profile() { [dev-dependencies] a = { path = "a" } "#, - ).file( + ) + .file( "src/main.rs", r#" #[cfg(test)] extern crate a; @@ -325,7 +350,8 @@ fn rustc_with_other_profile() { #[test] fn foo() {} "#, - ).file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) .file("a/src/lib.rs", "") .build(); @@ -347,7 +373,8 @@ fn rustc_fingerprint() { [RUNNING] `rustc [..]-C debug-assertions [..] [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("rustc -v -- -C debug-assertions") .with_stderr( @@ -355,7 +382,8 @@ fn rustc_fingerprint() { [FRESH] foo [..] [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("rustc -v") .with_stderr_does_not_contain("-C debug-assertions") @@ -365,7 +393,8 @@ fn rustc_fingerprint() { [RUNNING] `rustc [..] [FINISHED] [..] ", - ).run(); + ) + .run(); p.cargo("rustc -v") .with_stderr( @@ -373,7 +402,8 @@ fn rustc_fingerprint() { [FRESH] foo [..] [FINISHED] [..] ", - ).run(); + ) + .run(); } #[test] @@ -387,21 +417,25 @@ fn rustc_test_with_implicit_bin() { fn f() { compile_fail!("Foo shouldn't be set."); } fn main() {} "#, - ).file( + ) + .file( "tests/test1.rs", r#" #[cfg(not(foo))] fn f() { compile_fail!("Foo should be set."); } "#, - ).build(); + ) + .build(); p.cargo("rustc --test test1 -v -- --cfg foo") .with_stderr_contains( "\ [RUNNING] `rustc --crate-name test1 tests/test1.rs [..] --cfg foo [..] ", - ).with_stderr_contains( + ) + .with_stderr_contains( "\ [RUNNING] `rustc --crate-name foo src/main.rs [..] ", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/rustc_info_cache.rs b/tests/testsuite/rustc_info_cache.rs index 882c3cb36a7..257aea57a9d 100644 --- a/tests/testsuite/rustc_info_cache.rs +++ b/tests/testsuite/rustc_info_cache.rs @@ -1,6 +1,6 @@ -use std::env; use crate::support::paths::CargoPathExt; use crate::support::{basic_manifest, project}; +use std::env; #[test] fn rustc_info_cache() { @@ -53,7 +53,8 @@ fn rustc_info_cache() { std::process::exit(cmd.status().unwrap().code().unwrap()); } "#, - ).build(); + ) + .build(); p.cargo("build").run(); p.root() diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index 1ad277c295a..405ba6526c9 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -13,7 +13,8 @@ fn rustdoc_simple() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -30,7 +31,8 @@ fn rustdoc_args() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -47,7 +49,8 @@ fn rustdoc_foo_with_bar_dependency() { [dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "extern crate bar; pub fn foo() {}") + ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .build(); let _bar = project() .at("bar") @@ -68,7 +71,8 @@ fn rustdoc_foo_with_bar_dependency() { --extern [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -85,7 +89,8 @@ fn rustdoc_only_bar_dependency() { [dependencies.bar] path = "../bar" "#, - ).file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") + ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") .build(); let _bar = project() .at("bar") @@ -103,7 +108,8 @@ fn rustdoc_only_bar_dependency() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -123,7 +129,8 @@ fn rustdoc_same_name_documents_lib() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -140,7 +147,8 @@ fn features() { [features] quux = [] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("rustdoc --verbose --features quux") @@ -149,11 +157,7 @@ fn features() { } #[test] -#[cfg(all( - target_arch = "x86_64", - target_os = "linux", - target_env = "gnu" -))] +#[cfg(all(target_arch = "x86_64", target_os = "linux", target_env = "gnu"))] fn rustdoc_target() { let p = project().file("src/lib.rs", "").build(); @@ -167,5 +171,6 @@ fn rustdoc_target() { -L dependency=[CWD]/target/x86_64-unknown-linux-gnu/debug/deps \ -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]", - ).run(); + ) + .run(); } diff --git a/tests/testsuite/rustdocflags.rs b/tests/testsuite/rustdocflags.rs index ad9546be3dc..11b88f75571 100644 --- a/tests/testsuite/rustdocflags.rs +++ b/tests/testsuite/rustdocflags.rs @@ -20,7 +20,8 @@ fn parses_config() { [build] rustdocflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); p.cargo("doc -v") .with_stderr_contains("[RUNNING] `rustdoc [..] --cfg foo[..]`") @@ -53,7 +54,8 @@ fn rerun() { [DOCUMENTING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -66,7 +68,8 @@ fn rustdocflags_passed_to_rustdoc_through_cargo_test() { //! assert!(cfg!(do_not_choke)); //! ``` "#, - ).build(); + ) + .build(); p.cargo("test --doc") .env("RUSTDOCFLAGS", "--cfg do_not_choke") diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 08c96b54d58..796e36be805 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -17,7 +17,8 @@ fn env_rustflags_normal_source() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); // Use RUSTFLAGS to pass an argument that will generate an error p.cargo("build --lib") @@ -56,7 +57,8 @@ fn env_rustflags_build_script() { version = "0.0.1" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -64,7 +66,8 @@ fn env_rustflags_build_script() { #[cfg(not(foo))] fn main() { } "#, - ).build(); + ) + .build(); p.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); } @@ -86,7 +89,8 @@ fn env_rustflags_build_script_dep() { [build-dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .build(); let _bar = project() @@ -99,7 +103,8 @@ fn env_rustflags_build_script_dep() { #[cfg(not(foo))] fn bar() { } "#, - ).build(); + ) + .build(); foo.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); } @@ -121,14 +126,16 @@ fn env_rustflags_plugin() { name = "foo" plugin = true "#, - ).file( + ) + .file( "src/lib.rs", r#" fn main() { } #[cfg(not(foo))] fn main() { } "#, - ).build(); + ) + .build(); p.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); } @@ -153,7 +160,8 @@ fn env_rustflags_plugin_dep() { [dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "fn foo() {}") + ) + .file("src/lib.rs", "fn foo() {}") .build(); let _bar = project() .at("bar") @@ -165,7 +173,8 @@ fn env_rustflags_plugin_dep() { #[cfg(not(foo))] fn bar() { } "#, - ).build(); + ) + .build(); foo.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); } @@ -183,7 +192,8 @@ fn env_rustflags_normal_source_with_target() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).build(); + ) + .build(); let host = &rustc_host(); @@ -229,7 +239,8 @@ fn env_rustflags_build_script_with_target() { version = "0.0.1" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -237,7 +248,8 @@ fn env_rustflags_build_script_with_target() { #[cfg(foo)] fn main() { } "#, - ).build(); + ) + .build(); let host = rustc_host(); p.cargo("build --target") @@ -263,7 +275,8 @@ fn env_rustflags_build_script_dep_with_target() { [build-dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .build(); let _bar = project() @@ -276,7 +289,8 @@ fn env_rustflags_build_script_dep_with_target() { #[cfg(foo)] fn bar() { } "#, - ).build(); + ) + .build(); let host = rustc_host(); foo.cargo("build --target") @@ -302,14 +316,16 @@ fn env_rustflags_plugin_with_target() { name = "foo" plugin = true "#, - ).file( + ) + .file( "src/lib.rs", r#" fn main() { } #[cfg(foo)] fn main() { } "#, - ).build(); + ) + .build(); let host = rustc_host(); p.cargo("build --target") @@ -338,7 +354,8 @@ fn env_rustflags_plugin_dep_with_target() { [dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "fn foo() {}") + ) + .file("src/lib.rs", "fn foo() {}") .build(); let _bar = project() .at("bar") @@ -350,7 +367,8 @@ fn env_rustflags_plugin_dep_with_target() { #[cfg(foo)] fn bar() { } "#, - ).build(); + ) + .build(); let host = rustc_host(); foo.cargo("build --target") @@ -407,13 +425,15 @@ fn build_rustflags_normal_source() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( ".cargo/config", r#" [build] rustflags = ["-Z", "bogus"] "#, - ).build(); + ) + .build(); p.cargo("build --lib").with_status(101).run(); p.cargo("build --bin=a").with_status(101).run(); @@ -436,7 +456,8 @@ fn build_rustflags_build_script() { version = "0.0.1" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -444,13 +465,15 @@ fn build_rustflags_build_script() { #[cfg(not(foo))] fn main() { } "#, - ).file( + ) + .file( ".cargo/config", r#" [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -472,7 +495,8 @@ fn build_rustflags_build_script_dep() { [build-dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .file( ".cargo/config", @@ -480,7 +504,8 @@ fn build_rustflags_build_script_dep() { [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -491,7 +516,8 @@ fn build_rustflags_build_script_dep() { #[cfg(not(foo))] fn bar() { } "#, - ).build(); + ) + .build(); foo.cargo("build").run(); } @@ -513,20 +539,23 @@ fn build_rustflags_plugin() { name = "foo" plugin = true "#, - ).file( + ) + .file( "src/lib.rs", r#" fn main() { } #[cfg(not(foo))] fn main() { } "#, - ).file( + ) + .file( ".cargo/config", r#" [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -551,14 +580,16 @@ fn build_rustflags_plugin_dep() { [dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "fn foo() {}") + ) + .file("src/lib.rs", "fn foo() {}") .file( ".cargo/config", r#" [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_lib_manifest("bar")) @@ -569,7 +600,8 @@ fn build_rustflags_plugin_dep() { #[cfg(not(foo))] fn bar() { } "#, - ).build(); + ) + .build(); foo.cargo("build").run(); } @@ -587,13 +619,15 @@ fn build_rustflags_normal_source_with_target() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( ".cargo/config", r#" [build] rustflags = ["-Z", "bogus"] "#, - ).build(); + ) + .build(); let host = &rustc_host(); @@ -628,7 +662,8 @@ fn build_rustflags_build_script_with_target() { version = "0.0.1" build = "build.rs" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "build.rs", r#" @@ -636,13 +671,15 @@ fn build_rustflags_build_script_with_target() { #[cfg(foo)] fn main() { } "#, - ).file( + ) + .file( ".cargo/config", r#" [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); let host = rustc_host(); p.cargo("build --target").arg(host).run(); @@ -665,7 +702,8 @@ fn build_rustflags_build_script_dep_with_target() { [build-dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("build.rs", "fn main() {}") .file( ".cargo/config", @@ -673,7 +711,8 @@ fn build_rustflags_build_script_dep_with_target() { [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -684,7 +723,8 @@ fn build_rustflags_build_script_dep_with_target() { #[cfg(foo)] fn bar() { } "#, - ).build(); + ) + .build(); let host = rustc_host(); foo.cargo("build --target").arg(host).run(); @@ -707,20 +747,23 @@ fn build_rustflags_plugin_with_target() { name = "foo" plugin = true "#, - ).file( + ) + .file( "src/lib.rs", r#" fn main() { } #[cfg(foo)] fn main() { } "#, - ).file( + ) + .file( ".cargo/config", r#" [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); let host = rustc_host(); p.cargo("build --target").arg(host).run(); @@ -746,14 +789,16 @@ fn build_rustflags_plugin_dep_with_target() { [dependencies.bar] path = "../bar" "#, - ).file("src/lib.rs", "fn foo() {}") + ) + .file("src/lib.rs", "fn foo() {}") .file( ".cargo/config", r#" [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); let _bar = project() .at("bar") .file("Cargo.toml", &basic_lib_manifest("bar")) @@ -764,7 +809,8 @@ fn build_rustflags_plugin_dep_with_target() { #[cfg(foo)] fn bar() { } "#, - ).build(); + ) + .build(); let host = rustc_host(); foo.cargo("build --target").arg(host).run(); @@ -818,7 +864,8 @@ fn build_rustflags_no_recompile() { [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); p.cargo("build").env("RUSTFLAGS", "--cfg foo").run(); p.cargo("build") @@ -840,7 +887,8 @@ fn build_rustflags_with_home_config() { [build] rustflags = ["-Cllvm-args=-x86-asm-syntax=intel"] "#, - ).unwrap(); + ) + .unwrap(); // And we need the project to be inside the home directory // so the walking process finds the home project twice. @@ -862,7 +910,8 @@ fn target_rustflags_normal_source() { #![feature(test)] extern crate test; #[bench] fn run1(_ben: &mut test::Bencher) { }"#, - ).file( + ) + .file( ".cargo/config", &format!( " @@ -871,7 +920,8 @@ fn target_rustflags_normal_source() { ", rustc_host() ), - ).build(); + ) + .build(); p.cargo("build --lib").with_status(101).run(); p.cargo("build --bin=a").with_status(101).run(); @@ -897,7 +947,8 @@ fn target_rustflags_precedence() { ", rustc_host() ), - ).build(); + ) + .build(); p.cargo("build --lib").with_status(101).run(); p.cargo("build --bin=a").with_status(101).run(); @@ -926,7 +977,8 @@ fn cfg_rustflags_normal_source() { "not(windows)" } ), - ).build(); + ) + .build(); p.cargo("build --lib -v") .with_stderr( @@ -935,7 +987,8 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build --bin=a -v") .with_stderr( @@ -944,7 +997,8 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build --example=b -v") .with_stderr( @@ -953,7 +1007,8 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("test --no-run -v") .with_stderr( @@ -964,7 +1019,8 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("bench --no-run -v") .with_stderr( @@ -975,7 +1031,8 @@ fn cfg_rustflags_normal_source() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } // target.'cfg(...)'.rustflags takes precedence over build.rustflags @@ -1002,7 +1059,8 @@ fn cfg_rustflags_precedence() { "not(windows)" } ), - ).build(); + ) + .build(); p.cargo("build --lib -v") .with_stderr( @@ -1011,7 +1069,8 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build --bin=a -v") .with_stderr( @@ -1020,7 +1079,8 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build --example=b -v") .with_stderr( @@ -1029,7 +1089,8 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("test --no-run -v") .with_stderr( @@ -1040,7 +1101,8 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("bench --no-run -v") .with_stderr( @@ -1051,7 +1113,8 @@ fn cfg_rustflags_precedence() { [RUNNING] `rustc [..] --cfg bar[..]` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1064,7 +1127,8 @@ fn target_rustflags_string_and_array_form1() { [build] rustflags = ["--cfg", "foo"] "#, - ).build(); + ) + .build(); p1.cargo("build -v") .with_stderr( @@ -1073,7 +1137,8 @@ fn target_rustflags_string_and_array_form1() { [RUNNING] `rustc [..] --cfg foo[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); let p2 = project() .file("src/lib.rs", "") @@ -1083,7 +1148,8 @@ fn target_rustflags_string_and_array_form1() { [build] rustflags = "--cfg foo" "#, - ).build(); + ) + .build(); p2.cargo("build -v") .with_stderr( @@ -1092,7 +1158,8 @@ fn target_rustflags_string_and_array_form1() { [RUNNING] `rustc [..] --cfg foo[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1107,7 +1174,8 @@ fn target_rustflags_string_and_array_form2() { "#, rustc_host() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p1.cargo("build -v") @@ -1117,7 +1185,8 @@ fn target_rustflags_string_and_array_form2() { [RUNNING] `rustc [..] --cfg foo[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); let p2 = project() .file( @@ -1129,7 +1198,8 @@ fn target_rustflags_string_and_array_form2() { "#, rustc_host() ), - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p2.cargo("build -v") @@ -1139,7 +1209,8 @@ fn target_rustflags_string_and_array_form2() { [RUNNING] `rustc [..] --cfg foo[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1157,7 +1228,8 @@ fn two_matching_in_config() { [target.'cfg(target_pointer_width = "64")'] rustflags = ["--cfg", 'foo="b"'] "#, - ).file( + ) + .file( "src/main.rs", r#" fn main() { @@ -1170,7 +1242,8 @@ fn two_matching_in_config() { } } "#, - ).build(); + ) + .build(); p1.cargo("run").run(); p1.cargo("build").with_stderr("[FINISHED] [..]").run(); diff --git a/tests/testsuite/shell_quoting.rs b/tests/testsuite/shell_quoting.rs index 203831dc768..78bc0bb0ce5 100644 --- a/tests/testsuite/shell_quoting.rs +++ b/tests/testsuite/shell_quoting.rs @@ -19,7 +19,8 @@ fn features_are_quoted() { some_feature = [] default = ["some_feature"] "#, - ).file("src/main.rs", "fn main() {error}") + ) + .file("src/main.rs", "fn main() {error}") .build(); p.cargo("check -v") diff --git a/tests/testsuite/small_fd_limits.rs b/tests/testsuite/small_fd_limits.rs index 672439a7d3d..273190810ca 100644 --- a/tests/testsuite/small_fd_limits.rs +++ b/tests/testsuite/small_fd_limits.rs @@ -3,11 +3,11 @@ use std::ffi::OsStr; use std::path::PathBuf; use std::process::Command; -use git2; use crate::support::git; use crate::support::paths; use crate::support::project; use crate::support::registry::Package; +use git2; use url::Url; @@ -31,7 +31,8 @@ fn run_test(path_env: Option<&OsStr>) { [dependencies] bar = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); Package::new("bar", "0.1.0").publish(); diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index 0967101ee1b..3387db87941 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -516,7 +516,8 @@ pub fn cargo_dir() -> PathBuf { } path }) - }).unwrap_or_else(|| panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test")) + }) + .unwrap_or_else(|| panic!("CARGO_BIN_PATH wasn't set. Cannot continue running test")) } pub fn cargo_exe() -> PathBuf { @@ -968,20 +969,17 @@ impl Execs { None => out.to_string(), Some(ref p) => match p.get_cwd() { None => out.to_string(), - Some(cwd) => out - .replace( "[CWD]", &cwd.display().to_string()) - , + Some(cwd) => out.replace("[CWD]", &cwd.display().to_string()), }, }; // On Windows, we need to use a wildcard for the drive, // because we don't actually know what it will be. - let replaced = replaced - .replace("[ROOT]", - if cfg!(windows) { r#"[..]:\"# } else { "/" }); + let replaced = + replaced.replace("[ROOT]", if cfg!(windows) { r#"[..]:\"# } else { "/" }); replaced - }, + } None => return Ok(()), }; @@ -1157,7 +1155,8 @@ impl Execs { (Some(a), None) => Some(format!("{:3} -\n + |{}|\n", i, a)), (None, Some(e)) => Some(format!("{:3} - |{}|\n +\n", i, e)), (None, None) => panic!("Cannot get here"), - }).collect() + }) + .collect() } } @@ -1450,43 +1449,39 @@ pub fn process>(t: T) -> cargo::util::ProcessBuilder { fn _process(t: &OsStr) -> cargo::util::ProcessBuilder { let mut p = cargo::util::process(t); p.cwd(&paths::root()) - .env_remove("CARGO_HOME") - .env("HOME", paths::home()) - .env("CARGO_HOME", paths::home().join(".cargo")) - .env("__CARGO_TEST_ROOT", paths::root()) - - // Force cargo to think it's on the stable channel for all tests, this - // should hopefully not surprise us as we add cargo features over time and - // cargo rides the trains. - .env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "stable") - - // For now disable incremental by default as support hasn't ridden to the - // stable channel yet. Once incremental support hits the stable compiler we - // can switch this to one and then fix the tests. - .env("CARGO_INCREMENTAL", "0") - - // This env var can switch the git backend from libgit2 to git2-curl, which - // can tweak error messages and cause some tests to fail, so let's forcibly - // remove it. - .env_remove("CARGO_HTTP_CHECK_REVOKE") - - .env_remove("__CARGO_DEFAULT_LIB_METADATA") - .env_remove("RUSTC") - .env_remove("RUSTDOC") - .env_remove("RUSTC_WRAPPER") - .env_remove("RUSTFLAGS") - .env_remove("XDG_CONFIG_HOME") // see #2345 - .env("GIT_CONFIG_NOSYSTEM", "1") // keep trying to sandbox ourselves - .env_remove("EMAIL") - .env_remove("MFLAGS") - .env_remove("MAKEFLAGS") - .env_remove("CARGO_MAKEFLAGS") - .env_remove("GIT_AUTHOR_NAME") - .env_remove("GIT_AUTHOR_EMAIL") - .env_remove("GIT_COMMITTER_NAME") - .env_remove("GIT_COMMITTER_EMAIL") - .env_remove("CARGO_TARGET_DIR") // we assume 'target' - .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows + .env_remove("CARGO_HOME") + .env("HOME", paths::home()) + .env("CARGO_HOME", paths::home().join(".cargo")) + .env("__CARGO_TEST_ROOT", paths::root()) + // Force cargo to think it's on the stable channel for all tests, this + // should hopefully not surprise us as we add cargo features over time and + // cargo rides the trains. + .env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "stable") + // For now disable incremental by default as support hasn't ridden to the + // stable channel yet. Once incremental support hits the stable compiler we + // can switch this to one and then fix the tests. + .env("CARGO_INCREMENTAL", "0") + // This env var can switch the git backend from libgit2 to git2-curl, which + // can tweak error messages and cause some tests to fail, so let's forcibly + // remove it. + .env_remove("CARGO_HTTP_CHECK_REVOKE") + .env_remove("__CARGO_DEFAULT_LIB_METADATA") + .env_remove("RUSTC") + .env_remove("RUSTDOC") + .env_remove("RUSTC_WRAPPER") + .env_remove("RUSTFLAGS") + .env_remove("XDG_CONFIG_HOME") // see #2345 + .env("GIT_CONFIG_NOSYSTEM", "1") // keep trying to sandbox ourselves + .env_remove("EMAIL") + .env_remove("MFLAGS") + .env_remove("MAKEFLAGS") + .env_remove("CARGO_MAKEFLAGS") + .env_remove("GIT_AUTHOR_NAME") + .env_remove("GIT_AUTHOR_EMAIL") + .env_remove("GIT_COMMITTER_NAME") + .env_remove("GIT_COMMITTER_EMAIL") + .env_remove("CARGO_TARGET_DIR") // we assume 'target' + .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows p } diff --git a/tests/testsuite/support/publish.rs b/tests/testsuite/support/publish.rs index 8a16afc734e..afb2e109456 100644 --- a/tests/testsuite/support/publish.rs +++ b/tests/testsuite/support/publish.rs @@ -20,7 +20,8 @@ pub fn setup() -> Repository { index = "{registry}" "#, registry = registry().to_string() - ).as_bytes() + ) + .as_bytes() )); let credentials = paths::root().join("home/.cargo/credentials"); @@ -44,7 +45,8 @@ pub fn setup() -> Repository { }}"#, upload() ), - ).build() + ) + .build() } pub fn registry_path() -> PathBuf { diff --git a/tests/testsuite/support/registry.rs b/tests/testsuite/support/registry.rs index d2b2748e61b..7f4e4dd3e13 100644 --- a/tests/testsuite/support/registry.rs +++ b/tests/testsuite/support/registry.rs @@ -159,7 +159,8 @@ pub fn init() { "#, reg = registry(), alt = alt_registry() - ).as_bytes() + ) + .as_bytes() )); // Init a new registry @@ -172,7 +173,8 @@ pub fn init() { "#, dl_url() ), - ).build(); + ) + .build(); fs::create_dir_all(dl_path().join("api/v1/crates")).unwrap(); // Init an alt registry @@ -186,7 +188,8 @@ pub fn init() { alt_dl_url(), alt_api_url() ), - ).build(); + ) + .build(); fs::create_dir_all(alt_api_path().join("api/v1/crates")).unwrap(); } @@ -341,7 +344,8 @@ impl Package { "registry": dep.registry, "package": dep.package, }) - }).collect::>(); + }) + .collect::>(); let cksum = { let mut c = Vec::new(); t!(t!(File::open(&self.archive_dst())).read_to_end(&mut c)); @@ -354,7 +358,8 @@ impl Package { "cksum": cksum, "features": self.features, "yanked": self.yanked, - }).to_string(); + }) + .to_string(); let file = match self.name.len() { 1 => format!("1/{}", self.name), diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 9080702d478..60daa8226a3 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -1,11 +1,11 @@ use std::fs::File; use std::io::prelude::*; -use cargo; use crate::support::paths::CargoPathExt; use crate::support::registry::Package; use crate::support::{basic_bin_manifest, basic_lib_manifest, basic_manifest, cargo_exe, project}; use crate::support::{is_nightly, rustc_host, sleep_ms}; +use cargo; #[test] fn cargo_test_simple() { @@ -26,7 +26,8 @@ fn cargo_test_simple() { fn test_hello() { assert_eq!(hello(), "hello") }"#, - ).build(); + ) + .build(); p.cargo("build").run(); assert!(p.bin("foo").is_file()); @@ -39,7 +40,8 @@ fn cargo_test_simple() { [COMPILING] foo v0.5.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("test test_hello ... ok") + ) + .with_stdout_contains("test test_hello ... ok") .run(); } @@ -57,7 +59,8 @@ fn cargo_test_release() { [dependencies] bar = { path = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -66,7 +69,8 @@ fn cargo_test_release() { #[test] fn test() { foo(); } "#, - ).file( + ) + .file( "tests/test.rs", r#" extern crate foo; @@ -74,7 +78,8 @@ fn cargo_test_release() { #[test] fn test() { foo::foo(); } "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "pub fn bar() {}") .build(); @@ -92,7 +97,8 @@ fn cargo_test_release() { [RUNNING] `[..]target/release/deps/test-[..][EXE]` [DOCTEST] foo [RUNNING] `rustdoc --test [..]lib.rs[..]`", - ).with_stdout_contains_n("test test ... ok", 2) + ) + .with_stdout_contains_n("test test ... ok", 2) .with_stdout_contains("running 0 tests") .run(); } @@ -117,7 +123,8 @@ fn cargo_test_overflow_checks() { [profile.release] overflow-checks = true "#, - ).file( + ) + .file( "src/foo.rs", r#" use std::panic; @@ -127,7 +134,8 @@ fn cargo_test_overflow_checks() { }); assert!(r.is_err()); }"#, - ).build(); + ) + .build(); p.cargo("build --release").run(); assert!(p.release_bin("foo").is_file()); @@ -145,7 +153,8 @@ fn cargo_test_verbose() { fn main() {} #[test] fn test_hello() {} "#, - ).build(); + ) + .build(); p.cargo("test -v hello") .with_stderr( @@ -154,7 +163,8 @@ fn cargo_test_verbose() { [RUNNING] `rustc [..] src/main.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]target/debug/deps/foo-[..][EXE] hello`", - ).with_stdout_contains("test test_hello ... ok") + ) + .with_stdout_contains("test test_hello ... ok") .run(); } @@ -167,20 +177,23 @@ fn many_similar_names() { pub fn foo() {} #[test] fn lib_test() {} ", - ).file( + ) + .file( "src/main.rs", " extern crate foo; fn main() {} #[test] fn bin_test() { foo::foo() } ", - ).file( + ) + .file( "tests/foo.rs", r#" extern crate foo; #[test] fn test_test() { foo::foo() } "#, - ).build(); + ) + .build(); p.cargo("test -v") .with_stdout_contains("test bin_test ... ok") @@ -208,7 +221,8 @@ fn cargo_test_failing_test_in_bin() { fn test_hello() { assert_eq!(hello(), "nope") }"#, - ).build(); + ) + .build(); p.cargo("build").run(); assert!(p.bin("foo").is_file()); @@ -222,7 +236,8 @@ fn cargo_test_failing_test_in_bin() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [ERROR] test failed, to rerun pass '--bin foo'", - ).with_stdout_contains( + ) + .with_stdout_contains( " running 1 test test test_hello ... FAILED @@ -231,7 +246,8 @@ failures: ---- test_hello stdout ---- [..]thread 'test_hello' panicked at 'assertion failed:[..]", - ).with_stdout_contains("[..]`(left == right)`[..]") + ) + .with_stdout_contains("[..]`(left == right)`[..]") .with_stdout_contains("[..]left: `\"hello\"`,[..]") .with_stdout_contains("[..]right: `\"nope\"`[..]") .with_stdout_contains("[..]src/main.rs:12[..]") @@ -240,7 +256,8 @@ failures: failures: test_hello ", - ).with_status(101) + ) + .with_status(101) .run(); } @@ -252,7 +269,8 @@ fn cargo_test_failing_test_in_test() { .file( "tests/footest.rs", "#[test] fn test_hello() { assert!(false) }", - ).build(); + ) + .build(); p.cargo("build").run(); assert!(p.bin("foo").is_file()); @@ -267,7 +285,8 @@ fn cargo_test_failing_test_in_test() { [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/footest-[..][EXE] [ERROR] test failed, to rerun pass '--test footest'", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .with_stdout_contains( "\ running 1 test @@ -279,12 +298,14 @@ failures: [..]thread 'test_hello' panicked at 'assertion failed: false', \ tests/footest.rs:1[..] ", - ).with_stdout_contains( + ) + .with_stdout_contains( "\ failures: test_hello ", - ).with_status(101) + ) + .with_status(101) .run(); } @@ -302,7 +323,8 @@ fn cargo_test_failing_test_in_lib() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [ERROR] test failed, to rerun pass '--lib'", - ).with_stdout_contains( + ) + .with_stdout_contains( "\ test test_hello ... FAILED @@ -312,12 +334,14 @@ failures: [..]thread 'test_hello' panicked at 'assertion failed: false', \ src/lib.rs:1[..] ", - ).with_stdout_contains( + ) + .with_stdout_contains( "\ failures: test_hello ", - ).with_status(101) + ) + .with_status(101) .run(); } @@ -336,7 +360,8 @@ fn test_with_lib_dep() { name = "baz" path = "src/main.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" /// @@ -350,7 +375,8 @@ fn test_with_lib_dep() { pub fn foo(){} #[test] fn lib_test() {} "#, - ).file( + ) + .file( "src/main.rs", " #[allow(unused_extern_crates)] @@ -361,7 +387,8 @@ fn test_with_lib_dep() { #[test] fn bin_test() {} ", - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -371,7 +398,8 @@ fn test_with_lib_dep() { [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/baz-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test lib_test ... ok") + ) + .with_stdout_contains("test lib_test ... ok") .with_stdout_contains("test bin_test ... ok") .with_stdout_contains_n("test [..] ... ok", 3) .run(); @@ -391,7 +419,8 @@ fn test_with_deep_lib_dep() { [dependencies.bar] path = "../bar" "#, - ).file( + ) + .file( "src/lib.rs", " #[cfg(test)] @@ -406,7 +435,8 @@ fn test_with_deep_lib_dep() { bar::bar(); } ", - ).build(); + ) + .build(); let _p2 = project() .at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -421,7 +451,8 @@ fn test_with_deep_lib_dep() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target[..] [DOCTEST] foo", - ).with_stdout_contains("test bar_test ... ok") + ) + .with_stdout_contains("test bar_test ... ok") .with_stdout_contains_n("test [..] ... ok", 2) .run(); } @@ -441,7 +472,8 @@ fn external_test_explicit() { name = "test" path = "src/test.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn get_hello() -> &'static str { "Hello" } @@ -449,7 +481,8 @@ fn external_test_explicit() { #[test] fn internal_test() {} "#, - ).file( + ) + .file( "src/test.rs", r#" extern crate foo; @@ -457,7 +490,8 @@ fn external_test_explicit() { #[test] fn external_test() { assert_eq!(foo::get_hello(), "Hello") } "#, - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -467,7 +501,8 @@ fn external_test_explicit() { [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test internal_test ... ok") + ) + .with_stdout_contains("test internal_test ... ok") .with_stdout_contains("test external_test ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -487,7 +522,8 @@ fn external_test_named_test() { [[test]] name = "test" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("tests/test.rs", "#[test] fn foo() {}") .build(); @@ -505,7 +541,8 @@ fn external_test_implicit() { #[test] fn internal_test() {} "#, - ).file( + ) + .file( "tests/external.rs", r#" extern crate foo; @@ -513,7 +550,8 @@ fn external_test_implicit() { #[test] fn external_test() { assert_eq!(foo::get_hello(), "Hello") } "#, - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -523,7 +561,8 @@ fn external_test_implicit() { [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/external-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test internal_test ... ok") + ) + .with_stdout_contains("test internal_test ... ok") .with_stdout_contains("test external_test ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -538,7 +577,8 @@ fn dont_run_examples() { r#" fn main() { panic!("Examples should not be run by 'cargo test'"); } "#, - ).build(); + ) + .build(); p.cargo("test").run(); } @@ -551,7 +591,8 @@ fn pass_through_command_line() { #[test] fn foo() {} #[test] fn bar() {} ", - ).build(); + ) + .build(); p.cargo("test bar") .with_stderr( @@ -560,7 +601,8 @@ fn pass_through_command_line() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test bar ... ok") + ) + .with_stdout_contains("test bar ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -570,7 +612,8 @@ fn pass_through_command_line() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test foo ... ok") + ) + .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); } @@ -589,7 +632,8 @@ fn cargo_test_twice() { #[test] fn dummy_test() { } "#, - ).build(); + ) + .build(); for _ in 0..2 { p.cargo("test").run(); @@ -612,7 +656,8 @@ fn lib_bin_same_name() { [[bin]] name = "foo" "#, - ).file("src/lib.rs", "#[test] fn lib_test() {}") + ) + .file("src/lib.rs", "#[test] fn lib_test() {}") .file( "src/main.rs", " @@ -622,7 +667,8 @@ fn lib_bin_same_name() { #[test] fn bin_test() {} ", - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -632,7 +678,8 @@ fn lib_bin_same_name() { [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains_n("test [..] ... ok", 2) + ) + .with_stdout_contains_n("test [..] ... ok", 2) .with_stdout_contains("running 0 tests") .run(); } @@ -652,7 +699,8 @@ fn lib_with_standard_name() { #[test] fn foo_test() {} ", - ).file( + ) + .file( "tests/test.rs", " extern crate syntax; @@ -660,7 +708,8 @@ fn lib_with_standard_name() { #[test] fn test() { syntax::foo() } ", - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -670,7 +719,8 @@ fn lib_with_standard_name() { [RUNNING] target/debug/deps/syntax-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE] [DOCTEST] syntax", - ).with_stdout_contains("test foo_test ... ok") + ) + .with_stdout_contains("test foo_test ... ok") .with_stdout_contains("test test ... ok") .with_stdout_contains_n("test [..] ... ok", 3) .run(); @@ -692,7 +742,8 @@ fn lib_with_standard_name2() { test = false doctest = false "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -703,7 +754,8 @@ fn lib_with_standard_name2() { #[test] fn test() { syntax::foo() } ", - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -711,7 +763,8 @@ fn lib_with_standard_name2() { [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/syntax-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); } @@ -730,7 +783,8 @@ fn lib_without_name() { test = false doctest = false "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -741,7 +795,8 @@ fn lib_without_name() { #[test] fn test() { syntax::foo() } ", - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -749,7 +804,8 @@ fn lib_without_name() { [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/syntax-[..][EXE]", - ).with_stdout_contains("test test ... ok") + ) + .with_stdout_contains("test test ... ok") .run(); } @@ -771,7 +827,8 @@ fn bin_without_name() { [[bin]] path = "src/main.rs" "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -782,7 +839,8 @@ fn bin_without_name() { #[test] fn test() { syntax::foo() } ", - ).build(); + ) + .build(); p.cargo("test") .with_status(101) @@ -792,7 +850,8 @@ fn bin_without_name() { Caused by: binary target bin.name is required", - ).run(); + ) + .run(); } #[test] @@ -813,7 +872,8 @@ fn bench_without_name() { [[bench]] path = "src/bench.rs" "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -824,7 +884,8 @@ fn bench_without_name() { #[test] fn test() { syntax::foo() } ", - ).file( + ) + .file( "src/bench.rs", " #![feature(test)] @@ -834,7 +895,8 @@ fn bench_without_name() { #[bench] fn external_bench(_b: &mut test::Bencher) {} ", - ).build(); + ) + .build(); p.cargo("test") .with_status(101) @@ -844,7 +906,8 @@ fn bench_without_name() { Caused by: benchmark target bench.name is required", - ).run(); + ) + .run(); } #[test] @@ -865,13 +928,15 @@ fn test_without_name() { [[test]] path = "src/test.rs" "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn foo() {} pub fn get_hello() -> &'static str { "Hello" } "#, - ).file( + ) + .file( "src/main.rs", " extern crate syntax; @@ -881,7 +946,8 @@ fn test_without_name() { #[test] fn test() { syntax::foo() } ", - ).file( + ) + .file( "src/test.rs", r#" extern crate syntax; @@ -889,7 +955,8 @@ fn test_without_name() { #[test] fn external_test() { assert_eq!(syntax::get_hello(), "Hello") } "#, - ).build(); + ) + .build(); p.cargo("test") .with_status(101) @@ -899,7 +966,8 @@ fn test_without_name() { Caused by: test target test.name is required", - ).run(); + ) + .run(); } #[test] @@ -920,7 +988,8 @@ fn example_without_name() { [[example]] path = "examples/example.rs" "#, - ).file("src/lib.rs", "pub fn foo() {}") + ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -931,7 +1000,8 @@ fn example_without_name() { #[test] fn test() { syntax::foo() } ", - ).file( + ) + .file( "examples/example.rs", r#" extern crate syntax; @@ -940,7 +1010,8 @@ fn example_without_name() { println!("example1"); } "#, - ).build(); + ) + .build(); p.cargo("test") .with_status(101) @@ -950,7 +1021,8 @@ fn example_without_name() { Caused by: example target example.name is required", - ).run(); + ) + .run(); } #[test] @@ -962,7 +1034,8 @@ fn bin_there_for_integration() { fn main() { std::process::exit(101); } #[test] fn main_test() {} ", - ).file( + ) + .file( "tests/foo.rs", r#" use std::process::Command; @@ -972,7 +1045,8 @@ fn bin_there_for_integration() { assert_eq!(status.code(), Some(101)); } "#, - ).build(); + ) + .build(); p.cargo("test -v") .with_stdout_contains("test main_test ... ok") @@ -998,7 +1072,8 @@ fn test_dylib() { [dependencies.bar] path = "bar" "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar as the_bar; @@ -1008,7 +1083,8 @@ fn test_dylib() { #[test] fn foo() { bar(); } "#, - ).file( + ) + .file( "tests/test.rs", r#" extern crate foo as the_foo; @@ -1016,7 +1092,8 @@ fn test_dylib() { #[test] fn foo() { the_foo::bar(); } "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -1028,7 +1105,8 @@ fn test_dylib() { name = "bar" crate_type = ["dylib"] "#, - ).file("bar/src/lib.rs", "pub fn baz() {}") + ) + .file("bar/src/lib.rs", "pub fn baz() {}") .build(); p.cargo("test") @@ -1039,7 +1117,8 @@ fn test_dylib() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE]", - ).with_stdout_contains_n("test foo ... ok", 2) + ) + .with_stdout_contains_n("test foo ... ok", 2) .run(); p.root().move_into_the_past(); @@ -1049,7 +1128,8 @@ fn test_dylib() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test-[..][EXE]", - ).with_stdout_contains_n("test foo ... ok", 2) + ) + .with_stdout_contains_n("test foo ... ok", 2) .run(); } @@ -1065,7 +1145,8 @@ fn test_twice_with_build_cmd() { authors = [] build = "build.rs" "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "#[test] fn foo() {}") .build(); @@ -1076,7 +1157,8 @@ fn test_twice_with_build_cmd() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test foo ... ok") + ) + .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -1086,7 +1168,8 @@ fn test_twice_with_build_cmd() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test foo ... ok") + ) + .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); } @@ -1102,7 +1185,8 @@ fn test_then_build() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test foo ... ok") + ) + .with_stdout_contains("test foo ... ok") .with_stdout_contains("running 0 tests") .run(); @@ -1121,7 +1205,8 @@ fn test_no_run() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1143,7 +1228,8 @@ fn test_run_specific_bin_target() { name="bin2" path="src/bin2.rs" "#, - ).file("src/bin1.rs", "#[test] fn test1() { }") + ) + .file("src/bin1.rs", "#[test] fn test1() { }") .file("src/bin2.rs", "#[test] fn test2() { }") .build(); @@ -1153,7 +1239,8 @@ fn test_run_specific_bin_target() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/bin2-[..][EXE]", - ).with_stdout_contains("test test2 ... ok") + ) + .with_stdout_contains("test test2 ... ok") .run(); } @@ -1172,17 +1259,20 @@ fn test_run_implicit_bin_target() { name="mybin" path="src/mybin.rs" "#, - ).file( + ) + .file( "src/mybin.rs", "#[test] fn test_in_bin() { } fn main() { panic!(\"Don't execute me!\"); }", - ).file("tests/mytest.rs", "#[test] fn test_in_test() { }") + ) + .file("tests/mytest.rs", "#[test] fn test_in_test() { }") .file("benches/mybench.rs", "#[test] fn test_in_bench() { }") .file( "examples/myexm.rs", "#[test] fn test_in_exm() { } fn main() { panic!(\"Don't execute me!\"); }", - ).build(); + ) + .build(); prj.cargo("test --bins") .with_stderr( @@ -1190,7 +1280,8 @@ fn test_run_implicit_bin_target() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/mybin-[..][EXE]", - ).with_stdout_contains("test test_in_bin ... ok") + ) + .with_stdout_contains("test test_in_bin ... ok") .run(); } @@ -1209,7 +1300,8 @@ fn test_run_specific_test_target() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/b-[..][EXE]", - ).with_stdout_contains("test test_b ... ok") + ) + .with_stdout_contains("test test_b ... ok") .run(); } @@ -1228,16 +1320,19 @@ fn test_run_implicit_test_target() { name="mybin" path="src/mybin.rs" "#, - ).file( + ) + .file( "src/mybin.rs", "#[test] fn test_in_bin() { } fn main() { panic!(\"Don't execute me!\"); }", - ).file("tests/mytest.rs", "#[test] fn test_in_test() { }") + ) + .file("tests/mytest.rs", "#[test] fn test_in_test() { }") .file("benches/mybench.rs", "#[test] fn test_in_bench() { }") .file( "examples/myexm.rs", "fn main() { compile_error!(\"Don't build me!\"); }", - ).build(); + ) + .build(); prj.cargo("test --tests") .with_stderr( @@ -1246,7 +1341,8 @@ fn test_run_implicit_test_target() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/mybin-[..][EXE] [RUNNING] target/debug/deps/mytest-[..][EXE]", - ).with_stdout_contains("test test_in_test ... ok") + ) + .with_stdout_contains("test test_in_test ... ok") .run(); } @@ -1265,16 +1361,19 @@ fn test_run_implicit_bench_target() { name="mybin" path="src/mybin.rs" "#, - ).file( + ) + .file( "src/mybin.rs", "#[test] fn test_in_bin() { } fn main() { panic!(\"Don't execute me!\"); }", - ).file("tests/mytest.rs", "#[test] fn test_in_test() { }") + ) + .file("tests/mytest.rs", "#[test] fn test_in_test() { }") .file("benches/mybench.rs", "#[test] fn test_in_bench() { }") .file( "examples/myexm.rs", "fn main() { compile_error!(\"Don't build me!\"); }", - ).build(); + ) + .build(); prj.cargo("test --benches") .with_stderr( @@ -1283,7 +1382,8 @@ fn test_run_implicit_bench_target() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/mybin-[..][EXE] [RUNNING] target/debug/deps/mybench-[..][EXE]", - ).with_stdout_contains("test test_in_bench ... ok") + ) + .with_stdout_contains("test test_in_bench ... ok") .run(); } @@ -1309,21 +1409,25 @@ fn test_run_implicit_example_target() { name = "myexm2" test = true "#, - ).file( + ) + .file( "src/mybin.rs", "#[test] fn test_in_bin() { } fn main() { panic!(\"Don't execute me!\"); }", - ).file("tests/mytest.rs", "#[test] fn test_in_test() { }") + ) + .file("tests/mytest.rs", "#[test] fn test_in_test() { }") .file("benches/mybench.rs", "#[test] fn test_in_bench() { }") .file( "examples/myexm1.rs", "#[test] fn test_in_exm() { } fn main() { panic!(\"Don't execute me!\"); }", - ).file( + ) + .file( "examples/myexm2.rs", "#[test] fn test_in_exm() { } fn main() { panic!(\"Don't execute me!\"); }", - ).build(); + ) + .build(); // Compiles myexm1 as normal, but does not run it. prj.cargo("test -v") @@ -1377,7 +1481,8 @@ fn test_no_harness() { path = "foo.rs" harness = false "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("foo.rs", "fn main() {}") .build(); @@ -1388,7 +1493,8 @@ fn test_no_harness() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/bar-[..][EXE] ", - ).run(); + ) + .run(); } #[test] @@ -1411,7 +1517,8 @@ fn selective_testing() { name = "foo" doctest = false "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "d1/Cargo.toml", r#" @@ -1424,11 +1531,13 @@ fn selective_testing() { name = "d1" doctest = false "#, - ).file("d1/src/lib.rs", "") + ) + .file("d1/src/lib.rs", "") .file( "d1/src/main.rs", "#[allow(unused_extern_crates)] extern crate d1; fn main() {}", - ).file( + ) + .file( "d2/Cargo.toml", r#" [package] @@ -1440,7 +1549,8 @@ fn selective_testing() { name = "d2" doctest = false "#, - ).file("d2/src/lib.rs", "") + ) + .file("d2/src/lib.rs", "") .file( "d2/src/main.rs", "#[allow(unused_extern_crates)] extern crate d2; fn main() {}", @@ -1455,7 +1565,8 @@ fn selective_testing() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/d1-[..][EXE] [RUNNING] target/debug/deps/d1-[..][EXE]", - ).with_stdout_contains_n("running 0 tests", 2) + ) + .with_stdout_contains_n("running 0 tests", 2) .run(); println!("d2"); @@ -1466,7 +1577,8 @@ fn selective_testing() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/d2-[..][EXE] [RUNNING] target/debug/deps/d2-[..][EXE]", - ).with_stdout_contains_n("running 0 tests", 2) + ) + .with_stdout_contains_n("running 0 tests", 2) .run(); println!("whole"); @@ -1476,7 +1588,8 @@ fn selective_testing() { [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); } @@ -1496,13 +1609,15 @@ fn almost_cyclic_but_not_quite() { [dev-dependencies.c] path = "c" "#, - ).file( + ) + .file( "src/lib.rs", r#" #[cfg(test)] extern crate b; #[cfg(test)] extern crate c; "#, - ).file( + ) + .file( "b/Cargo.toml", r#" [package] @@ -1513,13 +1628,15 @@ fn almost_cyclic_but_not_quite() { [dependencies.foo] path = ".." "#, - ).file( + ) + .file( "b/src/lib.rs", r#" #[allow(unused_extern_crates)] extern crate foo; "#, - ).file("c/Cargo.toml", &basic_manifest("c", "0.0.1")) + ) + .file("c/Cargo.toml", &basic_manifest("c", "0.0.1")) .file("c/src/lib.rs", "") .build(); @@ -1541,10 +1658,12 @@ fn build_then_selective_test() { [dependencies.b] path = "b" "#, - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate b;", - ).file( + ) + .file( "src/main.rs", r#" #[allow(unused_extern_crates)] @@ -1553,7 +1672,8 @@ fn build_then_selective_test() { extern crate foo; fn main() {} "#, - ).file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) + ) + .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -1576,7 +1696,8 @@ fn example_dev_dep() { [dev-dependencies.bar] path = "bar" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/e1.rs", "extern crate bar; fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file( @@ -1596,7 +1717,8 @@ fn example_dev_dep() { f8!(); } "#, - ).build(); + ) + .build(); p.cargo("test").run(); p.cargo("run --example e1 --release -v").run(); } @@ -1615,7 +1737,8 @@ fn selective_testing_with_docs() { [dependencies.d1] path = "d1" "#, - ).file( + ) + .file( "src/lib.rs", r#" /// ``` @@ -1623,7 +1746,8 @@ fn selective_testing_with_docs() { /// ``` pub fn foo() {} "#, - ).file( + ) + .file( "d1/Cargo.toml", r#" [package] @@ -1635,7 +1759,8 @@ fn selective_testing_with_docs() { name = "d1" path = "d1.rs" "#, - ).file("d1/d1.rs", ""); + ) + .file("d1/d1.rs", ""); let p = p.build(); p.cargo("test -p d1") @@ -1645,7 +1770,8 @@ fn selective_testing_with_docs() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/d1[..][EXE] [DOCTEST] d1", - ).with_stdout_contains_n("running 0 tests", 2) + ) + .with_stdout_contains_n("running 0 tests", 2) .run(); } @@ -1664,7 +1790,8 @@ fn example_bin_same_name() { [RUNNING] `rustc [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(!p.bin("foo").is_file()); assert!(p.bin("examples/foo").is_file()); @@ -1679,7 +1806,8 @@ fn example_bin_same_name() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] [..]", - ).with_stdout("bin") + ) + .with_stdout("bin") .run(); assert!(p.bin("foo").is_file()); } @@ -1718,11 +1846,13 @@ fn example_with_dev_dep() { [dev-dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "examples/ex.rs", "#[allow(unused_extern_crates)] extern crate a; fn main() {}", - ).file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -1736,7 +1866,8 @@ fn example_with_dev_dep() { [RUNNING] `rustc --crate-name ex [..] --extern a=[..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1782,7 +1913,8 @@ fn doctest_feature() { [features] bar = [] "#, - ).file( + ) + .file( "src/lib.rs", r#" /// ```rust @@ -1791,7 +1923,8 @@ fn doctest_feature() { #[cfg(feature = "bar")] pub fn foo() -> i32 { 1 } "#, - ).build(); + ) + .build(); p.cargo("test --features bar") .with_stderr( @@ -1800,7 +1933,8 @@ fn doctest_feature() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .with_stdout_contains("test [..] ... ok") .run(); } @@ -1817,7 +1951,8 @@ fn dashes_to_underscores() { /// ``` pub fn foo() -> i32 { 1 } "#, - ).build(); + ) + .build(); p.cargo("test -v").run(); } @@ -1836,7 +1971,8 @@ fn doctest_dev_dep() { [dev-dependencies] b = { path = "b" } "#, - ).file( + ) + .file( "src/lib.rs", r#" /// ``` @@ -1844,7 +1980,8 @@ fn doctest_dev_dep() { /// ``` pub fn foo() {} "#, - ).file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) + ) + .file("b/Cargo.toml", &basic_manifest("b", "0.0.1")) .file("b/src/lib.rs", "") .build(); @@ -1862,7 +1999,8 @@ fn filter_no_doc_tests() { /// ``` pub fn foo() {} "#, - ).file("tests/foo.rs", "") + ) + .file("tests/foo.rs", "") .build(); p.cargo("test --test=foo") @@ -1871,7 +2009,8 @@ fn filter_no_doc_tests() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .run(); } @@ -1891,7 +2030,8 @@ fn dylib_doctest() { crate-type = ["rlib", "dylib"] test = false "#, - ).file( + ) + .file( "src/lib.rs", r#" /// ``` @@ -1899,7 +2039,8 @@ fn dylib_doctest() { /// ``` pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("test") .with_stderr( @@ -1907,7 +2048,8 @@ fn dylib_doctest() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [DOCTEST] foo", - ).with_stdout_contains("test [..] ... ok") + ) + .with_stdout_contains("test [..] ... ok") .run(); } @@ -1928,7 +2070,8 @@ fn dylib_doctest2() { crate-type = ["dylib"] test = false "#, - ).file( + ) + .file( "src/lib.rs", r#" /// ``` @@ -1936,7 +2079,8 @@ fn dylib_doctest2() { /// ``` pub fn foo() {} "#, - ).build(); + ) + .build(); p.cargo("test").with_stdout("").run(); } @@ -1955,14 +2099,16 @@ fn cyclic_dev_dep_doc_test() { [dev-dependencies] bar = { path = "bar" } "#, - ).file( + ) + .file( "src/lib.rs", r#" //! ``` //! extern crate bar; //! ``` "#, - ).file( + ) + .file( "bar/Cargo.toml", r#" [package] @@ -1973,13 +2119,15 @@ fn cyclic_dev_dep_doc_test() { [dependencies] foo = { path = ".." } "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" #[allow(unused_extern_crates)] extern crate foo; "#, - ).build(); + ) + .build(); p.cargo("test") .with_stderr( "\ @@ -1988,7 +2136,8 @@ fn cyclic_dev_dep_doc_test() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .with_stdout_contains("test [..] ... ok") .run(); } @@ -2007,7 +2156,8 @@ fn dev_dep_with_build_script() { [dev-dependencies] bar = { path = "bar" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("examples/foo.rs", "fn main() {}") .file( "bar/Cargo.toml", @@ -2018,7 +2168,8 @@ fn dev_dep_with_build_script() { authors = [] build = "build.rs" "#, - ).file("bar/src/lib.rs", "") + ) + .file("bar/src/lib.rs", "") .file("bar/build.rs", "fn main() {}") .build(); p.cargo("test").run(); @@ -2042,7 +2193,8 @@ fn no_fail_fast() { x - 1 } "#, - ).file( + ) + .file( "tests/test_add_one.rs", r#" extern crate foo; @@ -2058,7 +2210,8 @@ fn no_fail_fast() { assert_eq!(add_one(1), 1); } "#, - ).file( + ) + .file( "tests/test_sub_one.rs", r#" extern crate foo; @@ -2069,7 +2222,8 @@ fn no_fail_fast() { assert_eq!(sub_one(1), 0); } "#, - ).build(); + ) + .build(); p.cargo("test --no-fail-fast") .with_status(101) .with_stderr_contains( @@ -2078,12 +2232,14 @@ fn no_fail_fast() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE] [RUNNING] target/debug/deps/test_add_one-[..][EXE]", - ).with_stdout_contains("running 0 tests") + ) + .with_stdout_contains("running 0 tests") .with_stderr_contains( "\ [RUNNING] target/debug/deps/test_sub_one-[..][EXE] [DOCTEST] foo", - ).with_stdout_contains("test result: FAILED. [..]") + ) + .with_stdout_contains("test result: FAILED. [..]") .with_stdout_contains("test sub_one_test ... ok") .with_stdout_contains_n("test [..] ... ok", 3) .run(); @@ -2109,7 +2265,8 @@ fn test_multiple_packages() { name = "foo" doctest = false "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "d1/Cargo.toml", r#" @@ -2122,7 +2279,8 @@ fn test_multiple_packages() { name = "d1" doctest = false "#, - ).file("d1/src/lib.rs", "") + ) + .file("d1/src/lib.rs", "") .file( "d2/Cargo.toml", r#" @@ -2135,7 +2293,8 @@ fn test_multiple_packages() { name = "d2" doctest = false "#, - ).file("d2/src/lib.rs", ""); + ) + .file("d2/src/lib.rs", ""); let p = p.build(); p.cargo("test -p d1 -p d2") @@ -2169,7 +2328,8 @@ fn bin_does_not_rebuild_tests() { [RUNNING] `rustc [..] src/main.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2189,7 +2349,8 @@ fn selective_test_wonky_profile() { [dependencies] a = { path = "a" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", ""); let p = p.build(); @@ -2211,7 +2372,8 @@ fn selective_test_optional_dep() { [dependencies] a = { path = "a", optional = true } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", ""); let p = p.build(); @@ -2224,7 +2386,8 @@ fn selective_test_optional_dep() { [RUNNING] `rustc [..] a/src/lib.rs [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2245,7 +2408,8 @@ fn only_test_docs() { pub fn bar() { } "#, - ).file("tests/foo.rs", "this is not rust"); + ) + .file("tests/foo.rs", "this is not rust"); let p = p.build(); p.cargo("test --doc") @@ -2254,7 +2418,8 @@ fn only_test_docs() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [DOCTEST] foo", - ).with_stdout_contains("test [..] ... ok") + ) + .with_stdout_contains("test [..] ... ok") .run(); } @@ -2275,7 +2440,8 @@ fn test_panic_abort_with_dep() { [profile.dev] panic = 'abort' "#, - ).file( + ) + .file( "src/lib.rs", r#" extern crate bar; @@ -2283,7 +2449,8 @@ fn test_panic_abort_with_dep() { #[test] fn foo() {} "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file("bar/src/lib.rs", "") .build(); p.cargo("test -v").run(); @@ -2304,10 +2471,12 @@ fn cfg_test_even_with_no_harness() { harness = false doctest = false "#, - ).file( + ) + .file( "src/lib.rs", r#"#[cfg(test)] fn main() { println!("hello!"); }"#, - ).build(); + ) + .build(); p.cargo("test -v") .with_stdout("hello!\n") .with_stderr( @@ -2317,7 +2486,8 @@ fn cfg_test_even_with_no_harness() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `[..]` ", - ).run(); + ) + .run(); } #[test] @@ -2337,10 +2507,12 @@ fn panic_abort_multiple() { [profile.release] panic = 'abort' "#, - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate a;", - ).file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); p.cargo("test --release -v -p foo -p a").run(); @@ -2365,7 +2537,8 @@ fn pass_correct_cfgs_flags_to_rustdoc() { path = "libs/feature_a" default-features = false "#, - ).file( + ) + .file( "src/lib.rs", r#" #[cfg(test)] @@ -2376,7 +2549,8 @@ fn pass_correct_cfgs_flags_to_rustdoc() { } } "#, - ).file( + ) + .file( "libs/feature_a/Cargo.toml", r#" [package] @@ -2394,7 +2568,8 @@ fn pass_correct_cfgs_flags_to_rustdoc() { [build-dependencies] mock_serde_codegen = { path = "../mock_serde_codegen", optional = true } "#, - ).file( + ) + .file( "libs/feature_a/src/lib.rs", r#" #[cfg(feature = "mock_serde_derive")] @@ -2407,14 +2582,17 @@ fn pass_correct_cfgs_flags_to_rustdoc() { MSG } "#, - ).file( + ) + .file( "libs/mock_serde_derive/Cargo.toml", &basic_manifest("mock_serde_derive", "0.1.0"), - ).file("libs/mock_serde_derive/src/lib.rs", "") + ) + .file("libs/mock_serde_derive/src/lib.rs", "") .file( "libs/mock_serde_codegen/Cargo.toml", &basic_manifest("mock_serde_codegen", "0.1.0"), - ).file("libs/mock_serde_codegen/src/lib.rs", ""); + ) + .file("libs/mock_serde_codegen/src/lib.rs", ""); let p = p.build(); p.cargo("test --package feature_a --verbose") @@ -2422,14 +2600,16 @@ fn pass_correct_cfgs_flags_to_rustdoc() { "\ [DOCTEST] feature_a [RUNNING] `rustdoc --test [..]mock_serde_codegen[..]`", - ).run(); + ) + .run(); p.cargo("test --verbose") .with_stderr_contains( "\ [DOCTEST] foo [RUNNING] `rustdoc --test [..]feature_a[..]`", - ).run(); + ) + .run(); } #[test] @@ -2451,10 +2631,12 @@ fn test_release_ignore_panic() { [profile.release] panic = 'abort' "#, - ).file( + ) + .file( "src/lib.rs", "#[allow(unused_extern_crates)] extern crate a;", - ).file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", ""); let p = p.build(); println!("test"); @@ -2482,7 +2664,8 @@ fn test_many_with_features() { [workspace] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -2505,7 +2688,8 @@ fn test_all_workspace() { [workspace] "#, - ).file("src/main.rs", "#[test] fn foo_test() {}") + ) + .file("src/main.rs", "#[test] fn foo_test() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "#[test] fn bar_test() {}") .build(); @@ -2529,7 +2713,8 @@ fn test_all_exclude() { [workspace] members = ["bar", "baz"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/lib.rs", "#[test] pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) @@ -2540,7 +2725,8 @@ fn test_all_exclude() { .with_stdout_contains( "running 1 test test bar ... ok", - ).run(); + ) + .run(); } #[test] @@ -2552,7 +2738,8 @@ fn test_all_virtual_manifest() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) .file("a/src/lib.rs", "#[test] fn a() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) .file("b/src/lib.rs", "#[test] fn b() {}") @@ -2573,7 +2760,8 @@ fn test_virtual_manifest_all_implied() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) .file("a/src/lib.rs", "#[test] fn a() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) .file("b/src/lib.rs", "#[test] fn b() {}") @@ -2594,7 +2782,8 @@ fn test_all_member_dependency_same_name() { [workspace] members = ["a"] "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -2604,7 +2793,8 @@ fn test_all_member_dependency_same_name() { [dependencies] a = "0.1.0" "#, - ).file("a/src/lib.rs", "#[test] fn a() {}") + ) + .file("a/src/lib.rs", "#[test] fn a() {}") .build(); Package::new("a", "0.1.0").publish(); @@ -2627,7 +2817,8 @@ fn doctest_only_with_dev_dep() { [dev-dependencies] b = { path = "b" } "#, - ).file( + ) + .file( "src/lib.rs", r#" /// ``` @@ -2637,7 +2828,8 @@ fn doctest_only_with_dev_dep() { /// ``` pub fn a() {} "#, - ).file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) + ) + .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) .file("b/src/lib.rs", "pub fn b() {}") .build(); @@ -2653,31 +2845,36 @@ fn test_many_targets() { fn main() {} #[test] fn bin_a() {} "#, - ).file( + ) + .file( "src/bin/b.rs", r#" fn main() {} #[test] fn bin_b() {} "#, - ).file( + ) + .file( "src/bin/c.rs", r#" fn main() {} #[test] fn bin_c() { panic!(); } "#, - ).file( + ) + .file( "examples/a.rs", r#" fn main() {} #[test] fn example_a() {} "#, - ).file( + ) + .file( "examples/b.rs", r#" fn main() {} #[test] fn example_b() {} "#, - ).file("examples/c.rs", "#[test] fn example_c() { panic!(); }") + ) + .file("examples/c.rs", "#[test] fn example_c() { panic!(); }") .file("tests/a.rs", "#[test] fn test_a() {}") .file("tests/b.rs", "#[test] fn test_b() {}") .file("tests/c.rs", "does not compile") @@ -2709,7 +2906,8 @@ fn doctest_and_registry() { [workspace] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) .file( "b/src/lib.rs", @@ -2719,7 +2917,8 @@ fn doctest_and_registry() { /// ``` pub fn foo() {} ", - ).file( + ) + .file( "c/Cargo.toml", r#" [project] @@ -2729,7 +2928,8 @@ fn doctest_and_registry() { [dependencies] b = "0.1" "#, - ).file("c/src/lib.rs", "") + ) + .file("c/src/lib.rs", "") .build(); Package::new("b", "0.1.0").publish(); @@ -2765,7 +2965,8 @@ fn cargo_test_env() { test env_test ... ok ", cargo.to_str().unwrap() - )).run(); + )) + .run(); } #[test] @@ -2796,7 +2997,8 @@ test test_z ... ok test result: ok. [..] ", - ).run(); + ) + .run(); } #[test] @@ -2812,7 +3014,8 @@ fn cyclic_dev() { [dev-dependencies] foo = { path = "." } "#, - ).file("src/lib.rs", "#[test] fn test_lib() {}") + ) + .file("src/lib.rs", "#[test] fn test_lib() {}") .file("tests/foo.rs", "extern crate foo;") .build(); @@ -2822,7 +3025,9 @@ fn cyclic_dev() { #[test] fn publish_a_crate_without_tests() { Package::new("testless", "0.1.0") - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" [project] name = "testless" version = "0.1.0" @@ -2830,15 +3035,14 @@ fn publish_a_crate_without_tests() { [[test]] name = "a_test" - "#) + "#, + ) .file("src/lib.rs", "") - // In real life, the package will have a test, // which would be excluded from .crate file by the // `exclude` field. Our test harness does not honor // exclude though, so let's just not add the file! // .file("tests/a_test.rs", "") - .publish(); let p = project() @@ -2852,7 +3056,8 @@ fn publish_a_crate_without_tests() { [dependencies] testless = "0.1.0" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("test").run(); @@ -2868,7 +3073,8 @@ fn find_dependency_of_proc_macro_dependency_with_target() { [workspace] members = ["root", "proc_macro_dep"] "#, - ).file( + ) + .file( "root/Cargo.toml", r#" [project] @@ -2879,7 +3085,8 @@ fn find_dependency_of_proc_macro_dependency_with_target() { [dependencies] proc_macro_dep = { path = "../proc_macro_dep" } "#, - ).file( + ) + .file( "root/src/lib.rs", r#" #[macro_use] @@ -2888,7 +3095,8 @@ fn find_dependency_of_proc_macro_dependency_with_target() { #[derive(Noop)] pub struct X; "#, - ).file( + ) + .file( "proc_macro_dep/Cargo.toml", r#" [project] @@ -2902,7 +3110,8 @@ fn find_dependency_of_proc_macro_dependency_with_target() { [dependencies] baz = "^0.1" "#, - ).file( + ) + .file( "proc_macro_dep/src/lib.rs", r#" extern crate baz; @@ -2914,7 +3123,8 @@ fn find_dependency_of_proc_macro_dependency_with_target() { "".parse().unwrap() } "#, - ).build(); + ) + .build(); Package::new("bar", "0.1.0").publish(); Package::new("baz", "0.1.0") .dep("bar", "0.1") @@ -2934,7 +3144,8 @@ fn test_hint_not_masked_by_doctest() { /// ``` pub fn this_works() {} "#, - ).file( + ) + .file( "tests/integ.rs", r#" #[test] @@ -2942,7 +3153,8 @@ fn test_hint_not_masked_by_doctest() { panic!(); } "#, - ).build(); + ) + .build(); p.cargo("test --no-fail-fast") .with_status(101) .with_stdout_contains("test this_fails ... FAILED") @@ -2950,7 +3162,8 @@ fn test_hint_not_masked_by_doctest() { .with_stderr_contains( "[ERROR] test failed, to rerun pass \ '--test integ'", - ).run(); + ) + .run(); } #[test] @@ -2962,7 +3175,8 @@ fn test_hint_workspace() { [workspace] members = ["a", "b"] "#, - ).file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) .file("a/src/lib.rs", "#[test] fn t1() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) .file("b/src/lib.rs", "#[test] fn t1() {assert!(false)}") @@ -2989,7 +3203,8 @@ fn json_artifact_includes_test_flag() { [profile.test] opt-level = 1 "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("test --lib -v --message-format=json") @@ -3018,7 +3233,8 @@ fn json_artifact_includes_test_flag() { "fresh": false } "#, - ).run(); + ) + .run(); } #[test] @@ -3029,7 +3245,8 @@ fn json_artifact_includes_executable_for_library_tests() { .build(); p.cargo("test --lib -v --no-run --message-format=json") - .with_json(r#" + .with_json( + r#" { "executable": "[..]/foo/target/debug/foo-[..][EXE]", "features": [], @@ -3046,18 +3263,23 @@ fn json_artifact_includes_executable_for_library_tests() { "src_path": "[..]/foo/src/lib.rs" } } - "#) + "#, + ) .run(); } #[test] fn json_artifact_includes_executable_for_integration_tests() { let p = project() - .file("tests/integration_test.rs", r#"#[test] fn integration_test() {}"#) + .file( + "tests/integration_test.rs", + r#"#[test] fn integration_test() {}"#, + ) .build(); p.cargo("test -v --no-run --message-format=json --test integration_test") - .with_json(r#" + .with_json( + r#" { "executable": "[..]/foo/target/debug/integration_test-[..][EXE]", "features": [], @@ -3074,7 +3296,8 @@ fn json_artifact_includes_executable_for_integration_tests() { "src_path": "[..]/foo/tests/integration_test.rs" } } - "#) + "#, + ) .run(); } @@ -3092,7 +3315,8 @@ fn test_build_script_links() { [lib] test = false "#, - ).file("build.rs", "fn main() {}") + ) + .file("build.rs", "fn main() {}") .file("src/lib.rs", "") .build(); @@ -3112,14 +3336,16 @@ fn doctest_skip_staticlib() { [lib] crate-type = ["staticlib"] "#, - ).file( + ) + .file( "src/lib.rs", r#" //! ``` //! assert_eq!(1,2); //! ``` "#, - ).build(); + ) + .build(); p.cargo("test --doc") .with_status(101) @@ -3127,7 +3353,8 @@ fn doctest_skip_staticlib() { "\ [WARNING] doc tests are not supported for crate type(s) `staticlib` in package `foo` [ERROR] no library targets found in package `foo`", - ).run(); + ) + .run(); p.cargo("test") .with_stderr( @@ -3135,13 +3362,16 @@ fn doctest_skip_staticlib() { [COMPILING] foo [..] [FINISHED] dev [..] [RUNNING] target/debug/deps/foo-[..]", - ).run(); + ) + .run(); } #[test] fn can_not_mix_doc_tests_and_regular_tests() { let p = project() - .file("src/lib.rs", "\ + .file( + "src/lib.rs", + "\ /// ``` /// assert_eq!(1, 1) /// ``` @@ -3150,17 +3380,21 @@ pub fn foo() -> u8 { 1 } #[cfg(test)] mod tests { #[test] fn it_works() { assert_eq!(2 + 2, 4); } } -") +", + ) .build(); p.cargo("test") - .with_stderr("\ + .with_stderr( + "\ [COMPILING] foo v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..] [DOCTEST] foo -") - .with_stdout(" +", + ) + .with_stdout( + " running 1 test test tests::it_works ... ok @@ -3171,33 +3405,43 @@ running 1 test test src/lib.rs - foo (line 1) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -\n") +\n", + ) .run(); p.cargo("test --lib") - .with_stderr("\ + .with_stderr( + "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] -[RUNNING] target/debug/deps/foo-[..]\n") - .with_stdout(" +[RUNNING] target/debug/deps/foo-[..]\n", + ) + .with_stdout( + " running 1 test test tests::it_works ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -\n") +\n", + ) .run(); p.cargo("test --doc") - .with_stderr("\ + .with_stderr( + "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [DOCTEST] foo -") - .with_stdout(" +", + ) + .with_stdout( + " running 1 test test src/lib.rs - foo (line 1) ... ok test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out -").run(); +", + ) + .run(); p.cargo("test --lib --doc") .with_status(101) @@ -3216,10 +3460,10 @@ fn test_all_targets_lib() { [FINISHED] dev [..] [RUNNING] [..]foo[..] ", - ).run(); + ) + .run(); } - #[test] fn test_dep_with_dev() { Package::new("devdep", "0.1.0").publish(); diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index ce06fd54283..edb0e774a55 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -18,7 +18,8 @@ fn pathless_tools() { "#, target ), - ).build(); + ) + .build(); foo.cargo("build --verbose") .with_stderr( @@ -27,7 +28,8 @@ fn pathless_tools() { [RUNNING] `rustc [..] -C ar=nonexistent-ar -C linker=nonexistent-linker [..]` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -59,7 +61,8 @@ fn absolute_tools() { ar = config.0, linker = config.1 ), - ).build(); + ) + .build(); foo.cargo("build --verbose").with_stderr("\ [COMPILING] foo v0.5.0 ([CWD]) @@ -97,7 +100,8 @@ fn relative_tools() { ar = config.0, linker = config.1 ), - ).build(); + ) + .build(); let prefix = p.root().into_os_string().into_string().unwrap(); @@ -128,7 +132,8 @@ fn custom_runner() { "#, target ), - ).build(); + ) + .build(); p.cargo("run -- --param") .with_status(101) @@ -138,7 +143,8 @@ fn custom_runner() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param` ", - ).run(); + ) + .run(); p.cargo("test --test test --verbose -- --param") .with_status(101) @@ -149,7 +155,8 @@ fn custom_runner() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `nonexistent-runner -r [..]/target/debug/deps/test-[..][EXE] --param` ", - ).run(); + ) + .run(); p.cargo("bench --bench bench --verbose -- --param") .with_status(101) @@ -161,7 +168,8 @@ fn custom_runner() { [FINISHED] release [optimized] target(s) in [..] [RUNNING] `nonexistent-runner -r [..]/target/release/deps/bench-[..][EXE] --param --bench` ", - ).run(); + ) + .run(); } // can set a custom runner via `target.'cfg(..)'.runner` @@ -175,7 +183,8 @@ fn custom_runner_cfg() { [target.'cfg(not(target_os = "none"))'] runner = "nonexistent-runner -r" "#, - ).build(); + ) + .build(); p.cargo("run -- --param") .with_status(101) @@ -185,7 +194,8 @@ fn custom_runner_cfg() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param` ", - )).run(); + )) + .run(); } // custom runner set via `target.$triple.runner` have precende over `target.'cfg(..)'.runner` @@ -207,7 +217,8 @@ fn custom_runner_cfg_precedence() { "#, target ), - ).build(); + ) + .build(); p.cargo("run -- --param") .with_status(101) @@ -217,7 +228,8 @@ fn custom_runner_cfg_precedence() { [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] `nonexistent-runner -r target/debug/foo[EXE] --param` ", - )).run(); + )) + .run(); } #[test] @@ -233,7 +245,8 @@ fn custom_runner_cfg_collision() { [target.'cfg(not(target_os = "none"))'] runner = "false" "#, - ).build(); + ) + .build(); p.cargo("run -- --param") .with_status(101) @@ -241,5 +254,6 @@ fn custom_runner_cfg_collision() { "\ [ERROR] several matching instances of `target.'cfg(..)'.runner` in `.cargo/config` ", - )).run(); + )) + .run(); } diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index e0de2b5ccaf..f1641d8f93c 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -20,7 +20,8 @@ fn minor_update_two_places() { log = "0.1" foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -32,7 +33,8 @@ fn minor_update_two_places() { [dependencies] log = "0.1" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -50,7 +52,8 @@ fn minor_update_two_places() { [dependencies] log = "0.1.1" "#, - ).unwrap(); + ) + .unwrap(); p.cargo("build").run(); } @@ -74,7 +77,8 @@ fn transitive_minor_update() { log = "0.1" foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -86,7 +90,8 @@ fn transitive_minor_update() { [dependencies] serde = "0.1" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -108,7 +113,8 @@ fn transitive_minor_update() { "\ [UPDATING] `[..]` index ", - ).run(); + ) + .run(); } #[test] @@ -130,7 +136,8 @@ fn conservative() { log = "0.1" foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -142,7 +149,8 @@ fn conservative() { [dependencies] serde = "0.1" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -156,7 +164,8 @@ fn conservative() { [UPDATING] `[..]` index [UPDATING] serde v0.1.0 -> v0.1.1 ", - ).run(); + ) + .run(); } #[test] @@ -175,7 +184,8 @@ fn update_via_new_dep() { log = "0.1" # foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -187,7 +197,8 @@ fn update_via_new_dep() { [dependencies] log = "0.1.1" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -215,7 +226,8 @@ fn update_via_new_member() { [dependencies] log = "0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -227,7 +239,8 @@ fn update_via_new_member() { [dependencies] log = "0.1.1" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -253,7 +266,8 @@ fn add_dep_deep_new_requirement() { log = "0.1" # bar = "0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -282,7 +296,8 @@ fn everything_real_deep() { foo = "0.1" # bar = "0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -308,7 +323,8 @@ fn change_package_version() { [dependencies] bar = { path = "bar", version = "0.2.0-alpha" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.2.0-alpha")) .file("bar/src/lib.rs", "") .file( @@ -323,7 +339,8 @@ fn change_package_version() { name = "bar" version = "0.2.0" "#, - ).build(); + ) + .build(); p.cargo("build").run(); } @@ -347,7 +364,8 @@ fn update_precise() { serde = "0.2" foo = { path = "foo" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "foo/Cargo.toml", r#" @@ -359,7 +377,8 @@ fn update_precise() { [dependencies] serde = "0.1" "#, - ).file("foo/src/lib.rs", "") + ) + .file("foo/src/lib.rs", "") .build(); p.cargo("build").run(); @@ -372,7 +391,8 @@ fn update_precise() { [UPDATING] `[..]` index [UPDATING] serde v0.2.1 -> v0.2.0 ", - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/verify_project.rs b/tests/testsuite/verify_project.rs index 3c15b9cef21..15626826e1d 100644 --- a/tests/testsuite/verify_project.rs +++ b/tests/testsuite/verify_project.rs @@ -46,13 +46,16 @@ fn cargo_verify_project_cwd() { #[test] fn cargo_verify_project_honours_unstable_features() { let p = project() - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" cargo-features = ["test-dummy-unstable"] [package] name = "foo" version = "0.0.1" - "#) + "#, + ) .file("src/lib.rs", "") .build(); diff --git a/tests/testsuite/version.rs b/tests/testsuite/version.rs index 6a3e2576a7f..82395c583e4 100644 --- a/tests/testsuite/version.rs +++ b/tests/testsuite/version.rs @@ -1,5 +1,5 @@ -use cargo; use crate::support::project; +use cargo; #[test] fn simple() { @@ -36,6 +36,7 @@ fn version_works_with_bad_target_dir() { [build] target-dir = 4 "#, - ).build(); + ) + .build(); p.cargo("version").run(); } diff --git a/tests/testsuite/warn_on_failure.rs b/tests/testsuite/warn_on_failure.rs index a34fad970aa..4b10d20ae82 100644 --- a/tests/testsuite/warn_on_failure.rs +++ b/tests/testsuite/warn_on_failure.rs @@ -15,7 +15,8 @@ fn make_lib(lib_src: &str) { version = "0.0.1" build = "build.rs" "#, - ).file( + ) + .file( "build.rs", &format!( r#" @@ -29,7 +30,8 @@ fn make_lib(lib_src: &str) { "#, WARNING1, WARNING2 ), - ).file("src/lib.rs", &format!("fn f() {{ {} }}", lib_src)) + ) + .file("src/lib.rs", &format!("fn f() {{ {} }}", lib_src)) .publish(); } @@ -46,7 +48,8 @@ fn make_upstream(main_src: &str) -> Project { [dependencies] bar = "*" "#, - ).file("src/main.rs", &format!("fn main() {{ {} }}", main_src)) + ) + .file("src/main.rs", &format!("fn main() {{ {} }}", main_src)) .build() } @@ -65,7 +68,8 @@ fn no_warning_on_success() { [COMPILING] foo v0.0.1 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index ebe26276b2c..199b4194283 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -20,7 +20,8 @@ fn simple_explicit() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -30,7 +31,8 @@ fn simple_explicit() { authors = [] workspace = ".." "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").run(); @@ -60,7 +62,8 @@ fn simple_explicit_default_members() { members = ["bar"] default-members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -70,7 +73,8 @@ fn simple_explicit_default_members() { authors = [] workspace = ".." "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").run(); @@ -92,7 +96,8 @@ fn inferred_root() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); @@ -125,7 +130,8 @@ fn inferred_path_dep() { [workspace] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}") .file("bar/src/lib.rs", ""); @@ -159,7 +165,8 @@ fn transitive_path_dep() { [workspace] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -171,7 +178,8 @@ fn transitive_path_dep() { [dependencies] baz = { path = "../baz" } "#, - ).file("bar/src/main.rs", "fn main() {}") + ) + .file("bar/src/main.rs", "fn main() {}") .file("bar/src/lib.rs", "") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("baz/src/main.rs", "fn main() {}") @@ -214,7 +222,8 @@ fn parent_pointer_works() { [workspace] "#, - ).file("foo/src/main.rs", "fn main() {}") + ) + .file("foo/src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -224,7 +233,8 @@ fn parent_pointer_works() { authors = [] workspace = "../foo" "#, - ).file("bar/src/main.rs", "fn main() {}") + ) + .file("bar/src/main.rs", "fn main() {}") .file("bar/src/lib.rs", ""); let p = p.build(); @@ -248,7 +258,8 @@ fn same_names_in_workspace() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -258,7 +269,8 @@ fn same_names_in_workspace() { authors = [] workspace = ".." "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -269,7 +281,8 @@ error: two packages named `foo` in this workspace: - [..]Cargo.toml - [..]Cargo.toml ", - ).run(); + ) + .run(); } #[test] @@ -285,7 +298,8 @@ fn parent_doesnt_point_to_child() { [workspace] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); @@ -301,7 +315,8 @@ workspace: [..]Cargo.toml this may be fixable [..] ", - ).run(); + ) + .run(); } #[test] @@ -316,7 +331,8 @@ fn invalid_parent_pointer() { authors = [] workspace = "foo" "#, - ).file("src/main.rs", "fn main() {}"); + ) + .file("src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -328,7 +344,8 @@ error: failed to read `[..]Cargo.toml` Caused by: [..] ", - ).run(); + ) + .run(); } #[test] @@ -345,7 +362,8 @@ fn invalid_members() { [workspace] members = ["foo"] "#, - ).file("src/main.rs", "fn main() {}"); + ) + .file("src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -357,7 +375,8 @@ error: failed to read `[..]Cargo.toml` Caused by: [..] ", - ).run(); + ) + .run(); } #[test] @@ -373,7 +392,8 @@ fn bare_workspace_ok() { [workspace] "#, - ).file("src/main.rs", "fn main() {}"); + ) + .file("src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").run(); @@ -393,7 +413,8 @@ fn two_roots() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -405,7 +426,8 @@ fn two_roots() { [workspace] members = [".."] "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -416,7 +438,8 @@ error: multiple workspace roots found in the same workspace: [..] [..] ", - ).run(); + ) + .run(); } #[test] @@ -431,7 +454,8 @@ fn workspace_isnt_root() { authors = [] workspace = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); @@ -456,7 +480,8 @@ fn dangling_member() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -466,7 +491,8 @@ fn dangling_member() { authors = [] workspace = "../baz" "#, - ).file("bar/src/main.rs", "fn main() {}") + ) + .file("bar/src/main.rs", "fn main() {}") .file( "baz/Cargo.toml", r#" @@ -476,7 +502,8 @@ fn dangling_member() { authors = [] workspace = "../baz" "#, - ).file("baz/src/main.rs", "fn main() {}"); + ) + .file("baz/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -487,7 +514,8 @@ error: package `[..]` is a member of the wrong workspace expected: [..] actual: [..] ", - ).run(); + ) + .run(); } #[test] @@ -502,7 +530,8 @@ fn cycle() { authors = [] workspace = "bar" "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -512,7 +541,8 @@ fn cycle() { authors = [] workspace = ".." "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").with_status(101).run(); @@ -535,7 +565,8 @@ fn share_dependencies() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -547,7 +578,8 @@ fn share_dependencies() { [dependencies] dep1 = "< 0.1.5" "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); Package::new("dep1", "0.1.3").publish(); @@ -563,7 +595,8 @@ fn share_dependencies() { [COMPILING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -580,7 +613,8 @@ fn fetch_fetches_all() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -592,7 +626,8 @@ fn fetch_fetches_all() { [dependencies] dep1 = "*" "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); Package::new("dep1", "0.1.3").publish(); @@ -604,7 +639,8 @@ fn fetch_fetches_all() { [DOWNLOADING] crates ... [DOWNLOADED] dep1 v0.1.3 ([..]) ", - ).run(); + ) + .run(); } #[test] @@ -624,7 +660,8 @@ fn lock_works_for_everyone() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -636,7 +673,8 @@ fn lock_works_for_everyone() { [dependencies] dep1 = "0.1" "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); Package::new("dep1", "0.1.0").publish(); @@ -658,7 +696,8 @@ fn lock_works_for_everyone() { [COMPILING] foo v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); p.cargo("build") .cwd(p.root().join("bar")) @@ -670,7 +709,8 @@ fn lock_works_for_everyone() { [COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -682,7 +722,8 @@ fn virtual_works() { [workspace] members = ["bar"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").cwd(p.root().join("bar")).run(); @@ -700,7 +741,8 @@ fn explicit_package_argument_works_with_virtual_manifest() { [workspace] members = ["bar"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .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").run(); @@ -717,7 +759,8 @@ fn virtual_misconfigure() { r#" [workspace] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -732,7 +775,8 @@ workspace: [..]Cargo.toml this may be fixable by adding `bar` to the `workspace.members` array of the \ manifest located at: [..] ", - ).run(); + ) + .run(); } #[test] @@ -744,7 +788,8 @@ fn virtual_build_all_implied() { [workspace] members = ["bar"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").run(); @@ -760,7 +805,8 @@ fn virtual_default_members() { members = ["bar", "baz"] default-members = ["bar"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("bar/src/main.rs", "fn main() {}") .file("baz/src/main.rs", "fn main() {}"); @@ -780,7 +826,8 @@ fn virtual_default_member_is_not_a_member() { members = ["bar"] default-members = ["something-else"] "#, - ).file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build") @@ -790,7 +837,8 @@ fn virtual_default_member_is_not_a_member() { error: package `[..]something-else` is listed in workspace’s default-members \ but is not a member. ", - ).run(); + ) + .run(); } #[test] @@ -809,7 +857,8 @@ fn virtual_build_no_members() { error: manifest path `[..]` contains no package: The manifest is virtual, \ and the workspace has no members. ", - ).run(); + ) + .run(); } #[test] @@ -825,7 +874,8 @@ fn include_virtual() { [workspace] members = ["bar"] "#, - ).file("src/main.rs", "") + ) + .file("src/main.rs", "") .file( "bar/Cargo.toml", r#" @@ -841,7 +891,8 @@ error: multiple workspace roots found in the same workspace: [..] [..] ", - ).run(); + ) + .run(); } #[test] @@ -861,7 +912,8 @@ fn members_include_path_deps() { [dependencies] p3 = { path = "p3" } "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "p1/Cargo.toml", r#" @@ -873,7 +925,8 @@ fn members_include_path_deps() { [dependencies] p2 = { path = "../p2" } "#, - ).file("p1/src/lib.rs", "") + ) + .file("p1/src/lib.rs", "") .file("p2/Cargo.toml", &basic_manifest("p2", "0.1.0")) .file("p2/src/lib.rs", "") .file("p3/Cargo.toml", &basic_manifest("p3", "0.1.0")) @@ -904,7 +957,8 @@ fn new_warns_you_this_will_not_work() { [workspace] "#, - ).file("src/lib.rs", ""); + ) + .file("src/lib.rs", ""); let p = p.build(); p.cargo("new --lib bar") @@ -922,7 +976,8 @@ this may be fixable by ensuring that this crate is depended on by the workspace root: [..] [CREATED] library `bar` package ", - ).run(); + ) + .run(); } #[test] @@ -942,7 +997,8 @@ fn lock_doesnt_change_depending_on_crate() { [dependencies] foo = "*" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "baz/Cargo.toml", r#" @@ -954,7 +1010,8 @@ fn lock_doesnt_change_depending_on_crate() { [dependencies] bar = "*" "#, - ).file("baz/src/lib.rs", ""); + ) + .file("baz/src/lib.rs", ""); let p = p.build(); Package::new("foo", "1.0.0").publish(); @@ -982,13 +1039,15 @@ fn rebuild_please() { [workspace] members = ['lib', 'bin'] "#, - ).file("lib/Cargo.toml", &basic_manifest("lib", "0.1.0")) + ) + .file("lib/Cargo.toml", &basic_manifest("lib", "0.1.0")) .file( "lib/src/lib.rs", r#" pub fn foo() -> u32 { 0 } "#, - ).file( + ) + .file( "bin/Cargo.toml", r#" [package] @@ -998,7 +1057,8 @@ fn rebuild_please() { [dependencies] lib = { path = "../lib" } "#, - ).file( + ) + .file( "bin/src/main.rs", r#" extern crate lib; @@ -1035,9 +1095,11 @@ fn workspace_in_git() { [workspace] members = ["foo"] "#, - ).file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) + ) + .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "") - }).unwrap(); + }) + .unwrap(); let p = project() .file( "Cargo.toml", @@ -1052,7 +1114,8 @@ fn workspace_in_git() { "#, git_project.url() ), - ).file( + ) + .file( "src/lib.rs", r#" pub fn foo() -> u32 { 0 } @@ -1072,7 +1135,8 @@ fn lockfile_can_specify_nonexistant_members() { [workspace] members = ["a"] "#, - ).file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) + ) + .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) .file("a/src/main.rs", "fn main() {}") .file( "Cargo.lock", @@ -1100,7 +1164,8 @@ fn you_cannot_generate_lockfile_for_empty_workspaces() { r#" [workspace] "#, - ).file("bar/Cargo.toml", &basic_manifest("foo", "0.1.0")) + ) + .file("bar/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); @@ -1126,7 +1191,8 @@ fn workspace_with_transitive_dev_deps() { [workspace] "#, - ).file("src/main.rs", r#"fn main() {}"#) + ) + .file("src/main.rs", r#"fn main() {}"#) .file( "bar/Cargo.toml", r#" @@ -1138,7 +1204,8 @@ fn workspace_with_transitive_dev_deps() { [dev-dependencies.baz] path = "../baz" "#, - ).file( + ) + .file( "bar/src/lib.rs", r#" pub fn init() {} @@ -1151,7 +1218,8 @@ fn workspace_with_transitive_dev_deps() { baz::do_stuff(); } "#, - ).file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0")) + ) + .file("baz/Cargo.toml", &basic_manifest("baz", "0.5.0")) .file("baz/src/lib.rs", r#"pub fn do_stuff() {}"#); let p = p.build(); @@ -1187,7 +1255,8 @@ fn relative_path_for_member_works() { [workspace] members = ["../bar"] "#, - ).file("foo/src/main.rs", "fn main() {}") + ) + .file("foo/src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -1197,7 +1266,8 @@ fn relative_path_for_member_works() { authors = [] workspace = "../foo" "#, - ).file("bar/src/main.rs", "fn main() {}"); + ) + .file("bar/src/main.rs", "fn main() {}"); let p = p.build(); p.cargo("build").cwd(p.root().join("foo")).run(); @@ -1220,13 +1290,13 @@ fn relative_path_for_root_works() { [dependencies] subproj = { path = "./subproj" } "#, - ).file("src/main.rs", "fn main() {}") + ) + .file("src/main.rs", "fn main() {}") .file("subproj/Cargo.toml", &basic_manifest("subproj", "0.1.0")) .file("subproj/src/main.rs", "fn main() {}"); let p = p.build(); - p.cargo("build --manifest-path ./Cargo.toml") - .run(); + p.cargo("build --manifest-path ./Cargo.toml").run(); p.cargo("build --manifest-path ../Cargo.toml") .cwd(p.root().join("subproj")) @@ -1250,7 +1320,8 @@ fn path_dep_outside_workspace_is_not_member() { [workspace] "#, - ).file("ws/src/lib.rs", r"extern crate foo;") + ) + .file("ws/src/lib.rs", r"extern crate foo;") .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", ""); let p = p.build(); @@ -1276,10 +1347,12 @@ fn test_in_and_out_of_workspace() { [workspace] members = [ "../bar" ] "#, - ).file( + ) + .file( "ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }", - ).file( + ) + .file( "foo/Cargo.toml", r#" [project] @@ -1290,10 +1363,12 @@ fn test_in_and_out_of_workspace() { [dependencies] bar = { path = "../bar" } "#, - ).file( + ) + .file( "foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }", - ).file( + ) + .file( "bar/Cargo.toml", r#" [project] @@ -1302,7 +1377,8 @@ fn test_in_and_out_of_workspace() { version = "0.1.0" authors = [] "#, - ).file("bar/src/lib.rs", "pub fn f() { }"); + ) + .file("bar/src/lib.rs", "pub fn f() { }"); let p = p.build(); p.cargo("build").cwd(p.root().join("ws")).run(); @@ -1337,10 +1413,12 @@ fn test_path_dependency_under_member() { [workspace] "#, - ).file( + ) + .file( "ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }", - ).file( + ) + .file( "foo/Cargo.toml", r#" [project] @@ -1352,10 +1430,12 @@ fn test_path_dependency_under_member() { [dependencies] bar = { path = "./bar" } "#, - ).file( + ) + .file( "foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }", - ).file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) + ) + .file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("foo/bar/src/lib.rs", "pub fn f() { }"); let p = p.build(); @@ -1384,7 +1464,8 @@ fn excluded_simple() { [workspace] exclude = ["foo"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", ""); let p = p.build(); @@ -1410,7 +1491,8 @@ fn exclude_members_preferred() { members = ["foo/bar"] exclude = ["foo"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "") .file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -1442,7 +1524,8 @@ fn exclude_but_also_depend() { [workspace] exclude = ["foo"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "") .file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) @@ -1460,7 +1543,9 @@ fn exclude_but_also_depend() { #[test] fn glob_syntax() { let p = project() - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" [project] name = "foo" version = "0.1.0" @@ -1469,30 +1554,40 @@ fn glob_syntax() { [workspace] members = ["crates/*"] exclude = ["crates/qux"] - "#) + "#, + ) .file("src/main.rs", "fn main() {}") - .file("crates/bar/Cargo.toml", r#" + .file( + "crates/bar/Cargo.toml", + r#" [project] name = "bar" version = "0.1.0" authors = [] workspace = "../.." - "#) + "#, + ) .file("crates/bar/src/main.rs", "fn main() {}") - .file("crates/baz/Cargo.toml", r#" + .file( + "crates/baz/Cargo.toml", + r#" [project] name = "baz" version = "0.1.0" authors = [] workspace = "../.." - "#) + "#, + ) .file("crates/baz/src/main.rs", "fn main() {}") - .file("crates/qux/Cargo.toml", r#" + .file( + "crates/qux/Cargo.toml", + r#" [project] name = "qux" version = "0.1.0" authors = [] - "#) + "#, + ) .file("crates/qux/src/main.rs", "fn main() {}"); let p = p.build(); @@ -1584,7 +1679,9 @@ fn glob_syntax_2() { #[test] fn glob_syntax_invalid_members() { let p = project() - .file("Cargo.toml", r#" + .file( + "Cargo.toml", + r#" [project] name = "foo" version = "0.1.0" @@ -1592,7 +1689,8 @@ fn glob_syntax_invalid_members() { [workspace] members = ["crates/*"] - "#) + "#, + ) .file("src/main.rs", "fn main() {}") .file("crates/bar/src/main.rs", "fn main() {}"); let p = p.build(); @@ -1606,7 +1704,8 @@ error: failed to read `[..]Cargo.toml` Caused by: [..] ", - ).run(); + ) + .run(); } /// This is a freshness test for feature use with workspaces @@ -1626,7 +1725,8 @@ fn dep_used_with_separate_features() { [workspace] members = ["feat_lib", "caller1", "caller2"] "#, - ).file( + ) + .file( "feat_lib/Cargo.toml", r#" [project] @@ -1637,7 +1737,8 @@ fn dep_used_with_separate_features() { [features] myfeature = [] "#, - ).file("feat_lib/src/lib.rs", "") + ) + .file("feat_lib/src/lib.rs", "") .file( "caller1/Cargo.toml", r#" @@ -1649,7 +1750,8 @@ fn dep_used_with_separate_features() { [dependencies] feat_lib = { path = "../feat_lib" } "#, - ).file("caller1/src/main.rs", "fn main() {}") + ) + .file("caller1/src/main.rs", "fn main() {}") .file("caller1/src/lib.rs", "") .file( "caller2/Cargo.toml", @@ -1663,7 +1765,8 @@ fn dep_used_with_separate_features() { feat_lib = { path = "../feat_lib", features = ["myfeature"] } caller1 = { path = "../caller1" } "#, - ).file("caller2/src/main.rs", "fn main() {}") + ) + .file("caller2/src/main.rs", "fn main() {}") .file("caller2/src/lib.rs", ""); let p = p.build(); @@ -1676,7 +1779,8 @@ fn dep_used_with_separate_features() { [..]Compiling caller2 v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); assert!(p.bin("caller1").is_file()); assert!(p.bin("caller2").is_file()); @@ -1692,7 +1796,8 @@ fn dep_used_with_separate_features() { [..]Compiling caller1 v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); // Alternate building caller2/caller1 a few times, just to make sure // features are being built separately. Should not rebuild anything @@ -1738,7 +1843,8 @@ fn dont_recurse_out_of_cargo_home() { } "#, ) - }).unwrap(); + }) + .unwrap(); let p = project() .file( "Cargo.toml", @@ -1755,7 +1861,8 @@ fn dont_recurse_out_of_cargo_home() { "#, git_project.url() ), - ).file("src/lib.rs", ""); + ) + .file("src/lib.rs", ""); let p = p.build(); p.cargo("build") @@ -1799,7 +1906,8 @@ fn cargo_home_at_root_works() { [workspace] members = ["a"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) .file("a/src/lib.rs", ""); let p = p.build(); @@ -1825,7 +1933,8 @@ fn relative_rustc() { std::process::exit(cmd.status().unwrap().code().unwrap()); } "#, - ).build(); + ) + .build(); p.cargo("build").run(); let src = p @@ -1847,7 +1956,8 @@ fn relative_rustc() { [dependencies] a = "0.1" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); fs::copy(&src, p.root().join(src.file_name().unwrap())).unwrap(); @@ -1865,7 +1975,8 @@ fn ws_rustc_err() { [workspace] members = ["a"] "#, - ).file("a/Cargo.toml", &basic_lib_manifest("a")) + ) + .file("a/Cargo.toml", &basic_lib_manifest("a")) .file("a/src/lib.rs", "") .build();