Skip to content

Commit 0f8ad4b

Browse files
PgBielBromeon
authored andcommitted
check wasm with atomics to run threaded tests
no feature needed
1 parent 6113b0b commit 0f8ad4b

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

godot-cell/tests/mock/blocking.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ impl MyClass {
4040
///
4141
/// This should not cause borrow failures and should not lead to deadlocks.
4242
#[test]
43+
#[cfg_attr(
44+
all(target_family = "wasm", not(target_feature = "atomics")),
45+
ignore = "Threading not available"
46+
)]
4347
fn calls_parallel() {
4448
use std::thread;
4549

@@ -72,6 +76,10 @@ fn calls_parallel() {
7276
/// Runs each method several times in a row. This should reduce the non-determinism that comes from
7377
/// scheduling of threads.
7478
#[test]
79+
#[cfg_attr(
80+
all(target_family = "wasm", not(target_feature = "atomics")),
81+
ignore = "Threading not available"
82+
)]
7583
fn calls_parallel_many_serial() {
7684
use std::thread;
7785

@@ -106,6 +114,10 @@ fn calls_parallel_many_serial() {
106114
/// Runs all the tests several times. This is different from [`calls_parallel_many_serial`] as that calls the
107115
/// methods like AAA...BBB...CCC..., whereas this interleaves the methods like ABC...ABC...ABC...
108116
#[test]
117+
#[cfg_attr(
118+
all(target_family = "wasm", not(target_feature = "atomics")),
119+
ignore = "Threading not available"
120+
)]
109121
fn calls_parallel_many_parallel() {
110122
use std::thread;
111123

@@ -142,6 +154,10 @@ fn calls_parallel_many_parallel() {
142154
/// a) Thread A holds mutable reference AND thread B holds no references.
143155
/// b) One or more threads hold shared references AND thread A holds no references
144156
#[test]
157+
#[cfg_attr(
158+
all(target_family = "wasm", not(target_feature = "atomics")),
159+
ignore = "Threading not available"
160+
)]
145161
fn non_blocking_reborrow() {
146162
use std::thread;
147163
let instance_id = MyClass::init();
@@ -172,6 +188,10 @@ fn non_blocking_reborrow() {
172188
/// This verifies that the thread which initialized the `GdCell` does not panic when it attempts to mutably borrow while there is already a
173189
/// shared borrow on an other thread.
174190
#[test]
191+
#[cfg_attr(
192+
all(target_family = "wasm", not(target_feature = "atomics")),
193+
ignore = "Threading not available"
194+
)]
175195
fn no_mut_panic_on_main() {
176196
use std::thread;
177197
let instance_id = MyClass::init();

godot-cell/tests/mock/panicking.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ fn all_calls_work() {
5858

5959
/// Run each method both from the main thread and a newly created thread.
6060
#[test]
61+
#[cfg_attr(
62+
all(target_family = "wasm", not(target_feature = "atomics")),
63+
ignore = "Threading not available"
64+
)]
6165
fn calls_different_thread() {
6266
use std::thread;
6367

@@ -87,6 +91,10 @@ fn calls_different_thread() {
8791
/// if the first call failed, so then we know the integer was incremented by 0. Otherwise, we at least know
8892
/// the range of values that it can be incremented by.
8993
#[test]
94+
#[cfg_attr(
95+
all(target_family = "wasm", not(target_feature = "atomics")),
96+
ignore = "Threading not available"
97+
)]
9098
fn calls_parallel() {
9199
use std::thread;
92100

@@ -121,6 +129,10 @@ fn calls_parallel() {
121129
/// Runs each method several times in a row. This should reduce the non-determinism that comes from
122130
/// scheduling of threads.
123131
#[test]
132+
#[cfg_attr(
133+
all(target_family = "wasm", not(target_feature = "atomics")),
134+
ignore = "Threading not available"
135+
)]
124136
fn calls_parallel_many_serial() {
125137
use std::thread;
126138

@@ -157,6 +169,10 @@ fn calls_parallel_many_serial() {
157169
/// Runs all the tests several times. This is different from [`calls_parallel_many_serial`] as that calls the
158170
/// methods like AAA...BBB...CCC..., whereas this interleaves the methods like ABC...ABC...ABC...
159171
#[test]
172+
#[cfg_attr(
173+
all(target_family = "wasm", not(target_feature = "atomics")),
174+
ignore = "Threading not available"
175+
)]
160176
fn calls_parallel_many_parallel() {
161177
use std::thread;
162178

0 commit comments

Comments
 (0)