From 96b59dd5b2bd99cb1fe05463ec17c46492e7c5e6 Mon Sep 17 00:00:00 2001 From: "Dustin J. Mitchell" Date: Wed, 26 Jan 2022 01:38:25 +0000 Subject: [PATCH] serialize C integration tests --- Cargo.lock | 1 + integration-tests/Cargo.toml | 1 + integration-tests/tests/bindings.rs | 10 ++++++++++ 3 files changed, 12 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index b2b905807..094b83445 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1529,6 +1529,7 @@ dependencies = [ "anyhow", "cc", "env_logger 0.8.4", + "lazy_static", "log", "pretty_assertions", "taskchampion", diff --git a/integration-tests/Cargo.toml b/integration-tests/Cargo.toml index 71f39b6e6..2b4a3bd8a 100644 --- a/integration-tests/Cargo.toml +++ b/integration-tests/Cargo.toml @@ -18,6 +18,7 @@ tempfile = "3" pretty_assertions = "1" log = "^0.4.14" env_logger = "^0.8.3" +lazy_static = "1" [build-dependencies] cc = "1.0" diff --git a/integration-tests/tests/bindings.rs b/integration-tests/tests/bindings.rs index d4574c92f..9f14ec47f 100644 --- a/integration-tests/tests/bindings.rs +++ b/integration-tests/tests/bindings.rs @@ -1,7 +1,17 @@ +use lazy_static::lazy_static; +use std::sync::Mutex; + +lazy_static! { + // the C library running the tests is not reentrant, so we use a mutex to ensure that only one + // test runs at a time. + static ref MUTEX: Mutex<()> = Mutex::new(()); +} + macro_rules! suite( { $s:ident } => { #[test] fn $s() { + let _guard = MUTEX.lock().unwrap(); assert_eq!(integration_tests::bindings_tests::$s(), 0); } };