Skip to content

Commit

Permalink
exit via ExitCode rather than process::exit
Browse files Browse the repository at this point in the history
This should fix #20.
  • Loading branch information
sunshowers committed Apr 9, 2024
1 parent 719600d commit 33d4725
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#[macro_export]
macro_rules! harness {
( $( $name:path, $root:expr, $pattern:expr ),+ $(,)* ) => {
fn main() {
fn main() -> ::std::process::ExitCode {
let mut requirements = Vec::new();

$(
Expand All @@ -22,7 +22,7 @@ macro_rules! harness {
);
)+

$crate::runner(&requirements);
$crate::runner(&requirements)
}
};
}
12 changes: 9 additions & 3 deletions src/runner.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
// Copyright (c) The datatest-stable Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

use std::path::Path;
use std::{path::Path, process::ExitCode};

use crate::{utils, Result};
use camino::{Utf8Path, Utf8PathBuf};
use libtest_mimic::{Arguments, Trial};

#[doc(hidden)]
pub fn runner(requirements: &[Requirements]) {
pub fn runner(requirements: &[Requirements]) -> ExitCode {
let args = Arguments::from_args();

let mut tests: Vec<_> = requirements.iter().flat_map(|req| req.expand()).collect();
tests.sort_unstable_by(|a, b| a.name().cmp(b.name()));

libtest_mimic::run(&args, tests).exit()
let conclusion = libtest_mimic::run(&args, tests);
if conclusion.has_failed() {
// libtest-mimic uses exit code 101 for test failures -- retain the same behavior.
101.into()
} else {
ExitCode::SUCCESS
}
}

#[doc(hidden)]
Expand Down

0 comments on commit 33d4725

Please sign in to comment.