fix: run tests sequentially for glib

This commit is contained in:
Saber Haj Rabiee
2025-03-28 12:15:33 -07:00
parent 4973cc9eff
commit e8e0808684
3 changed files with 47 additions and 0 deletions

41
Cargo.lock generated
View File

@@ -268,6 +268,7 @@ dependencies = [
"async-executor",
"futures",
"glib",
"serial_test",
"thiserror 2.0.12",
"tokio",
"tracing",
@@ -3092,6 +3093,15 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "scc"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea091f6cac2595aa38993f04f4ee692ed43757035c36e67c180b6828356385b1"
dependencies = [
"sdd",
]
[[package]]
name = "schannel"
version = "0.1.27"
@@ -3107,6 +3117,12 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sdd"
version = "3.0.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "584e070911c7017da6cb2eb0788d09f43d789029b5877d3e5ecc8acf86ceee21"
[[package]]
name = "security-framework"
version = "2.11.1"
@@ -3251,6 +3267,31 @@ dependencies = [
"serde",
]
[[package]]
name = "serial_test"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b258109f244e1d6891bf1053a55d63a5cd4f8f4c30cf9a1280989f80e7a1fa9"
dependencies = [
"futures",
"log",
"once_cell",
"parking_lot",
"scc",
"serial_test_derive",
]
[[package]]
name = "serial_test_derive"
version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d69265a08751de7844521fd15003ae0a888e035773ba05695c5c759a6f89eef"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.100",
]
[[package]]
name = "server_fn"
version = "0.8.0-beta"

View File

@@ -26,6 +26,7 @@ tokio = { version = "1.41", default-features = false, features = [
"time",
] }
wasm-bindgen-test = { version = "0.3.50" }
serial_test = "3.2.0"
[features]
async-executor = ["dep:async-executor"]

View File

@@ -2,6 +2,7 @@
use any_spawner::Executor;
use glib::{MainContext, MainLoop};
use serial_test::serial;
use std::{
cell::Cell,
future::Future,
@@ -57,6 +58,7 @@ where
// This test must run after a test that successfully initializes glib,
// or within its own process.
#[test]
#[serial]
fn test_glib_spawn() {
let success_flag = Arc::new(AtomicBool::new(false));
let flag_clone = success_flag.clone();
@@ -81,6 +83,7 @@ fn test_glib_spawn() {
// Similar conditions as test_glib_spawn regarding initialization state.
#[test]
#[serial]
fn test_glib_spawn_local() {
let success_flag = Rc::new(Cell::new(false));
let flag_clone = success_flag.clone();
@@ -115,6 +118,7 @@ fn test_glib_spawn_local() {
// Test Executor::tick with glib backend
#[test]
#[serial]
fn test_glib_tick() {
run_on_glib_context(async {
let value = Arc::new(Mutex::new(false));
@@ -136,6 +140,7 @@ fn test_glib_tick() {
// Test Executor::poll_local with glib backend (should be a no-op)
#[test]
#[serial]
fn test_glib_poll_local_is_no_op() {
// Ensure glib executor is initialized
let _ = Executor::init_glib();