Skip to content

Commit f1a79b8

Browse files
authored
Rollup merge of #124807 - GuillaumeGomez:migrate-rustdoc-io-error, r=jieyouxu
Migrate `run-make/rustdoc-io-error` to `rmake.rs` Part of #121876. r? `@jieyouxu`
2 parents df940d9 + bce3598 commit f1a79b8

File tree

3 files changed

+32
-21
lines changed

3 files changed

+32
-21
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,6 @@ run-make/rlib-format-packed-bundled-libs-3/Makefile
241241
run-make/rlib-format-packed-bundled-libs/Makefile
242242
run-make/rmeta-preferred/Makefile
243243
run-make/rustc-macro-dep-files/Makefile
244-
run-make/rustdoc-io-error/Makefile
245244
run-make/rustdoc-scrape-examples-invalid-expr/Makefile
246245
run-make/rustdoc-scrape-examples-macros/Makefile
247246
run-make/rustdoc-scrape-examples-multiple/Makefile

tests/run-make/rustdoc-io-error/Makefile

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// This test verifies that rustdoc doesn't ICE when it encounters an IO error
2+
// while generating files. Ideally this would be a rustdoc-ui test, so we could
3+
// verify the error message as well.
4+
//
5+
// It operates by creating a temporary directory and modifying its
6+
// permissions so that it is not writable. We have to take special care to set
7+
// the permissions back to normal so that it's able to be deleted later.
8+
9+
use run_make_support::{rustdoc, tmp_dir};
10+
use std::fs;
11+
12+
fn main() {
13+
let out_dir = tmp_dir().join("rustdoc-io-error");
14+
let output = fs::create_dir(&out_dir).unwrap();
15+
let mut permissions = fs::metadata(&out_dir).unwrap().permissions();
16+
let original_permissions = permissions.clone();
17+
permissions.set_readonly(true);
18+
fs::set_permissions(&out_dir, permissions.clone()).unwrap();
19+
20+
let output = rustdoc().input("foo.rs").output(&out_dir).command_output();
21+
22+
// Changing back permissions.
23+
fs::set_permissions(&out_dir, original_permissions).unwrap();
24+
25+
// Checks that rustdoc failed with the error code 1.
26+
#[cfg(unix)]
27+
assert_eq!(output.status.code().unwrap(), 1);
28+
assert!(!output.status.success());
29+
let stderr = String::from_utf8(output.stderr).unwrap();
30+
31+
assert!(stderr.contains("error: couldn't generate documentation: Permission denied"));
32+
}

0 commit comments

Comments
 (0)