File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
src/tools/tidy/src/alphabetical Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,23 @@ fn bad(lines: &str, expected_msg: &str) {
2929 test ( lines, "bad" , expected_msg, true ) ;
3030}
3131
32+ #[ track_caller]
33+ fn bless_test ( before : & str , after : & str ) {
34+ let tempfile = tempfile:: Builder :: new ( ) . tempfile ( ) . unwrap ( ) ;
35+ std:: fs:: write ( tempfile. path ( ) , before) . unwrap ( ) ;
36+
37+ let tidy_ctx = TidyCtx :: new ( Path :: new ( "/" ) , false , TidyFlags :: new ( & [ "--bless" . to_owned ( ) ] ) ) ;
38+
39+ let mut check = tidy_ctx. start_check ( "alphabetical-test" ) ;
40+ check_lines ( tempfile. path ( ) , before, & tidy_ctx, & mut check) ;
41+
42+ assert ! ( !check. is_bad( ) ) ;
43+ let new = std:: fs:: read_to_string ( tempfile. path ( ) ) . unwrap ( ) ;
44+ assert_eq ! ( new, after) ;
45+
46+ good ( & new) ;
47+ }
48+
3249#[ test]
3350fn test_no_markers ( ) {
3451 let lines = "\
@@ -396,3 +413,25 @@ fn multiline() {
396413 " ;
397414 good ( lines) ;
398415}
416+
417+ #[ test]
418+ fn bless_smoke ( ) {
419+ let before = "\
420+ tidy-alphabetical-start
421+ 08
422+ 1
423+ 11
424+ 03
425+ tidy-alphabetical-end
426+ " ;
427+ let after = "\
428+ tidy-alphabetical-start
429+ 1
430+ 03
431+ 08
432+ 11
433+ tidy-alphabetical-end
434+ " ;
435+
436+ bless_test ( before, after) ;
437+ }
You can’t perform that action at this time.
0 commit comments