Declare one-line write_all contents on one line, too

This commit is contained in:
Dale Wijnand 2018-07-25 09:58:40 +01:00
parent ca7d9ee292
commit 6ca32be8a2
No known key found for this signature in database
GPG Key ID: 4F256E3D151DF5EF
8 changed files with 22 additions and 111 deletions

View File

@ -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));

View File

@ -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);

View File

@ -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(

View File

@ -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()
));
}

View File

@ -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());

View File

@ -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`

View File

@ -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()

View File

@ -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")),