Report whether all the tests passed.
This commit is contained in:
parent
ff04c4a131
commit
74a3512038
@ -2,6 +2,7 @@
|
|||||||
#![feature(exact_size_is_empty)]
|
#![feature(exact_size_is_empty)]
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::process::ExitCode;
|
||||||
|
|
||||||
use futures::future::BoxFuture;
|
use futures::future::BoxFuture;
|
||||||
use futures::future::FutureExt;
|
use futures::future::FutureExt;
|
||||||
@ -18,7 +19,7 @@ use crate::init_tracing::shutdown_telemetry;
|
|||||||
mod init_tracing;
|
mod init_tracing;
|
||||||
|
|
||||||
#[cfg(not(feature = "tracing"))]
|
#[cfg(not(feature = "tracing"))]
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
|
||||||
let rt = tokio::runtime::Runtime::new()?;
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
let result = rt.block_on(async {
|
let result = rt.block_on(async {
|
||||||
let main_body_result = main_body().await;
|
let main_body_result = main_body().await;
|
||||||
@ -28,7 +29,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "tracing")]
|
#[cfg(feature = "tracing")]
|
||||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
fn main() -> Result<ExitCode, Box<dyn std::error::Error>> {
|
||||||
let rt = tokio::runtime::Runtime::new()?;
|
let rt = tokio::runtime::Runtime::new()?;
|
||||||
let result = rt.block_on(async {
|
let result = rt.block_on(async {
|
||||||
init_telemetry()?;
|
init_telemetry()?;
|
||||||
@ -40,7 +41,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
|
||||||
async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main_body() -> Result<ExitCode, Box<dyn std::error::Error>> {
|
||||||
let layer = compare_group("org-mode", || {
|
let layer = compare_group("org-mode", || {
|
||||||
compare_all_org_document("/foreign_documents/org-mode")
|
compare_all_org_document("/foreign_documents/org-mode")
|
||||||
});
|
});
|
||||||
@ -56,12 +57,30 @@ async fn main_body() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
let running_tests: Vec<_> = layer.map(|c| tokio::spawn(c.run_test())).collect();
|
let running_tests: Vec<_> = layer.map(|c| tokio::spawn(c.run_test())).collect();
|
||||||
|
let mut any_failed = false;
|
||||||
for test in running_tests.into_iter() {
|
for test in running_tests.into_iter() {
|
||||||
let test_result = test.await??;
|
let test_result = test.await??;
|
||||||
|
if test_result.is_immediately_bad() || test_result.has_bad_children() {
|
||||||
|
any_failed = true;
|
||||||
|
}
|
||||||
test_result.print();
|
test_result.print();
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
if any_failed {
|
||||||
|
println!(
|
||||||
|
"{color}Some tests failed.{reset}",
|
||||||
|
color = TestResult::foreground_color(255, 0, 0),
|
||||||
|
reset = TestResult::reset_color(),
|
||||||
|
);
|
||||||
|
Ok(ExitCode::FAILURE)
|
||||||
|
} else {
|
||||||
|
println!(
|
||||||
|
"{color}All tests passed.{reset}",
|
||||||
|
color = TestResult::foreground_color(0, 255, 0),
|
||||||
|
reset = TestResult::reset_color(),
|
||||||
|
);
|
||||||
|
Ok(ExitCode::SUCCESS)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn compare_howard_abrams() -> impl Iterator<Item = TestConfig> {
|
fn compare_howard_abrams() -> impl Iterator<Item = TestConfig> {
|
||||||
|
Loading…
Reference in New Issue
Block a user