Skip to content

Commit 232e7a5

Browse files
authored
Rollup merge of #85997 - jyn514:rustdoc-diff, r=Mark-Simulacrum
rustdoc: Print a warning if the diff when comparing to old nightlies is empty This avoids confusing situations where it's unclear whether there's a bug in the diff tool or not: ``` 26: `@has` check failed `XPATH PATTERN` did not match // `@has` - '//code/a[`@href="{{channel}}/std/primitive.i32.html"]'` 'i32' Encountered 6 errors ------------------------------------------ info: generating a diff against nightly rustdoc failures: [rustdoc] rustdoc/primitive-reexport.rs ```
2 parents 578eb6d + 2430ede commit 232e7a5

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/tools/compiletest/src/runtest.rs

+21-9
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,7 @@ impl<'test> TestCx<'test> {
24882488

24892489
{
24902490
let mut diff_output = File::create(&diff_filename).unwrap();
2491+
let mut wrote_data = false;
24912492
for entry in walkdir::WalkDir::new(out_dir) {
24922493
let entry = entry.expect("failed to read file");
24932494
let extension = entry.path().extension().and_then(|p| p.to_str());
@@ -2500,17 +2501,28 @@ impl<'test> TestCx<'test> {
25002501
if let Ok(s) = std::fs::read(&expected_path) { s } else { continue };
25012502
let actual_path = entry.path();
25022503
let actual = std::fs::read(&actual_path).unwrap();
2503-
diff_output
2504-
.write_all(&unified_diff::diff(
2505-
&expected,
2506-
&expected_path.to_string_lossy(),
2507-
&actual,
2508-
&actual_path.to_string_lossy(),
2509-
3,
2510-
))
2511-
.unwrap();
2504+
let diff = unified_diff::diff(
2505+
&expected,
2506+
&expected_path.to_string_lossy(),
2507+
&actual,
2508+
&actual_path.to_string_lossy(),
2509+
3,
2510+
);
2511+
wrote_data |= !diff.is_empty();
2512+
diff_output.write_all(&diff).unwrap();
25122513
}
25132514
}
2515+
2516+
if !wrote_data {
2517+
println!("note: diff is identical to nightly rustdoc");
2518+
assert!(diff_output.metadata().unwrap().len() == 0);
2519+
return;
2520+
} else if self.config.verbose {
2521+
eprintln!("printing diff:");
2522+
let mut buf = Vec::new();
2523+
diff_output.read_to_end(&mut buf).unwrap();
2524+
std::io::stderr().lock().write_all(&mut buf).unwrap();
2525+
}
25142526
}
25152527

25162528
match self.config.color {

0 commit comments

Comments
 (0)