From 4a9f52466af44d6e71adefd4e91896db09a8634b Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 15 Mar 2020 20:59:24 +0100 Subject: [PATCH] Set locale during timer test Fixes #6757 --- src/fish_tests.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fish_tests.cpp b/src/fish_tests.cpp index 8d574f151..3d8136ded 100644 --- a/src/fish_tests.cpp +++ b/src/fish_tests.cpp @@ -5645,6 +5645,9 @@ static void test_topic_monitor_torture() { static void test_timer_format() { say(L"Testing timer format"); + // This test uses numeric output, so we need to set the locale. + char *saved_locale = strdup(setlocale(LC_NUMERIC, nullptr)); + setlocale(LC_NUMERIC, "C"); auto t1 = timer_snapshot_t::take(); t1.cpu_fish.ru_utime.tv_usec = 0; t1.cpu_fish.ru_stime.tv_usec = 0; @@ -5671,6 +5674,8 @@ Executed in 500.00 micros fish external err(L"Failed to format timer snapshot\n\Expected: %ls\nActual:%ls\n", expected, actual.c_str()); } + setlocale(LC_NUMERIC, saved_locale); + free(saved_locale); } /// Main test.