@@ -236,13 +236,20 @@ impl LanguagePlugin for CSharpPlugin {
236
236
#[ cfg( test) ]
237
237
mod test {
238
238
use super :: * ;
239
+ use std:: sync:: Once ;
239
240
use tempfile:: TempDir ;
240
241
242
+ static INIT_RUNNER : Once = Once :: new ( ) ;
243
+
241
244
fn init ( ) {
242
245
let _ = env_logger:: builder ( ) . is_test ( true ) . try_init ( ) ;
246
+ INIT_RUNNER . call_once ( || {
247
+ let _ = CSharpPlugin :: get_runner_dir ( ) . unwrap ( ) ;
248
+ } ) ;
243
249
}
244
250
245
251
fn copy_test_dir ( path : & str ) -> TempDir {
252
+ init ( ) ;
246
253
let path = Path :: new ( path) ;
247
254
248
255
let temp = tempfile:: tempdir ( ) . unwrap ( ) ;
@@ -265,20 +272,23 @@ mod test {
265
272
266
273
#[ test]
267
274
fn exercise_type_is_correct ( ) {
275
+ init ( ) ;
268
276
let temp = copy_test_dir ( "tests/data/PassingProject" ) ;
269
277
let is = CSharpPlugin :: is_exercise_type_correct ( temp. path ( ) ) ;
270
278
assert ! ( is) ;
271
279
}
272
280
273
281
#[ test]
274
282
fn exercise_type_is_incorrect ( ) {
283
+ init ( ) ;
275
284
let temp = copy_test_dir ( "tests/data" ) ;
276
285
let is = CSharpPlugin :: is_exercise_type_correct ( temp. path ( ) ) ;
277
286
assert ! ( !is) ;
278
287
}
279
288
280
289
#[ test]
281
290
fn scans_exercise ( ) {
291
+ init ( ) ;
282
292
let plugin = CSharpPlugin :: new ( ) ;
283
293
let temp = copy_test_dir ( "tests/data/PassingProject" ) ;
284
294
let scan = plugin
@@ -290,6 +300,7 @@ mod test {
290
300
291
301
#[ test]
292
302
fn runs_tests_passing ( ) {
303
+ init ( ) ;
293
304
let plugin = CSharpPlugin :: new ( ) ;
294
305
let temp = copy_test_dir ( "tests/data/PassingProject" ) ;
295
306
let res = plugin. run_tests ( temp. path ( ) ) . unwrap ( ) ;
@@ -303,6 +314,7 @@ mod test {
303
314
304
315
#[ test]
305
316
fn runs_tests_failing ( ) {
317
+ init ( ) ;
306
318
let plugin = CSharpPlugin :: new ( ) ;
307
319
let temp = copy_test_dir ( "tests/data/FailingProject" ) ;
308
320
let res = plugin. run_tests ( temp. path ( ) ) . unwrap ( ) ;
@@ -318,6 +330,7 @@ mod test {
318
330
319
331
#[ test]
320
332
fn runs_tests_compile_err ( ) {
333
+ init ( ) ;
321
334
let plugin = CSharpPlugin :: new ( ) ;
322
335
let temp = copy_test_dir ( "tests/data/NonCompilingProject" ) ;
323
336
let res = plugin. run_tests ( temp. path ( ) ) . unwrap ( ) ;
@@ -329,6 +342,7 @@ mod test {
329
342
330
343
#[ test]
331
344
fn cleans ( ) {
345
+ init ( ) ;
332
346
let plugin = CSharpPlugin :: new ( ) ;
333
347
let temp = copy_test_dir ( "tests/data/PassingProject" ) ;
334
348
let bin_path = temp. path ( ) . join ( "src" ) . join ( "PassingSample" ) . join ( "bin" ) ;
0 commit comments