Start invoking the tests.

This commit is contained in:
Tom Alexander 2023-10-13 13:20:21 -04:00
parent 8a26965e14
commit 8271f6b44a
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
1 changed files with 22 additions and 12 deletions

View File

@ -43,22 +43,32 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
let single_file = TestConfig::SingleFile(SingleFile {
name: "foo".to_owned(),
file_path: PathBuf::from("/tmp/test.org"),
let layer = compare_group("org-mode", || {
compare_all_org_document("/foreign_documents/org-mode")
});
// let result = single_file.run_test().await;
let result = tokio::spawn(single_file.run_test()).await;
println!("{:?}", result);
// let test_config = TestConfig::TestLayer(TestLayer {
// name: "foo",
// children: vec![TestConfig::SingleFile(SingleFile {
// file_path: Path::new("/tmp/test.org"),
// })],
// });
let layer = layer.chain(compare_group("emacs", || {
compare_all_org_document("/foreign_documents/emacs")
}));
let running_tests: Vec<_> = layer.map(|c| tokio::spawn(c.run_test())).collect();
for test in running_tests.into_iter() {
let test_result = test.await??;
println!("{:?}", test_result);
}
Ok(())
}
fn compare_group<N: Into<String>, F: Fn() -> I, I: Iterator<Item = TestConfig>>(
name: N,
inner: F,
) -> impl Iterator<Item = TestConfig> {
std::iter::once(TestConfig::TestLayer(TestLayer {
name: name.into(),
children: inner().collect(),
}))
}
fn compare_all_org_document<P: AsRef<Path>>(root_dir: P) -> impl Iterator<Item = TestConfig> {
let root_dir = root_dir.as_ref();
let test_files = WalkDir::new(root_dir)