This is an automated email from the ASF dual-hosted git repository.

paleolimbot pushed a commit to branch branch-0.3.0
in repository https://gitbox.apache.org/repos/asf/sedona-db.git

commit 8122e70b9860055d530eb7870b4c03314daf0f09
Author: Kristin Cowalcijk <[email protected]>
AuthorDate: Wed Mar 4 23:34:42 2026 +0800

    fix(rust/sedona-testing): serialize env-mutating tests with a mutex to 
prevent race conditions (#685)
---
 rust/sedona-testing/src/data.rs | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/rust/sedona-testing/src/data.rs b/rust/sedona-testing/src/data.rs
index a6bd991f..d26de3ba 100644
--- a/rust/sedona-testing/src/data.rs
+++ b/rust/sedona-testing/src/data.rs
@@ -128,9 +128,17 @@ pub fn sedona_testing_dir() -> Result<String> {
 #[cfg(test)]
 mod test {
     use super::*;
+    use std::sync::Mutex;
+
+    // These tests mutate global states including environment variables so 
they must
+    // run serially. The SERIAL_TEST mutex ensures that only one test executes 
at a time,
+    // preventing race conditions when modifying and restoring environment 
variables.
+    static SERIAL_TEST: Mutex<()> = Mutex::new(());
 
     #[test]
     fn example_files() {
+        let _guard = SERIAL_TEST.lock().unwrap();
+
         // By default this should resolve, since we are in a test!
         assert!(geoarrow_data_dir().is_ok());
         assert!(test_geoparquet("natural-earth", "countries").is_ok());
@@ -157,6 +165,8 @@ mod test {
 
     #[test]
     fn sedona_testing_dir_resolves() {
+        let _guard = SERIAL_TEST.lock().unwrap();
+
         assert!(sedona_testing_dir().is_ok());
 
         env::set_var("SEDONA_TESTING_DIR", "this_directory_does_not_exist");

Reply via email to