@@ -1,9 +1,12 @@
|
||||
use std::{cmp::Ordering, path::Path};
|
||||
|
||||
use cuddle_clusters::process::ProcessOpts;
|
||||
use cuddle_clusters::{process::ProcessOpts, ConcreteComponent, IntoComponent};
|
||||
use walkdir::DirEntry;
|
||||
|
||||
pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
|
||||
pub(crate) async fn run_test_with_components(
|
||||
name: &str,
|
||||
components: Vec<impl IntoComponent>,
|
||||
) -> anyhow::Result<()> {
|
||||
let _ = tracing_subscriber::fmt::try_init();
|
||||
|
||||
println!("running for: {name}");
|
||||
@@ -17,17 +20,25 @@ pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
|
||||
let expected = test_folder.join("expected");
|
||||
tokio::fs::create_dir_all(&expected).await?;
|
||||
|
||||
cuddle_clusters::process_opts(ProcessOpts {
|
||||
path: test_folder.clone(),
|
||||
output: actual.clone(),
|
||||
})
|
||||
let components: Vec<_> = components.into_iter().map(|p| p.into_component()).collect();
|
||||
|
||||
cuddle_clusters::process_opts(
|
||||
components.clone(),
|
||||
ProcessOpts {
|
||||
path: test_folder.clone(),
|
||||
output: actual.clone(),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
|
||||
if std::env::var("TEST_OVERRIDE") == Ok("true".to_string()) {
|
||||
cuddle_clusters::process_opts(ProcessOpts {
|
||||
path: test_folder,
|
||||
output: expected.clone(),
|
||||
})
|
||||
cuddle_clusters::process_opts(
|
||||
components,
|
||||
ProcessOpts {
|
||||
path: test_folder,
|
||||
output: expected.clone(),
|
||||
},
|
||||
)
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -36,6 +47,10 @@ pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub(crate) async fn run_test(name: &str) -> anyhow::Result<()> {
|
||||
run_test_with_components(name, Vec::<ConcreteComponent>::new()).await
|
||||
}
|
||||
|
||||
async fn compare(expected: &Path, actual: &Path) -> anyhow::Result<()> {
|
||||
let mut exp = walk_dir(expected)?;
|
||||
let mut act = walk_dir(actual)?;
|
||||
|
Reference in New Issue
Block a user