Skip to content

Commit

Permalink
Auto merge of rust-lang#124807 - GuillaumeGomez:migrate-rustdoc-io-er…
Browse files Browse the repository at this point in the history
…ror, r=<try>

Migrate `run-make/rustdoc-io-error` to `rmake.rs`

Part of rust-lang#121876.

r? `@jieyouxu`

try-job: armhf-gnu
  • Loading branch information
bors committed May 14, 2024
2 parents ac385a5 + a4ca364 commit d6adcab
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 21 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ run-make/rlib-format-packed-bundled-libs-3/Makefile
run-make/rlib-format-packed-bundled-libs/Makefile
run-make/rmeta-preferred/Makefile
run-make/rustc-macro-dep-files/Makefile
run-make/rustdoc-io-error/Makefile
run-make/rustdoc-scrape-examples-invalid-expr/Makefile
run-make/rustdoc-scrape-examples-macros/Makefile
run-make/rustdoc-scrape-examples-multiple/Makefile
Expand Down
20 changes: 0 additions & 20 deletions tests/run-make/rustdoc-io-error/Makefile

This file was deleted.

41 changes: 41 additions & 0 deletions tests/run-make/rustdoc-io-error/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// 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.

use run_make_support::{rustdoc, tmp_dir};
use std::fs;

fn main() {
// FIXME: Remove this line once figured out what's wrong.
std::env::set_var("RUST_BACKTRACE", "1");
let out_dir = tmp_dir().join("rustdoc-io-error");
let output = fs::create_dir(&out_dir).unwrap();
let mut permissions = fs::metadata(&out_dir).unwrap().permissions();
permissions.set_readonly(true);
fs::set_permissions(&out_dir, permissions.clone()).unwrap();

let output = rustdoc().input("foo.rs").output(&out_dir).command_output();

// Changing back permissions.
permissions.set_readonly(false);
fs::set_permissions(&out_dir, permissions).unwrap();

let stderr = String::from_utf8(output.stderr).unwrap();

// Checks that rustdoc failed with the error code 1.
#[cfg(target_os = "linux")]
if output.status.code().unwrap() != 1 {
eprintln!("=== STDOUT ===");
eprintln!("{}", String::from_utf8(output.stdout).unwrap());
eprintln!("=== STDERR ===");
eprintln!("{stderr}");
panic!("Expected status code to be 1, found {}", output.status.code().unwrap());
}
assert!(!output.status.success());

assert!(stderr.contains("error: couldn't generate documentation: Permission denied"));
}

0 comments on commit d6adcab

Please sign in to comment.