Skip to content

Commit 33d4725

Browse files
committed
exit via ExitCode rather than process::exit
This should fix #20.
1 parent 719600d commit 33d4725

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/macros.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[macro_export]
99
macro_rules! harness {
1010
( $( $name:path, $root:expr, $pattern:expr ),+ $(,)* ) => {
11-
fn main() {
11+
fn main() -> ::std::process::ExitCode {
1212
let mut requirements = Vec::new();
1313

1414
$(
@@ -22,7 +22,7 @@ macro_rules! harness {
2222
);
2323
)+
2424

25-
$crate::runner(&requirements);
25+
$crate::runner(&requirements)
2626
}
2727
};
2828
}

src/runner.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,26 @@
11
// Copyright (c) The datatest-stable Contributors
22
// SPDX-License-Identifier: MIT OR Apache-2.0
33

4-
use std::path::Path;
4+
use std::{path::Path, process::ExitCode};
55

66
use crate::{utils, Result};
77
use camino::{Utf8Path, Utf8PathBuf};
88
use libtest_mimic::{Arguments, Trial};
99

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

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

17-
libtest_mimic::run(&args, tests).exit()
17+
let conclusion = libtest_mimic::run(&args, tests);
18+
if conclusion.has_failed() {
19+
// libtest-mimic uses exit code 101 for test failures -- retain the same behavior.
20+
101.into()
21+
} else {
22+
ExitCode::SUCCESS
23+
}
1824
}
1925

2026
#[doc(hidden)]

0 commit comments

Comments
 (0)