From 8271f6b44a98afcecb8c4123c4f8221742728bd0 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 13 Oct 2023 13:20:21 -0400 Subject: [PATCH] Start invoking the tests. --- src/bin_foreign_document_test.rs | 34 +++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/src/bin_foreign_document_test.rs b/src/bin_foreign_document_test.rs index 20458348..c4d809b8 100644 --- a/src/bin_foreign_document_test.rs +++ b/src/bin_foreign_document_test.rs @@ -43,22 +43,32 @@ fn main() -> Result<(), Box> { #[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))] async fn main_body() -> Result<(), Box> { - 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, F: Fn() -> I, I: Iterator>( + name: N, + inner: F, +) -> impl Iterator { + std::iter::once(TestConfig::TestLayer(TestLayer { + name: name.into(), + children: inner().collect(), + })) +} + fn compare_all_org_document>(root_dir: P) -> impl Iterator { let root_dir = root_dir.as_ref(); let test_files = WalkDir::new(root_dir)