1
Fork 0

compiletest: Add a //@ needs-threads directive

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.
This commit is contained in:
Alex Crichton 2024-03-06 12:19:20 -08:00
parent bfe762e0ed
commit 75fa9f6dec
77 changed files with 109 additions and 76 deletions

View file

@ -2,7 +2,7 @@
// Reported as issue #126, child leaks the string.
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,13 +1,13 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};
pub fn main() {
let (tx, rx) = channel();
let t = thread::spawn(move|| { child(&tx) });
let t = thread::spawn(move || { child(&tx) });
let y = rx.recv().unwrap();
println!("received");
println!("{}", y);

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no processes
//@ needs-threads
//@ ignore-sgx no processes
use std::cell::RefCell;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads
//@ needs-threads
//@ ignore-sgx no processes
use std::thread;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,4 +1,4 @@
//@ ignore-wasm32
//@ needs-threads
//@ dont-check-compiler-stderr
#![feature(cfg_target_thread_local, thread_local_internals)]

View file

@ -1,4 +1,4 @@
//@ ignore-wasm32
//@ needs-threads
#![feature(thread_local)]
#![feature(cfg_target_thread_local, thread_local_internals)]

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::channel;
use std::thread;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::channel;
use std::thread;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Receiver};

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(deprecated)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{TryRecvError, channel};
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
//@ compile-flags:--test
//@ ignore-emscripten
//@ needs-threads
use std::sync::mpsc::channel;
use std::sync::mpsc::TryRecvError;

View file

@ -4,7 +4,7 @@
#![allow(non_camel_case_types)]
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::channel;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(non_camel_case_types)]
//@ ignore-emscripten no threads support
//@ needs-threads
/*
Make sure we can spawn tasks that take different types of

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -3,7 +3,7 @@
#![allow(unused_mut)]
//@ ignore-windows
//@ exec-env:RUST_LOG=debug
//@ ignore-emscripten no threads support
//@ needs-threads
// regression test for issue #10405, make sure we don't call println! too soon.

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
//@ pretty-expanded FIXME #23616
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_variables)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_parens)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
//@ pretty-expanded FIXME #23616
use std::sync::mpsc::{channel, Sender};

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
//@ pretty-expanded FIXME #23616
// Issue #922

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(unused_must_use)]
#![allow(unused_assignments)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::{channel, Sender};

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
//@ pretty-expanded FIXME #23616
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-fail
//@ error-pattern:Ensure that the child thread runs by panicking
//@ ignore-emscripten Needs threads.
//@ needs-threads
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;
use std::sync::mpsc::channel;

View file

@ -1,5 +1,5 @@
//@ run-pass
//@ ignore-emscripten no threads support
//@ needs-threads
//@ needs-unwind
#![feature(internal_output_capture)]

View file

@ -1,6 +1,6 @@
//@ run-pass
//@ ignore-android needs extra network permissions
//@ ignore-emscripten no threads or sockets support
//@ needs-threads
//@ ignore-netbsd system ulimit (Too many open files)
//@ ignore-openbsd system ulimit (Too many open files)

View file

@ -5,7 +5,7 @@
//@ error-pattern:should be a positive integer
//@ compile-flags: --test
//@ exec-env:RUST_TEST_THREADS=foo
//@ ignore-emscripten
//@ needs-threads
#[test]
fn do_nothing() {}

View file

@ -1,6 +1,6 @@
//@ run-pass
#![allow(unused_must_use)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -1,6 +1,6 @@
//@ run-pass
//@ no-prefer-dynamic
//@ ignore-emscripten no threads support
//@ needs-threads
static mut HIT: bool = false;

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(stable_features)]
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(thread_local_try_with)]

View file

@ -1,7 +1,7 @@
//@ run-pass
#![allow(stable_features)]
//@ ignore-emscripten no threads support
//@ needs-threads
#![feature(thread_local_try_with)]

View file

@ -2,7 +2,7 @@
//@ needs-unwind
#![allow(non_camel_case_types)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::sync::mpsc::{channel, Sender};
use std::thread;

View file

@ -2,7 +2,7 @@
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;

View file

@ -2,7 +2,7 @@
#![allow(unused_must_use)]
#![allow(unused_mut)]
//@ ignore-emscripten no threads support
//@ needs-threads
use std::thread;