From e7ea986aa7ebf7c7982dbcf07a95ff03e365b964 Mon Sep 17 00:00:00 2001 From: Simone Date: Thu, 22 Oct 2026 10:03:09 +0200 Subject: [PATCH] test(json2): build a decimal-comma locale for the numeric locale test Linux runners have no decimal-comma locale, so guest_json_numeric_locale skipped there. Build xx_COMMA from a charmap and an LC_NUMERIC source shipped with the test as a CTest fixture, point the test at it with LOCPATH and try it first. Co-Authored-By: Claude Opus 5.5 --- core/libs/prx/libSceJson2/CMakeLists.txt | 9 ++ core/libs/tests/GuestJson.cpp | 2 +- core/libs/tests/numeric-locale/comma.charmap | 135 +++++++++++++++++++ core/libs/tests/numeric-locale/comma.locale | 5 + 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 core/libs/tests/numeric-locale/comma.charmap create mode 100644 core/libs/tests/numeric-locale/comma.locale diff --git a/core/libs/prx/libSceJson2/CMakeLists.txt b/core/libs/prx/libSceJson2/CMakeLists.txt index edfcf10e10..dbc704366f 100644 --- a/core/libs/prx/libSceJson2/CMakeLists.txt +++ b/core/libs/prx/libSceJson2/CMakeLists.txt @@ -10,6 +10,15 @@ if(BUILD_TESTING) add_test(NAME guest_json COMMAND guest_json_tests) add_test(NAME guest_json_numeric_locale COMMAND guest_json_tests --numeric-locale) set_tests_properties(guest_json_numeric_locale PROPERTIES SKIP_RETURN_CODE 77) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + set(numeric_locale_dir ${CMAKE_CURRENT_BINARY_DIR}/numeric-locale) + set(numeric_locale_data ${LIBS_INCLUDE_DIR}/tests/numeric-locale) + add_test(NAME guest_json_numeric_locale_setup COMMAND sh -c + "rm -rf '${numeric_locale_dir}' && mkdir -p '${numeric_locale_dir}' && I18NPATH='${numeric_locale_dir}' localedef -c -f '${numeric_locale_data}/comma.charmap' -i '${numeric_locale_data}/comma.locale' '${numeric_locale_dir}/xx_COMMA'; test -f '${numeric_locale_dir}/xx_COMMA/LC_NUMERIC'") + set_tests_properties(guest_json_numeric_locale_setup PROPERTIES FIXTURES_SETUP json_numeric_locale) + set_tests_properties(guest_json_numeric_locale PROPERTIES FIXTURES_REQUIRED json_numeric_locale + ENVIRONMENT "LOCPATH=${numeric_locale_dir}") + endif() if(WIN32) set_tests_properties(guest_json guest_json_numeric_locale PROPERTIES ENVIRONMENT_MODIFICATION "PATH=path_list_prepend:$") diff --git a/core/libs/tests/GuestJson.cpp b/core/libs/tests/GuestJson.cpp index 05c455b6c3..506e7da1a2 100644 --- a/core/libs/tests/GuestJson.cpp +++ b/core/libs/tests/GuestJson.cpp @@ -1380,7 +1380,7 @@ static void ValueOperatorBool() { static int NumericLocale() { const std::string previous = std::setlocale(LC_NUMERIC, nullptr); const char* selected = nullptr; - for (const char* name : {"de_DE.UTF-8", "de_DE.utf8", "de-DE", "German_Germany.1252", "fr_FR.UTF-8"}) { + for (const char* name : {"xx_COMMA", "de_DE.UTF-8", "de_DE.utf8", "de-DE", "German_Germany.1252", "fr_FR.UTF-8"}) { if (std::setlocale(LC_NUMERIC, name) && std::strcmp(std::localeconv()->decimal_point, ",") == 0) { selected = name; break; diff --git a/core/libs/tests/numeric-locale/comma.charmap b/core/libs/tests/numeric-locale/comma.charmap new file mode 100644 index 0000000000..cbfea3c784 --- /dev/null +++ b/core/libs/tests/numeric-locale/comma.charmap @@ -0,0 +1,135 @@ + ANYPS5_COMMA + % + / + 1 + 1 +CHARMAP + /x00 + /x01 + /x02 + /x03 + /x04 + /x05 + /x06 + /x07 + /x08 + /x09 + /x0a + /x0b + /x0c + /x0d + /x0e + /x0f + /x10 + /x11 + /x12 + /x13 + /x14 + /x15 + /x16 + /x17 + /x18 + /x19 + /x1a + /x1b + /x1c + /x1d + /x1e + /x1f + /x20 + /x21 + /x22 + /x23 + /x24 + /x25 + /x26 + /x27 + /x28 + /x29 + /x2a + /x2b + /x2c + /x2d + /x2e + /x2f + /x30 + /x31 + /x32 + /x33 + /x34 + /x35 + /x36 + /x37 + /x38 + /x39 + /x3a + /x3b + /x3c + /x3d + /x3e + /x3f + /x40 + /x41 + /x42 + /x43 + /x44 + /x45 + /x46 + /x47 + /x48 + /x49 + /x4a + /x4b + /x4c + /x4d + /x4e + /x4f + /x50 + /x51 + /x52 + /x53 + /x54 + /x55 + /x56 + /x57 + /x58 + /x59 + /x5a + /x5b + /x5c + /x5d + /x5e + /x5f + /x60 + /x61 + /x62 + /x63 + /x64 + /x65 + /x66 + /x67 + /x68 + /x69 + /x6a + /x6b + /x6c + /x6d + /x6e + /x6f + /x70 + /x71 + /x72 + /x73 + /x74 + /x75 + /x76 + /x77 + /x78 + /x79 + /x7a + /x7b + /x7c + /x7d + /x7e + /x7f +END CHARMAP diff --git a/core/libs/tests/numeric-locale/comma.locale b/core/libs/tests/numeric-locale/comma.locale new file mode 100644 index 0000000000..3207685c62 --- /dev/null +++ b/core/libs/tests/numeric-locale/comma.locale @@ -0,0 +1,5 @@ +LC_NUMERIC +decimal_point "" +thousands_sep "" +grouping -1 +END LC_NUMERIC