|
13 | 13 | // use a directory with non-existing parent like `/does-not-exist/output`. |
14 | 14 | // See https://github.com/rust-lang/rust/issues/66530 |
15 | 15 |
|
16 | | -//@ only-linux |
17 | | -// Reason: set_mode is only available on Unix |
18 | | - |
19 | 16 | //@ ignore-arm |
20 | 17 | // Reason: linker error on `armhf-gnu` |
21 | 18 |
|
22 | | -use run_make_support::{fs_wrapper, rustc}; |
| 19 | +use run_make_support::{fs_wrapper, rustc, test_while_readonly}; |
23 | 20 |
|
24 | 21 | fn main() { |
25 | 22 | // Create an inaccessible directory. |
26 | 23 | fs_wrapper::create_dir("inaccessible"); |
27 | | - let meta = fs_wrapper::metadata("inaccessible"); |
28 | | - let mut perms = meta.permissions(); |
29 | | - perms.set_mode(0o000); // Lock down the directory. |
30 | | - fs_wrapper::set_permissions("inaccessible", perms); |
31 | | - |
32 | | - // Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one, |
33 | | - // so that it can't create `tmp`. |
34 | | - rustc() |
35 | | - .input("program.rs") |
36 | | - .arg("-Ztemps-dir=inaccessible/tmp") |
37 | | - .run_fail() |
38 | | - .assert_stderr_contains( |
39 | | - "failed to find or create the directory specified by `--temps-dir`", |
40 | | - ); |
41 | | - |
42 | | - perms.set_mode(0o666); // Unlock the directory, so that compiletest can delete it. |
43 | | - fs_wrapper::set_permissions("inaccessible", perms); |
| 24 | + test_while_readonly("inaccessible", || { |
| 25 | + // Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one, |
| 26 | + // so that it can't create `tmp`. |
| 27 | + rustc() |
| 28 | + .input("program.rs") |
| 29 | + .arg("-Ztemps-dir=inaccessible/tmp") |
| 30 | + .run_fail() |
| 31 | + .assert_stderr_contains( |
| 32 | + "failed to find or create the directory specified by `--temps-dir`", |
| 33 | + ); |
| 34 | + }); |
44 | 35 | } |
0 commit comments