File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,9 +128,17 @@ pub fn sedona_testing_dir() -> Result<String> {
128128#[ cfg( test) ]
129129mod test {
130130 use super :: * ;
131+ use std:: sync:: Mutex ;
132+
133+ // These tests mutate global states including environment variables so they must
134+ // run serially. The SERIAL_TEST mutex ensures that only one test executes at a time,
135+ // preventing race conditions when modifying and restoring environment variables.
136+ static SERIAL_TEST : Mutex < ( ) > = Mutex :: new ( ( ) ) ;
131137
132138 #[ test]
133139 fn example_files ( ) {
140+ let _guard = SERIAL_TEST . lock ( ) . unwrap ( ) ;
141+
134142 // By default this should resolve, since we are in a test!
135143 assert ! ( geoarrow_data_dir( ) . is_ok( ) ) ;
136144 assert ! ( test_geoparquet( "natural-earth" , "countries" ) . is_ok( ) ) ;
@@ -157,6 +165,8 @@ mod test {
157165
158166 #[ test]
159167 fn sedona_testing_dir_resolves ( ) {
168+ let _guard = SERIAL_TEST . lock ( ) . unwrap ( ) ;
169+
160170 assert ! ( sedona_testing_dir( ) . is_ok( ) ) ;
161171
162172 env:: set_var ( "SEDONA_TESTING_DIR" , "this_directory_does_not_exist" ) ;
You can’t perform that action at this time.
0 commit comments