Skip to content

Commit 6ca32be

Browse files
committed
Declare one-line write_all contents on one line, too
1 parent ca7d9ee commit 6ca32be

File tree

8 files changed

+22
-111
lines changed

8 files changed

+22
-111
lines changed

tests/testsuite/freshness.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -138,24 +138,14 @@ fn rebuild_sub_package_then_while_package() {
138138

139139
File::create(&p.root().join("b/src/lib.rs"))
140140
.unwrap()
141-
.write_all(
142-
br#"
143-
pub fn b() {}
144-
"#,
145-
)
141+
.write_all(br#"pub fn b() {}"#)
146142
.unwrap();
147143

148144
assert_that(p.cargo("build").arg("-pb"), execs().with_status(0));
149145

150146
File::create(&p.root().join("src/lib.rs"))
151147
.unwrap()
152-
.write_all(
153-
br#"
154-
extern crate a;
155-
extern crate b;
156-
pub fn toplevel() {}
157-
"#,
158-
)
148+
.write_all(br#"extern crate a; extern crate b; pub fn toplevel() {}"#)
159149
.unwrap();
160150

161151
assert_that(p.cargo("build"), execs().with_status(0));

tests/testsuite/git.rs

+8-40
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,7 @@ fn cargo_compile_offline_with_cached_git_dep() {
125125
// Commit the changes and make sure we trigger a recompile
126126
File::create(&git_project.root().join("src/lib.rs"))
127127
.unwrap()
128-
.write_all(
129-
br#"
130-
pub static COOL_STR:&str = "cached git repo rev2";
131-
"#,
132-
)
128+
.write_all(br#"pub static COOL_STR:&str = "cached git repo rev2";"#)
133129
.unwrap();
134130
git::add(&repo);
135131
let rev2 = git::commit(&repo);
@@ -657,11 +653,7 @@ fn two_revs_same_deps() {
657653
// Commit the changes and make sure we trigger a recompile
658654
File::create(&bar.root().join("src/lib.rs"))
659655
.unwrap()
660-
.write_all(
661-
br#"
662-
pub fn bar() -> i32 { 2 }
663-
"#,
664-
)
656+
.write_all(br#"pub fn bar() -> i32 { 2 }"#)
665657
.unwrap();
666658
git::add(&repo);
667659
let rev2 = git::commit(&repo);
@@ -784,11 +776,7 @@ fn recompilation() {
784776
// Modify a file manually, shouldn't trigger a recompile
785777
File::create(&git_project.root().join("src/bar.rs"))
786778
.unwrap()
787-
.write_all(
788-
br#"
789-
pub fn bar() { println!("hello!"); }
790-
"#,
791-
)
779+
.write_all(br#"pub fn bar() { println!("hello!"); }"#)
792780
.unwrap();
793781

794782
assert_that(p.cargo("build"), execs().with_stdout(""));
@@ -940,11 +928,7 @@ fn update_with_shared_deps() {
940928
// Modify a file manually, and commit it
941929
File::create(&git_project.root().join("src/bar.rs"))
942930
.unwrap()
943-
.write_all(
944-
br#"
945-
pub fn bar() { println!("hello!"); }
946-
"#,
947-
)
931+
.write_all(br#"pub fn bar() { println!("hello!"); }"#)
948932
.unwrap();
949933
let repo = git2::Repository::open(&git_project.root()).unwrap();
950934
let old_head = repo.head().unwrap().target().unwrap();
@@ -1204,11 +1188,7 @@ fn two_deps_only_update_one() {
12041188

12051189
File::create(&git1.root().join("src/lib.rs"))
12061190
.unwrap()
1207-
.write_all(
1208-
br#"
1209-
pub fn foo() {}
1210-
"#,
1211-
)
1191+
.write_all(br#"pub fn foo() {}"#)
12121192
.unwrap();
12131193
let repo = git2::Repository::open(&git1.root()).unwrap();
12141194
git::add(&repo);
@@ -1268,11 +1248,7 @@ fn stale_cached_version() {
12681248
// us pulling it down.
12691249
File::create(&bar.root().join("src/lib.rs"))
12701250
.unwrap()
1271-
.write_all(
1272-
br#"
1273-
pub fn bar() -> i32 { 1 + 0 }
1274-
"#,
1275-
)
1251+
.write_all(br#"pub fn bar() -> i32 { 1 + 0 }"#)
12761252
.unwrap();
12771253
let repo = git2::Repository::open(&bar.root()).unwrap();
12781254
git::add(&repo);
@@ -1657,11 +1633,7 @@ fn git_repo_changing_no_rebuild() {
16571633
// Make a commit to lock p2 to a different rev
16581634
File::create(&bar.root().join("src/lib.rs"))
16591635
.unwrap()
1660-
.write_all(
1661-
br#"
1662-
pub fn bar() -> i32 { 2 }
1663-
"#,
1664-
)
1636+
.write_all(br#"pub fn bar() -> i32 { 2 }"#)
16651637
.unwrap();
16661638
let repo = git2::Repository::open(&bar.root()).unwrap();
16671639
git::add(&repo);
@@ -2121,11 +2093,7 @@ fn update_one_source_updates_all_packages_in_that_git_source() {
21212093
// Just be sure to change a file
21222094
File::create(&dep.root().join("src/lib.rs"))
21232095
.unwrap()
2124-
.write_all(
2125-
br#"
2126-
pub fn bar() -> i32 { 2 }
2127-
"#,
2128-
)
2096+
.write_all(br#"pub fn bar() -> i32 { 2 }"#)
21292097
.unwrap();
21302098
git::add(&repo);
21312099
git::commit(&repo);

tests/testsuite/init.rs

+4-28
Original file line numberDiff line numberDiff line change
@@ -167,26 +167,14 @@ fn confused_by_multiple_lib_files() {
167167

168168
File::create(&sourcefile_path1)
169169
.unwrap()
170-
.write_all(
171-
br#"
172-
fn qqq () {
173-
println!("Hello, world 2!");
174-
}
175-
"#,
176-
)
170+
.write_all(br#"fn qqq () { println!("Hello, world 2!"); }"#)
177171
.unwrap();
178172

179173
let sourcefile_path2 = path.join("lib.rs");
180174

181175
File::create(&sourcefile_path2)
182176
.unwrap()
183-
.write_all(
184-
br#"
185-
fn qqq () {
186-
println!("Hello, world 3!");
187-
}
188-
"#,
189-
)
177+
.write_all(br#" fn qqq () { println!("Hello, world 3!"); }"#)
190178
.unwrap();
191179

192180
assert_that(
@@ -215,26 +203,14 @@ fn multibin_project_name_clash() {
215203

216204
File::create(&sourcefile_path1)
217205
.unwrap()
218-
.write_all(
219-
br#"
220-
fn main () {
221-
println!("Hello, world 2!");
222-
}
223-
"#,
224-
)
206+
.write_all(br#"fn main () { println!("Hello, world 2!"); }"#)
225207
.unwrap();
226208

227209
let sourcefile_path2 = path.join("main.rs");
228210

229211
File::create(&sourcefile_path2)
230212
.unwrap()
231-
.write_all(
232-
br#"
233-
fn main () {
234-
println!("Hello, world 3!");
235-
}
236-
"#,
237-
)
213+
.write_all(br#"fn main () { println!("Hello, world 3!"); }"#)
238214
.unwrap();
239215

240216
assert_that(

tests/testsuite/login.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ fn setup_new_credentials() {
3030
let config = cargo_home().join("credentials");
3131
t!(fs::create_dir_all(config.parent().unwrap()));
3232
t!(t!(File::create(&config)).write_all(
33-
format!(
34-
r#"
35-
token = "{token}"
36-
"#,
37-
token = ORIGINAL_TOKEN
38-
).as_bytes()
33+
format!(r#"token = "{token}""#, token = ORIGINAL_TOKEN).as_bytes()
3934
));
4035
}
4136

tests/testsuite/package.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -615,11 +615,7 @@ fn repackage_on_source_change() {
615615
)
616616
});
617617

618-
file.write_all(
619-
br#"
620-
fn main() { println!("foo"); }
621-
"#,
622-
).unwrap();
618+
file.write_all(br#"fn main() { println!("foo"); }"#).unwrap();
623619
std::mem::drop(file);
624620

625621
let mut pro = process(&cargo_exe());

tests/testsuite/path.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -381,11 +381,7 @@ fn deep_dependencies_trigger_rebuild() {
381381
sleep_ms(1000);
382382
File::create(&p.root().join("baz/src/baz.rs"))
383383
.unwrap()
384-
.write_all(
385-
br#"
386-
pub fn baz() { println!("hello!"); }
387-
"#,
388-
)
384+
.write_all(br#"pub fn baz() { println!("hello!"); }"#)
389385
.unwrap();
390386
assert_that(
391387
p.cargo("build"),
@@ -520,11 +516,7 @@ fn nested_deps_recompile() {
520516

521517
File::create(&p.root().join("src/main.rs"))
522518
.unwrap()
523-
.write_all(
524-
br#"
525-
fn main() {}
526-
"#,
527-
)
519+
.write_all(br#"fn main() {}"#)
528520
.unwrap();
529521

530522
// This shouldn't recompile `bar`

tests/testsuite/publish.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,7 @@ fn old_token_location() {
8787
let credentials = paths::root().join("home/.cargo/credentials");
8888
File::create(credentials)
8989
.unwrap()
90-
.write_all(
91-
br#"
92-
token = "api-token"
93-
"#,
94-
)
90+
.write_all(br#"token = "api-token""#)
9591
.unwrap();
9692

9793
let p = project()

tests/testsuite/workspaces.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1119,11 +1119,9 @@ fn rebuild_please() {
11191119

11201120
sleep_ms(1000);
11211121

1122-
t!(t!(File::create(p.root().join("lib/src/lib.rs"))).write_all(
1123-
br#"
1124-
pub fn foo() -> u32 { 1 }
1125-
"#
1126-
));
1122+
t!(t!(File::create(p.root().join("lib/src/lib.rs")))
1123+
.write_all(br#"pub fn foo() -> u32 { 1 }"#)
1124+
);
11271125

11281126
assert_that(
11291127
p.cargo("build").cwd(p.root().join("lib")),

0 commit comments

Comments
 (0)