From 6ca32be8a2079141a8d6ff6fb36c4bc3de90de19 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Wed, 25 Jul 2018 09:58:40 +0100 Subject: [PATCH] Declare one-line write_all contents on one line, too --- tests/testsuite/freshness.rs | 14 ++-------- tests/testsuite/git.rs | 48 ++++++----------------------------- tests/testsuite/init.rs | 32 +++-------------------- tests/testsuite/login.rs | 7 +---- tests/testsuite/package.rs | 6 +---- tests/testsuite/path.rs | 12 ++------- tests/testsuite/publish.rs | 6 +---- tests/testsuite/workspaces.rs | 8 +++--- 8 files changed, 22 insertions(+), 111 deletions(-) diff --git a/tests/testsuite/freshness.rs b/tests/testsuite/freshness.rs index 6ee5f79b7..59da71ea3 100644 --- a/tests/testsuite/freshness.rs +++ b/tests/testsuite/freshness.rs @@ -138,24 +138,14 @@ fn rebuild_sub_package_then_while_package() { File::create(&p.root().join("b/src/lib.rs")) .unwrap() - .write_all( - br#" - pub fn b() {} - "#, - ) + .write_all(br#"pub fn b() {}"#) .unwrap(); assert_that(p.cargo("build").arg("-pb"), execs().with_status(0)); File::create(&p.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - extern crate a; - extern crate b; - pub fn toplevel() {} - "#, - ) + .write_all(br#"extern crate a; extern crate b; pub fn toplevel() {}"#) .unwrap(); assert_that(p.cargo("build"), execs().with_status(0)); diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 5ccecff7a..46820523d 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -125,11 +125,7 @@ fn cargo_compile_offline_with_cached_git_dep() { // Commit the changes and make sure we trigger a recompile File::create(&git_project.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - pub static COOL_STR:&str = "cached git repo rev2"; - "#, - ) + .write_all(br#"pub static COOL_STR:&str = "cached git repo rev2";"#) .unwrap(); git::add(&repo); let rev2 = git::commit(&repo); @@ -657,11 +653,7 @@ fn two_revs_same_deps() { // Commit the changes and make sure we trigger a recompile File::create(&bar.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - pub fn bar() -> i32 { 2 } - "#, - ) + .write_all(br#"pub fn bar() -> i32 { 2 }"#) .unwrap(); git::add(&repo); let rev2 = git::commit(&repo); @@ -784,11 +776,7 @@ fn recompilation() { // Modify a file manually, shouldn't trigger a recompile File::create(&git_project.root().join("src/bar.rs")) .unwrap() - .write_all( - br#" - pub fn bar() { println!("hello!"); } - "#, - ) + .write_all(br#"pub fn bar() { println!("hello!"); }"#) .unwrap(); assert_that(p.cargo("build"), execs().with_stdout("")); @@ -940,11 +928,7 @@ fn update_with_shared_deps() { // Modify a file manually, and commit it File::create(&git_project.root().join("src/bar.rs")) .unwrap() - .write_all( - br#" - pub fn bar() { println!("hello!"); } - "#, - ) + .write_all(br#"pub fn bar() { println!("hello!"); }"#) .unwrap(); let repo = git2::Repository::open(&git_project.root()).unwrap(); let old_head = repo.head().unwrap().target().unwrap(); @@ -1204,11 +1188,7 @@ fn two_deps_only_update_one() { File::create(&git1.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - pub fn foo() {} - "#, - ) + .write_all(br#"pub fn foo() {}"#) .unwrap(); let repo = git2::Repository::open(&git1.root()).unwrap(); git::add(&repo); @@ -1268,11 +1248,7 @@ fn stale_cached_version() { // us pulling it down. File::create(&bar.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - pub fn bar() -> i32 { 1 + 0 } - "#, - ) + .write_all(br#"pub fn bar() -> i32 { 1 + 0 }"#) .unwrap(); let repo = git2::Repository::open(&bar.root()).unwrap(); git::add(&repo); @@ -1657,11 +1633,7 @@ fn git_repo_changing_no_rebuild() { // Make a commit to lock p2 to a different rev File::create(&bar.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - pub fn bar() -> i32 { 2 } - "#, - ) + .write_all(br#"pub fn bar() -> i32 { 2 }"#) .unwrap(); let repo = git2::Repository::open(&bar.root()).unwrap(); git::add(&repo); @@ -2121,11 +2093,7 @@ fn update_one_source_updates_all_packages_in_that_git_source() { // Just be sure to change a file File::create(&dep.root().join("src/lib.rs")) .unwrap() - .write_all( - br#" - pub fn bar() -> i32 { 2 } - "#, - ) + .write_all(br#"pub fn bar() -> i32 { 2 }"#) .unwrap(); git::add(&repo); git::commit(&repo); diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index cc4101000..bc2fdbfaf 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -167,26 +167,14 @@ fn confused_by_multiple_lib_files() { File::create(&sourcefile_path1) .unwrap() - .write_all( - br#" - fn qqq () { - println!("Hello, world 2!"); - } - "#, - ) + .write_all(br#"fn qqq () { println!("Hello, world 2!"); }"#) .unwrap(); let sourcefile_path2 = path.join("lib.rs"); File::create(&sourcefile_path2) .unwrap() - .write_all( - br#" - fn qqq () { - println!("Hello, world 3!"); - } - "#, - ) + .write_all(br#" fn qqq () { println!("Hello, world 3!"); }"#) .unwrap(); assert_that( @@ -215,26 +203,14 @@ fn multibin_project_name_clash() { File::create(&sourcefile_path1) .unwrap() - .write_all( - br#" - fn main () { - println!("Hello, world 2!"); - } - "#, - ) + .write_all(br#"fn main () { println!("Hello, world 2!"); }"#) .unwrap(); let sourcefile_path2 = path.join("main.rs"); File::create(&sourcefile_path2) .unwrap() - .write_all( - br#" - fn main () { - println!("Hello, world 3!"); - } - "#, - ) + .write_all(br#"fn main () { println!("Hello, world 3!"); }"#) .unwrap(); assert_that( diff --git a/tests/testsuite/login.rs b/tests/testsuite/login.rs index 4e728d393..d847861dd 100644 --- a/tests/testsuite/login.rs +++ b/tests/testsuite/login.rs @@ -30,12 +30,7 @@ fn setup_new_credentials() { let config = cargo_home().join("credentials"); t!(fs::create_dir_all(config.parent().unwrap())); t!(t!(File::create(&config)).write_all( - format!( - r#" - token = "{token}" - "#, - token = ORIGINAL_TOKEN - ).as_bytes() + format!(r#"token = "{token}""#, token = ORIGINAL_TOKEN).as_bytes() )); } diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index f26607276..e00f65178 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -615,11 +615,7 @@ fn repackage_on_source_change() { ) }); - file.write_all( - br#" - fn main() { println!("foo"); } - "#, - ).unwrap(); + file.write_all(br#"fn main() { println!("foo"); }"#).unwrap(); std::mem::drop(file); let mut pro = process(&cargo_exe()); diff --git a/tests/testsuite/path.rs b/tests/testsuite/path.rs index 0bae3553c..0e699b596 100644 --- a/tests/testsuite/path.rs +++ b/tests/testsuite/path.rs @@ -381,11 +381,7 @@ fn deep_dependencies_trigger_rebuild() { sleep_ms(1000); File::create(&p.root().join("baz/src/baz.rs")) .unwrap() - .write_all( - br#" - pub fn baz() { println!("hello!"); } - "#, - ) + .write_all(br#"pub fn baz() { println!("hello!"); }"#) .unwrap(); assert_that( p.cargo("build"), @@ -520,11 +516,7 @@ fn nested_deps_recompile() { File::create(&p.root().join("src/main.rs")) .unwrap() - .write_all( - br#" - fn main() {} - "#, - ) + .write_all(br#"fn main() {}"#) .unwrap(); // This shouldn't recompile `bar` diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index 9b011c23b..f229bbd6d 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -87,11 +87,7 @@ fn old_token_location() { let credentials = paths::root().join("home/.cargo/credentials"); File::create(credentials) .unwrap() - .write_all( - br#" - token = "api-token" - "#, - ) + .write_all(br#"token = "api-token""#) .unwrap(); let p = project() diff --git a/tests/testsuite/workspaces.rs b/tests/testsuite/workspaces.rs index 1d9e47d5b..0439c5811 100644 --- a/tests/testsuite/workspaces.rs +++ b/tests/testsuite/workspaces.rs @@ -1119,11 +1119,9 @@ fn rebuild_please() { sleep_ms(1000); - t!(t!(File::create(p.root().join("lib/src/lib.rs"))).write_all( - br#" - pub fn foo() -> u32 { 1 } - "# - )); + t!(t!(File::create(p.root().join("lib/src/lib.rs"))) + .write_all(br#"pub fn foo() -> u32 { 1 }"#) + ); assert_that( p.cargo("build").cwd(p.root().join("lib")),