File tree 3 files changed +18
-7
lines changed
3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -10,17 +10,16 @@ use std::{
10
10
time:: Duration ,
11
11
} ;
12
12
13
+ use crate :: interface:: { RMain , R_MAIN } ;
14
+ use crossbeam:: channel:: bounded;
13
15
use harp:: exec:: safely;
16
+ use harp:: test:: R_TASK_BYPASS ;
17
+ use log:: info;
14
18
15
19
extern "C" {
16
20
pub static mut R_PolledEvents : Option < unsafe extern "C" fn ( ) > ;
17
21
}
18
22
19
- use crossbeam:: channel:: bounded;
20
- use log:: info;
21
-
22
- use crate :: interface:: { RMain , R_MAIN } ;
23
-
24
23
type SharedOption < T > = Arc < Mutex < Option < T > > > ;
25
24
26
25
pub fn r_task < ' env , F , T > ( f : F ) -> T
29
28
F : ' env + Send ,
30
29
T : ' env + Send ,
31
30
{
31
+ // Escape hatch for unit tests
32
+ if unsafe { R_TASK_BYPASS } {
33
+ return f ( ) ;
34
+ }
35
+
32
36
let main = acquire_r_main ( ) ;
33
37
34
38
// Recursive case: If we're on ark-r-main already, just run the
Original file line number Diff line number Diff line change @@ -179,7 +179,7 @@ fn test_environment_list() {
179
179
assert_eq!( Rf_length ( * contents) , 0 ) ;
180
180
}
181
181
182
- // create some more variables
182
+ // Create some more variables
183
183
r_lock ! {
184
184
let sym = r_symbol!( "a" ) ;
185
185
Rf_defineVar ( sym, Rf_ScalarInteger ( 42 ) , test_env. sexp) ;
@@ -225,6 +225,6 @@ fn test_environment_list() {
225
225
assert_eq ! ( update. removed, [ "a" ] ) ;
226
226
assert_eq ! ( update. version, 6 ) ;
227
227
228
- // close the comm. Otherwise the thread panics
228
+ // Close the comm. Otherwise the thread panics
229
229
incoming_tx. send ( CommChannelMsg :: Close ) . unwrap ( ) ;
230
230
}
Original file line number Diff line number Diff line change @@ -22,10 +22,17 @@ use stdext::cargs;
22
22
23
23
use crate :: lock:: with_r_lock;
24
24
25
+ // Escape hatch for unit tests
26
+ pub static mut R_TASK_BYPASS : bool = false ;
27
+
25
28
static INIT : Once = Once :: new ( ) ;
26
29
27
30
pub fn start_r ( ) {
28
31
INIT . call_once ( || {
32
+ unsafe {
33
+ R_TASK_BYPASS = true ;
34
+ }
35
+
29
36
// TODO: Right now, tests can fail if the version of R discovered
30
37
// on the PATH, and the version of R that 'ark' linked to at compile
31
38
// time, do not match. We could relax this requirement by allowing
You can’t perform that action at this time.
0 commit comments