Skip to content

Commit 4225d33

Browse files
committed
fix(tests): handle mutex lock gracefully to prevent poisoning
Use if let Ok() pattern instead of unwrap() on mutex locks in test output handlers to prevent cascade failures when tests run in parallel.
1 parent f881ab7 commit 4225d33

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

tests/integration_tests.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ impl SCStreamOutputTrait for VideoTestOutput {
2525
sample_buffer: CMSampleBuffer,
2626
_of_type: SCStreamOutputType,
2727
) {
28-
self.samples.lock().unwrap().push(sample_buffer);
28+
if let Ok(mut guard) = self.samples.lock() {
29+
guard.push(sample_buffer);
30+
}
2931
}
3032
}
3133

@@ -40,7 +42,9 @@ impl SCStreamOutputTrait for AudioTestOutput {
4042
sample_buffer: CMSampleBuffer,
4143
_of_type: SCStreamOutputType,
4244
) {
43-
self.samples.lock().unwrap().push(sample_buffer);
45+
if let Ok(mut guard) = self.samples.lock() {
46+
guard.push(sample_buffer);
47+
}
4448
}
4549
}
4650

0 commit comments

Comments
 (0)