Limit concurrency of running tests.
This commit is contained in:
		
							parent
							
								
									182c2737cd
								
							
						
					
					
						commit
						b0b795d13b
					
				| @ -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. | ||||
|  | ||||
| @ -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, | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Tom Alexander
						Tom Alexander