|
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`
|
| 18 | +//@ ignore-windows |
| 19 | +// Reason: `set_readonly` has no effect on directories |
| 20 | +// and does not prevent modification. |
21 | 21 |
|
22 |
| -use run_make_support::{fs_wrapper, rustc}; |
| 22 | +use run_make_support::{fs_wrapper, rustc, test_while_readonly}; |
23 | 23 |
|
24 | 24 | fn main() {
|
25 | 25 | // Create an inaccessible directory.
|
26 | 26 | 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); |
| 27 | + test_while_readonly("inaccessible", || { |
| 28 | + // Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one, |
| 29 | + // so that it can't create `tmp`. |
| 30 | + rustc() |
| 31 | + .input("program.rs") |
| 32 | + .arg("-Ztemps-dir=inaccessible/tmp") |
| 33 | + .run_fail() |
| 34 | + .assert_stderr_contains( |
| 35 | + "failed to find or create the directory specified by `--temps-dir`", |
| 36 | + ); |
| 37 | + }); |
44 | 38 | }
|
0 commit comments