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

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


The following commit(s) were added to refs/heads/main by this push:
     new 89b8ebda fix(rust/sedona-testing): serialize env-mutating tests with a 
mutex to prevent race conditions (#685)
89b8ebda is described below

commit 89b8ebda87000ce3cccaa8d669f23b4c4dd558f1
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 | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/rust/sedona-testing/src/data.rs b/rust/sedona-testing/src/data.rs
index 1db628bf..38d5af3f 100644
--- a/rust/sedona-testing/src/data.rs
+++ b/rust/sedona-testing/src/data.rs
@@ -144,9 +144,17 @@ pub fn test_raster(name: &str) -> 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());
@@ -173,6 +181,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");
@@ -191,6 +201,8 @@ mod test {
 
     #[test]
     fn test_raster_resolves() {
+        let _guard = SERIAL_TEST.lock().unwrap();
+
         // Test that test_raster can find existing raster files
         let path = test_raster("test4.tiff");
         assert!(path.is_ok(), "Failed to find test4.tiff: {:?}", path.err());

Reply via email to