use crate::{ExecuteOptions, execute};
#[test]
fn test_concurrent_execute_stress() {
let handles: Vec<_> = (0..4)
.map(|i| {
std::thread::spawn(move || {
let rt = tokio::runtime::Builder::new_current_thread()
.enable_all()
.build()
.unwrap();
rt.block_on(async {
for j in 0..3 {
let code =
format!("const x{i}_{j}: number = {i} + {j}; export default x{i}_{j};");
let result = execute(&code, ExecuteOptions::new()).await.unwrap();
assert!(
result.success,
"iteration {i}_{j} failed: {:?}",
result.diagnostics
);
}
})
})
})
.collect();
for h in handles {
h.join().unwrap();
}
}