From ca7d9ee29288d0bd416ad09ac3451bd78b928288 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 25 Jul 2018 01:30:32 +0100 Subject: [PATCH] Declare one-line files on one line, in test projects --- tests/testsuite/bad_config.rs | 56 +---- tests/testsuite/bench.rs | 92 ++------ tests/testsuite/build.rs | 316 ++++--------------------- tests/testsuite/build_lib.rs | 21 +- tests/testsuite/build_script.rs | 277 +++------------------- tests/testsuite/build_script_env.rs | 14 +- tests/testsuite/cargo_alias_config.rs | 49 +--- tests/testsuite/cfg.rs | 10 +- tests/testsuite/check.rs | 116 ++------- tests/testsuite/concurrent.rs | 20 +- tests/testsuite/cross_compile.rs | 51 +--- tests/testsuite/directory.rs | 77 +----- tests/testsuite/doc.rs | 160 ++----------- tests/testsuite/features.rs | 66 +----- tests/testsuite/fetch.rs | 7 +- tests/testsuite/fix.rs | 61 +---- tests/testsuite/freshness.rs | 15 +- tests/testsuite/git.rs | 87 ++----- tests/testsuite/install.rs | 47 +--- tests/testsuite/local_registry.rs | 30 +-- tests/testsuite/overrides.rs | 111 ++------- tests/testsuite/package.rs | 93 ++------ tests/testsuite/patch.rs | 76 +----- tests/testsuite/path.rs | 97 ++------ tests/testsuite/plugins.rs | 30 +-- tests/testsuite/profile_overrides.rs | 31 +-- tests/testsuite/profile_targets.rs | 10 +- tests/testsuite/registry.rs | 16 +- tests/testsuite/rename_deps.rs | 26 +-- tests/testsuite/required_features.rs | 8 +- tests/testsuite/run.rs | 157 ++----------- tests/testsuite/rustc.rs | 111 ++------- tests/testsuite/rustdoc.rs | 43 +--- tests/testsuite/rustflags.rs | 56 +---- tests/testsuite/search.rs | 11 +- tests/testsuite/test.rs | 323 ++++---------------------- tests/testsuite/workspaces.rs | 20 +- 37 files changed, 378 insertions(+), 2413 deletions(-) diff --git a/tests/testsuite/bad_config.rs b/tests/testsuite/bad_config.rs index a45436e86..9b8ab6320 100644 --- a/tests/testsuite/bad_config.rs +++ b/tests/testsuite/bad_config.rs @@ -599,19 +599,9 @@ Caused by: fn duplicate_deps() { let p = project() .file("shim-bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "shim-bar/src/lib.rs", - r#" - pub fn a() {} - "#, - ) + .file("shim-bar/src/lib.rs", "pub fn a() {}") .file("linux-bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "linux-bar/src/lib.rs", - r#" - pub fn a() {} - "#, - ) + .file("linux-bar/src/lib.rs", "pub fn a() {}") .file( "Cargo.toml", r#" @@ -648,19 +638,9 @@ have a single canonical source path irrespective of build target. fn duplicate_deps_diff_sources() { let p = project() .file("shim-bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "shim-bar/src/lib.rs", - r#" - pub fn a() {} - "#, - ) + .file("shim-bar/src/lib.rs", "pub fn a() {}") .file("linux-bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "linux-bar/src/lib.rs", - r#" - pub fn a() {} - "#, - ) + .file("linux-bar/src/lib.rs", "pub fn a() {}") .file( "Cargo.toml", r#" @@ -734,12 +714,7 @@ warning: unused manifest key: target.foo.bar bulid = "foo" "#, ) - .file( - "src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); assert_that( p.cargo("build"), @@ -766,12 +741,7 @@ warning: unused manifest key: project.bulid build = "foo" "#, ) - .file( - "src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); assert_that( p.cargo("build"), @@ -845,12 +815,7 @@ to use. This will be considered an error in future versions #[test] fn invalid_toml_historically_allowed_is_warned() { let p = project() - .file( - ".cargo/config", - r#" - [bar] baz = 2 - "#, - ) + .file(".cargo/config", "[bar] baz = 2") .file("src/main.rs", "fn main() {}") .build(); @@ -908,12 +873,7 @@ This will be considered an error in future versions fn bad_source_config1() { let p = project() .file("src/lib.rs", "") - .file( - ".cargo/config", - r#" - [source.foo] - "#, - ) + .file(".cargo/config", "[source.foo]") .build(); assert_that( diff --git a/tests/testsuite/bench.rs b/tests/testsuite/bench.rs index 9e6c4ae6e..61f4c18ea 100644 --- a/tests/testsuite/bench.rs +++ b/tests/testsuite/bench.rs @@ -724,9 +724,7 @@ fn dont_run_examples() { .file("src/lib.rs", r"") .file( "examples/dont-run-me-i-will-fail.rs", - r#" - fn main() { panic!("Examples should not be run by 'cargo test'"); } - "#, + r#"fn main() { panic!("Examples should not be run by 'cargo test'"); }"#, ) .build(); assert_that(p.cargo("bench"), execs().with_status(0)); @@ -944,12 +942,7 @@ fn lib_with_standard_name2() { doctest = false "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -1043,12 +1036,7 @@ fn bench_dylib() { crate_type = ["dylib"] "#, ) - .file( - "bar/src/lib.rs", - " - pub fn baz() {} - ", - ) + .file("bar/src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -1263,13 +1251,7 @@ fn test_a_bench() { "#, ) .file("src/lib.rs", "") - .file( - "benches/b.rs", - r#" - #[test] - fn foo() {} - "#, - ) + .file("benches/b.rs", "#[test] fn foo() {}") .build(); assert_that( @@ -1483,12 +1465,7 @@ fn bench_all_workspace() { [workspace] "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file( "benches/foo.rs", r#" @@ -1502,12 +1479,7 @@ fn bench_all_workspace() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file( "bar/benches/bar.rs", r#" @@ -1551,12 +1523,7 @@ fn bench_all_exclude() { members = ["bar", "baz"] "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file( "bar/src/lib.rs", @@ -1572,15 +1539,7 @@ fn bench_all_exclude() { "#, ) .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - #[test] - pub fn baz() { - break_the_build(); - } - "#, - ) + .file("baz/src/lib.rs", "#[test] pub fn baz() { break_the_build(); }") .build(); assert_that( @@ -1608,12 +1567,7 @@ fn bench_all_virtual_manifest() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file( "bar/benches/bar.rs", r#" @@ -1627,12 +1581,7 @@ fn bench_all_virtual_manifest() { "#, ) .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .file( "baz/benches/baz.rs", r#" @@ -1678,12 +1627,7 @@ fn legacy_bench_name() { name = "bench" "#, ) - .file( - "src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/bench.rs", r#" @@ -1723,12 +1667,7 @@ fn bench_virtual_manifest_all_implied() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn foo() {}") .file( "bar/benches/bar.rs", r#" @@ -1740,12 +1679,7 @@ fn bench_virtual_manifest_all_implied() { "#, ) .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .file( "baz/benches/baz.rs", r#" diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index b5211b0da..34e918252 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -275,13 +275,7 @@ fn cargo_compile_duplicate_build_targets() { [dependencies] "#, ) - .file( - "src/main.rs", - r#" - #![allow(warnings)] - fn main() {} - "#, - ) + .file("src/main.rs", "#![allow(warnings)] fn main() {}") .build(); assert_that( @@ -938,12 +932,7 @@ fn cargo_compile_with_filename() { 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(); assert_that( @@ -1104,10 +1093,7 @@ fn compile_offline_without_maxvers_cached() { Package::new("present_dep", "1.2.3") .file("Cargo.toml", &basic_manifest("present_dep", "1.2.3")) - .file( - "src/lib.rs", - r#"pub fn get_version()->&'static str {"1.2.3"}"#, - ) + .file("src/lib.rs", r#"pub fn get_version()->&'static str {"1.2.3"}"#) .publish(); Package::new("present_dep", "1.2.5") @@ -1359,12 +1345,7 @@ fn compile_path_dep_then_change_version() { #[test] fn ignores_carriage_return_in_lockfile() { let p = project() - .file( - "src/main.rs", - r#" - mod a; fn main() {} - "#, - ) + .file("src/main.rs", r"mod a; fn main() {}") .file("src/a.rs", "") .build(); @@ -1648,12 +1629,7 @@ fn crate_library_path_env_var() { #[test] fn build_with_fake_libc_not_loading() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .file("libc.so.6", r#""#) .build(); @@ -1683,12 +1659,7 @@ fn many_crate_types_old_style_lib_location() { crate_type = ["rlib", "dylib"] "#, ) - .file( - "src/foo.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/foo.rs", "pub fn foo() {}") .build(); assert_that( p.cargo("build"), @@ -1722,12 +1693,7 @@ fn many_crate_types_correct() { crate_type = ["rlib", "dylib"] "#, ) - .file( - "src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); assert_that(p.cargo("build"), execs().with_status(0)); @@ -2250,12 +2216,7 @@ fn release_build_ndebug() { #[test] fn inferred_main_bin() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that(p.cargo("build"), execs().with_status(0)); @@ -2277,13 +2238,7 @@ fn deletion_causes_failure() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - 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(); @@ -2296,12 +2251,7 @@ fn deletion_causes_failure() { #[test] fn bad_cargo_toml_in_target_dir() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("target/Cargo.toml", "bad-toml") .build(); @@ -2313,19 +2263,8 @@ fn bad_cargo_toml_in_target_dir() { fn lib_with_standard_name() { let p = project() .file("Cargo.toml", &basic_manifest("syntax", "0.0.1")) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) - .file( - "src/main.rs", - " - extern crate syntax; - fn main() { syntax::foo() } - ", - ) + .file("src/lib.rs", "pub fn foo() {}") + .file("src/main.rs", "extern crate syntax; fn main() { syntax::foo() }") .build(); assert_that( @@ -2383,15 +2322,7 @@ fn staticlib_rlib_and_bin() { "#, ) .file("src/lib.rs", "pub fn foo() {}") - .file( - "src/main.rs", - r#" - extern crate foo; - - fn main() { - foo::foo(); - }"#, - ) + .file("src/main.rs", "extern crate foo; fn main() { foo::foo(); }") .build(); assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); @@ -2605,12 +2536,7 @@ fn bad_cargo_config() { let foo = project() .file("Cargo.toml", &basic_manifest("foo", "0.0.0")) .file("src/lib.rs", "") - .file( - ".cargo/config", - r#" - this is not valid toml - "#, - ) + .file(".cargo/config", "this is not valid toml") .build(); assert_that( foo.cargo("build").arg("-v"), @@ -2625,7 +2551,7 @@ Caused by: could not parse input as TOML Caused by: - expected an equals, found an identifier at line 2 + expected an equals, found an identifier at line 1 ", ), ); @@ -2655,28 +2581,9 @@ fn cargo_platform_specific_dependency() { host = host ), ) - .file( - "src/main.rs", - r#" - extern crate dep; - fn main() { dep::dep() } - "#, - ) - .file( - "tests/foo.rs", - r#" - extern crate dev; - #[test] - fn foo() { dev::dev() } - "#, - ) - .file( - "build.rs", - r#" - extern crate build; - fn main() { build::build(); } - "#, - ) + .file("src/main.rs", "extern crate dep; fn main() { dep::dep() }") + .file("tests/foo.rs", "extern crate dev; #[test] fn foo() { dev::dev() }") + .file("build.rs", "extern crate build; fn main() { build::build(); }") .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")) @@ -2709,16 +2616,7 @@ fn bad_platform_specific_dependency() { ) .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!("") - } - "#, - ) + .file("bar/src/lib.rs", r#"extern crate baz; pub fn gimme() -> String { format!("") }"#) .build(); assert_that(p.cargo("build"), execs().with_status(101)); @@ -2740,19 +2638,9 @@ fn cargo_platform_specific_dependency_wrong_platform() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) - .file( - "bar/src/lib.rs", - r#" - invalid rust file, should not be compiled - "#, - ) + .file("bar/src/lib.rs", "invalid rust file, should not be compiled") .build(); p.cargo("build").exec_with_output().unwrap(); @@ -3821,19 +3709,9 @@ fn build_all_workspace() { [workspace] "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( @@ -3860,28 +3738,11 @@ fn build_all_exclude() { members = ["bar", "baz"] "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() { - break_the_build(); - } - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() { break_the_build(); }") .build(); assert_that( @@ -3952,19 +3813,9 @@ fn build_all_virtual_manifest() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); // The order in which bar and baz are built is not guaranteed @@ -3993,19 +3844,9 @@ fn build_virtual_manifest_all_implied() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); // The order in which bar and baz are built is not guaranteed @@ -4034,19 +3875,9 @@ fn build_virtual_manifest_one_project() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file( "bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file( "baz/src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -4130,12 +3961,7 @@ fn build_all_member_dependency_same_name() { a = "0.1.0" "#, ) - .file( - "a/src/lib.rs", - r#" - pub fn a() {} - "#, - ) + .file("a/src/lib.rs", "pub fn a() {}") .build(); Package::new("a", "0.1.0").publish(); @@ -4169,21 +3995,8 @@ fn run_proper_binary() { "#, ) .file("src/lib.rs", "") - .file( - "src/bin/main.rs", - r#" - fn main() { - panic!("This should never be run."); - } - "#, - ) - .file( - "src/bin/other.rs", - r#" - fn main() { - } - "#, - ) + .file("src/bin/main.rs", r#"fn main() { panic!("This should never be run."); }"#) + .file("src/bin/other.rs", "fn main() {}") .build(); assert_that( @@ -4197,13 +4010,7 @@ fn run_proper_binary_main_rs() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) .file("src/lib.rs", "") - .file( - "src/bin/main.rs", - r#" - fn main() { - } - "#, - ) + .file("src/bin/main.rs", "fn main() {}") .build(); assert_that( @@ -4228,22 +4035,8 @@ fn run_proper_alias_binary_from_src() { name = "bar" "#, ) - .file( - "src/foo.rs", - r#" - fn main() { - println!("foo"); - } - "#, - ) - .file( - "src/bar.rs", - r#" - fn main() { - println!("bar"); - } - "#, - ) + .file("src/foo.rs", r#"fn main() { println!("foo"); }"#) + .file("src/bar.rs", r#"fn main() { println!("bar"); }"#) .build(); assert_that(p.cargo("build").arg("--all"), execs().with_status(0)); @@ -4273,14 +4066,7 @@ fn run_proper_alias_binary_main_rs() { name = "bar" "#, ) - .file( - "src/main.rs", - r#" - fn main() { - println!("main"); - } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("main"); }"#) .build(); assert_that(p.cargo("build").arg("--all"), execs().with_status(0)); @@ -4298,21 +4084,8 @@ fn run_proper_alias_binary_main_rs() { fn run_proper_binary_main_rs_as_foo() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/foo.rs", - r#" - fn main() { - panic!("This should never be run."); - } - "#, - ) - .file( - "src/main.rs", - r#" - fn main() { - } - "#, - ) + .file("src/foo.rs", r#" fn main() { panic!("This should never be run."); }"#) + .file("src/main.rs", "fn main() {}") .build(); assert_that( @@ -4448,12 +4221,7 @@ fn deterministic_cfg_flags() { } "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( diff --git a/tests/testsuite/build_lib.rs b/tests/testsuite/build_lib.rs index 538775932..282650000 100644 --- a/tests/testsuite/build_lib.rs +++ b/tests/testsuite/build_lib.rs @@ -22,12 +22,7 @@ fn verbose_output_for_lib(p: &Project) -> String { #[test] fn build_lib_only() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -43,12 +38,7 @@ fn build_lib_only() { fn build_with_no_lib() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( @@ -76,12 +66,7 @@ fn build_with_relative_cargo_home_path() { "test-dependency" = { path = "src/test_dependency" } "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/test_dependency/src/lib.rs", r#" "#) .file("src/test_dependency/Cargo.toml", &basic_manifest("test-dependency", "0.0.1")) .build(); diff --git a/tests/testsuite/build_script.rs b/tests/testsuite/build_script.rs index e16899bda..0e84b8445 100644 --- a/tests/testsuite/build_script.rs +++ b/tests/testsuite/build_script.rs @@ -27,20 +27,8 @@ fn custom_build_script_failed() { build = "build.rs" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) - .file( - "build.rs", - r#" - fn main() { - std::process::exit(101); - } - "#, - ) + .file("src/main.rs", "fn main() {}") + .file("build.rs", "fn main() { std::process::exit(101); }") .build(); assert_that( p.cargo("build").arg("-v"), @@ -75,12 +63,7 @@ fn custom_build_env_vars() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file( "bar/Cargo.toml", r#" @@ -95,12 +78,7 @@ fn custom_build_env_vars() { foo = [] "#, ) - .file( - "bar/src/lib.rs", - r#" - pub fn hello() {} - "#, - ); + .file("bar/src/lib.rs", "pub fn hello() {}"); let file_content = format!( r#" @@ -208,20 +186,8 @@ fn custom_build_script_wrong_rustc_flags() { build = "build.rs" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-flags=-aaa -bbb"); - } - "#, - ) + .file("src/main.rs", "fn main() {}") + .file("build.rs", r#"fn main() { println!("cargo:rustc-flags=-aaa -bbb"); }"#) .build(); assert_that( @@ -249,9 +215,7 @@ fn custom_build_script_rustc_flags() { [dependencies.foo] path = "foo" "#) - .file("src/main.rs", r#" - fn main() {} - "#) + .file("src/main.rs", "fn main() {}") .file("foo/Cargo.toml", r#" [project] @@ -608,12 +572,7 @@ fn only_rerun_build_script() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() {} - "#, - ) + .file("build.rs", "fn main() {}") .build(); assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); @@ -717,12 +676,7 @@ fn testing_and_such() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() {} - "#, - ) + .file("build.rs", "fn main() {}") .build(); println!("build"); @@ -811,14 +765,7 @@ fn propagation_of_l_flags() { "#, ) .file("a/src/lib.rs", "") - .file( - "a/build.rs", - r#" - fn main() { - println!("cargo:rustc-flags=-L bar"); - } - "#, - ) + .file("a/build.rs", r#"fn main() { println!("cargo:rustc-flags=-L bar"); }"#) .file( "b/Cargo.toml", r#" @@ -1561,13 +1508,7 @@ fn build_script_with_dynamic_native_dependency() { plugin = true "#, ) - .file( - "src/lib.rs", - r#" - #[no_mangle] - pub extern fn foo() {} - "#, - ) + .file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") .build(); let foo = project().at("ws/foo") @@ -1584,13 +1525,7 @@ fn build_script_with_dynamic_native_dependency() { path = "bar" "#, ) - .file( - "build.rs", - r#" - 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", @@ -1723,13 +1658,7 @@ fn build_script_with_lto() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() { - } - "#, - ) + .file("build.rs", "fn main() {}") .build(); assert_that(p.cargo("build"), execs().with_status(0)); } @@ -1787,21 +1716,8 @@ fn cfg_feedback() { build = "build.rs" "#, ) - .file( - "src/main.rs", - " - #[cfg(foo)] - fn main() {} - ", - ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-cfg=foo"); - } - "#, - ) + .file("src/main.rs", "#[cfg(foo)] fn main() {}") + .file("build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#) .build(); assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); } @@ -1822,13 +1738,7 @@ fn cfg_override() { 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", @@ -1858,14 +1768,7 @@ fn cfg_test() { build = "build.rs" "#, ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-cfg=foo"); - } - "#, - ) + .file("build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#) .file( "src/lib.rs", r#" @@ -1888,14 +1791,7 @@ fn cfg_test() { } "#, ) - .file( - "tests/test.rs", - r#" - #[cfg(foo)] - #[test] - fn test_bar() {} - "#, - ) + .file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") .build(); assert_that( p.cargo("test").arg("-v"), @@ -1937,21 +1833,8 @@ fn cfg_doc() { path = "bar" "#, ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-cfg=foo"); - } - "#, - ) - .file( - "src/lib.rs", - r#" - #[cfg(foo)] - pub fn foo() {} - "#, - ) + .file("build.rs", r#"fn main() { println!("cargo:rustc-cfg=foo"); }"#) + .file("src/lib.rs", "#[cfg(foo)] pub fn foo() {}") .file( "bar/Cargo.toml", r#" @@ -1962,21 +1845,8 @@ fn cfg_doc() { build = "build.rs" "#, ) - .file( - "bar/build.rs", - r#" - fn main() { - println!("cargo:rustc-cfg=bar"); - } - "#, - ) - .file( - "bar/src/lib.rs", - r#" - #[cfg(bar)] - pub fn bar() {} - "#, - ) + .file("bar/build.rs", r#"fn main() { println!("cargo:rustc-cfg=bar"); }"#) + .file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") .build(); assert_that(p.cargo("doc"), execs().with_status(0)); assert_that(&p.root().join("target/doc"), existing_dir()); @@ -2037,14 +1907,7 @@ fn cfg_override_test() { } "#, ) - .file( - "tests/test.rs", - r#" - #[cfg(foo)] - #[test] - fn test_bar() {} - "#, - ) + .file("tests/test.rs", "#[cfg(foo)] #[test] fn test_bar() {}") .build(); assert_that( p.cargo("test").arg("-v"), @@ -2098,13 +1961,7 @@ fn cfg_override_doc() { ), ) .file("build.rs", "") - .file( - "src/lib.rs", - r#" - #[cfg(foo)] - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "#[cfg(foo)] pub fn foo() {}") .file( "bar/Cargo.toml", r#" @@ -2117,13 +1974,7 @@ fn cfg_override_doc() { "#, ) .file("bar/build.rs", "") - .file( - "bar/src/lib.rs", - r#" - #[cfg(bar)] - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "#[cfg(bar)] pub fn bar() {}") .build(); assert_that(p.cargo("doc"), execs().with_status(0)); assert_that(&p.root().join("target/doc"), existing_dir()); @@ -2159,14 +2010,7 @@ fn env_build() { } "#, ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-env=FOO=foo"); - } - "#, - ) + .file("build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#) .build(); assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); assert_that( @@ -2188,20 +2032,8 @@ fn env_test() { build = "build.rs" "#, ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-env=FOO=foo"); - } - "#, - ) - .file( - "src/lib.rs", - r#" - pub const FOO: &'static str = env!("FOO"); - "#, - ) + .file("build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#) + .file("src/lib.rs", r#"pub const FOO: &'static str = env!("FOO"); "#) .file( "tests/test.rs", r#" @@ -2257,13 +2089,7 @@ fn env_doc() { fn main() {} "#, ) - .file( - "build.rs", - r#" - fn main() { - println!("cargo:rustc-env=FOO=foo"); - } - "#, + .file("build.rs", r#"fn main() { println!("cargo:rustc-env=FOO=foo"); }"#, ) .build(); assert_that(p.cargo("doc").arg("-v"), execs().with_status(0)); @@ -2931,13 +2757,7 @@ fn non_utf8_output() { } "#, ) - .file( - "src/main.rs", - r#" - #[cfg(foo)] - fn main() {} - "#, - ) + .file("src/main.rs", "#[cfg(foo)] fn main() {}") .build(); assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); @@ -3588,12 +3408,7 @@ fn deterministic_rustc_dependency_flags() { dep4 = "*" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( @@ -3687,13 +3502,7 @@ fn rename_with_link_search_path() { crate-type = ["cdylib"] "#, ) - .file( - "src/lib.rs", - " - #[no_mangle] - pub extern fn cargo_test_foo() {} - ", - ); + .file("src/lib.rs", "#[no_mangle] pub extern fn cargo_test_foo() {}"); let p = p.build(); assert_that(p.cargo("build"), execs().with_status(0)); @@ -3851,12 +3660,7 @@ fn optional_build_script_dep() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() -> u32 { 1 } - "#, - ); + .file("bar/src/lib.rs", "pub fn bar() -> u32 { 1 }"); let p = p.build(); assert_that(p.cargo("run"), execs().with_status(0).with_stdout("0\n")); @@ -3885,13 +3689,7 @@ fn optional_build_dep_and_required_normal_dep() { bar = { path = "./bar" } "#, ) - .file( - "build.rs", - r#" - extern crate bar; - fn main() { bar::bar(); } - "#, - ) + .file("build.rs", "extern crate bar; fn main() { bar::bar(); }") .file( "src/main.rs", r#" @@ -3909,12 +3707,7 @@ fn optional_build_dep_and_required_normal_dep() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.5.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() -> u32 { 1 } - "#, - ); + .file("bar/src/lib.rs", "pub fn bar() -> u32 { 1 }"); let p = p.build(); assert_that( diff --git a/tests/testsuite/build_script_env.rs b/tests/testsuite/build_script_env.rs index fdf06b1e6..2aa9d5490 100644 --- a/tests/testsuite/build_script_env.rs +++ b/tests/testsuite/build_script_env.rs @@ -7,12 +7,7 @@ use support::hamcrest::assert_that; #[test] fn rerun_if_env_changes() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file( "build.rs", r#" @@ -68,12 +63,7 @@ fn rerun_if_env_changes() { #[test] fn rerun_if_env_or_file_changes() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file( "build.rs", r#" diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index 6f5447a15..5e1364678 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -5,12 +5,7 @@ use support::hamcrest::assert_that; fn alias_incorrect_config_type() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -34,12 +29,7 @@ expected a list, but found a integer for [..]", fn alias_default_config_overrides_config() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -61,12 +51,7 @@ fn alias_default_config_overrides_config() { fn alias_config() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -92,12 +77,7 @@ fn alias_config() { fn recursive_alias() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", r"fn main() {}") .file( ".cargo/config", r#" @@ -122,12 +102,7 @@ fn recursive_alias() { fn alias_list_test() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -150,12 +125,7 @@ fn alias_list_test() { fn alias_with_flags_config() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -178,12 +148,7 @@ fn alias_with_flags_config() { fn cant_shadow_builtin() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - fn main() { - }"#, - ) + .file("src/main.rs", "fn main() {}") .file( ".cargo/config", r#" diff --git a/tests/testsuite/cfg.rs b/tests/testsuite/cfg.rs index 31c0b322e..190150f46 100644 --- a/tests/testsuite/cfg.rs +++ b/tests/testsuite/cfg.rs @@ -220,10 +220,7 @@ fn works_through_the_registry() { bar = "0.1.0" "#, ) - .file( - "src/lib.rs", - "#[allow(unused_extern_crates)] extern crate bar;", - ) + .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate bar;") .build(); assert_that( @@ -268,10 +265,7 @@ fn ignore_version_from_other_platform() { this_family, other_family ), ) - .file( - "src/lib.rs", - "#[allow(unused_extern_crates)] extern crate bar;", - ) + .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate bar;") .build(); assert_that( diff --git a/tests/testsuite/check.rs b/tests/testsuite/check.rs index ee58de9b5..153b3210d 100644 --- a/tests/testsuite/check.rs +++ b/tests/testsuite/check.rs @@ -21,24 +21,11 @@ fn check_success() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - ::bar::baz(); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that(foo.cargo("check"), execs().with_status(0)); @@ -59,24 +46,11 @@ fn check_fail() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - ::bar::baz(42); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { ::bar::baz(42); }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that(foo.cargo("check"), execs().with_status(101)); @@ -162,25 +136,12 @@ fn check_build() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - ::bar::baz(); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that(foo.cargo("check"), execs().with_status(0)); @@ -202,25 +163,12 @@ fn build_check() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - ::bar::baz(); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that(foo.cargo("build"), execs().with_status(0)); @@ -363,24 +311,11 @@ fn rustc_check() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - ::bar::baz(); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { ::bar::baz(); }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -408,24 +343,11 @@ fn rustc_check_err() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - ::bar::qux(); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { ::bar::qux(); }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -485,19 +407,9 @@ fn check_virtual_all_implied() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); assert_that( diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index 19ea33c90..645eb3c5a 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -234,10 +234,7 @@ fn git_same_repo_different_tags() { a.url() ), ) - .file( - "a/src/main.rs", - "extern crate dep; fn main() { dep::tag1(); }", - ) + .file("a/src/main.rs", "extern crate dep; fn main() { dep::tag1(); }") .file( "b/Cargo.toml", &format!( @@ -253,10 +250,7 @@ fn git_same_repo_different_tags() { a.url() ), ) - .file( - "b/src/main.rs", - "extern crate dep; fn main() { dep::tag2(); }", - ); + .file("b/src/main.rs", "extern crate dep; fn main() { dep::tag2(); }"); let p = p.build(); let mut a = p.cargo("build") @@ -306,10 +300,7 @@ fn git_same_branch_different_revs() { a.url() ), ) - .file( - "a/src/main.rs", - "extern crate dep; fn main() { dep::f1(); }", - ) + .file("a/src/main.rs", "extern crate dep; fn main() { dep::f1(); }") .file( "b/Cargo.toml", &format!( @@ -325,10 +316,7 @@ fn git_same_branch_different_revs() { a.url() ), ) - .file( - "b/src/main.rs", - "extern crate dep; fn main() { dep::f2(); }", - ); + .file("b/src/main.rs", "extern crate dep; fn main() { dep::f2(); }"); let p = p.build(); // Generate a Cargo.lock pointing at the current rev, then clear out the diff --git a/tests/testsuite/cross_compile.rs b/tests/testsuite/cross_compile.rs index bef6fcd05..7e927fd53 100644 --- a/tests/testsuite/cross_compile.rs +++ b/tests/testsuite/cross_compile.rs @@ -139,13 +139,7 @@ fn simple_deps() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { bar::bar(); } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }") .build(); let _p2 = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -787,12 +781,7 @@ fn build_script_needed_for_host_and_target() { build = 'build.rs' "#, ) - .file( - "d1/src/lib.rs", - " - pub fn d1() {} - ", - ) + .file("d1/src/lib.rs", "pub fn d1() {}") .file( "d1/build.rs", r#" @@ -889,12 +878,7 @@ fn build_deps_for_the_right_arch() { ) .file("src/main.rs", "extern crate d2; fn main() {}") .file("d1/Cargo.toml", &basic_manifest("d1", "0.0.0")) - .file( - "d1/src/lib.rs", - " - pub fn d1() {} - ", - ) + .file("d1/src/lib.rs", "pub fn d1() {}") .file( "d2/Cargo.toml", r#" @@ -951,12 +935,7 @@ fn build_script_only_host() { build = "build.rs" "#, ) - .file( - "d1/src/lib.rs", - " - pub fn d1() {} - ", - ) + .file("d1/src/lib.rs", "pub fn d1() {}") .file( "d1/build.rs", r#" @@ -1065,13 +1044,7 @@ fn build_script_with_platform_specific_dependencies() { host ), ) - .file( - "d1/src/lib.rs", - " - #[allow(unused_extern_crates)] - extern crate d2; - ", - ) + .file("d1/src/lib.rs", "#[allow(unused_extern_crates)] extern crate d2;") .file("d2/Cargo.toml", &basic_manifest("d2", "0.0.0")) .file("d2/src/lib.rs", "") .build(); @@ -1216,12 +1189,7 @@ fn platform_specific_variables_reflected_in_build_scripts() { build = "build.rs" "#, ) - .file( - "d1/build.rs", - r#" - fn main() { println!("cargo:val=1") } - "#, - ) + .file("d1/build.rs", r#"fn main() { println!("cargo:val=1") }"#) .file("d1/src/lib.rs", "") .file( "d2/Cargo.toml", @@ -1234,12 +1202,7 @@ fn platform_specific_variables_reflected_in_build_scripts() { build = "build.rs" "#, ) - .file( - "d2/build.rs", - r#" - fn main() { println!("cargo:val=1") } - "#, - ) + .file("d2/build.rs", r#"fn main() { println!("cargo:val=1") }"#) .file("d2/src/lib.rs", "") .build(); diff --git a/tests/testsuite/directory.rs b/tests/testsuite/directory.rs index 20315fc50..20067c87b 100644 --- a/tests/testsuite/directory.rs +++ b/tests/testsuite/directory.rs @@ -95,16 +95,7 @@ fn simple() { bar = "0.1.0" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -140,16 +131,7 @@ fn simple_install() { foo = "0.0.1" "#, ) - .file( - "src/main.rs", - r#" - extern crate foo; - - pub fn main() { - foo::foo(); - } - "#, - ) + .file("src/main.rs", "extern crate foo; pub fn main() { foo::foo(); }") .build(); assert_that( @@ -188,16 +170,7 @@ fn simple_install_fail() { baz = "9.8.7" "#, ) - .file( - "src/main.rs", - r#" - extern crate foo; - - pub fn main() { - foo::foo(); - } - "#, - ) + .file("src/main.rs", "extern crate foo; pub fn main() { foo::foo(); }") .build(); assert_that( @@ -241,16 +214,7 @@ fn install_without_feature_dep() { wantbaz = ["baz"] "#, ) - .file( - "src/main.rs", - r#" - extern crate foo; - - pub fn main() { - foo::foo(); - } - "#, - ) + .file("src/main.rs", "extern crate foo; pub fn main() { foo::foo(); }") .build(); assert_that( @@ -286,16 +250,7 @@ fn not_there() { bar = "0.1.0" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -339,16 +294,7 @@ fn multiple() { bar = "0.1.0" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -378,16 +324,7 @@ fn crates_io_then_directory() { bar = "0.1.0" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); let cksum = Package::new("bar", "0.1.0") diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index 7714e9e2a..7feeccced 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -25,12 +25,7 @@ fn simple() { "#, ) .file("build.rs", "fn main() {}") - .file( - "src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); assert_that( @@ -64,12 +59,7 @@ fn doc_no_libs() { doc = false "#, ) - .file( - "src/main.rs", - r#" - bad code - "#, - ) + .file("src/main.rs", "bad code") .build(); assert_that(p.cargo("doc"), execs().with_status(0)); @@ -78,12 +68,7 @@ fn doc_no_libs() { #[test] fn doc_twice() { let p = project() - .file( - "src/lib.rs", - r#" - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); assert_that( @@ -115,20 +100,9 @@ fn doc_deps() { path = "bar" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( @@ -188,20 +162,9 @@ fn doc_no_deps() { path = "bar" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( @@ -239,20 +202,9 @@ fn doc_only_bin() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - pub fn foo() {} - "#, - ) + .file("src/main.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that(p.cargo("doc").arg("-v"), execs().with_status(0)); @@ -833,12 +785,7 @@ fn no_document_build_deps() { a = { path = "a" } "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file( "a/src/lib.rs", @@ -891,27 +838,11 @@ fn doc_multiple_deps() { path = "baz" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -947,13 +878,7 @@ fn features() { foo = ["bar/bar"] "#, ) - .file( - "src/lib.rs", - r#" - #[cfg(feature = "foo")] - pub fn foo() {} - "#, - ) + .file("src/lib.rs", r#"#[cfg(feature = "foo")] pub fn foo() {}"#) .file( "bar/Cargo.toml", r#" @@ -974,13 +899,7 @@ fn features() { } "#, ) - .file( - "bar/src/lib.rs", - r#" - #[cfg(feature = "bar")] - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", r#"#[cfg(feature = "bar")] pub fn bar() {}"#) .build(); assert_that( p.cargo("doc").arg("--features").arg("foo"), @@ -1087,19 +1006,9 @@ fn doc_all_workspace() { [workspace] "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); // The order in which bar is compiled or documented is not deterministic @@ -1124,19 +1033,9 @@ fn doc_all_virtual_manifest() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); // The order in which bar and baz are documented is not guaranteed @@ -1160,19 +1059,9 @@ fn doc_virtual_manifest_all_implied() { "#, ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/lib.rs", "pub fn baz() {}") .build(); // The order in which bar and baz are documented is not guaranteed @@ -1210,12 +1099,7 @@ fn doc_all_member_dependency_same_name() { bar = "0.1.0" "#, ) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); Package::new("bar", "0.1.0").publish(); diff --git a/tests/testsuite/features.rs b/tests/testsuite/features.rs index fdaf27f12..97eaa039c 100644 --- a/tests/testsuite/features.rs +++ b/tests/testsuite/features.rs @@ -389,13 +389,7 @@ fn no_transitive_dep_feature_requirement() { path = "../bar" "#, ) - .file( - "derived/src/lib.rs", - r#" - extern crate bar; - pub use bar::test; - "#, - ) + .file("derived/src/lib.rs", "extern crate bar; pub use bar::test;") .file( "bar/Cargo.toml", r#" @@ -887,13 +881,7 @@ fn transitive_features() { path = "bar" "#, ) - .file( - "src/main.rs", - " - extern crate bar; - fn main() { bar::baz(); } - ", - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz(); }") .file( "bar/Cargo.toml", r#" @@ -906,13 +894,7 @@ fn transitive_features() { baz = [] "#, ) - .file( - "bar/src/lib.rs", - r#" - #[cfg(feature = "baz")] - pub fn baz() {} - "#, - ) + .file("bar/src/lib.rs", r#"#[cfg(feature = "baz")] pub fn baz() {}"#) .build(); assert_that( @@ -1065,13 +1047,7 @@ fn unions_work_with_no_default_features() { b = { path = "b" } "#, ) - .file( - "src/lib.rs", - r#" - extern crate a; - pub fn foo() { a::a(); } - "#, - ) + .file("src/lib.rs", "extern crate a; pub fn foo() { a::a(); }") .file( "b/Cargo.toml", r#" @@ -1098,13 +1074,7 @@ fn unions_work_with_no_default_features() { f1 = [] "#, ) - .file( - "a/src/lib.rs", - r#" - #[cfg(feature = "f1")] - pub fn a() {} - "#, - ) + .file("a/src/lib.rs", r#"#[cfg(feature = "f1")] pub fn a() {}"#) .build(); assert_that(p.cargo("build"), execs().with_status(0)); @@ -1163,15 +1133,7 @@ fn activating_feature_activates_dep() { a = ["foo/a"] "#, ) - .file( - "src/lib.rs", - " - extern crate foo; - pub fn bar() { - foo::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate foo; pub fn bar() { foo::bar(); }") .file( "foo/Cargo.toml", r#" @@ -1184,13 +1146,7 @@ fn activating_feature_activates_dep() { a = [] "#, ) - .file( - "foo/src/lib.rs", - r#" - #[cfg(feature = "a")] - pub fn bar() {} - "#, - ) + .file("foo/src/lib.rs", r#"#[cfg(feature = "a")] pub fn bar() {}"#) .build(); assert_that( @@ -1237,13 +1193,7 @@ fn dep_feature_in_cmd_line() { derived-feat = ["bar/some-feat"] "#, ) - .file( - "derived/src/lib.rs", - r#" - extern crate bar; - pub use bar::test; - "#, - ) + .file("derived/src/lib.rs", "extern crate bar; pub use bar::test;") .file( "bar/Cargo.toml", r#" diff --git a/tests/testsuite/fetch.rs b/tests/testsuite/fetch.rs index ba712890d..3e64c9f06 100644 --- a/tests/testsuite/fetch.rs +++ b/tests/testsuite/fetch.rs @@ -6,12 +6,7 @@ use support::hamcrest::assert_that; #[test] fn no_deps() { let p = project() - .file( - "src/main.rs", - r#" - mod a; fn main() {} - "#, - ) + .file("src/main.rs", "mod a; fn main() {}") .file("src/a.rs", "") .build(); diff --git a/tests/testsuite/fix.rs b/tests/testsuite/fix.rs index 4cf14f47a..f79777434 100644 --- a/tests/testsuite/fix.rs +++ b/tests/testsuite/fix.rs @@ -657,10 +657,7 @@ fn fix_two_files() { #[test] fn fixes_missing_ampersand() { let p = project() - .file( - "src/main.rs", - "fn main() { let mut x = 3; drop(x); }", - ) + .file("src/main.rs", "fn main() { let mut x = 3; drop(x); }") .file( "src/lib.rs", r#" @@ -677,18 +674,8 @@ fn fixes_missing_ampersand() { pub fn foo() { let mut x = 3; drop(x); } "#, ) - .file( - "examples/foo.rs", - r#" - fn main() { let mut x = 3; drop(x); } - "#, - ) - .file( - "build.rs", - r#" - fn main() { let mut x = 3; drop(x); } - "#, - ) + .file("examples/foo.rs", "fn main() { let mut x = 3; drop(x); }") + .file("build.rs", "fn main() { let mut x = 3; drop(x); }") .build(); assert_that( @@ -748,15 +735,7 @@ fn fix_features() { #[test] fn shows_warnings() { let p = project() - .file( - "src/lib.rs", - r#" - use std::default::Default; - - pub fn foo() { - } - "#, - ) + .file("src/lib.rs", "use std::default::Default; pub fn foo() {}") .build(); assert_that( @@ -769,13 +748,7 @@ fn shows_warnings() { fn warns_if_no_vcs_detected() { let p = project() .use_temp_dir() - .file( - "src/lib.rs", - r#" - pub fn foo() { - } - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); assert_that( @@ -796,13 +769,7 @@ destructive changes; if you'd like to suppress this error pass `--allow-no-vcs`\ #[test] fn warns_about_dirty_working_directory() { let p = project() - .file( - "src/lib.rs", - r#" - pub fn foo() { - } - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); let repo = git2::Repository::init(&p.root()).unwrap(); @@ -838,13 +805,7 @@ these files: #[test] fn does_not_warn_about_clean_working_directory() { let p = project() - .file( - "src/lib.rs", - r#" - pub fn foo() { - } - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .build(); let repo = git2::Repository::init(&p.root()).unwrap(); @@ -864,13 +825,7 @@ fn does_not_warn_about_clean_working_directory() { #[test] fn does_not_warn_about_dirty_ignored_files() { let p = project() - .file( - "src/lib.rs", - r#" - pub fn foo() { - } - "#, - ) + .file("src/lib.rs", "pub fn foo() {}") .file(".gitignore", "foo\n") .build(); diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 4acc26667..6ee5f79b7 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -10,12 +10,7 @@ use support::hamcrest::{assert_that, existing_file}; #[test] fn modifying_and_moving() { let p = project() - .file( - "src/main.rs", - r#" - mod a; fn main() {} - "#, - ) + .file("src/main.rs", "mod a; fn main() {}") .file("src/a.rs", "") .build(); @@ -58,13 +53,7 @@ fn modify_only_some_files() { let p = project() .file("src/lib.rs", "mod a;") .file("src/a.rs", "") - .file( - "src/main.rs", - r#" - mod b; - fn main() {} - "#, - ) + .file("src/main.rs", "mod b; fn main() {}") .file("src/b.rs", "") .file("tests/test.rs", "") .build(); diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 58c32d642..5ccecff7a 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -48,10 +48,7 @@ fn cargo_compile_simple_git_dep() { git_project.url() ), ) - .file( - "src/main.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); let root = project.root(); @@ -297,10 +294,7 @@ fn cargo_compile_git_dep_branch() { git_project.url() ), ) - .file( - "src/main.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); let root = project.root(); @@ -373,10 +367,7 @@ fn cargo_compile_git_dep_tag() { git_project.url() ), ) - .file( - "src/main.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); let root = project.root(); @@ -472,10 +463,7 @@ fn cargo_compile_with_nested_paths() { git_project.url() ), ) - .file( - "src/foo.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); p.cargo("build").exec_with_output().unwrap(); @@ -501,12 +489,7 @@ fn cargo_compile_with_malformed_nested_paths() { } "#, ) - .file( - "vendor/dep2/Cargo.toml", - r#" - !INVALID! - "#, - ) + .file("vendor/dep2/Cargo.toml", "!INVALID!") }).unwrap(); let p = project() @@ -532,10 +515,7 @@ fn cargo_compile_with_malformed_nested_paths() { git_project.url() ), ) - .file( - "src/foo.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); p.cargo("build").exec_with_output().unwrap(); @@ -646,10 +626,7 @@ fn cargo_compile_with_short_ssh_git() { url ), ) - .file( - "src/foo.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/foo.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); assert_that( @@ -761,12 +738,7 @@ fn recompilation() { let git_project = git::new("bar", |project| { project .file("Cargo.toml", &basic_lib_manifest("bar")) - .file( - "src/bar.rs", - r#" - pub fn bar() {} - "#, - ) + .file("src/bar.rs", "pub fn bar() {}") }).unwrap(); let p = project() @@ -885,12 +857,7 @@ fn update_with_shared_deps() { let git_project = git::new("bar", |project| { project .file("Cargo.toml", &basic_lib_manifest("bar")) - .file( - "src/bar.rs", - r#" - pub fn bar() {} - "#, - ) + .file("src/bar.rs", "pub fn bar() {}") }).unwrap(); let p = project() @@ -1094,13 +1061,7 @@ fn dep_with_submodule() { git_project.url() ), ) - .file( - "src/lib.rs", - " - extern crate dep1; - pub fn foo() { dep1::dep() } - ", - ) + .file("src/lib.rs", "extern crate dep1; pub fn foo() { dep1::dep() }") .build(); assert_that( @@ -1165,13 +1126,7 @@ fn dep_with_bad_submodule() { git_project.url() ), ) - .file( - "src/lib.rs", - " - extern crate dep1; - pub fn foo() { dep1::dep() } - ", - ) + .file("src/lib.rs", "extern crate dep1; pub fn foo() { dep1::dep() }") .build(); let expected = format!( @@ -1577,12 +1532,7 @@ fn git_build_cmd_freshness() { ) .file("build.rs", "fn main() {}") .file("src/lib.rs", "pub fn bar() -> i32 { 1 }") - .file( - ".gitignore", - " - src/bar.rs - ", - ) + .file(".gitignore", "src/bar.rs") }).unwrap(); foo.root().move_into_the_past(); @@ -2608,13 +2558,7 @@ fn include_overrides_gitignore() { } "#, ) - .file( - "src/lib.rs", - r#" - mod not_incl; - mod incl; - "#, - ) + .file("src/lib.rs", "mod not_incl; mod incl;") .file( "src/mod.md", r#" @@ -2745,10 +2689,7 @@ fn invalid_git_dependency_manifest() { git_project.url() ), ) - .file( - "src/main.rs", - &main_file(r#""{}", dep1::hello()"#, &["dep1"]), - ) + .file("src/main.rs", &main_file(r#""{}", dep1::hello()"#, &["dep1"])) .build(); let git_root = git_project.root(); diff --git a/tests/testsuite/install.rs b/tests/testsuite/install.rs index 1b12f1b05..867b4ab56 100644 --- a/tests/testsuite/install.rs +++ b/tests/testsuite/install.rs @@ -22,16 +22,7 @@ fn cargo_process(s: &str) -> ProcessBuilder { fn pkg(name: &str, vers: &str) { Package::new(name, vers) .file("src/lib.rs", "") - .file( - "src/main.rs", - &format!( - " - extern crate {}; - fn main() {{}} - ", - name - ), - ) + .file("src/main.rs", &format!("extern crate {}; fn main() {{}}", name)) .publish(); } @@ -822,14 +813,7 @@ fn uninstall_piecemeal() { #[test] fn subcommand_works_out_of_the_box() { Package::new("cargo-foo", "1.0.0") - .file( - "src/main.rs", - r#" - fn main() { - println!("bar"); - } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("bar"); }"#) .publish(); assert_that( cargo_process("install").arg("cargo-foo"), @@ -926,14 +910,7 @@ warning: be sure to add `[..]` to your PATH to be able to run the installed bina #[test] fn reports_unsuccessful_subcommand_result() { Package::new("cargo-fail", "1.0.0") - .file( - "src/main.rs", - r#" - fn main() { - panic!(); - } - "#, - ) + .file("src/main.rs", "fn main() { panic!(); }") .publish(); assert_that( cargo_process("install").arg("cargo-fail"), @@ -1292,14 +1269,7 @@ fn install_respects_lock_file() { Package::new("foo", "0.1.0") .dep("bar", "0.1") .file("src/lib.rs", "") - .file( - "src/main.rs", - " - extern crate foo; - extern crate bar; - fn main() {} - ", - ) + .file("src/main.rs", "extern crate foo; extern crate bar; fn main() {}") .file( "Cargo.lock", r#" @@ -1328,14 +1298,7 @@ fn lock_file_path_deps_ok() { Package::new("foo", "0.1.0") .dep("bar", "0.1") .file("src/lib.rs", "") - .file( - "src/main.rs", - " - extern crate foo; - extern crate bar; - fn main() {} - ", - ) + .file("src/main.rs", "extern crate foo; extern crate bar; fn main() {}") .file( "Cargo.lock", r#" diff --git a/tests/testsuite/local_registry.rs b/tests/testsuite/local_registry.rs index 351e6787f..2c7a0816f 100644 --- a/tests/testsuite/local_registry.rs +++ b/tests/testsuite/local_registry.rs @@ -42,15 +42,7 @@ fn simple() { bar = "0.0.1" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -94,15 +86,7 @@ fn multiple_versions() { bar = "*" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -452,15 +436,7 @@ fn crates_io_registry_url_is_optional() { bar = "0.0.1" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( diff --git a/tests/testsuite/overrides.rs b/tests/testsuite/overrides.rs index 95dd72cbe..944a29bbe 100644 --- a/tests/testsuite/overrides.rs +++ b/tests/testsuite/overrides.rs @@ -32,15 +32,7 @@ fn override_simple() { bar.url() ), ) - .file( - "src/lib.rs", - " - extern crate bar; - pub fn foo() { - bar::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -243,15 +235,7 @@ fn persists_across_rebuilds() { foo.url() ), ) - .file( - "src/lib.rs", - " - extern crate bar; - pub fn foo() { - bar::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -295,15 +279,7 @@ fn replace_registry_with_path() { "bar:0.1.0" = { path = "../bar" } "#, ) - .file( - "src/lib.rs", - " - extern crate bar; - pub fn foo() { - bar::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -327,13 +303,7 @@ fn use_a_spec_to_select() { Package::new("baz", "0.2.0").publish(); Package::new("bar", "0.1.1") .dep("baz", "0.2") - .file( - "src/lib.rs", - " - extern crate baz; - pub fn bar() { baz::baz3(); } - ", - ) + .file("src/lib.rs", "extern crate baz; pub fn bar() { baz::baz3(); }") .publish(); let foo = git::repo(&paths::root().join("override")) @@ -812,13 +782,7 @@ fn no_override_self() { far = { path = "../far" } "#, ) - .file( - "near/src/lib.rs", - r#" - #![no_std] - pub extern crate far; - "#, - ) + .file("near/src/lib.rs", "#![no_std] pub extern crate far;") .build(); let p = project() @@ -840,13 +804,7 @@ fn no_override_self() { deps.url() ), ) - .file( - "src/lib.rs", - r#" - #![no_std] - pub extern crate near; - "#, - ) + .file("src/lib.rs", "#![no_std] pub extern crate near;") .build(); assert_that(p.cargo("build").arg("--verbose"), execs().with_status(0)); @@ -897,12 +855,7 @@ fn broken_path_override_warns() { "#, ) .file("a2/src/lib.rs", "") - .file( - ".cargo/config", - r#" - paths = ["a2"] - "#, - ) + .file(".cargo/config", r#"paths = ["a2"]"#) .build(); assert_that( @@ -1039,12 +992,7 @@ fn override_an_override() { ", ) .file("serde/Cargo.toml", &basic_manifest("serde", "0.8.0")) - .file( - "serde/src/lib.rs", - " - pub fn serde08_override() {} - ", - ) + .file("serde/src/lib.rs", "pub fn serde08_override() {}") .build(); assert_that(p.cargo("build").arg("-v"), execs().with_status(0)); @@ -1199,12 +1147,7 @@ fn override_to_path_dep() { .file("bar/src/lib.rs", "") .file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.0.1")) .file("bar/baz/src/lib.rs", "") - .file( - ".cargo/config", - r#" - paths = ["bar"] - "#, - ) + .file(".cargo/config", r#"paths = ["bar"]"#) .build(); assert_that(p.cargo("build"), execs().with_status(0)); @@ -1244,16 +1187,7 @@ fn replace_to_path_dep() { baz = { path = "baz" } "#, ) - .file( - "bar/src/lib.rs", - " - extern crate baz; - - pub fn bar() { - baz::baz(); - } - ", - ) + .file("bar/src/lib.rs", "extern crate baz; pub fn bar() { baz::baz(); }") .file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) .file("bar/baz/src/lib.rs", "pub fn baz() {}") .build(); @@ -1305,12 +1239,7 @@ fn paths_ok_with_optional() { "#, ) .file("bar2/src/lib.rs", "") - .file( - ".cargo/config", - r#" - paths = ["bar2"] - "#, - ) + .file(".cargo/config", r#"paths = ["bar2"]"#) .build(); assert_that( @@ -1358,12 +1287,7 @@ fn paths_add_optional_bad() { "#, ) .file("bar2/src/lib.rs", "") - .file( - ".cargo/config", - r#" - paths = ["bar2"] - "#, - ) + .file(".cargo/config", r#"paths = ["bar2"]"#) .build(); assert_that( @@ -1401,16 +1325,7 @@ fn override_with_default_feature() { 'bar:0.1.0' = { path = "bar" } "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - - fn main() { - bar::bar(); - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar(); }") .file( "bar/Cargo.toml", r#" diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 3ff05c304..f26607276 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -23,9 +23,7 @@ fn simple() { license = "MIT" description = "foo" "#) - .file("src/main.rs", r#" - fn main() { println!("hello"); } - "#) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("src/bar.txt", "") // should be ignored when packaging .build(); @@ -79,12 +77,7 @@ src[/]main.rs #[test] fn metadata_warning() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( p.cargo("package"), @@ -113,12 +106,7 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. license = "MIT" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( p.cargo("package"), @@ -148,12 +136,7 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. repository = "bar" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( p.cargo("package"), @@ -174,12 +157,7 @@ fn package_verbose() { let root = paths::root().join("all"); let p = git::repo(&root) .file("Cargo.toml", &basic_manifest("foo", "0.0.1")) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("a/Cargo.toml", &basic_manifest("a", "0.0.1")) .file("a/src/lib.rs", "") .build(); @@ -223,12 +201,7 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. #[test] fn package_verification() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that(p.cargo("build"), execs().with_status(0)); assert_that( @@ -318,9 +291,7 @@ fn exclude() { "dir_deep_5/**", # CHANGING (packaged -> ignored) ] "#) - .file("src/main.rs", r#" - fn main() { println!("hello"); } - "#) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("bar.txt", "") .file("src/bar.txt", "") // file in root @@ -434,9 +405,7 @@ fn include() { include = ["foo.txt", "**/*.rs", "Cargo.toml"] "#) .file("foo.txt", "") - .file("src/main.rs", r#" - fn main() { println!("hello"); } - "#) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("src/bar.txt", "") // should be ignored when packaging .build(); @@ -458,13 +427,7 @@ See http://doc.crates.io/manifest.html#package-metadata for more info. #[test] fn package_lib_with_bin() { let p = project() - .file( - "src/main.rs", - r#" - extern crate foo; - fn main() {} - "#, - ) + .file("src/main.rs", "extern crate foo; fn main() {}") .file("src/lib.rs", "") .build(); @@ -522,20 +485,11 @@ fn no_duplicates_from_modified_tracked_files() { let root = paths::root().join("all"); let p = git::repo(&root) .file("Cargo.toml", &basic_manifest("foo", "0.0.1")) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); File::create(p.root().join("src/main.rs")) .unwrap() - .write_all( - br#" - fn main() { println!("A change!"); } - "#, - ) + .write_all(br#"fn main() { println!("A change!"); }"#) .unwrap(); let mut cargo = cargo_process(); cargo.cwd(p.root()); @@ -624,12 +578,7 @@ src[..]main.rs #[test] fn package_weird_characters() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("src/:foo", "") .build(); @@ -652,12 +601,7 @@ Caused by: #[test] fn repackage_on_source_change() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); assert_that(p.cargo("package"), execs().with_status(0)); @@ -733,12 +677,7 @@ fn broken_symlink() { repository = 'foo' "#, ) - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); t!(fs::symlink("nowhere", &p.root().join("src/foo.rs"))); @@ -1335,9 +1274,7 @@ fn lock_file_and_workspace() { #[test] fn do_not_package_if_src_was_modified() { let p = project() - .file("src/main.rs", r#" - fn main() { println!("hello"); } - "#) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .file("build.rs", r#" use std::fs::File; use std::io::Write; diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index dc07fa611..2de96f86e 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -12,15 +12,7 @@ use support::hamcrest::assert_that; fn replace() { Package::new("bar", "0.1.0").publish(); Package::new("baz", "0.1.0") - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn baz() { - bar::bar(); - } - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn baz() { bar::bar(); }") .dep("bar", "0.1.0") .publish(); @@ -53,12 +45,7 @@ fn replace() { ", ) .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( @@ -101,22 +88,9 @@ fn nonexistent() { bar = { path = "bar" } "#, ) - .file( - "src/lib.rs", - " - extern crate bar; - pub fn foo() { - bar::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( @@ -162,22 +136,9 @@ fn patch_git() { bar.url() ), ) - .file( - "src/lib.rs", - " - extern crate bar; - pub fn foo() { - bar::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that( @@ -225,15 +186,7 @@ fn patch_to_git() { bar.url() ), ) - .file( - "src/lib.rs", - " - extern crate bar; - pub fn foo() { - bar::bar(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::bar(); }") .build(); assert_that( @@ -276,12 +229,7 @@ fn unused() { ) .file("src/lib.rs", "") .file("bar/Cargo.toml", &basic_manifest("bar", "0.2.0")) - .file( - "bar/src/lib.rs", - r#" - not rust code - "#, - ) + .file("bar/src/lib.rs", "not rust code") .build(); assert_that( @@ -984,13 +932,7 @@ fn replace_prerelease() { baz = "1.1.0-pre.1" "#, ) - .file( - "bar/src/main.rs", - " - extern crate baz; - fn main() { baz::baz() } - ", - ) + .file("bar/src/main.rs", "extern crate baz; fn main() { baz::baz() }") .file( "baz/Cargo.toml", r#" diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 49b2a2f2d..0bae3553c 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -286,20 +286,9 @@ fn no_rebuild_dependency() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { bar::bar() } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") .file("bar/Cargo.toml", &basic_lib_manifest("bar")) - .file( - "bar/src/bar.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/bar.rs", "pub fn bar() {}") .build(); // First time around we should compile both foo and bar assert_that( @@ -350,13 +339,7 @@ fn deep_dependencies_trigger_rebuild() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { bar::bar() } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") .file( "bar/Cargo.toml", r#" @@ -372,20 +355,9 @@ fn deep_dependencies_trigger_rebuild() { path = "../baz" "#, ) - .file( - "bar/src/bar.rs", - r#" - extern crate baz; - pub fn bar() { baz::baz() } - "#, - ) + .file("bar/src/bar.rs", "extern crate baz; pub fn bar() { baz::baz() }") .file("baz/Cargo.toml", &basic_lib_manifest("baz")) - .file( - "baz/src/baz.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/baz.rs", "pub fn baz() {}") .build(); assert_that( p.cargo("build"), @@ -471,13 +443,7 @@ fn no_rebuild_two_deps() { path = "baz" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { bar::bar() } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::bar() }") .file( "bar/Cargo.toml", r#" @@ -493,19 +459,9 @@ fn no_rebuild_two_deps() { path = "../baz" "#, ) - .file( - "bar/src/bar.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/bar.rs", "pub fn bar() {}") .file("baz/Cargo.toml", &basic_lib_manifest("baz")) - .file( - "baz/src/baz.rs", - r#" - pub fn baz() {} - "#, - ) + .file("baz/src/baz.rs", "pub fn baz() {}") .build(); assert_that( p.cargo("build"), @@ -667,15 +623,9 @@ fn override_self() { let p = project(); let root = p.root().clone(); - let p = p.file( - ".cargo/config", - &format!( - r#" - paths = ['{}'] - "#, - root.display() - ), - ).file( + let p = p + .file(".cargo/config", &format!("paths = ['{}']", root.display())) + .file( "Cargo.toml", &format!( r#" @@ -723,9 +673,7 @@ fn override_path_dep() { .file( ".cargo/config", &format!( - r#" - paths = ['{}', '{}'] - "#, + "paths = ['{}', '{}']", bar.root().join("p1").display(), bar.root().join("p2").display() ), @@ -796,12 +744,7 @@ fn path_dep_build_cmd() { } "#, ) - .file( - "bar/src/bar.rs.in", - r#" - pub fn gimme() -> i32 { 0 } - "#, - ) + .file("bar/src/bar.rs.in", "pub fn gimme() -> i32 { 0 }") .build(); p.root().join("bar").move_into_the_past(); @@ -990,12 +933,7 @@ fn override_and_depend() { "#, ) .file("b/src/lib.rs", "") - .file( - "b/.cargo/config", - r#" - paths = ["../a"] - "#, - ) + .file("b/.cargo/config", r#"paths = ["../a"]"#) .build(); assert_that( p.cargo("build").cwd(p.root().join("b")), @@ -1015,12 +953,7 @@ fn missing_path_dependency() { let p = project() .file("Cargo.toml", &basic_manifest("a", "0.5.0")) .file("src/lib.rs", "") - .file( - ".cargo/config", - r#" - paths = ["../whoa-this-does-not-exist"] - "#, - ) + .file(".cargo/config", r#"paths = ["../whoa-this-does-not-exist"]"#) .build(); assert_that( p.cargo("build"), diff --git a/tests/testsuite/plugins.rs b/tests/testsuite/plugins.rs index 4aa78b72a..b78e17a73 100644 --- a/tests/testsuite/plugins.rs +++ b/tests/testsuite/plugins.rs @@ -132,13 +132,7 @@ fn plugin_with_dynamic_native_dependency() { crate-type = ["dylib"] "#, ) - .file( - "src/lib.rs", - r#" - #[no_mangle] - pub extern fn foo() {} - "#, - ) + .file("src/lib.rs", "#[no_mangle] pub extern fn foo() {}") .build(); let foo = project().at("ws/foo") @@ -268,13 +262,7 @@ fn doctest_a_plugin() { bar = { path = "bar" } "#, ) - .file( - "src/lib.rs", - r#" - #[macro_use] - extern crate bar; - "#, - ) + .file("src/lib.rs", "#[macro_use] extern crate bar;") .file( "bar/Cargo.toml", r#" @@ -288,12 +276,7 @@ fn doctest_a_plugin() { plugin = true "#, ) - .file( - "bar/src/lib.rs", - r#" - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "pub fn bar() {}") .build(); assert_that(p.cargo("test").arg("-v"), execs().with_status(0)); @@ -429,12 +412,7 @@ fn shared_panic_abort_plugins() { baz = { path = "baz" } "#, ) - .file( - "src/lib.rs", - " - extern crate baz; - ", - ) + .file("src/lib.rs", "extern crate baz;") .file( "bar/Cargo.toml", r#" diff --git a/tests/testsuite/profile_overrides.rs b/tests/testsuite/profile_overrides.rs index d23568bbf..bd8384bbb 100644 --- a/tests/testsuite/profile_overrides.rs +++ b/tests/testsuite/profile_overrides.rs @@ -273,13 +273,8 @@ fn profile_override_hierarchy() { m2 = { path = "../m2" } dep = { path = "../../dep" } "#) - .file("m1/src/lib.rs", - r#" - extern crate m2; - extern crate dep; - "#) - .file("m1/build.rs", - r#"fn main() {}"#) + .file("m1/src/lib.rs", "extern crate m2; extern crate dep;") + .file("m1/build.rs", "fn main() {}") // m2 .file("m2/Cargo.toml", @@ -295,16 +290,8 @@ fn profile_override_hierarchy() { m3 = { path = "../m3" } dep = { path = "../../dep" } "#) - .file("m2/src/lib.rs", - r#" - extern crate m3; - "#) - .file("m2/build.rs", - r#" - extern crate m3; - extern crate dep; - fn main() {} - "#) + .file("m2/src/lib.rs", "extern crate m3;") + .file("m2/build.rs", "extern crate m3; extern crate dep; fn main() {}") // m3 .file("m3/Cargo.toml", &basic_lib_manifest("m3")) @@ -413,10 +400,7 @@ fn profile_override_spec() { [dependencies] dep = { path = "../../dep1" } "#) - .file("m1/src/lib.rs", - r#" - extern crate dep; - "#) + .file("m1/src/lib.rs", "extern crate dep;") // m2 .file("m2/Cargo.toml", @@ -428,10 +412,7 @@ fn profile_override_spec() { [dependencies] dep = {path = "../../dep2" } "#) - .file("m2/src/lib.rs", - r#" - extern crate dep; - "#) + .file("m2/src/lib.rs", "extern crate dep;") .build(); diff --git a/tests/testsuite/profile_targets.rs b/tests/testsuite/profile_targets.rs index 97db347b4..3bbcc4089 100644 --- a/tests/testsuite/profile_targets.rs +++ b/tests/testsuite/profile_targets.rs @@ -35,14 +35,8 @@ fn all_target_project() -> Project { "#, ) .file("src/lib.rs", "extern crate bar;") - .file("src/main.rs", r#" - extern crate foo; - fn main() {} - "#) - .file("examples/ex1.rs", r#" - extern crate foo; - fn main() {} - "#) + .file("src/main.rs", "extern crate foo; fn main() {}") + .file("examples/ex1.rs", "extern crate foo; fn main() {}") .file("tests/test1.rs", "extern crate foo;") .file("benches/bench1.rs", "extern crate foo;") .file("build.rs", r#" diff --git a/tests/testsuite/registry.rs b/tests/testsuite/registry.rs index d372edd9a..fbb16ef2c 100644 --- a/tests/testsuite/registry.rs +++ b/tests/testsuite/registry.rs @@ -861,12 +861,7 @@ fn bad_license_file() { repository = "baz" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); assert_that( p.cargo("publish") @@ -1784,14 +1779,7 @@ fn toml_lies_but_index_is_truth() { #[test] fn vv_prints_warnings() { Package::new("foo", "0.2.0") - .file( - "src/lib.rs", - r#" - #![deny(warnings)] - - fn foo() {} // unused function - "#, - ) + .file("src/lib.rs", "#![deny(warnings)] fn foo() {} // unused function") .publish(); let p = project() diff --git a/tests/testsuite/rename_deps.rs b/tests/testsuite/rename_deps.rs index 6f35cfc40..e65844b92 100644 --- a/tests/testsuite/rename_deps.rs +++ b/tests/testsuite/rename_deps.rs @@ -89,13 +89,7 @@ fn rename_dependency() { baz = { version = "0.2.0", package = "bar" } "#, ) - .file( - "src/lib.rs", - " - extern crate bar; - extern crate baz; - ", - ) + .file("src/lib.rs", "extern crate bar; extern crate baz;") .build(); assert_that( @@ -121,12 +115,7 @@ fn rename_with_different_names() { baz = { path = "bar", package = "bar" } "#, ) - .file( - "src/lib.rs", - " - extern crate baz; - ", - ) + .file("src/lib.rs", "extern crate baz;") .file( "bar/Cargo.toml", r#" @@ -236,16 +225,7 @@ fn rename_and_patch() { foo = { path = "foo" } "#, ) - .file( - "src/lib.rs", - " - extern crate bar; - - pub fn foo() { - bar::foo(); - } - ", - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() { bar::foo(); }") .file("foo/Cargo.toml", &basic_manifest("foo", "0.1.0")) .file("foo/src/lib.rs", "pub fn foo() {}") .build(); diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 25b4cd331..3890aeced 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -36,13 +36,7 @@ fn build_bin_default_features() { fn main() {} "#, ) - .file( - "src/lib.rs", - r#" - #[cfg(feature = "a")] - pub fn foo() {} - "#, - ) + .file("src/lib.rs", r#"#[cfg(feature = "a")] pub fn foo() {}"#) .build(); assert_that(p.cargo("build"), execs().with_status(0)); diff --git a/tests/testsuite/run.rs b/tests/testsuite/run.rs index f04b7eb9f..6f6407207 100644 --- a/tests/testsuite/run.rs +++ b/tests/testsuite/run.rs @@ -6,12 +6,7 @@ use support::hamcrest::{assert_that, existing_file}; #[test] fn simple() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); assert_that( @@ -33,12 +28,7 @@ fn simple() { #[test] fn simple_quiet() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); assert_that( @@ -55,12 +45,7 @@ fn simple_quiet() { #[test] fn simple_quiet_and_verbose() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); assert_that( @@ -81,12 +66,7 @@ fn quiet_and_verbose_config() { verbose = true "#, ) - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); assert_that(p.cargo("run").arg("-q"), execs().with_status(0)); @@ -115,12 +95,7 @@ fn simple_with_args() { #[test] fn exit_code() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { std::process::exit(2); } - "#, - ) + .file("src/main.rs", "fn main() { std::process::exit(2); }") .build(); let mut output = String::from( @@ -141,12 +116,7 @@ fn exit_code() { #[test] fn exit_code_verbose() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { std::process::exit(2); } - "#, - ) + .file("src/main.rs", "fn main() { std::process::exit(2); }") .build(); let mut output = String::from( @@ -389,18 +359,8 @@ consider adding `cargo-features = ["default-run"]` to the manifest fn run_example() { let p = project() .file("src/lib.rs", "") - .file( - "examples/a.rs", - r#" - fn main() { println!("example"); } - "#, - ) - .file( - "src/bin/a.rs", - r#" - fn main() { println!("bin"); } - "#, - ) + .file("examples/a.rs", r#"fn main() { println!("example"); }"#) + .file("src/bin/a.rs", r#"fn main() { println!("bin"); }"#) .build(); assert_that( @@ -434,12 +394,7 @@ fn run_library_example() { "#, ) .file("src/lib.rs", "") - .file( - "examples/bar.rs", - r#" - fn foo() {} - "#, - ) + .file("examples/bar.rs", "fn foo() {}") .build(); assert_that( @@ -480,12 +435,7 @@ fn autodiscover_examples_project(rust_edition: &str, autoexamples: Option) autoexamples = autoexamples ), ) - .file( - "examples/a.rs", - r#" - fn main() { println!("example"); } - "#, - ) + .file("examples/a.rs", r#"fn main() { println!("example"); }"#) .file( "examples/do_magic.rs", r#" @@ -602,18 +552,8 @@ fn run_example_autodiscover_2018() { fn run_bins() { let p = project() .file("src/lib.rs", "") - .file( - "examples/a.rs", - r#" - fn main() { println!("example"); } - "#, - ) - .file( - "src/bin/a.rs", - r#" - fn main() { println!("bin"); } - "#, - ) + .file("examples/a.rs", r#"fn main() { println!("example"); }"#) + .file("src/bin/a.rs", r#"fn main() { println!("bin"); }"#) .build(); assert_that( @@ -635,12 +575,7 @@ fn run_with_filename() { 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(); assert_that( @@ -681,18 +616,8 @@ Did you mean `a`?", #[test] fn either_name_or_example() { let p = project() - .file( - "src/bin/a.rs", - r#" - fn main() { println!("hello a.rs"); } - "#, - ) - .file( - "examples/b.rs", - r#" - fn main() { println!("hello b.rs"); } - "#, - ) + .file("src/bin/a.rs", r#"fn main() { println!("hello a.rs"); }"#) + .file("examples/b.rs", r#"fn main() { println!("hello b.rs"); }"#) .build(); assert_that( @@ -713,24 +638,9 @@ fn either_name_or_example() { fn one_bin_multiple_examples() { let p = project() .file("src/lib.rs", "") - .file( - "src/bin/main.rs", - r#" - fn main() { println!("hello main.rs"); } - "#, - ) - .file( - "examples/a.rs", - r#" - fn main() { println!("hello a.rs"); } - "#, - ) - .file( - "examples/b.rs", - r#" - fn main() { println!("hello b.rs"); } - "#, - ) + .file("src/bin/main.rs", r#"fn main() { println!("hello main.rs"); }"#) + .file("examples/a.rs", r#"fn main() { println!("hello a.rs"); }"#) + .file("examples/b.rs", r#"fn main() { println!("hello b.rs"); }"#) .build(); assert_that( @@ -882,13 +792,7 @@ fn run_dylib_dep() { path = "bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { bar::bar(); } - "#, - ) + .file("src/main.rs", r#"extern crate bar; fn main() { bar::bar(); }"#) .file( "bar/Cargo.toml", r#" @@ -951,12 +855,7 @@ fn run_bin_different_name() { name = "bar" "#, ) - .file( - "src/bar.rs", - r#" - fn main() { } - "#, - ) + .file("src/bar.rs", "fn main() {}") .build(); assert_that(p.cargo("run"), execs().with_status(0)); @@ -988,12 +887,7 @@ fn dashes_are_forwarded() { #[test] fn run_from_executable_folder() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { println!("hello"); } - "#, - ) + .file("src/main.rs", r#"fn main() { println!("hello"); }"#) .build(); let cwd = p.root().join("target").join("debug"); @@ -1128,14 +1022,7 @@ fn library_paths_sorted_alphabetically() { #[test] fn fail_no_extra_verbose() { let p = project() - .file( - "src/main.rs", - r#" - fn main() { - std::process::exit(1); - } - "#, - ) + .file("src/main.rs", "fn main() { std::process::exit(1); }") .build(); assert_that( diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index 269513998..d5406d4d7 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -8,12 +8,7 @@ the package by passing e.g. `--lib` or `--bin NAME` to specify a single target"; #[test] fn build_lib_for_foo() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -38,12 +33,7 @@ fn build_lib_for_foo() { #[test] fn lib() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -74,12 +64,7 @@ fn lib() { #[test] fn build_main_and_allow_unstable_options() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -113,12 +98,7 @@ fn build_main_and_allow_unstable_options() { #[test] fn fails_when_trying_to_build_main_and_lib_with_args() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -135,24 +115,9 @@ fn fails_when_trying_to_build_main_and_lib_with_args() { #[test] fn build_with_args_to_one_of_multiple_binaries() { let p = project() - .file( - "src/bin/foo.rs", - r#" - fn main() {} - "#, - ) - .file( - "src/bin/bar.rs", - r#" - fn main() {} - "#, - ) - .file( - "src/bin/baz.rs", - r#" - fn main() {} - "#, - ) + .file("src/bin/foo.rs", "fn main() {}") + .file("src/bin/bar.rs", "fn main() {}") + .file("src/bin/baz.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -176,24 +141,9 @@ fn build_with_args_to_one_of_multiple_binaries() { #[test] fn fails_with_args_to_all_binaries() { let p = project() - .file( - "src/bin/foo.rs", - r#" - fn main() {} - "#, - ) - .file( - "src/bin/bar.rs", - r#" - fn main() {} - "#, - ) - .file( - "src/bin/baz.rs", - r#" - fn main() {} - "#, - ) + .file("src/bin/foo.rs", "fn main() {}") + .file("src/bin/bar.rs", "fn main() {}") + .file("src/bin/baz.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); @@ -248,24 +198,11 @@ fn build_foo_with_bar_dependency() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - bar::baz() - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -302,24 +239,11 @@ fn build_only_bar_dependency() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - bar::baz() - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -398,12 +322,7 @@ fn fail_with_multiple_packages() { path = "../baz" "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .build(); let _bar = project().at("bar") diff --git a/tests/testsuite/rustdoc.rs b/tests/testsuite/rustdoc.rs index e4acef3fb..8678496e6 100644 --- a/tests/testsuite/rustdoc.rs +++ b/tests/testsuite/rustdoc.rs @@ -4,7 +4,7 @@ use support::hamcrest::assert_that; #[test] fn rustdoc_simple() { let p = project() - .file("src/lib.rs", r#" "#) + .file("src/lib.rs", "") .build(); assert_that( @@ -26,7 +26,7 @@ fn rustdoc_simple() { #[test] fn rustdoc_args() { let p = project() - .file("src/lib.rs", r#" "#) + .file("src/lib.rs", "") .build(); assert_that( @@ -61,22 +61,11 @@ fn rustdoc_foo_with_bar_dependency() { path = "../bar" "#, ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() {} - "#, - ) + .file("src/lib.rs", "extern crate bar; pub fn foo() {}") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -114,24 +103,11 @@ fn rustdoc_only_bar_dependency() { path = "../bar" "#, ) - .file( - "src/main.rs", - r#" - extern crate bar; - fn main() { - bar::baz() - } - "#, - ) + .file("src/main.rs", "extern crate bar; fn main() { bar::baz() }") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "src/lib.rs", - r#" - pub fn baz() {} - "#, - ) + .file("src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -158,12 +134,7 @@ fn rustdoc_only_bar_dependency() { #[test] fn rustdoc_same_name_documents_lib() { let p = project() - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("src/lib.rs", r#" "#) .build(); diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index a16da15ea..825ba3e4a 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -97,12 +97,7 @@ fn env_rustflags_build_script_dep() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() { } - "#, - ) + .file("build.rs", "fn main() {}") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -177,12 +172,7 @@ fn env_rustflags_plugin_dep() { path = "../bar" "#, ) - .file( - "src/lib.rs", - r#" - fn foo() { } - "#, - ) + .file("src/lib.rs", "fn foo() {}") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_lib_manifest("bar")) @@ -316,12 +306,7 @@ fn env_rustflags_build_script_dep_with_target() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() { } - "#, - ) + .file("build.rs", "fn main() {}") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) @@ -404,12 +389,7 @@ fn env_rustflags_plugin_dep_with_target() { path = "../bar" "#, ) - .file( - "src/lib.rs", - r#" - fn foo() { } - "#, - ) + .file("src/lib.rs", "fn foo() {}") .build(); let _bar = project().at("bar") .file("Cargo.toml", &basic_lib_manifest("bar")) @@ -568,12 +548,7 @@ fn build_rustflags_build_script_dep() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() { } - "#, - ) + .file("build.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -656,12 +631,7 @@ fn build_rustflags_plugin_dep() { path = "../bar" "#, ) - .file( - "src/lib.rs", - r#" - fn foo() { } - "#, - ) + .file("src/lib.rs", "fn foo() {}") .file( ".cargo/config", r#" @@ -795,12 +765,7 @@ fn build_rustflags_build_script_dep_with_target() { "#, ) .file("src/lib.rs", "") - .file( - "build.rs", - r#" - fn main() { } - "#, - ) + .file("build.rs", "fn main() {}") .file( ".cargo/config", r#" @@ -891,12 +856,7 @@ fn build_rustflags_plugin_dep_with_target() { path = "../bar" "#, ) - .file( - "src/lib.rs", - r#" - fn foo() { } - "#, - ) + .file("src/lib.rs", "fn foo() {}") .file( ".cargo/config", r#" diff --git a/tests/testsuite/search.rs b/tests/testsuite/search.rs index 13e1373f1..0a295eacc 100644 --- a/tests/testsuite/search.rs +++ b/tests/testsuite/search.rs @@ -67,16 +67,7 @@ fn setup() { // Init a new registry let _ = repo(®istry_path()) - .file( - "config.json", - &format!( - r#"{{ - "dl": "{0}", - "api": "{0}" - }}"#, - api() - ), - ) + .file("config.json", &format!(r#"{{"dl":"{0}","api":"{0}"}}"#, api())) .build(); let base = api_path().join("api/v1/crates"); diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 9233094d0..cf3c62095 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -304,21 +304,8 @@ failures: fn cargo_test_failing_test_in_test() { let p = project() .file("Cargo.toml", &basic_bin_manifest("foo")) - .file( - "src/main.rs", - r#" - pub fn main() { - println!("hello"); - }"#, - ) - .file( - "tests/footest.rs", - r#" - #[test] - fn test_hello() { - assert!(false) - }"#, - ) + .file("src/main.rs", r#"pub fn main() { println!("hello"); }"#) + .file("tests/footest.rs", "#[test] fn test_hello() { assert!(false) }") .build(); assert_that(p.cargo("build"), execs().with_status(0)); @@ -351,7 +338,7 @@ failures: ---- test_hello stdout ---- [..]thread 'test_hello' panicked at 'assertion failed: false', \ - tests[/]footest.rs:4[..] + tests[/]footest.rs:1[..] ", ) .with_stdout_contains( @@ -368,14 +355,7 @@ failures: fn cargo_test_failing_test_in_lib() { let p = project() .file("Cargo.toml", &basic_lib_manifest("foo")) - .file( - "src/lib.rs", - r#" - #[test] - fn test_hello() { - assert!(false) - }"#, - ) + .file("src/lib.rs", "#[test] fn test_hello() { assert!(false) }") .build(); assert_that( @@ -397,7 +377,7 @@ failures: ---- test_hello stdout ---- [..]thread 'test_hello' panicked at 'assertion failed: false', \ - src[/]lib.rs:4[..] + src[/]lib.rs:1[..] ", ) .with_stdout_contains( @@ -508,15 +488,7 @@ fn test_with_deep_lib_dep() { .build(); let _p2 = project().at("bar") .file("Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file( - "src/lib.rs", - " - pub fn bar() {} - - #[test] - fn foo_test() {} - ", - ) + .file("src/lib.rs", "pub fn bar() {} #[test] fn foo_test() {}") .build(); assert_that( @@ -608,13 +580,7 @@ fn external_test_named_test() { "#, ) .file("src/lib.rs", "") - .file( - "tests/test.rs", - r#" - #[test] - fn foo() { } - "#, - ) + .file("tests/test.rs", "#[test] fn foo() {}") .build(); assert_that(p.cargo("test"), execs().with_status(0)) @@ -665,11 +631,7 @@ fn external_test_implicit() { #[test] fn dont_run_examples() { let p = project() - .file( - "src/lib.rs", - r#" - "#, - ) + .file("src/lib.rs", "") .file( "examples/dont-run-me-i-will-fail.rs", r#" @@ -764,12 +726,7 @@ fn lib_bin_same_name() { name = "foo" "#, ) - .file( - "src/lib.rs", - " - #[test] fn lib_test() {} - ", - ) + .file("src/lib.rs", "#[test] fn lib_test() {}") .file( "src/main.rs", " @@ -863,12 +820,7 @@ fn lib_with_standard_name2() { doctest = false "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -913,12 +865,7 @@ fn lib_without_name() { doctest = false "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -966,12 +913,7 @@ fn bin_without_name() { path = "src/main.rs" "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -1016,12 +958,7 @@ fn bench_without_name() { path = "src/bench.rs" "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -1137,12 +1074,7 @@ fn example_without_name() { path = "examples/example.rs" "#, ) - .file( - "src/lib.rs", - " - pub fn foo() {} - ", - ) + .file("src/lib.rs", "pub fn foo() {}") .file( "src/main.rs", " @@ -1267,12 +1199,7 @@ fn test_dylib() { crate_type = ["dylib"] "#, ) - .file( - "bar/src/lib.rs", - " - pub fn baz() {} - ", - ) + .file("bar/src/lib.rs", "pub fn baz() {}") .build(); assert_that( @@ -1320,13 +1247,7 @@ fn test_twice_with_build_cmd() { "#, ) .file("build.rs", "fn main() {}") - .file( - "src/lib.rs", - " - #[test] - fn foo() {} - ", - ) + .file("src/lib.rs", "#[test] fn foo() {}") .build(); assert_that( @@ -1363,13 +1284,7 @@ fn test_twice_with_build_cmd() { #[test] fn test_then_build() { let p = project() - .file( - "src/lib.rs", - " - #[test] - fn foo() {} - ", - ) + .file("src/lib.rs", "#[test] fn foo() {}") .build(); assert_that( @@ -1394,13 +1309,7 @@ fn test_then_build() { #[test] fn test_no_run() { let p = project() - .file( - "src/lib.rs", - " - #[test] - fn foo() { panic!() } - ", - ) + .file("src/lib.rs", "#[test] fn foo() { panic!() }") .build(); assert_that( @@ -1914,10 +1823,7 @@ fn build_then_selective_test() { path = "b" "#, ) - .file( - "src/lib.rs", - "#[allow(unused_extern_crates)] extern crate b;", - ) + .file("src/lib.rs", "#[allow(unused_extern_crates)] extern crate b;") .file( "src/main.rs", r#" @@ -1952,18 +1858,8 @@ fn example_dev_dep() { path = "bar" "#, ) - .file( - "src/lib.rs", - r#" - "#, - ) - .file( - "examples/e1.rs", - r#" - extern crate bar; - fn main() { } - "#, - ) + .file("src/lib.rs", "") + .file("examples/e1.rs", "extern crate bar; fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) .file( "bar/src/lib.rs", @@ -2791,15 +2687,7 @@ fn cfg_test_even_with_no_harness() { doctest = false "#, ) - .file( - "src/lib.rs", - r#" - #[cfg(test)] - fn main() { - println!("hello!"); - } - "#, - ) + .file("src/lib.rs", r#"#[cfg(test)] fn main() { println!("hello!"); }"#) .build(); assert_that( p.cargo("test").arg("-v"), @@ -3018,21 +2906,9 @@ fn test_all_workspace() { [workspace] "#, ) - .file( - "src/main.rs", - r#" - #[test] - fn foo_test() {} - "#, - ) + .file("src/main.rs", "#[test] fn foo_test() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - #[test] - fn bar_test() {} - "#, - ) + .file("bar/src/lib.rs", "#[test] fn bar_test() {}") .build(); assert_that( @@ -3058,30 +2934,11 @@ fn test_all_exclude() { members = ["bar", "baz"] "#, ) - .file( - "src/main.rs", - r#" - fn main() {} - "#, - ) + .file("src/main.rs", "fn main() {}") .file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) - .file( - "bar/src/lib.rs", - r#" - #[test] - pub fn bar() {} - "#, - ) + .file("bar/src/lib.rs", "#[test] pub fn bar() {}") .file("baz/Cargo.toml", &basic_manifest("baz", "0.1.0")) - .file( - "baz/src/lib.rs", - r#" - #[test] - pub fn baz() { - assert!(false); - } - "#, - ) + .file("baz/src/lib.rs", "#[test] pub fn baz() { assert!(false); }") .build(); assert_that( @@ -3104,21 +2961,9 @@ fn test_all_virtual_manifest() { "#, ) .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) - .file( - "a/src/lib.rs", - r#" - #[test] - fn a() {} - "#, - ) + .file("a/src/lib.rs", "#[test] fn a() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) - .file( - "b/src/lib.rs", - r#" - #[test] - fn b() {} - "#, - ) + .file("b/src/lib.rs", "#[test] fn b() {}") .build(); assert_that( @@ -3141,21 +2986,9 @@ fn test_virtual_manifest_all_implied() { "#, ) .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) - .file( - "a/src/lib.rs", - r#" - #[test] - fn a() {} - "#, - ) + .file("a/src/lib.rs", "#[test] fn a() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) - .file( - "b/src/lib.rs", - r#" - #[test] - fn b() {} - "#, - ) + .file("b/src/lib.rs", "#[test] fn b() {}") .build(); assert_that( @@ -3188,13 +3021,7 @@ fn test_all_member_dependency_same_name() { a = "0.1.0" "#, ) - .file( - "a/src/lib.rs", - r#" - #[test] - fn a() {} - "#, - ) + .file("a/src/lib.rs", "#[test] fn a() {}") .build(); Package::new("a", "0.1.0").publish(); @@ -3231,12 +3058,7 @@ fn doctest_only_with_dev_dep() { "#, ) .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) - .file( - "b/src/lib.rs", - r#" - pub fn b() {} - "#, - ) + .file("b/src/lib.rs", "pub fn b() {}") .build(); assert_that( @@ -3283,30 +3105,10 @@ fn test_many_targets() { #[test] fn example_b() {} "#, ) - .file( - "examples/c.rs", - r#" - #[test] fn example_c() { panic!(); } - "#, - ) - .file( - "tests/a.rs", - r#" - #[test] fn test_a() {} - "#, - ) - .file( - "tests/b.rs", - r#" - #[test] fn test_b() {} - "#, - ) - .file( - "tests/c.rs", - r#" - does not compile - "#, - ) + .file("examples/c.rs", "#[test] fn example_c() { panic!(); }") + .file("tests/a.rs", "#[test] fn test_a() {}") + .file("tests/b.rs", "#[test] fn test_b() {}") + .file("tests/c.rs", "does not compile") .build(); assert_that( @@ -3422,24 +3224,9 @@ test env_test ... ok #[test] fn test_order() { let p = project() - .file( - "src/lib.rs", - r#" - #[test] fn test_lib() {} - "#, - ) - .file( - "tests/a.rs", - r#" - #[test] fn test_a() {} - "#, - ) - .file( - "tests/z.rs", - r#" - #[test] fn test_z() {} - "#, - ) + .file("src/lib.rs", "#[test] fn test_lib() {}") + .file("tests/a.rs", "#[test] fn test_a() {}") + .file("tests/z.rs", "#[test] fn test_z() {}") .build(); assert_that( @@ -3481,18 +3268,8 @@ fn cyclic_dev() { foo = { path = "." } "#, ) - .file( - "src/lib.rs", - r#" - #[test] fn test_lib() {} - "#, - ) - .file( - "tests/foo.rs", - r#" - extern crate foo; - "#, - ) + .file("src/lib.rs", "#[test] fn test_lib() {}") + .file("tests/foo.rs", "extern crate foo;") .build(); assert_that(p.cargo("test").arg("--all"), execs().with_status(0)); @@ -3664,21 +3441,9 @@ fn test_hint_workspace() { "#, ) .file("a/Cargo.toml", &basic_manifest("a", "0.1.0")) - .file( - "a/src/lib.rs", - r#" - #[test] - fn t1() {} - "#, - ) + .file("a/src/lib.rs", "#[test] fn t1() {}") .file("b/Cargo.toml", &basic_manifest("b", "0.1.0")) - .file( - "b/src/lib.rs", - r#" - #[test] - fn t1() {assert!(false)} - "#, - ) + .file("b/src/lib.rs", "#[test] fn t1() {assert!(false)}") .build(); assert_that( diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 7d9b8e6dc..1d9e47d5b 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -1423,10 +1423,7 @@ fn test_in_and_out_of_workspace() { members = [ "../bar" ] "#, ) - .file( - "ws/src/lib.rs", - r"extern crate foo; pub fn f() { foo::f() }", - ) + .file("ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }") .file( "foo/Cargo.toml", r#" @@ -1439,10 +1436,7 @@ fn test_in_and_out_of_workspace() { bar = { path = "../bar" } "#, ) - .file( - "foo/src/lib.rs", - "extern crate bar; pub fn f() { bar::f() }", - ) + .file("foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }") .file( "bar/Cargo.toml", r#" @@ -1495,10 +1489,7 @@ fn test_path_dependency_under_member() { [workspace] "#, ) - .file( - "ws/src/lib.rs", - r"extern crate foo; pub fn f() { foo::f() }", - ) + .file("ws/src/lib.rs", r"extern crate foo; pub fn f() { foo::f() }") .file( "foo/Cargo.toml", r#" @@ -1512,10 +1503,7 @@ fn test_path_dependency_under_member() { bar = { path = "./bar" } "#, ) - .file( - "foo/src/lib.rs", - "extern crate bar; pub fn f() { bar::f() }", - ) + .file("foo/src/lib.rs", "extern crate bar; pub fn f() { bar::f() }") .file("foo/bar/Cargo.toml", &basic_manifest("bar", "0.1.0")) .file("foo/bar/src/lib.rs", "pub fn f() { }"); let p = p.build();