From c8b28d4d24759522502280e2d1f3c13c8d3f4bbd Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Thu, 23 Apr 2026 16:43:28 +0800 Subject: [PATCH] cargo-test: remove unnecessary TTY initialization --- src/abbrs.rs | 4 ++-- src/ast.rs | 2 +- src/autoload.rs | 2 +- src/builtins/string/escape.rs | 2 +- src/builtins/string/join.rs | 2 +- src/builtins/string/length.rs | 2 +- src/builtins/string/match.rs | 2 +- src/builtins/string/replace.rs | 2 +- src/builtins/string/split.rs | 2 +- src/builtins/string/sub.rs | 2 +- src/builtins/string/trim.rs | 2 +- src/builtins/test.rs | 2 +- src/common.rs | 2 +- src/complete.rs | 6 +++--- src/env/environment.rs | 2 +- src/env/var.rs | 2 +- src/env_universal_common.rs | 16 ++++++++-------- src/expand.rs | 6 +++--- src/fd_monitor.rs | 2 +- src/fds.rs | 2 +- src/highlight/file_tester.rs | 2 +- src/highlight/highlight.rs | 6 +++--- src/history/history.rs | 2 +- src/localization/gettext.rs | 2 +- src/pager.rs | 4 ++-- src/parse_util.rs | 8 ++++---- src/parser.rs | 22 +++++++++++----------- src/reader/reader.rs | 5 ++--- src/screen.rs | 6 +++--- src/termsize.rs | 2 +- src/tests/prelude.rs | 8 +------- src/topic_monitor.rs | 4 ++-- src/wutil/mod.rs | 2 +- 33 files changed, 65 insertions(+), 72 deletions(-) diff --git a/src/abbrs.rs b/src/abbrs.rs index 4c82ae4b0..ab4a6f5b0 100644 --- a/src/abbrs.rs +++ b/src/abbrs.rs @@ -293,7 +293,7 @@ mod tests { #[test] #[serial] fn test_abbreviations() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); { let mut abbrs = abbrs_get_set(); @@ -424,7 +424,7 @@ macro_rules! validate { #[test] #[serial] fn rename_abbrs() { - let _cleanup = test_init(); + test_init(); with_abbrs_mut(|abbrs_g| { let mut add = |name: &wstr, repl: &wstr, position: Position| { diff --git a/src/ast.rs b/src/ast.rs index 71cd7e4bc..dd8ace2c8 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -2832,7 +2832,7 @@ mod tests { #[test] #[serial] fn test_ast_parse() { - let _cleanup = test_init(); + test_init(); let src = L!("echo"); let ast = ast::parse(src, ParseTreeFlags::default(), None); assert!(!ast.any_error); diff --git a/src/autoload.rs b/src/autoload.rs index 8f70e63b2..6a207c4f5 100644 --- a/src/autoload.rs +++ b/src/autoload.rs @@ -463,7 +463,7 @@ mod tests { #[test] #[serial] fn test_autoload() { - let _cleanup = test_init(); + test_init(); use crate::fds::wopen_cloexec; use fish_widestring::wcs2zstring; use nix::fcntl::OFlag; diff --git a/src/builtins/string/escape.rs b/src/builtins/string/escape.rs index c7ea6fa82..e13811547 100644 --- a/src/builtins/string/escape.rs +++ b/src/builtins/string/escape.rs @@ -74,7 +74,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "escape"], STATUS_CMD_ERROR, ""); validate!(["string", "escape", ""], STATUS_CMD_OK, "''\n"); validate!(["string", "escape", "-n", ""], STATUS_CMD_OK, "\n"); diff --git a/src/builtins/string/join.rs b/src/builtins/string/join.rs index 6396a229a..320c0bc07 100644 --- a/src/builtins/string/join.rs +++ b/src/builtins/string/join.rs @@ -113,7 +113,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "join"], STATUS_INVALID_ARGS, ""); validate!(["string", "join", ""], STATUS_CMD_ERROR, ""); validate!(["string", "join", "", "", "", ""], STATUS_CMD_OK, "\n"); diff --git a/src/builtins/string/length.rs b/src/builtins/string/length.rs index f76e07e8f..6a7f661ce 100644 --- a/src/builtins/string/length.rs +++ b/src/builtins/string/length.rs @@ -87,7 +87,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "length"], STATUS_CMD_ERROR, ""); validate!(["string", "length", ""], STATUS_CMD_ERROR, "0\n"); validate!(["string", "length", "", "", ""], STATUS_CMD_ERROR, "0\n0\n0\n"); diff --git a/src/builtins/string/match.rs b/src/builtins/string/match.rs index e23cf76e3..405cc0a32 100644 --- a/src/builtins/string/match.rs +++ b/src/builtins/string/match.rs @@ -427,7 +427,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "match"], STATUS_INVALID_ARGS, ""); validate!(["string", "match", ""], STATUS_CMD_ERROR, ""); validate!(["string", "match", "", ""], STATUS_CMD_OK, "\n"); diff --git a/src/builtins/string/replace.rs b/src/builtins/string/replace.rs index 91ae47f2e..fbaabb2f2 100644 --- a/src/builtins/string/replace.rs +++ b/src/builtins/string/replace.rs @@ -281,7 +281,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "replace", ""], STATUS_INVALID_ARGS, ""); validate!(["string", "replace", "", ""], STATUS_CMD_ERROR, ""); validate!(["string", "replace", "", "", ""], STATUS_CMD_ERROR, "\n"); diff --git a/src/builtins/string/split.rs b/src/builtins/string/split.rs index 149afb685..62482bf84 100644 --- a/src/builtins/string/split.rs +++ b/src/builtins/string/split.rs @@ -299,7 +299,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "split"], STATUS_INVALID_ARGS, ""); validate!(["string", "split", ":"], STATUS_CMD_ERROR, ""); validate!(["string", "split", ".", "www.ch.ic.ac.uk"], STATUS_CMD_OK, "www\nch\nic\nac\nuk\n"); diff --git a/src/builtins/string/sub.rs b/src/builtins/string/sub.rs index e2a581855..2926dbb36 100644 --- a/src/builtins/string/sub.rs +++ b/src/builtins/string/sub.rs @@ -130,7 +130,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "sub"], STATUS_CMD_ERROR, ""); validate!(["string", "sub", "abcde"], STATUS_CMD_OK, "abcde\n"); validate!(["string", "sub", "-l", "x", "abcde"], STATUS_INVALID_ARGS, ""); diff --git a/src/builtins/string/trim.rs b/src/builtins/string/trim.rs index dcceac33f..1ff9875ba 100644 --- a/src/builtins/string/trim.rs +++ b/src/builtins/string/trim.rs @@ -105,7 +105,7 @@ mod tests { #[serial] #[rustfmt::skip] fn plain() { - let _cleanup = test_init(); + test_init(); validate!(["string", "trim"], STATUS_CMD_ERROR, ""); validate!(["string", "trim", ""], STATUS_CMD_ERROR, "\n"); validate!(["string", "trim", " "], STATUS_CMD_OK, "\n"); diff --git a/src/builtins/test.rs b/src/builtins/test.rs index 476ecc8cc..276082bb9 100644 --- a/src/builtins/test.rs +++ b/src/builtins/test.rs @@ -1261,7 +1261,7 @@ fn test_test() { #[test] #[serial] fn test_test_builtin() { - let _cleanup = test_init(); + test_init(); test_test_brackets(); test_test(); } diff --git a/src/common.rs b/src/common.rs index dcf65adf6..9c35571cd 100644 --- a/src/common.rs +++ b/src/common.rs @@ -467,7 +467,7 @@ fn test_escape_no_printables() { #[test] #[serial] fn test_escape_quotes() { - let _cleanup = test_init(); + test_init(); macro_rules! validate { ($cmd:expr, $quote:expr, $no_tilde:expr, $expected:expr) => { assert_eq!( diff --git a/src/complete.rs b/src/complete.rs index 7b7712e26..751081989 100644 --- a/src/complete.rs +++ b/src/complete.rs @@ -2646,7 +2646,7 @@ fn comma_join(lst: Vec) -> WString { #[test] #[serial] fn test_complete() { - let _cleanup = test_init(); + test_init(); let vars = PwdEnvironment { parent: TestEnvironment { vars: HashMap::from([ @@ -3164,7 +3164,7 @@ macro_rules! unique_completion_applies_as { #[test] #[serial] fn test_autosuggest_suggest_special() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); macro_rules! perform_one_autosuggestion_cd_test { ($command:literal, $expected:literal, $vars:expr) => { @@ -3345,7 +3345,7 @@ macro_rules! perform_one_completion_cd_test { #[test] #[serial] fn test_autosuggestion_ignores() { - let _cleanup = test_init(); + test_init(); // Testing scenarios that should produce no autosuggestions macro_rules! perform_one_autosuggestion_should_ignore_test { ($command:literal) => { diff --git a/src/env/environment.rs b/src/env/environment.rs index 438062160..d00e3563a 100644 --- a/src/env/environment.rs +++ b/src/env/environment.rs @@ -812,7 +812,7 @@ mod tests { #[test] #[serial] fn test_env_snapshot() { - let _cleanup = test_init(); + test_init(); std::fs::create_dir_all("test/fish_env_snapshot_test/").unwrap(); let parser = TestParser::new(); let vars = parser.vars(); diff --git a/src/env/var.rs b/src/env/var.rs index 52b137237..48a6a1635 100644 --- a/src/env/var.rs +++ b/src/env/var.rs @@ -369,7 +369,7 @@ fn test_timezone_env_vars() { #[test] #[serial] fn test_env_vars() { - let _cleanup = test_init(); + test_init(); test_timezone_env_vars(); // TODO: Add tests for the locale vars. diff --git a/src/env_universal_common.rs b/src/env_universal_common.rs index d5a27dbf6..8efb6f330 100644 --- a/src/env_universal_common.rs +++ b/src/env_universal_common.rs @@ -830,7 +830,7 @@ fn make_test_uvar_path() -> std::io::Result<(TempDir, WString)> { } fn test_universal_helper(x: usize, path: &wstr) { - let _cleanup = test_init(); + test_init(); let mut uvars = EnvUniversal::new(); uvars.initialize_at_path(path.to_owned()); @@ -853,7 +853,7 @@ fn test_universal_helper(x: usize, path: &wstr) { #[test] fn test_universal() { - let _cleanup = test_init(); + test_init(); let (_test_dir, test_path) = make_test_uvar_path().unwrap(); let threads = 1; @@ -893,7 +893,7 @@ fn test_universal() { #[test] #[serial] fn test_universal_output() { - let _cleanup = test_init(); + test_init(); let flag_export = EnvVarFlags::EXPORT; let flag_pathvar = EnvVarFlags::PATHVAR; @@ -950,7 +950,7 @@ fn test_universal_output() { #[test] #[serial] fn test_universal_parsing() { - let _cleanup = test_init(); + test_init(); let input = concat!( "# This file contains fish universal variable definitions.\n", "# VERSION: 3.0\n", @@ -1002,7 +1002,7 @@ fn test_universal_parsing() { #[test] #[serial] fn test_universal_parsing_legacy() { - let _cleanup = test_init(); + test_init(); let input = concat!( "# This file contains fish universal variable definitions.\n", "SET varA:ValA1\\x1eValA2\n", @@ -1030,7 +1030,7 @@ fn test_universal_parsing_legacy() { #[test] fn test_universal_callbacks() { - let _cleanup = test_init(); + test_init(); let (_test_dir, test_path) = make_test_uvar_path().unwrap(); let mut uvars1 = EnvUniversal::new(); let mut uvars2 = EnvUniversal::new(); @@ -1100,7 +1100,7 @@ macro_rules! sync { #[test] #[serial] fn test_universal_formats() { - let _cleanup = test_init(); + test_init(); macro_rules! validate { ( $version_line:literal, $expected_format:expr ) => { assert_eq!( @@ -1121,7 +1121,7 @@ macro_rules! validate { #[test] fn test_universal_ok_to_save() { - let _cleanup = test_init(); + test_init(); // Ensure we don't try to save after reading from a newer fish. let (_test_dir, test_path) = make_test_uvar_path().unwrap(); let contents = b"# VERSION: 99999.99\n"; diff --git a/src/expand.rs b/src/expand.rs index 1e2627feb..a641930a3 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -1606,7 +1606,7 @@ fn expand_test_impl( #[test] #[serial] fn test_expand() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); /// Perform parameter expansion and test if the output equals the zero-terminated parameter list /// supplied. /// @@ -1900,7 +1900,7 @@ macro_rules! expand_test { #[test] #[serial] fn test_expand_overflow() { - let _cleanup = test_init(); + test_init(); // Testing overflowing expansions // Ensure that we have sane limits on number of expansions - see #7497. @@ -1937,7 +1937,7 @@ fn test_expand_overflow() { #[test] #[serial] fn test_abbreviations() { - let _cleanup = test_init(); + test_init(); // Testing abbreviations with_abbrs_mut(|abbrset| { diff --git a/src/fd_monitor.rs b/src/fd_monitor.rs index 225c2b702..a8f1ad451 100644 --- a/src/fd_monitor.rs +++ b/src/fd_monitor.rs @@ -551,7 +551,7 @@ fn write42(&self) { #[test] #[serial] fn fd_monitor_items() { - let _cleanup = test_init(); + test_init(); let monitor = FdMonitor::new(); // Item which will never receive data or be called. diff --git a/src/fds.rs b/src/fds.rs index abbb9ca56..e5b933cac 100644 --- a/src/fds.rs +++ b/src/fds.rs @@ -323,7 +323,7 @@ mod tests { #[test] #[serial] fn test_pipes() { - let _cleanup = test_init(); + test_init(); // Here we just test that each pipe has CLOEXEC set and is in the high range. // Note pipe creation may fail due to fd exhaustion; don't fail in that case. let mut pipes = vec![]; diff --git a/src/highlight/file_tester.rs b/src/highlight/file_tester.rs index 269d880b7..3e2fe8a4f 100644 --- a/src/highlight/file_tester.rs +++ b/src/highlight/file_tester.rs @@ -733,7 +733,7 @@ fn test_redirections() { #[test] #[serial] fn test_is_potential_path() { - let _cleanup = test_init(); + test_init(); // Directories std::fs::create_dir_all("test/is_potential_path_test/alpha/").unwrap(); std::fs::create_dir_all("test/is_potential_path_test/beta/").unwrap(); diff --git a/src/highlight/highlight.rs b/src/highlight/highlight.rs index 4770b259b..6b34f4a49 100644 --- a/src/highlight/highlight.rs +++ b/src/highlight/highlight.rs @@ -1330,7 +1330,7 @@ fn get_overlong_path() -> String { #[test] #[serial] fn test_highlighting() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); // Testing syntax highlighting parser.pushd("test/fish_highlight_test/"); @@ -1815,7 +1815,7 @@ macro_rules! validate { #[serial] #[allow(clippy::needless_range_loop)] fn test_trailing_spaces_after_command() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); let vars = parser.vars(); @@ -1869,7 +1869,7 @@ fn test_trailing_spaces_after_command() { #[test] #[serial] fn test_resolve_role() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); let vars = parser.vars(); diff --git a/src/history/history.rs b/src/history/history.rs index 6771111de..2b222707a 100644 --- a/src/history/history.rs +++ b/src/history/history.rs @@ -2288,7 +2288,7 @@ fn test_history_merge() { #[test] fn test_history_path_detection() { - let _cleanup = test_init(); + test_init(); // Regression test for #7582. // Temporary directory for the history files. let hist_tmpdir = fish_tempfile::new_dir().unwrap(); diff --git a/src/localization/gettext.rs b/src/localization/gettext.rs index 82982f28d..a1df32722 100644 --- a/src/localization/gettext.rs +++ b/src/localization/gettext.rs @@ -204,7 +204,7 @@ mod tests { #[test] #[serial] fn test_unlocalized() { - let _cleanup = test_init(); + test_init(); let abc_str = LocalizableString::from_external_source(WString::from("abc")); let s: &'static wstr = wgettext!(abc_str); assert_eq!(s, "abc"); diff --git a/src/pager.rs b/src/pager.rs index a5e2fcbd5..95091ba38 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -1322,7 +1322,7 @@ mod tests { #[test] #[serial] fn test_pager_navigation() { - let _cleanup = test_init(); + test_init(); // Generate 19 strings of width 10. There's 2 spaces between completions, and our term size is // 80; these can therefore fit into 6 columns (6 * 12 - 2 = 70) or 5 columns (58) but not 7 // columns (7 * 12 - 2 = 82). @@ -1412,7 +1412,7 @@ macro_rules! validate { #[test] #[serial] fn test_pager_layout() { - let _cleanup = test_init(); + test_init(); // These tests are woefully incomplete let rendered_lines = |pager: &mut Pager, width: u16| { diff --git a/src/parse_util.rs b/src/parse_util.rs index 41f917c7f..3ef73230c 100644 --- a/src/parse_util.rs +++ b/src/parse_util.rs @@ -1915,7 +1915,7 @@ mod tests { #[test] #[serial] fn test_error_messages() { - let _cleanup = test_init(); + test_init(); // Given a format string, returns a list of non-empty strings separated by format specifiers. The // format specifiers themselves are omitted. fn separate_by_format_specifiers(format: &wstr) -> Vec<&wstr> { @@ -2007,7 +2007,7 @@ macro_rules! validate { #[test] #[serial] fn test_get_cmdsubst_extent() { - let _cleanup = test_init(); + test_init(); let a = L!("echo (echo (echo hi"); assert_eq!(get_cmdsubst_extent(a, 0), 0..a.len()); assert_eq!(get_cmdsubst_extent(a, 1), 0..a.len()); @@ -2023,7 +2023,7 @@ fn test_get_cmdsubst_extent() { #[test] #[serial] fn test_slice_length() { - let _cleanup = test_init(); + test_init(); assert_eq!(slice_length(L!("[2]")), Some(3)); assert_eq!(slice_length(L!("[12]")), Some(4)); assert_eq!(slice_length(L!("[\"foo\"]")), Some(7)); @@ -2033,7 +2033,7 @@ fn test_slice_length() { #[test] #[serial] fn test_indents() { - let _cleanup = test_init(); + test_init(); // A struct which is either text or a new indent. struct Segment { // The indent to set diff --git a/src/parser.rs b/src/parser.rs index 7d24cde55..c62c69c77 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1522,7 +1522,7 @@ mod tests { #[test] #[serial] fn test_parser() { - let _cleanup = test_init(); + test_init(); macro_rules! detect_errors { ($src:literal) => { detect_parse_errors(L!($src), None, true /* accept incomplete */) @@ -1825,7 +1825,7 @@ fn detect_argument_errors(src: &str) -> Result<(), ParseIssue> { #[test] #[serial] fn test_new_parser_correctness() { - let _cleanup = test_init(); + test_init(); macro_rules! validate { ($src:expr, $ok:expr) => { let ast = ast::parse(L!($src), ParseTreeFlags::default(), None); @@ -1855,7 +1855,7 @@ macro_rules! validate { #[test] #[serial] fn test_new_parser_correctness_by_fuzzing() { - let _cleanup = test_init(); + test_init(); let fuzzes = [ L!("if"), L!("else"), @@ -1921,7 +1921,7 @@ fn string_for_permutation( #[test] #[serial] fn test_new_parser_ll2() { - let _cleanup = test_init(); + test_init(); // Parse a statement, returning the command, args (joined by spaces), and the decoration. Returns // true if successful. fn test_1_parse_ll2(src: &wstr) -> Option<(WString, WString, StatementDecoration)> { @@ -2042,7 +2042,7 @@ macro_rules! check_function_help { #[test] #[serial] fn test_new_parser_ad_hoc() { - let _cleanup = test_init(); + test_init(); // Very ad-hoc tests for issues encountered. // Ensure that 'case' terminates a job list. @@ -2102,7 +2102,7 @@ fn test_new_parser_ad_hoc() { #[test] #[serial] fn test_new_parser_errors() { - let _cleanup = test_init(); + test_init(); macro_rules! validate { ($src:expr, $expected_code:expr) => { let mut errors = vec![]; @@ -2138,7 +2138,7 @@ macro_rules! validate { #[test] #[serial] fn test_eval_recursion_detection() { - let _cleanup = test_init(); + test_init(); // Ensure that we don't crash on infinite self recursion and mutual recursion. let parser = TestParser::new(); parser.eval( @@ -2158,7 +2158,7 @@ fn test_eval_recursion_detection() { #[test] #[serial] fn test_eval_illegal_exit_code() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); macro_rules! validate { ($cmd:expr, $result:expr) => { @@ -2184,7 +2184,7 @@ macro_rules! validate { #[test] #[serial] fn test_eval_empty_function_name() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); parser.eval( L!("function '' ; echo fail; exit 42 ; end ; ''"), @@ -2195,7 +2195,7 @@ fn test_eval_empty_function_name() { #[test] #[serial] fn test_expand_argument_list() { - let _cleanup = test_init(); + test_init(); let parser = TestParser::new(); let comps: Vec = Parser::expand_argument_list( L!("alpha 'beta gamma' delta"), @@ -2237,7 +2237,7 @@ fn test_1_cancellation(parser: &Parser, src: &wstr) { #[test] #[serial] fn test_cancellation() { - let _cleanup = test_init(); + test_init(); let parser = Parser::new(EnvStack::new(), CancelBehavior::Clear); let _pop = fake_scoped_reader(&parser); diff --git a/src/reader/reader.rs b/src/reader/reader.rs index e3ae1c0f8..2eedd5d7d 100644 --- a/src/reader/reader.rs +++ b/src/reader/reader.rs @@ -989,6 +989,7 @@ fn read_ni(parser: &Parser, fd: RawFd, io: &IoChain) -> Result<(), ErrorCode> { /// Initialize the reader. pub fn reader_init(will_restore_foreground_pgroup: bool) { + assert_is_main_thread(); let terminal_mode_on_startup = match tcgetattr(unsafe { BorrowedFd::borrow_raw(STDIN_FILENO) }) { Ok(modes) => { @@ -1000,9 +1001,7 @@ pub fn reader_init(will_restore_foreground_pgroup: bool) { Err(_) => zeroed_termios(), }; - if !cfg!(test) { - assert!(AT_EXIT.get().is_none()); - } + assert!(AT_EXIT.get().is_none()); AT_EXIT.get_or_init(|| Box::new(move || reader_deinit(will_restore_foreground_pgroup))); // Set the mode used for program execution, initialized to the current mode. diff --git a/src/screen.rs b/src/screen.rs index 604d90ad6..9371eacaa 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -2086,7 +2086,7 @@ mod tests { #[test] #[serial] fn test_escape_code_length() { - let _cleanup = test_init(); + test_init(); let mut lc = LayoutCache::new(); assert_eq!(lc.escape_code_length(L!("")), 0); assert_eq!(lc.escape_code_length(L!("abcd")), 0); @@ -2121,7 +2121,7 @@ fn test_escape_code_length() { #[test] #[serial] fn test_layout_cache() { - let _cleanup = test_init(); + test_init(); let mut seqs = LayoutCache::new(); // Verify escape code cache. @@ -2193,7 +2193,7 @@ fn test_layout_cache() { #[test] #[serial] fn test_prompt_truncation() { - let _cleanup = test_init(); + test_init(); let mut cache = LayoutCache::new(); let mut trunc = WString::new(); diff --git a/src/termsize.rs b/src/termsize.rs index ffa403a06..9c313d353 100644 --- a/src/termsize.rs +++ b/src/termsize.rs @@ -271,7 +271,7 @@ mod tests { #[test] #[serial] fn test_termsize() { - let _cleanup = test_init(); + test_init(); let env_global = EnvSetMode::new(EnvMode::GLOBAL, false); let parser = TestParser::new(); let vars = parser.vars(); diff --git a/src/tests/prelude.rs b/src/tests/prelude.rs index 3606a2950..74932f90e 100644 --- a/src/tests/prelude.rs +++ b/src/tests/prelude.rs @@ -4,12 +4,10 @@ use crate::locale::set_libc_locales; use crate::parser::{CancelBehavior, Parser}; use crate::prelude::*; -use crate::reader::{reader_deinit, reader_init}; use crate::signal::signal_reset_handlers; use crate::topic_monitor::topic_monitor_init; use crate::wutil::wgetcwd; use crate::{env::EnvStack, proc::proc_init}; -use fish_common::{ScopeGuard, ScopeGuarding}; use std::cell::RefCell; use std::collections::HashMap; use std::env::set_current_dir; @@ -18,7 +16,7 @@ pub use serial_test::serial; -pub fn test_init() -> impl ScopeGuarding { +pub fn test_init() { static DONE: OnceLock<()> = OnceLock::new(); DONE.get_or_init(|| { // If we are building with `cargo build` and have build w/ `cmake`, this might not @@ -42,10 +40,6 @@ pub fn test_init() -> impl ScopeGuarding { // Set PWD from getcwd - fixes #5599 EnvStack::globals().set_pwd_from_getcwd(); }); - reader_init(false); - ScopeGuard::new((), |()| { - reader_deinit(false); - }) } /// An environment built around an std::map. diff --git a/src/topic_monitor.rs b/src/topic_monitor.rs index 9248e5cae..4b8c6cae1 100644 --- a/src/topic_monitor.rs +++ b/src/topic_monitor.rs @@ -618,7 +618,7 @@ mod tests { #[test] #[serial] fn test_topic_monitor() { - let _cleanup = test_init(); + test_init(); let monitor = TopicMonitor::default(); let gens = GenerationsList::new(); let t = Topic::SigChld; @@ -644,7 +644,7 @@ fn test_topic_monitor() { #[test] #[serial] fn test_topic_monitor_torture() { - let _cleanup = test_init(); + test_init(); let monitor = Arc::new(TopicMonitor::default()); const THREAD_COUNT: usize = 64; let t1 = Topic::SigChld; diff --git a/src/wutil/mod.rs b/src/wutil/mod.rs index 4c261b458..c64c01134 100644 --- a/src/wutil/mod.rs +++ b/src/wutil/mod.rs @@ -641,7 +641,7 @@ fn test_wdirname_wbasename() { #[test] #[serial] fn test_wwrite_to_fd() { - let _cleanup = test_init(); + test_init(); let temp_file = fish_tempfile::new_file().unwrap(); let mut rng = rand::rng(); let sizes = [1, 2, 3, 5, 13, 23, 64, 128, 255, 4096, 4096 * 2];