@@ -8,7 +8,7 @@ use crate::common::{CompareMode, FailMode, PassMode};
8
8
use crate :: common:: { Config , TestPaths } ;
9
9
use crate :: common:: { Pretty , RunPassValgrind } ;
10
10
use crate :: common:: { UI_RUN_STDERR , UI_RUN_STDOUT } ;
11
- use crate :: compute_diff:: write_diff;
11
+ use crate :: compute_diff:: { write_diff, write_rustdoc_diff } ;
12
12
use crate :: errors:: { self , Error , ErrorKind } ;
13
13
use crate :: header:: TestProps ;
14
14
use crate :: json;
@@ -2403,43 +2403,8 @@ impl<'test> TestCx<'test> {
2403
2403
2404
2404
let diff_filename = format ! ( "build/tmp/rustdoc-compare-{}.diff" , std:: process:: id( ) ) ;
2405
2405
2406
- {
2407
- let mut diff_output = File :: create ( & diff_filename) . unwrap ( ) ;
2408
- let mut wrote_data = false ;
2409
- for entry in walkdir:: WalkDir :: new ( out_dir) {
2410
- let entry = entry. expect ( "failed to read file" ) ;
2411
- let extension = entry. path ( ) . extension ( ) . and_then ( |p| p. to_str ( ) ) ;
2412
- if entry. file_type ( ) . is_file ( )
2413
- && ( extension == Some ( "html" . into ( ) ) || extension == Some ( "js" . into ( ) ) )
2414
- {
2415
- let expected_path =
2416
- compare_dir. join ( entry. path ( ) . strip_prefix ( & out_dir) . unwrap ( ) ) ;
2417
- let expected =
2418
- if let Ok ( s) = std:: fs:: read ( & expected_path) { s } else { continue } ;
2419
- let actual_path = entry. path ( ) ;
2420
- let actual = std:: fs:: read ( & actual_path) . unwrap ( ) ;
2421
- let diff = unified_diff:: diff (
2422
- & expected,
2423
- & expected_path. to_string_lossy ( ) ,
2424
- & actual,
2425
- & actual_path. to_string_lossy ( ) ,
2426
- 3 ,
2427
- ) ;
2428
- wrote_data |= !diff. is_empty ( ) ;
2429
- diff_output. write_all ( & diff) . unwrap ( ) ;
2430
- }
2431
- }
2432
-
2433
- if !wrote_data {
2434
- println ! ( "note: diff is identical to nightly rustdoc" ) ;
2435
- assert ! ( diff_output. metadata( ) . unwrap( ) . len( ) == 0 ) ;
2436
- return ;
2437
- } else if self . config . verbose {
2438
- eprintln ! ( "printing diff:" ) ;
2439
- let mut buf = Vec :: new ( ) ;
2440
- diff_output. read_to_end ( & mut buf) . unwrap ( ) ;
2441
- std:: io:: stderr ( ) . lock ( ) . write_all ( & mut buf) . unwrap ( ) ;
2442
- }
2406
+ if !write_rustdoc_diff ( & diff_filename, out_dir, & compare_dir, self . config . verbose ) {
2407
+ return ;
2443
2408
}
2444
2409
2445
2410
match self . config . color {
0 commit comments