diff --git a/src/abbrs.rs b/src/abbrs.rs index beae2de24..20d3ac510 100644 --- a/src/abbrs.rs +++ b/src/abbrs.rs @@ -269,7 +269,7 @@ pub fn abbrs_match(token: &wstr, position: Position) -> Vec { #[test] #[serial] fn rename_abbrs() { - test_init(); + let _cleanup = test_init(); use crate::abbrs::{Abbreviation, Position}; use crate::wchar::prelude::*; diff --git a/src/ast.rs b/src/ast.rs index a555e3113..0d194cbe2 100644 --- a/src/ast.rs +++ b/src/ast.rs @@ -4012,7 +4012,7 @@ fn keyword_for_token(tok: TokenType, token: &wstr) -> ParseKeyword { #[test] #[serial] fn test_ast_parse() { - test_init(); + let _cleanup = test_init(); let src = L!("echo"); let ast = Ast::parse(src, ParseTreeFlags::empty(), None); assert!(!ast.any_error); diff --git a/src/autoload.rs b/src/autoload.rs index 97eac452c..9b84cf1dd 100644 --- a/src/autoload.rs +++ b/src/autoload.rs @@ -319,7 +319,7 @@ fn locate_file(&self, cmd: &wstr) -> Option { #[test] #[serial] fn test_autoload() { - test_init(); + let _cleanup = test_init(); use crate::common::{charptr2wcstring, wcs2zstring}; use crate::fds::wopen_cloexec; use crate::wutil::sprintf; diff --git a/src/builtins/tests/string_tests.rs b/src/builtins/tests/string_tests.rs index 02b38f477..47a7423eb 100644 --- a/src/builtins/tests/string_tests.rs +++ b/src/builtins/tests/string_tests.rs @@ -5,7 +5,7 @@ #[test] #[serial] fn test_string() { - test_init(); + let _cleanup = test_init(); use crate::builtins::shared::{STATUS_CMD_ERROR, STATUS_CMD_OK, STATUS_INVALID_ARGS}; use crate::builtins::string::string; use crate::common::escape; @@ -15,7 +15,7 @@ fn test_string() { use crate::tests::prelude::*; use crate::wchar::prelude::*; - test_init(); + let _cleanup = test_init(); // avoid 1.3k L!()'s macro_rules! test_cases { diff --git a/src/builtins/tests/test_tests.rs b/src/builtins/tests/test_tests.rs index 572be26b6..ecfbf3058 100644 --- a/src/builtins/tests/test_tests.rs +++ b/src/builtins/tests/test_tests.rs @@ -169,7 +169,7 @@ fn test_test() { #[test] #[serial] fn test_test_builtin() { - test_init(); + let _cleanup = test_init(); test_test_brackets(); test_test(); } diff --git a/src/fds.rs b/src/fds.rs index c03be7cbc..a9737998b 100644 --- a/src/fds.rs +++ b/src/fds.rs @@ -310,7 +310,7 @@ pub fn make_fd_blocking(fd: RawFd) -> Result<(), io::Error> { #[test] #[serial] fn test_pipes() { - test_init(); + let _cleanup = 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/parse_util.rs b/src/parse_util.rs index eb6969ef6..6f0a26888 100644 --- a/src/parse_util.rs +++ b/src/parse_util.rs @@ -1830,7 +1830,7 @@ pub fn parse_util_expand_variable_error( #[test] #[serial] fn test_parse_util_cmdsubst_extent() { - test_init(); + let _cleanup = test_init(); const a: &wstr = L!("echo (echo (echo hi"); assert_eq!(parse_util_cmdsubst_extent(a, 0), 0..a.len()); assert_eq!(parse_util_cmdsubst_extent(a, 1), 0..a.len()); @@ -1849,7 +1849,7 @@ fn test_parse_util_cmdsubst_extent() { #[test] #[serial] fn test_parse_util_slice_length() { - test_init(); + let _cleanup = test_init(); assert_eq!(parse_util_slice_length(L!("[2]")), Some(3)); assert_eq!(parse_util_slice_length(L!("[12]")), Some(4)); assert_eq!(parse_util_slice_length(L!("[\"foo\"]")), Some(7)); @@ -1859,7 +1859,7 @@ fn test_parse_util_slice_length() { #[test] #[serial] fn test_escape_quotes() { - test_init(); + let _cleanup = test_init(); macro_rules! validate { ($cmd:expr, $quote:expr, $no_tilde:expr, $expected:expr) => { assert_eq!( @@ -1902,7 +1902,7 @@ macro_rules! validate { #[test] #[serial] fn test_indents() { - test_init(); + let _cleanup = test_init(); // A struct which is either text or a new indent. struct Segment { // The indent to set diff --git a/src/tests/abbrs.rs b/src/tests/abbrs.rs index c3c33d2c1..9528e0bd9 100644 --- a/src/tests/abbrs.rs +++ b/src/tests/abbrs.rs @@ -9,7 +9,7 @@ #[test] #[serial] fn test_abbreviations() { - test_init(); + let _cleanup = test_init(); { let mut abbrs = abbrs_get_set(); abbrs.add(Abbreviation::new( diff --git a/src/tests/complete.rs b/src/tests/complete.rs index affb08ef9..b93ef3e30 100644 --- a/src/tests/complete.rs +++ b/src/tests/complete.rs @@ -25,7 +25,7 @@ fn comma_join(lst: Vec) -> WString { #[test] #[serial] fn test_complete() { - test_init(); + let _cleanup = test_init(); let vars = PwdEnvironment { parent: TestEnvironment { vars: HashMap::from([ @@ -433,7 +433,7 @@ fn test_complete() { #[test] #[serial] fn test_autosuggest_suggest_special() { - test_init(); + let _cleanup = test_init(); macro_rules! perform_one_autosuggestion_cd_test { ($command:literal, $expected:literal, $vars:expr) => { let mut comps = complete( @@ -596,7 +596,7 @@ macro_rules! perform_one_completion_cd_test { #[test] #[serial] fn test_autosuggestion_ignores() { - test_init(); + let _cleanup = test_init(); // Testing scenarios that should produce no autosuggestions macro_rules! perform_one_autosuggestion_should_ignore_test { ($command:literal) => { diff --git a/src/tests/debounce.rs b/src/tests/debounce.rs index 1eb1e8bf9..cbe3eb5de 100644 --- a/src/tests/debounce.rs +++ b/src/tests/debounce.rs @@ -15,7 +15,7 @@ #[test] #[serial] fn test_debounce() { - test_init(); + let _cleanup = test_init(); // Run 8 functions using a condition variable. // Only the first and last should run. let db = Debounce::new(Duration::from_secs(0)); @@ -88,7 +88,7 @@ struct Context { #[test] #[serial] fn test_debounce_timeout() { - test_init(); + let _cleanup = test_init(); // Verify that debounce doesn't wait forever. // Use a shared_ptr so we don't have to join our threads. let timeout = Duration::from_millis(500); diff --git a/src/tests/env.rs b/src/tests/env.rs index 5cb0ecbd0..106c497dc 100644 --- a/src/tests/env.rs +++ b/src/tests/env.rs @@ -91,7 +91,7 @@ fn test_timezone_env_vars() { #[test] #[serial] fn test_env_vars() { - test_init(); + let _cleanup = test_init(); test_timezone_env_vars(); // TODO: Add tests for the locale and ncurses vars. @@ -110,7 +110,7 @@ fn test_env_vars() { #[test] #[serial] fn test_env_snapshot() { - test_init(); + let _cleanup = test_init(); std::fs::create_dir_all("test/fish_env_snapshot_test/").unwrap(); pushd("test/fish_env_snapshot_test/"); let vars = Parser::principal_parser().vars(); diff --git a/src/tests/env_universal_common.rs b/src/tests/env_universal_common.rs index 251a5c8c6..1ecfc25d2 100644 --- a/src/tests/env_universal_common.rs +++ b/src/tests/env_universal_common.rs @@ -14,7 +14,7 @@ const UVARS_TEST_PATH: &wstr = L!("test/fish_uvars_test/varsfile.txt"); fn test_universal_helper(x: usize) { - test_init(); + let _cleanup = test_init(); let mut callbacks = CallbackDataList::new(); let mut uvars = EnvUniversal::new(); uvars.initialize_at_path(&mut callbacks, UVARS_TEST_PATH.to_owned()); @@ -39,7 +39,7 @@ fn test_universal_helper(x: usize) { #[test] #[serial] fn test_universal() { - test_init(); + let _cleanup = test_init(); let _ = std::fs::remove_dir_all("test/fish_uvars_test/"); std::fs::create_dir_all("test/fish_uvars_test/").unwrap(); @@ -78,7 +78,7 @@ fn test_universal() { #[test] #[serial] fn test_universal_output() { - test_init(); + let _cleanup = test_init(); let flag_export = EnvVarFlags::EXPORT; let flag_pathvar = EnvVarFlags::PATHVAR; @@ -127,7 +127,7 @@ fn test_universal_output() { #[test] #[serial] fn test_universal_parsing() { - test_init(); + let _cleanup = test_init(); let input = concat!( "# This file contains fish universal variable definitions.\n", "# VERSION: 3.0\n", @@ -179,7 +179,7 @@ fn test_universal_parsing() { #[test] #[serial] fn test_universal_parsing_legacy() { - test_init(); + let _cleanup = test_init(); let input = concat!( "# This file contains fish universal variable definitions.\n", "SET varA:ValA1\\x1eValA2\n", @@ -208,7 +208,7 @@ fn test_universal_parsing_legacy() { #[test] #[serial] fn test_universal_callbacks() { - test_init(); + let _cleanup = test_init(); std::fs::create_dir_all("test/fish_uvars_test/").unwrap(); let mut callbacks = CallbackDataList::new(); let mut uvars1 = EnvUniversal::new(); @@ -265,7 +265,7 @@ fn test_universal_callbacks() { #[test] #[serial] fn test_universal_formats() { - test_init(); + let _cleanup = test_init(); macro_rules! validate { ( $version_line:literal, $expected_format:expr ) => { assert_eq!( @@ -287,7 +287,7 @@ macro_rules! validate { #[test] #[serial] fn test_universal_ok_to_save() { - test_init(); + let _cleanup = test_init(); // Ensure we don't try to save after reading from a newer fish. std::fs::create_dir_all("test/fish_uvars_test/").unwrap(); let contents = b"# VERSION: 99999.99\n"; diff --git a/src/tests/expand.rs b/src/tests/expand.rs index 61ba0f316..e328a9f75 100644 --- a/src/tests/expand.rs +++ b/src/tests/expand.rs @@ -65,7 +65,7 @@ fn expand_test_impl( #[test] #[serial] fn test_expand() { - test_init(); + let _cleanup = test_init(); /// Perform parameter expansion and test if the output equals the zero-terminated parameter list /// supplied. /// /// \param in the string to expand @@ -349,7 +349,7 @@ macro_rules! expand_test { #[test] #[serial] fn test_expand_overflow() { - test_init(); + let _cleanup = test_init(); // Testing overflowing expansions // Ensure that we have sane limits on number of expansions - see #7497. @@ -386,7 +386,7 @@ fn test_expand_overflow() { #[test] #[serial] fn test_abbreviations() { - test_init(); + let _cleanup = test_init(); // Testing abbreviations with_abbrs_mut(|abbrset| { diff --git a/src/tests/fd_monitor.rs b/src/tests/fd_monitor.rs index 9231658d9..588a63df3 100644 --- a/src/tests/fd_monitor.rs +++ b/src/tests/fd_monitor.rs @@ -109,7 +109,7 @@ fn write42(&self) { #[test] #[serial] fn fd_monitor_items() { - test_init(); + let _cleanup = test_init(); let monitor = FdMonitor::new(); // Items which will never receive data or be called. diff --git a/src/tests/highlight.rs b/src/tests/highlight.rs index 7b4e2b3e0..0dec59a4b 100644 --- a/src/tests/highlight.rs +++ b/src/tests/highlight.rs @@ -24,7 +24,7 @@ fn get_overlong_path() -> String { #[test] #[serial] fn test_is_potential_path() { - test_init(); + let _cleanup = 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(); @@ -160,7 +160,7 @@ fn test_is_potential_path() { #[test] #[serial] fn test_highlighting() { - test_init(); + let _cleanup = test_init(); // Testing syntax highlighting pushd("test/fish_highlight_test/"); let _popd = ScopeGuard::new((), |_| popd()); diff --git a/src/tests/history.rs b/src/tests/history.rs index 94ff467e5..9d9485ec2 100644 --- a/src/tests/history.rs +++ b/src/tests/history.rs @@ -43,7 +43,7 @@ fn random_string() -> WString { #[test] #[serial] fn test_history() { - test_init(); + let _cleanup = test_init(); macro_rules! test_history_matches { ($search:expr, $expected:expr) => { let expected: Vec<&wstr> = $expected; @@ -226,7 +226,7 @@ fn generate_history_lines(item_count: usize, idx: usize) -> Vec { } fn test_history_races_pound_on_history(item_count: usize, idx: usize) { - test_init(); + let _cleanup = test_init(); // Called in child thread to modify history. let hist = History::new(L!("race_test")); let hist_lines = generate_history_lines(item_count, idx); @@ -239,7 +239,7 @@ fn test_history_races_pound_on_history(item_count: usize, idx: usize) { #[test] #[serial] fn test_history_races() { - test_init(); + let _cleanup = test_init(); // This always fails under WSL if is_windows_subsystem_for_linux() { return; @@ -340,7 +340,7 @@ fn test_history_races() { #[test] #[serial] fn test_history_merge() { - test_init(); + let _cleanup = test_init(); // In a single fish process, only one history is allowed to exist with the given name But it's // common to have multiple history instances with the same name active in different processes, // e.g. when you have multiple shells open. We try to get that right and merge all their history @@ -449,7 +449,7 @@ fn test_history_merge() { #[test] #[serial] fn test_history_path_detection() { - test_init(); + let _cleanup = test_init(); // Regression test for #7582. let tmpdirbuff = CString::new("/tmp/fish_test_history.XXXXXX").unwrap(); let tmpdir = unsafe { libc::mkdtemp(tmpdirbuff.into_raw()) }; @@ -565,7 +565,7 @@ fn install_sample_history(name: &wstr) { #[test] #[serial] fn test_history_formats() { - test_init(); + let _cleanup = test_init(); // Test inferring and reading legacy and bash history formats. let name = L!("history_sample_fish_2_0"); install_sample_history(name); diff --git a/src/tests/input.rs b/src/tests/input.rs index 98be46b33..b74a92185 100644 --- a/src/tests/input.rs +++ b/src/tests/input.rs @@ -8,7 +8,7 @@ #[test] #[serial] fn test_input() { - test_init(); + let _cleanup = test_init(); use crate::env::EnvStack; let parser = Parser::new(Arc::pin(EnvStack::new()), false); let mut input = Inputter::new(parser, libc::STDIN_FILENO); diff --git a/src/tests/pager.rs b/src/tests/pager.rs index 9eda9fae9..d001426a6 100644 --- a/src/tests/pager.rs +++ b/src/tests/pager.rs @@ -9,7 +9,7 @@ #[test] #[serial] fn test_pager_navigation() { - test_init(); + let _cleanup = 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). @@ -99,7 +99,7 @@ macro_rules! validate { #[test] #[serial] fn test_pager_layout() { - test_init(); + let _cleanup = test_init(); // These tests are woefully incomplete // They only test the truncation logic for a single completion diff --git a/src/tests/parse_util.rs b/src/tests/parse_util.rs index 21de42a7b..89541685b 100644 --- a/src/tests/parse_util.rs +++ b/src/tests/parse_util.rs @@ -12,7 +12,7 @@ #[test] #[serial] fn test_error_messages() { - test_init(); + let _cleanup = 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> { diff --git a/src/tests/parser.rs b/src/tests/parser.rs index c006e3fb4..2fce062e2 100644 --- a/src/tests/parser.rs +++ b/src/tests/parser.rs @@ -21,7 +21,7 @@ #[test] #[serial] fn test_parser() { - test_init(); + let _cleanup = test_init(); macro_rules! detect_errors { ($src:literal) => { parse_util_detect_errors(L!($src), None, true /* accept incomplete */) @@ -303,7 +303,7 @@ fn detect_argument_errors(src: &str) -> Result<(), ParserTestErrorBits> { #[test] #[serial] fn test_new_parser_correctness() { - test_init(); + let _cleanup = test_init(); macro_rules! validate { ($src:expr, $ok:expr) => { let ast = Ast::parse(L!($src), ParseTreeFlags::default(), None); @@ -333,7 +333,7 @@ macro_rules! validate { #[test] #[serial] fn test_new_parser_correctness_by_fuzzing() { - test_init(); + let _cleanup = test_init(); let fuzzes = [ L!("if"), L!("else"), @@ -395,7 +395,7 @@ fn string_for_permutation(fuzzes: &[&wstr], len: usize, permutation: usize) -> O #[test] #[serial] fn test_new_parser_ll2() { - test_init(); + let _cleanup = 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)> { @@ -516,7 +516,7 @@ macro_rules! check_function_help { #[test] #[serial] fn test_new_parser_ad_hoc() { - test_init(); + let _cleanup = test_init(); // Very ad-hoc tests for issues encountered. // Ensure that 'case' terminates a job list. @@ -577,7 +577,7 @@ fn test_new_parser_ad_hoc() { #[test] #[serial] fn test_new_parser_errors() { - test_init(); + let _cleanup = test_init(); macro_rules! validate { ($src:expr, $expected_code:expr) => { let mut errors = vec![]; @@ -611,7 +611,7 @@ macro_rules! validate { #[test] #[serial] fn test_eval_recursion_detection() { - test_init(); + let _cleanup = test_init(); // Ensure that we don't crash on infinite self recursion and mutual recursion. These must use // the principal parser because we cannot yet execute jobs on other parsers. let parser = Parser::principal_parser().shared(); @@ -632,7 +632,7 @@ fn test_eval_recursion_detection() { #[test] #[serial] fn test_eval_illegal_exit_code() { - test_init(); + let _cleanup = test_init(); macro_rules! validate { ($cmd:expr, $result:expr) => { let parser = Parser::principal_parser(); @@ -664,7 +664,7 @@ macro_rules! validate { #[test] #[serial] fn test_eval_empty_function_name() { - test_init(); + let _cleanup = test_init(); let parser = Parser::principal_parser().shared(); parser.eval( L!("function '' ; echo fail; exit 42 ; end ; ''"), @@ -675,7 +675,7 @@ fn test_eval_empty_function_name() { #[test] #[serial] fn test_expand_argument_list() { - test_init(); + let _cleanup = test_init(); let parser = Parser::principal_parser().shared(); let comps: Vec = Parser::expand_argument_list( L!("alpha 'beta gamma' delta"), @@ -717,7 +717,7 @@ fn test_1_cancellation(src: &wstr) { #[test] #[serial] fn test_cancellation() { - test_init(); + let _cleanup = test_init(); reader_push(Parser::principal_parser(), L!(""), ReaderConfig::default()); let _pop = ScopeGuard::new((), |()| reader_pop()); diff --git a/src/tests/screen.rs b/src/tests/screen.rs index c90b11cbe..5866180d8 100644 --- a/src/tests/screen.rs +++ b/src/tests/screen.rs @@ -7,7 +7,7 @@ #[test] #[serial] fn test_complete() { - test_init(); + let _cleanup = test_init(); let mut lc = LayoutCache::new(); assert_eq!(lc.escape_code_length(L!("")), 0); assert_eq!(lc.escape_code_length(L!("abcd")), 0); @@ -42,7 +42,7 @@ fn test_complete() { #[test] #[serial] fn test_layout_cache() { - test_init(); + let _cleanup = test_init(); let mut seqs = LayoutCache::new(); // Verify escape code cache. @@ -116,7 +116,7 @@ fn test_layout_cache() { #[test] #[serial] fn test_prompt_truncation() { - test_init(); + let _cleanup = test_init(); let mut cache = LayoutCache::new(); let mut trunc = WString::new(); diff --git a/src/tests/termsize.rs b/src/tests/termsize.rs index 2c22186bc..42e2d64fb 100644 --- a/src/tests/termsize.rs +++ b/src/tests/termsize.rs @@ -9,7 +9,7 @@ #[test] #[serial] fn test_termsize() { - test_init(); + let _cleanup = test_init(); let env_global = EnvMode::GLOBAL; let parser = Parser::principal_parser(); let vars = parser.vars(); diff --git a/src/tests/topic_monitor.rs b/src/tests/topic_monitor.rs index d5805063c..1f84bbb5b 100644 --- a/src/tests/topic_monitor.rs +++ b/src/tests/topic_monitor.rs @@ -8,7 +8,7 @@ #[test] #[serial] fn test_topic_monitor() { - test_init(); + let _cleanup = test_init(); let monitor = topic_monitor_t::default(); let gens = GenerationsList::new(); let t = topic_t::sigchld; @@ -34,7 +34,7 @@ fn test_topic_monitor() { #[test] #[serial] fn test_topic_monitor_torture() { - test_init(); + let _cleanup = test_init(); let monitor = Arc::new(topic_monitor_t::default()); const THREAD_COUNT: usize = 64; let t1 = topic_t::sigchld; diff --git a/src/wutil/gettext.rs b/src/wutil/gettext.rs index b537ee42f..19620031f 100644 --- a/src/wutil/gettext.rs +++ b/src/wutil/gettext.rs @@ -168,7 +168,7 @@ macro_rules! wgettext_maybe_fmt { #[test] #[serial] fn test_untranslated() { - test_init(); + let _cleanup = test_init(); let s: &'static wstr = wgettext!("abc"); assert_eq!(s, "abc"); let s2: &'static wstr = wgettext!("static"); diff --git a/src/wutil/tests.rs b/src/wutil/tests.rs index d5b392e23..f29db47fa 100644 --- a/src/wutil/tests.rs +++ b/src/wutil/tests.rs @@ -59,7 +59,7 @@ fn test_wdirname_wbasename() { #[test] #[serial] fn test_wwrite_to_fd() { - test_init(); + let _cleanup = test_init(); let (_fd, filename) = fish_mkstemp_cloexec(CString::new("/tmp/fish_test_wwrite.XXXXXX").unwrap()).unwrap(); let sizes = [1, 2, 3, 5, 13, 23, 64, 128, 255, 4096, 4096 * 2];