2023-10-07 04:35:21 +00:00
|
|
|
#![feature(round_char_boundary)]
|
|
|
|
#![feature(exact_size_is_empty)]
|
|
|
|
use std::io::Read;
|
2023-10-08 11:54:21 +00:00
|
|
|
use std::path::Path;
|
2023-10-07 04:35:21 +00:00
|
|
|
|
|
|
|
use organic::compare::run_anonymous_compare;
|
|
|
|
use organic::compare::run_compare_on_file;
|
|
|
|
|
|
|
|
#[cfg(feature = "tracing")]
|
|
|
|
use crate::init_tracing::init_telemetry;
|
|
|
|
#[cfg(feature = "tracing")]
|
|
|
|
use crate::init_tracing::shutdown_telemetry;
|
|
|
|
#[cfg(feature = "tracing")]
|
|
|
|
mod init_tracing;
|
|
|
|
|
|
|
|
#[cfg(not(feature = "tracing"))]
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
let rt = tokio::runtime::Runtime::new()?;
|
|
|
|
let result = rt.block_on(async {
|
2023-10-07 05:13:26 +00:00
|
|
|
let main_body_result = main_body().await;
|
2023-10-07 04:35:21 +00:00
|
|
|
main_body_result
|
|
|
|
});
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg(feature = "tracing")]
|
|
|
|
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
let rt = tokio::runtime::Runtime::new()?;
|
|
|
|
let result = rt.block_on(async {
|
|
|
|
init_telemetry()?;
|
2023-10-07 05:13:26 +00:00
|
|
|
let main_body_result = main_body().await;
|
2023-10-07 04:35:21 +00:00
|
|
|
shutdown_telemetry()?;
|
|
|
|
main_body_result
|
|
|
|
});
|
|
|
|
result
|
|
|
|
}
|
|
|
|
|
|
|
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
2023-10-07 05:13:26 +00:00
|
|
|
async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
2023-10-08 21:17:32 +00:00
|
|
|
let test_config = TestConfig::TestLayer(TestLayer {
|
|
|
|
name: "foo",
|
|
|
|
children: vec![TestConfig::SingleFile(SingleFile {
|
|
|
|
file_path: Path::new("/tmp/test.org"),
|
|
|
|
})],
|
|
|
|
});
|
|
|
|
Ok(())
|
2023-10-07 04:35:21 +00:00
|
|
|
}
|
2023-10-07 05:13:26 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
enum TestConfig<'s> {
|
|
|
|
TestLayer(TestLayer<'s>),
|
|
|
|
SingleFile(SingleFile<'s>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct TestLayer<'s> {
|
|
|
|
name: &'s str,
|
2023-10-08 11:54:21 +00:00
|
|
|
children: Vec<TestConfig<'s>>,
|
2023-10-07 05:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct SingleFile<'s> {
|
2023-10-08 21:17:32 +00:00
|
|
|
file_path: &'s Path,
|
2023-10-08 11:54:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
enum TestResult<'s> {
|
|
|
|
ResultLayer(ResultLayer<'s>),
|
|
|
|
SingleFileResult(SingleFileResult<'s>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct ResultLayer<'s> {
|
|
|
|
name: &'s str,
|
|
|
|
children: Vec<TestResult<'s>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct SingleFileResult<'s> {
|
2023-10-08 21:17:32 +00:00
|
|
|
file_path: &'s Path,
|
|
|
|
status: TestStatus,
|
2023-10-07 05:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
2023-10-08 21:17:32 +00:00
|
|
|
pub(crate) enum TestStatus {
|
|
|
|
Good,
|
|
|
|
Bad,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'s> TestConfig<'s> {
|
|
|
|
async fn run_test(&self) -> TestResult<'s> {
|
|
|
|
match self {
|
|
|
|
TestConfig::TestLayer(test) => TestResult::ResultLayer(test.run_test().await),
|
|
|
|
TestConfig::SingleFile(test) => TestResult::SingleFileResult(test.run_test().await),
|
|
|
|
}
|
|
|
|
}
|
2023-10-07 05:13:26 +00:00
|
|
|
}
|
2023-10-08 11:54:21 +00:00
|
|
|
|
|
|
|
impl<'s> SingleFile<'s> {
|
2023-10-08 21:17:32 +00:00
|
|
|
async fn run_test(&self) -> SingleFileResult<'s> {
|
2023-10-08 11:54:21 +00:00
|
|
|
let result = run_compare_on_file(self.file_path);
|
2023-10-08 21:17:32 +00:00
|
|
|
SingleFileResult {
|
|
|
|
file_path: self.file_path,
|
|
|
|
status: if result.is_ok() {
|
|
|
|
TestStatus::Good
|
|
|
|
} else {
|
|
|
|
TestStatus::Bad
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'s> TestLayer<'s> {
|
|
|
|
async fn run_test(&self) -> ResultLayer<'s> {
|
2023-10-08 11:54:21 +00:00
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
}
|