-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate
run-make/rustdoc-io-error
to rmake.rs
- Loading branch information
1 parent
f873ae0
commit c5bb1ac
Showing
3 changed files
with
40 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// This test verifies that rustdoc doesn't ICE when it encounters an IO error | ||
// while generating files. Ideally this would be a rustdoc-ui test, so we could | ||
// verify the error message as well. | ||
// | ||
// It operates by creating a temporary directory and modifying its | ||
// permissions so that it is not writable. We have to take special care to set | ||
// the permissions back to normal so that it's able to be deleted later. | ||
|
||
// On windows, the `set_readonly` functions doesn't work on folders. | ||
//@ ignore-windows | ||
|
||
use run_make_support::{path, rustdoc}; | ||
use std::fs; | ||
|
||
fn main() { | ||
let out_dir = path("rustdoc-io-error"); | ||
let output = fs::create_dir(&out_dir).unwrap(); | ||
let mut permissions = fs::metadata(&out_dir).unwrap().permissions(); | ||
let original_permissions = permissions.clone(); | ||
|
||
permissions.set_readonly(true); | ||
fs::set_permissions(&out_dir, permissions).unwrap(); | ||
|
||
let output = rustdoc().input("foo.rs").output(&out_dir).env("RUST_BACKTRACE", "1").run_fail(); | ||
|
||
fs::set_permissions(&out_dir, original_permissions).unwrap(); | ||
|
||
let stderr = output.stderr_utf8(); | ||
|
||
// Checks that rustdoc failed with the error code 1. | ||
if output.status().code() != Some(1) { | ||
eprintln!("=== STDOUT ==="); | ||
eprintln!("{}", output.stdout_utf8()); | ||
eprintln!("=== STDERR ==="); | ||
eprintln!("{stderr}"); | ||
panic!("Expected status code to be 1, found {}", output.status().code().unwrap()); | ||
} | ||
|
||
assert!(stderr.contains("error: couldn't generate documentation: Permission denied")); | ||
} |