mirror of
https://github.com/rust-lang/rust
synced 2024-09-06 01:11:17 +00:00
![Alex Crichton](/assets/img/avatar_default.png)
This commit is extracted from #122036 and adds a new directive to the `compiletest` test runner, `//@ needs-threads`. This is intended to capture the need that a target must implement threading to execute a specific test, typically one that uses `std::thread`. This is primarily done for WebAssembly targets which currently do not have threads by default. This enables transitioning a lot of `//@ ignore-wasm*`-style ignores into a more self-documenting `//@ needs-threads` directive. Additionally the `wasm32-wasi-preview1-threads` target, for example, does actually have threads, but isn't tested in CI at this time. This change enables running these tests for that target, but not other wasm targets.
32 lines
800 B
Rust
32 lines
800 B
Rust
//@ run-pass
|
|
//@ needs-threads
|
|
|
|
use std::thread;
|
|
|
|
pub fn main() {
|
|
let t = thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) );
|
|
t.join().ok().unwrap(); // forget Err value, since it doesn't implement Debug
|
|
}
|
|
|
|
fn child(args: (isize, isize, isize, isize, isize, isize, isize, isize, isize)) {
|
|
let (i1, i2, i3, i4, i5, i6, i7, i8, i9) = args;
|
|
println!("{}", i1);
|
|
println!("{}", i2);
|
|
println!("{}", i3);
|
|
println!("{}", i4);
|
|
println!("{}", i5);
|
|
println!("{}", i6);
|
|
println!("{}", i7);
|
|
println!("{}", i8);
|
|
println!("{}", i9);
|
|
assert_eq!(i1, 10);
|
|
assert_eq!(i2, 20);
|
|
assert_eq!(i3, 30);
|
|
assert_eq!(i4, 40);
|
|
assert_eq!(i5, 50);
|
|
assert_eq!(i6, 60);
|
|
assert_eq!(i7, 70);
|
|
assert_eq!(i8, 80);
|
|
assert_eq!(i9, 90);
|
|
}
|