diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index 8252af66f6b..575124213b4 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -565,10 +565,19 @@ impl Links { let pkg = unit.pkg.package_id(); let describe_path = |pkgid: PackageId| -> String { - let dep_path = resolve.path_to_top(&pkgid); - let mut dep_path_desc = format!("package `{}`", dep_path[0]); - for dep in dep_path.iter().skip(1) { - write!(dep_path_desc, "\n ... which is depended on by `{}`", dep).unwrap(); + let dep_path = resolve.graph().path_to_top(&pkgid); + let mut dep_path_desc = format!("package `{}`", pkgid); + for &(dep, req) in dep_path.iter() { + let req = req.first().unwrap(); + write!( + dep_path_desc, + "\n ... selected to fulfill the requirement \ + `{} = \"{}\"` from package `{}`", + req.name_in_toml(), + req.version_req(), + dep + ) + .unwrap(); } dep_path_desc }; diff --git a/src/cargo/core/resolver/errors.rs b/src/cargo/core/resolver/errors.rs index cb5679e7ac9..9b78663ce0a 100644 --- a/src/cargo/core/resolver/errors.rs +++ b/src/cargo/core/resolver/errors.rs @@ -81,9 +81,14 @@ pub(super) fn activation_error( let to_resolve_err = |err| { ResolveError::new( err, - graph - .path_to_top(&parent.package_id()) - .into_iter() + Some(parent.package_id()) + .iter() + .chain( + graph + .path_to_top(&parent.package_id()) + .into_iter() + .map(|x| x.0), + ) .cloned() .collect(), ) @@ -92,7 +97,11 @@ pub(super) fn activation_error( if !candidates.is_empty() { let mut msg = format!("failed to select a version for `{}`.", dep.package_name()); msg.push_str("\n ... required by "); - msg.push_str(&describe_path(&graph.path_to_top(&parent.package_id()))); + msg.push_str(&describe_path(&graph, parent.package_id())); + msg.push_str("which requires "); + msg.push_str(&dep.package_name()); + msg.push_str(" "); + msg.push_str(&dep.version_req().to_string()); msg.push_str("\nversions that meet the requirements `"); msg.push_str(&dep.version_req().to_string()); @@ -113,7 +122,7 @@ pub(super) fn activation_error( .rev() .partition(|&(_, r)| r.is_links()); - for &(p, r) in links_errors.iter() { + for &(&p, r) in links_errors.iter() { if let ConflictReason::Links(ref link) = *r { msg.push_str("\n\nthe package `"); msg.push_str(&*dep.package_name()); @@ -123,7 +132,7 @@ pub(super) fn activation_error( msg.push_str(link); msg.push_str("` as well:\n"); } - msg.push_str(&describe_path(&graph.path_to_top(p))); + msg.push_str(&describe_path(&graph, p)); } let (features_errors, other_errors): (Vec<_>, Vec<_>) = other_errors @@ -152,9 +161,9 @@ pub(super) fn activation_error( ); } - for &(p, _) in other_errors.iter() { + for &(&p, _) in other_errors.iter() { msg.push_str("\n\n previously selected "); - msg.push_str(&describe_path(&graph.path_to_top(p))); + msg.push_str(&describe_path(&graph, p)); } msg.push_str("\n\nfailed to select a version for `"); @@ -204,7 +213,7 @@ pub(super) fn activation_error( registry.describe_source(dep.source_id()), ); msg.push_str("required by "); - msg.push_str(&describe_path(&graph.path_to_top(&parent.package_id()))); + msg.push_str(&describe_path(&graph, parent.package_id())); // If we have a path dependency with a locked version, then this may // indicate that we updated a sub-package and forgot to run `cargo @@ -258,7 +267,7 @@ pub(super) fn activation_error( msg.push_str("\n"); } msg.push_str("required by "); - msg.push_str(&describe_path(&graph.path_to_top(&parent.package_id()))); + msg.push_str(&describe_path(&graph, parent.package_id())); msg }; @@ -278,11 +287,23 @@ pub(super) fn activation_error( } /// Returns String representation of dependency chain for a particular `pkgid`. -pub(super) fn describe_path(path: &[&PackageId]) -> String { +pub(super) fn describe_path( + graph: &::util::graph::Graph>, + this: PackageId, +) -> String { use std::fmt::Write; - let mut dep_path_desc = format!("package `{}`", path[0]); - for dep in path[1..].iter() { - write!(dep_path_desc, "\n ... which is depended on by `{}`", dep).unwrap(); + let path = &graph.path_to_top(&this); + let mut dep_path_desc = format!("package `{}`", this); + for &(dep, req) in path.iter() { + let req = req.first().unwrap(); + write!( + dep_path_desc, + "\n ... selected to fulfill the requirement `{} = \"{}\"` from package `{}`", + req.name_in_toml(), + req.version_req(), + dep + ) + .unwrap(); } dep_path_desc } diff --git a/src/cargo/core/resolver/mod.rs b/src/cargo/core/resolver/mod.rs index 6df605cb1b7..a6e1453a407 100644 --- a/src/cargo/core/resolver/mod.rs +++ b/src/cargo/core/resolver/mod.rs @@ -848,7 +848,7 @@ fn check_cycles(resolve: &Resolve, activations: &Activations) -> CargoResult<()> bail!( "cyclic package dependency: package `{}` depends on itself. Cycle:\n{}", id, - errors::describe_path(&resolve.path_to_top(&id)) + errors::describe_path(&resolve.graph(), id) ); } diff --git a/src/cargo/core/resolver/resolve.rs b/src/cargo/core/resolver/resolve.rs index 1b2e8dcb928..ded3ff8d2b9 100644 --- a/src/cargo/core/resolver/resolve.rs +++ b/src/cargo/core/resolver/resolve.rs @@ -54,12 +54,6 @@ impl Resolve { } } - /// Resolves one of the paths from the given dependent package up to - /// the root. - pub fn path_to_top<'a>(&'a self, pkg: &'a PackageId) -> Vec<&'a PackageId> { - self.graph.path_to_top(pkg) - } - pub fn register_used_patches(&mut self, patches: &HashMap>) { for summary in patches.values().flat_map(|v| v) { if self.iter().any(|id| id == summary.package_id()) { @@ -194,6 +188,10 @@ unable to verify that `{0}` is the same as when the lockfile was generated &self.replacements } + pub fn graph(&self) -> &Graph> { + &self.graph + } + pub fn features(&self, pkg: PackageId) -> &HashSet { self.features.get(&pkg).unwrap_or(&self.empty_features) } diff --git a/src/cargo/util/graph.rs b/src/cargo/util/graph.rs index 50df74f873e..6766521beda 100644 --- a/src/cargo/util/graph.rs +++ b/src/cargo/util/graph.rs @@ -72,23 +72,24 @@ impl Graph { /// Resolves one of the paths from the given dependent package up to /// the root. - pub fn path_to_top<'a>(&'a self, mut pkg: &'a N) -> Vec<&'a N> { + pub fn path_to_top<'s: 'q, 'q>(&'s self, mut pkg: &'q N) -> Vec<(&'s N, &'s E)> { // Note that this implementation isn't the most robust per se, we'll // likely have to tweak this over time. For now though it works for what // it's used for! - let mut result = vec![pkg]; - let first_pkg_depending_on = |pkg: &N, res: &[&N]| { + let mut result: Vec<(&'s N, &'s E)> = vec![]; + let first_pkg_depending_on = |pkg: &N, res: &[(&'s N, &'s E)]| { self.nodes .iter() .filter(|&(_, adjacent)| adjacent.contains_key(pkg)) // Note that we can have "cycles" introduced through dev-dependency // edges, so make sure we don't loop infinitely. - .find(|&(node, _)| !res.contains(&node)) - .map(|p| p.0) + .find(|&(node, _)| res.iter().find(|p| p.0 == node).is_none()) + // TODO: find_map would be clearer + .map(|(node, adjacent)| (node, adjacent.get(pkg).unwrap())) }; while let Some(p) = first_pkg_depending_on(pkg, &result) { result.push(p); - pkg = p; + pkg = p.0; } result } diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 09f044f7981..a4c8f0c40c9 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -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") @@ -1109,18 +1171,19 @@ fn incompatible_dependencies() { .with_stderr_contains( "\ error: failed to select a version for `bad`. - ... required by package `qux v0.1.0` - ... which is depended on by `foo v0.0.1 ([..])` + ... required by package `qux v0.1.0` which requires `bad >=1.0.1` + ... selected to fulfill the requirement `qux = \"^0.1.0\"` from package `foo v0.0.1 ([..])` versions that meet the requirements `>= 1.0.1` are: 1.0.2, 1.0.1 all possible versions conflict with previously selected packages. previously selected package `bad v1.0.0` - ... which is depended on by `baz v0.1.0` - ... which is depended on by `foo v0.0.1 ([..])` + ... selected to fulfill the requirement `bad = \"= 1.0.0\"` from package `baz v0.1.0` + ... selected to fulfill the requirement `baz = \"^0.1.0\"` from package `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") @@ -1153,21 +1217,22 @@ fn incompatible_dependencies_with_multi_semver() { .with_stderr_contains( "\ error: failed to select a version for `bad`. - ... required by package `foo v0.0.1 ([..])` + ... required by package `foo v0.0.1 ([..]) which requires `bad = >=1.0.1, <=2.0.0` versions that meet the requirements `>= 1.0.1, <= 2.0.0` are: 2.0.0, 1.0.1 all possible versions conflict with previously selected packages. previously selected package `bad v2.0.1` - ... which is depended on by `baz v0.1.0` - ... which is depended on by `foo v0.0.1 ([..])` + ... selected to fulfill the requirement `bad = \">= 2.0.1\"` from package `baz v0.1.0` + ... selected to fulfill the requirement `baz = \"^0.1.0\"` from package `foo v0.0.1 ([..])` previously selected package `bad v1.0.0` - ... which is depended on by `bar v0.1.0` - ... which is depended on by `foo v0.0.1 ([..])` + ... selected to fulfill the requirement `bad = \"= 1.0.0\"` from package `bar v0.1.0` + ... selected to fulfill the requirement `bar = \"^0.1.0\"` from package `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 @@ -1212,12 +1278,14 @@ fn compile_offline_while_transitive_dep_not_cached() { error: no matching package named `baz` found location searched: registry `[..]` required by package `bar v0.1.0` - ... which is depended on by `foo v0.0.1 ([CWD])` + ... selected to fulfill the requirement `bar = \"= 0.1.0\"` \ +from package `foo v0.0.1 ([CWD])` 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 +1302,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 +1357,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 +1371,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 +1397,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 +1426,8 @@ fn cargo_default_env_metadata_env_var() { ", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX, - )).run(); + )) + .run(); } #[test] @@ -1371,7 +1444,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 +1477,8 @@ fn crate_env_vars() { assert_eq!(s, VERSION); } "#, - ).file( + ) + .file( "src/lib.rs", r#" pub fn version() -> String { @@ -1415,13 +1490,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 +1516,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 +1531,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 +1582,8 @@ fn crate_library_path_env_var() { "##, dylib_path_envvar() ), - ).build(); + ) + .build(); setenv_for_removing_empty_component(p.cargo("run")).run(); } @@ -1536,14 +1618,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 +1651,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,15 +1681,18 @@ 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) .with_stderr( "\ [ERROR] cyclic package dependency: package `test v0.0.0 ([CWD])` depends on itself. Cycle: -package `test v0.0.0 ([CWD])`", - ).run(); +package `test v0.0.0 ([CWD])` + ... selected to fulfill the requirement `test = \"*\"` from package `test v0.0.0 ([..]foo)`", + ) + .run(); } #[test] @@ -1638,7 +1726,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 +1750,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 +1766,8 @@ fn lto_build() { -L dependency=[CWD]/target/release/deps` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1693,7 +1784,8 @@ fn verbose_build() { -L dependency=[CWD]/target/debug/deps` [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1711,7 +1803,8 @@ fn verbose_release_build() { -L dependency=[CWD]/target/release/deps` [FINISHED] release [optimized] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -1729,7 +1822,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 +1837,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 +1865,8 @@ fn verbose_release_build_deps() { ", prefix = env::consts::DLL_PREFIX, suffix = env::consts::DLL_SUFFIX - )).run(); + )) + .run(); } #[test] @@ -1796,26 +1892,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 +1944,8 @@ fn non_existing_example() { [[example]] name = "hello" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("test -v") @@ -1855,7 +1956,8 @@ fn non_existing_example() { Caused by: can't find `hello` example, specify example.path", - ).run(); + ) + .run(); } #[test] @@ -1874,7 +1976,8 @@ fn non_existing_binary() { Caused by: can't find `foo` bin, specify bin.path", - ).run(); + ) + .run(); } #[test] @@ -1891,7 +1994,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 +2004,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 +2019,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 +2029,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 +2044,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 +2053,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 +2067,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 +2076,8 @@ fn implicit_examples() { println!("{}, {}!", foo::get_hello(), foo::get_world()); } "#, - ).file( + ) + .file( "examples/goodbye.rs", r#" extern crate foo; @@ -1974,7 +2085,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 +2112,8 @@ fn standard_build_no_ndebug() { } } "#, - ).build(); + ) + .build(); p.cargo("build").run(); p.process(&p.bin("foo")).with_stdout("slow\n").run(); @@ -2021,7 +2134,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 +2163,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 +2193,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 +2202,8 @@ fn lib_with_standard_name() { [COMPILING] syntax v0.0.1 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2104,7 +2221,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 +2244,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 +2265,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 +2287,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 +2306,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 +2318,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 +2343,8 @@ fn rebuild_preserves_out_dir() { authors = [] build = 'build.rs' "#, - ).file( + ) + .file( "build.rs", r#" use std::env; @@ -2236,7 +2360,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 +2372,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 +2382,8 @@ fn rebuild_preserves_out_dir() { [COMPILING] foo v0.0.0 ([CWD]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] ", - ).run(); + ) + .run(); } #[test] @@ -2273,7 +2400,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 +2423,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 +2472,8 @@ Caused by: Caused by: expected an equals, found an identifier at line 1 ", - ).run(); + ) + .run(); } #[test] @@ -2369,14 +2499,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 +2538,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 +2565,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 +2603,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 +2627,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 +2651,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 +2679,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 +2736,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 +2752,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 +2778,8 @@ fn cyclic_deps_rejected() { [dependencies.a] path = "a" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .file( "a/Cargo.toml", r#" @@ -2646,7 +2791,8 @@ fn cyclic_deps_rejected() { [dependencies.foo] path = ".." "#, - ).file("a/src/lib.rs", "") + ) + .file("a/src/lib.rs", "") .build(); p.cargo("build -v") @@ -2654,7 +2800,8 @@ fn cyclic_deps_rejected() { .with_stderr( "[ERROR] cyclic package dependency: package `a v0.0.1 ([CWD]/a)` depends on itself. Cycle: package `a v0.0.1 ([CWD]/a)` - ... which is depended on by `foo v0.0.1 ([CWD])`", + ... selected to fulfill the requirement `a = \"*\"` from package `foo v0.0.1 ([..]foo)` + ... selected to fulfill the requirement `foo = \"*\"` from package `a v0.0.1 ([..]a)`", ).run(); } @@ -2673,7 +2820,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 +2856,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 +2878,8 @@ fn rustc_env_var() { Caused by: [..] ", - ).run(); + ) + .run(); assert!(!p.bin("a").is_file()); } @@ -2838,7 +2988,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 +3018,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 +3028,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 +3057,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 +3074,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 +3116,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 +3145,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 +3165,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 +3192,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 +3211,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(); @@ -3167,7 +3326,8 @@ fn compiler_json_error_format() { "fresh": false } "#, - ).run(); + ) + .run(); // With fresh build, we should repeat the artifacts, // but omit compiler warnings. @@ -3249,7 +3409,8 @@ fn compiler_json_error_format() { "fresh": true } "#, - ).run(); + ) + .run(); } #[test] @@ -3266,7 +3427,8 @@ fn wrong_message_format_option() { error: 'XML' isn't a valid value for '--message-format ' [possible values: human, json, short] ", - ).run(); + ) + .run(); } #[test] @@ -3314,7 +3476,8 @@ fn message_format_json_forward_stderr() { "fresh": false } "#, - ).run(); + ) + .run(); } #[test] @@ -3336,13 +3499,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] @@ -3374,7 +3539,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(); @@ -3384,7 +3550,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] @@ -3400,7 +3567,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")) @@ -3429,7 +3597,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() {}") @@ -3447,7 +3616,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()); @@ -3467,7 +3637,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() {}") @@ -3481,7 +3652,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] @@ -3493,7 +3665,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() {}") @@ -3507,7 +3680,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] @@ -3519,7 +3693,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() {}") @@ -3531,7 +3706,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] @@ -3543,7 +3719,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() {}") @@ -3565,7 +3742,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()); @@ -3585,7 +3763,8 @@ fn build_all_member_dependency_same_name() { [workspace] members = ["a"] "#, - ).file( + ) + .file( "a/Cargo.toml", r#" [project] @@ -3595,7 +3774,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(); @@ -3608,7 +3788,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] @@ -3626,11 +3807,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(); @@ -3662,7 +3845,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(); @@ -3686,7 +3870,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(); @@ -3701,7 +3886,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(); @@ -3739,7 +3925,8 @@ fn cdylib_not_lifted() { [lib] crate-type = ["cdylib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -3772,7 +3959,8 @@ fn cdylib_final_outputs() { [lib] crate-type = ["cdylib"] "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build").run(); @@ -3812,7 +4000,8 @@ fn deterministic_cfg_flags() { f_c = [] f_d = [] "#, - ).file( + ) + .file( "build.rs", r#" fn main() { @@ -3823,7 +4012,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") @@ -3837,7 +4027,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] @@ -3857,7 +4048,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(); @@ -3881,7 +4073,8 @@ fn no_bin_in_src_with_lib() { Caused by: can't find `foo` bin, specify bin.path", - ).run(); + ) + .run(); } #[test] @@ -3928,7 +4121,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(); @@ -3983,7 +4177,8 @@ fn target_edition() { [lib] edition = "2018" "#, - ).file("src/lib.rs", "") + ) + .file("src/lib.rs", "") .build(); p.cargo("build -v") @@ -3993,7 +4188,8 @@ fn target_edition() { [COMPILING] foo v0.0.1 ([..]) [RUNNING] `rustc [..]--edition=2018 [..] ", - ).run(); + ) + .run(); } #[test] @@ -4011,13 +4207,14 @@ fn target_edition_override() { [lib] edition = "2015" "#, - ).file( + ) + .file( "src/lib.rs", " pub fn async() {} pub fn try() {} pub fn await() {} - " + ", ) .build(); @@ -4065,7 +4262,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() @@ -4079,7 +4277,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") @@ -4103,13 +4302,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()); } @@ -4149,23 +4347,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`. @@ -4173,15 +4376,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] @@ -4189,17 +4394,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] @@ -4207,13 +4419,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] @@ -4221,13 +4438,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] @@ -4244,7 +4466,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#" @@ -4255,14 +4478,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] @@ -4280,7 +4505,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(); @@ -4312,7 +4538,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")) @@ -4327,7 +4554,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) @@ -4351,7 +4579,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() {}") @@ -4413,14 +4642,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_script.rs b/tests/testsuite/build_script.rs index b04707df75d..d07f591a464 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -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,14 +307,15 @@ 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(); p.cargo("build").with_status(101) .with_stderr("\ error: failed to select a version for `a-sys`. - ... required by package `foo v0.5.0 ([..])` + ... required by package `foo v0.5.0 ([..]) which requires ` versions that meet the requirements `*` are: 0.5.0 the package `a-sys` links to the native library `a`, but it conflicts with a previous package which links to `a` as well: @@ -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,15 +370,16 @@ 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(); p.cargo("build").with_status(101) .with_stderr("\ error: failed to select a version for `a-sys`. - ... required by package `a v0.5.0 ([..])` - ... which is depended on by `foo v0.5.0 ([..])` + ... required by package `a v0.5.0 ([..]) which requires a-sys = *` + ... selected to fulfill the requirement `a = \"*\"` from package `foo v0.5.0 ([..])` versions that meet the requirements `*` are: 0.5.0 the package `a-sys` links to the native library `a`, but it conflicts with a previous package which links to `a` as well: @@ -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,13 +3404,14 @@ 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) .with_stderr("\ error: failed to select a version for `a`. - ... required by package `foo v0.5.0 ([..])` + ... required by package `foo v0.5.0 ([..])` which requires `a-sys *` versions that meet the requirements `*` are: 0.5.0 the package `a` links to the native library `a`, but it conflicts with a previous package which links to `a` as well: @@ -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/features.rs b/tests/testsuite/features.rs index daf68a6053d..829654cf850 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -124,7 +124,7 @@ fn invalid4() { .with_stderr( "\ error: failed to select a version for `bar`. - ... required by package `foo v0.0.1 ([..])` + ... required by package `foo v0.0.1 ([..])` which requires bar * versions that meet the requirements `*` are: 0.0.1 the package `foo` depends on `bar`, with features: `bar` but `bar` does not have these features. diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index 804eba4bccb..1034307c06e 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -524,7 +524,7 @@ error: failed to select a version for the requirement `baz = \"= 0.0.2\"` candidate versions found which didn't match: 0.0.1 location searched: `[..]` index (which is replacing registry `[..]`) required by package `bar v0.0.1` - ... which is depended on by `foo [..]` + ... which is depended on by `foo [..] which requires bar = *` ", ).run(); }