Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit e96bb6a

Browse files
authored
Rollup merge of rust-lang#135926 - jieyouxu:needs-subprocess-thread, r=oli-obk
Implement `needs-subprocess` directive, and cleanup a bunch of tests to use `needs-{subprocess,threads}` ### Summary Closes rust-lang#128295. - Implements `//@ needs-subprocess` directive in compiletest as requested in rust-lang#128295. However, compiletest is a host tool, so we can't just try to spawn process because that spawns the process on *host*, not the *target*, under cross-compilation scenarios. - The short-term solution is to add *Yet Another* list of allow-list targets. - The long-term solution is to first check if a `$target` supports std, then try to run a binary to do run-time capability detection *on the target*. But that is tricky because you have to build-and-run a binary *for the target*. - This PR picks the short-term solution, because the long-term solution is highly non-trivial, and it's already an improvement over individual `ignore-*`s all over the place. - Opened an issue about the long-term solution in rust-lang#135928. - Documents `//@ needs-subprocess` in rustc-dev-guide. - Replace `ignore-{wasm,wasm32,emscripten,sgx}` with `needs-{subprocess,threads}` where suitable in tests. - Some drive-by test changes as I was trying to figure out if I could use `needs-{subprocess,threads}` and found some bits needlessly distracting. Count of tests that use `ignore-{wasm,wasm32,emscripten,sgx}` before and after this PR: | State | `ignore-sgx` | `ignore-wasm` | `ignore-emscripten` | | - | - | - | - | | Before this PR | 96 | 88 | 207 | | After this PR | 36 | 38 | 61 | <details> <summary>Commands used to find out locally</summary> ``` --- before [17:40] Joe:rust (fresh) | rg --no-ignore -l "ignore-sgx" tests | wc -l 96 [17:40] Joe:rust (fresh) | rg --no-ignore -l "ignore-wasm" tests | wc -l 88 [17:40] Joe:rust (fresh) | rg --no-ignore -l "ignore-emscripten" tests | wc -l 207 --- after [17:39] Joe:rust (needs-subprocess-thread) | rg --no-ignore -l "ignore-sgx" tests | wc -l 36 [17:39] Joe:rust (needs-subprocess-thread) | rg --no-ignore -l "ignore-wasm" tests | wc -l 38 [17:39] Joe:rust (needs-subprocess-thread) | rg --no-ignore -l "ignore-emscripten" tests | wc -l 61 ``` </details> ### Review advice - Best reviewed commit-by-commit. - Non-trivial test changes (not mechanically simple replacements) are split into individual commits to help with review. Their individual commit messages give some basic description of the changes. - I *could* split some test changes out into another PR, but I found that I needed to change some tests to `needs-threads`, some to `needs-subprocess`, and some needed to use *both*, so they might conflict and become very annoying. --- r? ``@ghost`` (need to run try jobs) try-job: x86_64-msvc-1 try-job: i686-msvc-1 try-job: i686-mingw try-job: x86_64-mingw-1 try-job: x86_64-apple-1 try-job: aarch64-apple try-job: aarch64-gnu try-job: test-various try-job: armhf-gnu
2 parents 135cd69 + 071ad37 commit e96bb6a

File tree

214 files changed

