Skip to content

Commit 7d0ebeb

Browse files
committed
Reintroduce a simple lock for unit tests
1 parent 1ab04b7 commit 7d0ebeb

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

crates/harp/src/test.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use std::os::raw::c_char;
1717
use std::process::Command;
18+
use std::sync::Mutex;
1819
use std::sync::Once;
1920

2021
use libR_sys::*;
@@ -62,10 +63,14 @@ pub fn start_r() {
6263
});
6364
}
6465

65-
// FIXME: Actually run `f` and fix thread safety in tests
66+
static mut R_RUNTIME_LOCK: Mutex<()> = Mutex::new(());
67+
6668
pub fn r_test_impl<F: FnMut()>(f: F) {
6769
start_r();
68-
r_safely(|| f);
70+
71+
let guard = unsafe { R_RUNTIME_LOCK.lock() };
72+
r_safely(f);
73+
drop(guard);
6974
}
7075

7176
#[macro_export]

0 commit comments

Comments
 (0)