Skip to content

Commit 3731add

Browse files
committed
synchronise C# runner init in tests
1 parent 4d9b86c commit 3731add

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tmc-langs-csharp/src/plugin.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,20 @@ impl LanguagePlugin for CSharpPlugin {
236236
#[cfg(test)]
237237
mod test {
238238
use super::*;
239+
use std::sync::Once;
239240
use tempfile::TempDir;
240241

242+
static INIT_RUNNER: Once = Once::new();
243+
241244
fn init() {
242245
let _ = env_logger::builder().is_test(true).try_init();
246+
INIT_RUNNER.call_once(|| {
247+
let _ = CSharpPlugin::get_runner_dir().unwrap();
248+
});
243249
}
244250

245251
fn copy_test_dir(path: &str) -> TempDir {
252+
init();
246253
let path = Path::new(path);
247254

248255
let temp = tempfile::tempdir().unwrap();
@@ -265,20 +272,23 @@ mod test {
265272

266273
#[test]
267274
fn exercise_type_is_correct() {
275+
init();
268276
let temp = copy_test_dir("tests/data/PassingProject");
269277
let is = CSharpPlugin::is_exercise_type_correct(temp.path());
270278
assert!(is);
271279
}
272280

273281
#[test]
274282
fn exercise_type_is_incorrect() {
283+
init();
275284
let temp = copy_test_dir("tests/data");
276285
let is = CSharpPlugin::is_exercise_type_correct(temp.path());
277286
assert!(!is);
278287
}
279288

280289
#[test]
281290
fn scans_exercise() {
291+
init();
282292
let plugin = CSharpPlugin::new();
283293
let temp = copy_test_dir("tests/data/PassingProject");
284294
let scan = plugin
@@ -290,6 +300,7 @@ mod test {
290300

291301
#[test]
292302
fn runs_tests_passing() {
303+
init();
293304
let plugin = CSharpPlugin::new();
294305
let temp = copy_test_dir("tests/data/PassingProject");
295306
let res = plugin.run_tests(temp.path()).unwrap();
@@ -303,6 +314,7 @@ mod test {
303314

304315
#[test]
305316
fn runs_tests_failing() {
317+
init();
306318
let plugin = CSharpPlugin::new();
307319
let temp = copy_test_dir("tests/data/FailingProject");
308320
let res = plugin.run_tests(temp.path()).unwrap();
@@ -318,6 +330,7 @@ mod test {
318330

319331
#[test]
320332
fn runs_tests_compile_err() {
333+
init();
321334
let plugin = CSharpPlugin::new();
322335
let temp = copy_test_dir("tests/data/NonCompilingProject");
323336
let res = plugin.run_tests(temp.path()).unwrap();
@@ -329,6 +342,7 @@ mod test {
329342

330343
#[test]
331344
fn cleans() {
345+
init();
332346
let plugin = CSharpPlugin::new();
333347
let temp = copy_test_dir("tests/data/PassingProject");
334348
let bin_path = temp.path().join("src").join("PassingSample").join("bin");

0 commit comments

Comments
 (0)