diff --git a/Cargo.toml b/Cargo.toml index 1cfd314..366c3a9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -54,7 +54,7 @@ walkdir = "2.3.3" [features] default = ["compare", "foreign_document_test"] compare = [] -foreign_document_test = ["compare", "dep:tokio", "dep:futures"] +foreign_document_test = ["compare", "dep:tokio", "dep:futures", "tokio/sync"] tracing = ["dep:opentelemetry", "dep:opentelemetry-otlp", "dep:opentelemetry-semantic-conventions", "dep:tokio", "dep:tracing", "dep:tracing-opentelemetry", "dep:tracing-subscriber"] # Optimized build for any sort of release. diff --git a/src/bin_foreign_document_test.rs b/src/bin_foreign_document_test.rs index ae5d276..4bb471a 100644 --- a/src/bin_foreign_document_test.rs +++ b/src/bin_foreign_document_test.rs @@ -6,9 +6,9 @@ use std::path::PathBuf; use futures::future::BoxFuture; use futures::future::FutureExt; -use futures::stream::FuturesUnordered; use organic::compare::run_anonymous_compare; use organic::compare::run_compare_on_file; +use tokio::sync::Semaphore; #[cfg(feature = "tracing")] use crate::init_tracing::init_telemetry; @@ -44,7 +44,6 @@ async fn main_body() -> Result<(), Box> { let single_file = TestConfig::SingleFile(SingleFile { file_path: PathBuf::from("/tmp/test.org"), }); - let mut futs = FuturesUnordered::new(); // let result = single_file.run_test().await; let result = tokio::spawn(single_file.run_test()).await; println!("{:?}", result); @@ -57,6 +56,8 @@ async fn main_body() -> Result<(), Box> { Ok(()) } +static TEST_PERMITS: Semaphore = Semaphore::const_new(8); + #[derive(Debug)] enum TestConfig { TestLayer(TestLayer), @@ -112,6 +113,7 @@ impl TestConfig { impl SingleFile { async fn run_test(self) -> SingleFileResult { + let _permit = TEST_PERMITS.acquire().await.unwrap(); let result = run_compare_on_file(&self.file_path); SingleFileResult { file_path: self.file_path,