Limit concurrency of running tests.

This commit is contained in:
Tom Alexander
2023-10-13 11:41:49 -04:00
parent 182c2737cd
commit b0b795d13b
2 changed files with 5 additions and 3 deletions

View File

@@ -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<dyn std::error::Error>> {
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<dyn std::error::Error>> {
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,