File tree Expand file tree Collapse file tree 4 files changed +63
-78
lines changed Expand file tree Collapse file tree 4 files changed +63
-78
lines changed Original file line number Diff line number Diff line change @@ -334,78 +334,3 @@ impl VisitMut for FormatInlineTable {
334
334
} ) ;
335
335
}
336
336
}
337
-
338
- #[ cfg( test) ]
339
- mod tests {
340
- use super :: * ;
341
-
342
- #[ test]
343
- fn cargo_toml ( ) {
344
- #[ rustfmt:: skip]
345
- let s = r#"
346
-
347
-
348
- [[bin]]
349
- "aa" = 1
350
- 'bb' = 2
351
- "啊"=1
352
- [package]
353
- version = 1
354
- description = "a\nb\nhaha"
355
- name = 3
356
-
357
- # comment 1
358
-
359
- arr1 = [1,
360
- 2,3]
361
-
362
- # comment 2
363
-
364
- arr2 = ["11111111111111111111111111111111111111111111111111111111111111111111111111111111","1111111111111111111111111111111111111111111111111111111111111111111111111111111"]
365
-
366
- [dependencies]
367
- extremely_long_crate_name_goes_here = {path = "extremely_long_path_name_goes_right_here",version = "4.5.6"}
368
- crate1 = { path = "crate1",version = "1.2.3" }
369
-
370
- [[bin]]
371
- d = "git-rustfmt"
372
- c = "src/git-rustfmt/main.rs""# ;
373
-
374
- let formatted = format_cargo_toml_inner ( s, & Default :: default ( ) ) . unwrap ( ) ;
375
-
376
- #[ rustfmt:: skip]
377
- let expected = r#"[package]
378
- name = 3
379
- version = 1
380
- # comment 1
381
- arr1 = [1, 2, 3]
382
- # comment 2
383
- arr2 = [
384
- "11111111111111111111111111111111111111111111111111111111111111111111111111111111",
385
- "1111111111111111111111111111111111111111111111111111111111111111111111111111111"
386
- ]
387
- description = """
388
- a
389
- b
390
- haha"""
391
-
392
- [[bin]]
393
- aa = 1
394
- bb = 2
395
- "啊" = 1
396
-
397
- [[bin]]
398
- c = "src/git-rustfmt/main.rs"
399
- d = "git-rustfmt"
400
-
401
- [dependencies]
402
- crate1 = { path = "crate1", version = "1.2.3" }
403
-
404
- [dependencies.extremely_long_crate_name_goes_here]
405
- path = "extremely_long_path_name_goes_right_here"
406
- version = "4.5.6"
407
- "# ;
408
-
409
- assert_eq ! ( formatted, expected) ;
410
- }
411
- }
Original file line number Diff line number Diff line change @@ -95,8 +95,8 @@ fn is_file_skip(path: &Path) -> bool {
95
95
. any ( |file_path| is_subpath ( path, file_path) )
96
96
}
97
97
98
- // Returns a `Vec` containing `PathBuf`s of files with an `rs` extension in the
99
- // given path. The `recursive` argument controls if files from subdirectories
98
+ // Returns a `Vec` containing `PathBuf`s of files with an `rs` extension or a `Cargo.toml` filename
99
+ // in the given path. The `recursive` argument controls if files from subdirectories
100
100
// are also returned.
101
101
fn get_test_files ( path : & Path , recursive : bool ) -> Vec < PathBuf > {
102
102
let mut files = vec ! [ ] ;
@@ -109,7 +109,10 @@ fn get_test_files(path: &Path, recursive: bool) -> Vec<PathBuf> {
109
109
let path = entry. path ( ) ;
110
110
if path. is_dir ( ) && recursive {
111
111
files. append ( & mut get_test_files ( & path, recursive) ) ;
112
- } else if path. extension ( ) . map_or ( false , |f| f == "rs" ) && !is_file_skip ( & path) {
112
+ } else if ( path. extension ( ) . map_or ( false , |f| f == "rs" )
113
+ || path. file_name ( ) . map_or ( false , |f| f == "Cargo.toml" ) )
114
+ && !is_file_skip ( & path)
115
+ {
113
116
files. push ( path) ;
114
117
}
115
118
}
Original file line number Diff line number Diff line change
1
+
2
+
3
+ [[bin ]]
4
+ "aa" = 1
5
+ 'bb' = 2
6
+ "啊" =1
7
+ [package ]
8
+ version = 1
9
+ description = " a\n b\n haha"
10
+ name = 3
11
+
12
+ # comment 1
13
+
14
+ arr1 = [1 ,
15
+ 2 ,3 ]
16
+
17
+ # comment 2
18
+
19
+ arr2 = [" 11111111111111111111111111111111111111111111111111111111111111111111111111111111" ," 1111111111111111111111111111111111111111111111111111111111111111111111111111111" ]
20
+
21
+ [dependencies ]
22
+ extremely_long_crate_name_goes_here = {path = " extremely_long_path_name_goes_right_here" ,version = " 4.5.6" }
23
+ crate1 = { path = " crate1" ,version = " 1.2.3" }
24
+
25
+ [[bin ]]
26
+ d = " git-rustfmt"
27
+ c = " src/git-rustfmt/main.rs"
Original file line number Diff line number Diff line change
1
+ [package ]
2
+ name = 3
3
+ version = 1
4
+ # comment 1
5
+ arr1 = [1 , 2 , 3 ]
6
+ # comment 2
7
+ arr2 = [
8
+ " 11111111111111111111111111111111111111111111111111111111111111111111111111111111" ,
9
+ " 1111111111111111111111111111111111111111111111111111111111111111111111111111111"
10
+ ]
11
+ description = """
12
+ a
13
+ b
14
+ haha"""
15
+
16
+ [[bin ]]
17
+ aa = 1
18
+ bb = 2
19
+ "啊" = 1
20
+
21
+ [[bin ]]
22
+ c = " src/git-rustfmt/main.rs"
23
+ d = " git-rustfmt"
24
+
25
+ [dependencies ]
26
+ crate1 = { path = " crate1" , version = " 1.2.3" }
27
+
28
+ [dependencies .extremely_long_crate_name_goes_here ]
29
+ path = " extremely_long_path_name_goes_right_here"
30
+ version = " 4.5.6"
You can’t perform that action at this time.
0 commit comments