+292
-334
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+292
-334
lines changed

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ for more details.
9494
| Directive | Explanation | Supported test suites | Possible values |
9595
|-----------------------------------|--------------------------------------------------------------------------------------------------------------------------|----------------------------------------------|-----------------------------------------------------------------------------------------|
9696
| `check-run-results` | Check run test binary `run-{pass,fail}` output snapshot | `ui`, `crashes`, `incremental` if `run-pass` | N/A |
97-
| `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String |
97+
| `error-pattern` | Check that output contains a specific string | `ui`, `crashes`, `incremental` if `run-pass` | String |
9898
| `regex-error-pattern` | Check that output contains a regex pattern | `ui`, `crashes`, `incremental` if `run-pass` | Regex |
9999
| `check-stdout` | Check `stdout` against `error-pattern`s from running test binary[^check_stdout] | `ui`, `crashes`, `incremental` | N/A |
100100
| `normalize-stderr-32bit` | Normalize actual stderr (for 32-bit platforms) with a rule `"<raw>" -> "<normalized>"` before comparing against snapshot | `ui`, `incremental` | `"<RAW>" -> "<NORMALIZED>"`, `<RAW>`/`<NORMALIZED>` is regex capture and replace syntax |
@@ -176,6 +176,7 @@ settings:
176176
- `needs-rust-lld` — ignores if the rust lld support is not enabled (`rust.lld =
177177
true` in `config.toml`)
178178
- `needs-threads` — ignores if the target does not have threading support
179+
- `needs-subprocess` — ignores if the target does not have subprocess support
179180
- `needs-symlink` — ignores if the target does not support symlinks. This can be
180181
the case on Windows if the developer did not enable privileged symlink
181182
permissions.

src/tools/compiletest/src/common.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,17 @@ impl Config {
488488
git_merge_commit_email: &self.git_merge_commit_email,
489489
}
490490
}
491+
492+
pub fn has_subprocess_support(&self) -> bool {
493+
// FIXME(#135928): compiletest is always a **host** tool. Building and running an
494+
// capability detection executable against the **target** is not trivial. The short term
495+
// solution here is to hard-code some targets to allow/deny, unfortunately.
496+
497+
let unsupported_target = self.target_cfg().env == "sgx"
498+
|| matches!(self.target_cfg().arch.as_str(), "wasm32" | "wasm64")
499+
|| self.target_cfg().os == "emscripten";
500+
!unsupported_target
501+
}
491502
}
492503

493504
/// Known widths of `target_has_atomic`.

src/tools/compiletest/src/directive-list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
152152
"needs-sanitizer-support",
153153
"needs-sanitizer-thread",
154154
"needs-std-debug-assertions",
155+
"needs-subprocess",
155156
"needs-symlink",
156157
"needs-target-has-atomic",
157158
"needs-threads",

src/tools/compiletest/src/header/needs.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@ pub(super) fn handle_needs(
9494
condition: config.has_threads(),
9595
ignore_reason: "ignored on targets without threading support",
9696
},
97+
Need {
98+
name: "needs-subprocess",
99+
condition: config.has_subprocess_support(),
100+
ignore_reason: "ignored on targets without subprocess support",
101+
},
97102
Need {
98103
name: "needs-unwind",
99104
condition: config.can_unwind(),
@@ -351,6 +356,9 @@ fn find_dlltool(config: &Config) -> bool {
351356
dlltool_found
352357
}
353358

359+
// FIXME(#135928): this is actually not quite right because this detection is run on the **host**.
360+
// This however still helps the case of windows -> windows local development in case symlinks are
361+
// not available.
354362
#[cfg(windows)]
355363
fn has_symlinks() -> bool {
356364
if std::env::var_os("CI").is_some() {

src/tools/tidy/src/issues.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2204,7 +2204,6 @@ ui/issues/issue-3895.rs
22042204
ui/issues/issue-38954.rs
22052205
ui/issues/issue-38987.rs
22062206
ui/issues/issue-39089.rs
2207-
ui/issues/issue-39175.rs
22082207
ui/issues/issue-39211.rs
22092208
ui/issues/issue-39367.rs
22102209
ui/issues/issue-39548.rs

src/tools/tidy/src/ui_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use ignore::Walk;
1717
const ENTRY_LIMIT: u32 = 901;
1818
// FIXME: The following limits should be reduced eventually.
1919

20-
const ISSUES_ENTRY_LIMIT: u32 = 1664;
20+
const ISSUES_ENTRY_LIMIT: u32 = 1662;
2121

2222
const EXPECTED_TEST_FILE_EXTENSIONS: &[&str] = &[
2323
"rs", // test source files

tests/ui/abi/homogenous-floats-target-feature-mixup.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
// without #[repr(simd)]
66

77
//@ run-pass
8-
//@ ignore-wasm32 no processes
9-
//@ ignore-sgx no processes
8+
//@ needs-subprocess
109

1110
#![feature(avx512_target_feature)]
1211

tests/ui/abi/segfault-no-out-of-stack.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//@ run-pass
2-
//@ ignore-wasm32 can't run commands
3-
//@ ignore-sgx no processes
2+
//@ needs-subprocess
43
//@ ignore-fuchsia must translate zircon signal to SIGSEGV/SIGBUS, FIXME (#58590)
54

65
#![feature(rustc_private)]

tests/ui/abi/stack-probes-lto.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@[aarch64] only-aarch64
44
//@[x32] only-x86
55
//@[x64] only-x86_64
6-
//@ ignore-sgx no processes
6+
//@ needs-subprocess
77
//@ ignore-musl FIXME #31506
88
//@ ignore-fuchsia no exception handler registered for segfault
99
//@ compile-flags: -C lto

tests/ui/abi/stack-probes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
//@[aarch64] only-aarch64
44
//@[x32] only-x86
55
//@[x64] only-x86_64
6-
//@ ignore-emscripten no processes
7-
//@ ignore-sgx no processes
6+
//@ needs-subprocess
87
//@ ignore-fuchsia no exception handler registered for segfault
98
//@ ignore-nto Crash analysis impossible at SIGSEGV in QNX Neutrino
109
//@ ignore-ios Stack probes are enabled, but the SIGSEGV handler isn't

0 commit comments

Comments
 (0)