Skip to content

Commit 1ba5c98

Browse files
Migrate run-make/rustdoc-io-error to rmake.rs
1 parent f873ae0 commit 1ba5c98

File tree

3 files changed

+31
-21
lines changed

3 files changed

+31
-21
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ run-make/rlib-format-packed-bundled-libs-3/Makefile
189189
run-make/rlib-format-packed-bundled-libs/Makefile
190190
run-make/rmeta-preferred/Makefile
191191
run-make/rustc-macro-dep-files/Makefile
192-
run-make/rustdoc-io-error/Makefile
193192
run-make/sanitizer-cdylib-link/Makefile
194193
run-make/sanitizer-dylib-link/Makefile
195194
run-make/sanitizer-staticlib-link/Makefile

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

-20
This file was deleted.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
// On windows, the `set_readonly` functions doesn't work on folders.
10+
//@ ignore-windows
11+
12+
use run_make_support::{path, rustdoc};
13+
use std::fs;
14+
15+
fn main() {
16+
let out_dir = path("rustdoc-io-error");
17+
let output = fs::create_dir(&out_dir).unwrap();
18+
let mut permissions = fs::metadata(&out_dir).unwrap().permissions();
19+
let original_permissions = permissions.clone();
20+
21+
permissions.set_readonly(true);
22+
fs::set_permissions(&out_dir, permissions).unwrap();
23+
24+
let output = rustdoc().input("foo.rs").output(&out_dir).env("RUST_BACKTRACE", "1").run_fail();
25+
26+
fs::set_permissions(&out_dir, original_permissions).unwrap();
27+
28+
output
29+
.assert_exit_code(1)
30+
.assert_stderr_contains("error: couldn't generate documentation: Permission denied");
31+
}

0 commit comments

Comments
 (0)