-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #81546 - hyd-dev:libtest-run-out-of-threads, r=Mark-S…
…imulacrum [libtest] Run the test synchronously when hitting thread limit libtest currently panics if it hits the thread limit. This often results in spurious test failures (<code>thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 11, kind: WouldBlock, message: "Resource temporarily unavailable" }'</code> ... `error: test failed, to rerun pass '--lib'`). This PR makes it continue to run the test synchronously if it runs out of threads. Closes #78165. ``@rustbot`` label: A-libtest T-libs
- Loading branch information
Showing
3 changed files
with
35 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
-include ../../run-make-fulldeps/tools.mk | ||
|
||
# only-linux | ||
|
||
all: | ||
$(RUSTC) test.rs --test --target $(TARGET) | ||
$(shell ulimit -p 0 && $(call RUN,test)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#![feature(once_cell)] | ||
|
||
use std::{io::ErrorKind, lazy::SyncOnceCell, thread::{self, Builder, ThreadId}}; | ||
|
||
static THREAD_ID: SyncOnceCell<ThreadId> = SyncOnceCell::new(); | ||
|
||
#[test] | ||
fn spawn_thread_would_block() { | ||
assert_eq!(Builder::new().spawn(|| unreachable!()).unwrap_err().kind(), ErrorKind::WouldBlock); | ||
THREAD_ID.set(thread::current().id()).unwrap(); | ||
} | ||
|
||
#[test] | ||
fn run_in_same_thread() { | ||
assert_eq!(*THREAD_ID.get().unwrap(), thread::current().id()); | ||
} |