Prevent test suite from hanging on panic

This commit is contained in:
Mahmoud Al-Qudsi 2024-11-11 16:44:15 -06:00
parent 960415db3f
commit 4e3dc51bc4
2 changed files with 9 additions and 1 deletions

View file

@ -16,7 +16,11 @@ use crate::{
pub static AT_EXIT: OnceCell<Box<dyn Fn(bool) + Send + Sync>> = OnceCell::new();
pub fn panic_handler(main: impl FnOnce() -> i32 + UnwindSafe) -> ! {
if isatty(STDIN_FILENO) {
// The isatty() check will stop us from hanging in most fish tests, but not those
// running in a simulated terminal emulator environment (such as the tmux or pexpect
// tests). The FISH_FAST_FAIL environment variable is set in the test driver to
// prevent the test suite from hanging on panic.
if isatty(STDIN_FILENO) && std::env::var_os("FISH_FAST_FAIL").is_none() {
let standard_hook = take_hook();
set_hook(Box::new(move |panic_info| {
standard_hook(panic_info);

View file

@ -61,6 +61,10 @@ export suppress_color
# Source test util functions at startup
fish_init_cmd="${fish_init_cmd} && source ${TESTS_ROOT}/test_util.fish";
# Indicate that the fish panic handler shouldn't wait for input to prevent tests from hanging
FISH_FAST_FAIL=1
export FISH_FAST_FAIL
# Run the test script, but don't exec so we can clean up after it succeeds/fails. Each test is
# launched directly within its TMPDIR, so that the fish tests themselves do not need to refer to
# TMPDIR (to ensure their output as displayed in case of failure by littlecheck is reproducible).