Skip to content

Commit 430ce3b

Browse files
committed
fix(tests): add serial_test to fix race conditions in integration tests
Integration tests were failing due to mutex poisoning when tests ran in parallel. Added serial_test crate to ensure tests that use shared ScreenCaptureKit resources run sequentially. - Add serial_test dev-dependency - Add #[serial] attribute to all integration tests - All tests now pass
1 parent f83f83c commit 430ce3b

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ macos_15_0 = ["macos_14_4"]
4242
[dev-dependencies]
4343
png = "0.17"
4444
tokio = { version = "1.40", features = ["sync", "rt", "rt-multi-thread", "macros", "test-util"] }
45+
serial_test = "3"

tests/integration_tests.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#![allow(clippy::pedantic, clippy::nursery)]
2+
// Integration tests must run serially due to shared ScreenCaptureKit resources
3+
24
use screencapturekit::{
35
shareable_content::SCShareableContent,
46
stream::{
@@ -10,6 +12,7 @@ use screencapturekit::{
1012
},
1113
CMSampleBuffer,
1214
};
15+
use serial_test::serial;
1316
use std::sync::{Arc, Mutex};
1417
use std::time::Duration;
1518

@@ -44,6 +47,7 @@ impl SCStreamOutputTrait for AudioTestOutput {
4447
}
4548

4649
#[test]
50+
#[serial]
4751
fn test_video_capture() {
4852
// Get shareable content
4953
let content = match SCShareableContent::get() {
@@ -121,6 +125,7 @@ fn test_video_capture() {
121125
}
122126

123127
#[test]
128+
#[serial]
124129
fn test_audio_capture() {
125130
// Get shareable content
126131
let content = match SCShareableContent::get() {
@@ -200,6 +205,7 @@ fn test_audio_capture() {
200205
}
201206

202207
#[test]
208+
#[serial]
203209
fn test_video_and_audio_capture() {
204210
// Get shareable content
205211
let content = match SCShareableContent::get() {
@@ -276,6 +282,7 @@ fn test_video_and_audio_capture() {
276282
}
277283

278284
#[test]
285+
#[serial]
279286
fn test_pixel_buffer_locking() {
280287
// Get shareable content
281288
let content = match SCShareableContent::get() {
@@ -362,6 +369,7 @@ fn test_pixel_buffer_locking() {
362369
}
363370

364371
#[test]
372+
#[serial]
365373
fn test_iosurface_backed_buffer() {
366374
// Get shareable content
367375
let content = match SCShareableContent::get() {

0 commit comments

Comments
 (0)