|
| 1 | +// ignore-tidy-linelength |
| 2 | +//! If the environment variables contain an invalid `jobserver-auth`, this used to cause an ICE |
| 3 | +//! until this was fixed in [do not panic on failure to acquire jobserver token |
| 4 | +//! #109694](https://github.com/rust-lang/rust/pull/109694). |
| 5 | +//! |
| 6 | +//! Proper handling has been added, and this test checks that helpful warnings and errors are |
| 7 | +//! printed instead in case of a wrong jobserver. See |
| 8 | +//! <https://github.com/rust-lang/rust/issues/46981>. |
| 9 | +
|
| 10 | +//@ only-linux |
| 11 | +//@ ignore-cross-compile |
| 12 | + |
| 13 | +#![deny(warnings)] |
| 14 | + |
| 15 | +use run_make_support::{diff, rustc}; |
| 16 | + |
| 17 | +fn main() { |
| 18 | + let out = rustc() |
| 19 | + .stdin_buf(("fn main() {}").as_bytes()) |
| 20 | + .env("MAKEFLAGS", "--jobserver-auth=1000,1000") |
| 21 | + .run_fail() |
| 22 | + .stderr_utf8(); |
| 23 | + diff().expected_file("cannot_open_fd.stderr").actual_text("actual", out).run(); |
| 24 | + |
| 25 | + let out = rustc() |
| 26 | + .stdin_buf(("fn main() {}").as_bytes()) |
| 27 | + .input("-") |
| 28 | + .env("MAKEFLAGS", "--jobserver-auth=3,3") |
| 29 | + .set_aux_fd(3, std::fs::File::open("/dev/null").unwrap()) |
| 30 | + .run() |
| 31 | + .stderr_utf8(); |
| 32 | + diff().expected_file("not_a_pipe.stderr").actual_text("actual", out).run(); |
| 33 | + |
| 34 | + // FIXME(#110321): the Makefile version had a disabled check: |
| 35 | + // |
| 36 | + // ```makefile |
| 37 | + // bash -c 'echo "fn main() {}" | MAKEFLAGS="--jobserver-auth=3,3" $(RUSTC) - 3< <(cat /dev/null)' 2>&1 | diff poisoned_pipe.stderr - |
| 38 | + // ``` |
| 39 | + // |
| 40 | + // > the jobserver helper thread launched here gets starved out and doesn't run, while the |
| 41 | + // > coordinator thread continually processes work using the implicit jobserver token, never |
| 42 | + // > yielding long enough for the jobserver helper to do its work (and process the error). |
| 43 | + // |
| 44 | + // but is not necessarily worth fixing as it might require changing coordinator behavior that |
| 45 | + // might regress performance. See discussion at |
| 46 | + // <https://github.com/rust-lang/rust/issues/110321#issuecomment-1636914956>. |
| 47 | +} |
0 commit comments