diff --git a/plugins/csharp/Cargo.toml b/plugins/csharp/Cargo.toml index baefcf7ecf2..d21cd000153 100644 --- a/plugins/csharp/Cargo.toml +++ b/plugins/csharp/Cargo.toml @@ -18,5 +18,6 @@ walkdir = "2" zip = "0.5" [dev-dependencies] +once_cell = "1" simple_logger = "1" tempfile = "3" diff --git a/plugins/csharp/src/plugin.rs b/plugins/csharp/src/plugin.rs index bb36316bedb..9bf70b84938 100644 --- a/plugins/csharp/src/plugin.rs +++ b/plugins/csharp/src/plugin.rs @@ -350,10 +350,13 @@ impl LanguagePlugin for CSharpPlugin { #[cfg(test)] mod test { use super::*; - use std::sync::Once; + use once_cell::sync::Lazy; + use std::sync::{Mutex, Once}; use tempfile::TempDir; static INIT_RUNNER: Once = Once::new(); + // running the runner in parallel seems to sometimes make tests run for an excessively long time + static MUTEX: Lazy> = Lazy::new(|| Mutex::new(())); fn init() { use log::*; @@ -524,6 +527,7 @@ mod test { #[test] fn scans_exercise() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/passing-exercise"); let plugin = CSharpPlugin::new(); @@ -537,6 +541,7 @@ mod test { #[test] fn runs_tests_passing() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/passing-exercise"); let plugin = CSharpPlugin::new(); @@ -553,6 +558,7 @@ mod test { #[test] fn runs_tests_failing() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/failing-exercise"); let plugin = CSharpPlugin::new(); @@ -571,6 +577,7 @@ mod test { #[test] fn runs_tests_compile_err() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/non-compiling-exercise"); let plugin = CSharpPlugin::new(); @@ -588,6 +595,7 @@ mod test { #[test] fn runs_tests_timeout() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/passing-exercise"); let plugin = CSharpPlugin::new(); @@ -600,6 +608,7 @@ mod test { #[test] fn cleans() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/passing-exercise"); let plugin = CSharpPlugin::new(); @@ -637,6 +646,7 @@ mod test { #[test] fn doesnt_give_points_unless_all_relevant_exercises_pass() { init(); + let _lock = MUTEX.lock().unwrap(); let temp = dir_to_temp("tests/data/partially-passing"); let plugin = CSharpPlugin::new();