Add futures.
This commit is contained in:
@@ -4,6 +4,9 @@ use std::io::Read;
|
||||
use std::path::Path;
|
||||
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;
|
||||
|
||||
@@ -41,8 +44,9 @@ 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());
|
||||
let result = tokio::spawn(single_file.run_test()).await;
|
||||
println!("{:?}", result);
|
||||
// let test_config = TestConfig::TestLayer(TestLayer {
|
||||
// name: "foo",
|
||||
@@ -95,11 +99,14 @@ pub(crate) enum TestStatus {
|
||||
}
|
||||
|
||||
impl TestConfig {
|
||||
async fn run_test(self) -> TestResult {
|
||||
match self {
|
||||
TestConfig::TestLayer(test) => TestResult::ResultLayer(test.run_test().await),
|
||||
TestConfig::SingleFile(test) => TestResult::SingleFileResult(test.run_test().await),
|
||||
fn run_test(self) -> BoxFuture<'static, TestResult> {
|
||||
async move {
|
||||
match self {
|
||||
TestConfig::TestLayer(test) => TestResult::ResultLayer(test.run_test().await),
|
||||
TestConfig::SingleFile(test) => TestResult::SingleFileResult(test.run_test().await),
|
||||
}
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user