From 8dee291200dfa79c43df34546542ece25a92d9c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20H=C3=B8rl=C3=BCck=20Berg?= <36937807+henrikhorluck@users.noreply.github.com> Date: Sun, 24 May 2026 13:33:23 +0200 Subject: [PATCH] Fix `threads::init() was not called at startup!` Happens when running `cargo nextest run test_replace_home_directory_with_tilde`, due to process-isolation model. Backtrace shows: EnvStack::set_one(HOME) EnvStack::set env_dispatch_var_change reader_current_data reader_data_stack assert_is_main_thread is_main_thread main_thread_id Fix by using TestEnvironment instead, as this is a unit-test and does not need anything more. --- src/expand.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/expand.rs b/src/expand.rs index 14bca7e41..f488158f6 100644 --- a/src/expand.rs +++ b/src/expand.rs @@ -1559,7 +1559,7 @@ mod tests { tests::prelude::*, }; use fish_widestring::{ANY_STRING, str2wcstring}; - use std::collections::{HashSet, hash_map::RandomState}; + use std::collections::{HashMap, HashSet, hash_map::RandomState}; fn expand_test_impl( input: &wstr, @@ -2004,13 +2004,9 @@ fn test_abbreviations() { #[test] fn test_replace_home_directory_with_tilde() { use super::replace_home_directory_with_tilde as rhdwt; - use crate::env::{EnvMode, EnvSetMode, EnvStack}; - let vars = EnvStack::new(); - vars.set_one( - L!("HOME"), - EnvSetMode::new(EnvMode::GLOBAL, false), - L!("/home/testuser").to_owned(), - ); + let vars = TestEnvironment { + vars: HashMap::from([(L!("HOME").to_owned(), L!("/home/testuser").to_owned())]), + }; assert_eq!(rhdwt("/home/testuser/", &vars), "~/"); assert_eq!(rhdwt("/home/testuser/Documents/", &vars), "~/Documents/");