mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-13 05:28:49 +00:00
Prevent test suite from hanging on panic
This commit is contained in:
parent
960415db3f
commit
4e3dc51bc4
2 changed files with 9 additions and 1 deletions
|
@ -16,7 +16,11 @@ use crate::{
|
||||||
pub static AT_EXIT: OnceCell<Box<dyn Fn(bool) + Send + Sync>> = OnceCell::new();
|
pub static AT_EXIT: OnceCell<Box<dyn Fn(bool) + Send + Sync>> = OnceCell::new();
|
||||||
|
|
||||||
pub fn panic_handler(main: impl FnOnce() -> i32 + UnwindSafe) -> ! {
|
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();
|
let standard_hook = take_hook();
|
||||||
set_hook(Box::new(move |panic_info| {
|
set_hook(Box::new(move |panic_info| {
|
||||||
standard_hook(panic_info);
|
standard_hook(panic_info);
|
||||||
|
|
|
@ -61,6 +61,10 @@ export suppress_color
|
||||||
# Source test util functions at startup
|
# Source test util functions at startup
|
||||||
fish_init_cmd="${fish_init_cmd} && source ${TESTS_ROOT}/test_util.fish";
|
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
|
# 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
|
# 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).
|
# TMPDIR (to ensure their output as displayed in case of failure by littlecheck is reproducible).
|
||||||
|
|
Loading…
Reference in a new issue