On mingw, I see this test failure: FAIL: test-mbfile.sh ====================
../../gltests/test-mbfile.c:49: assertion 'mb_len (next) == 2' failed Stack trace: 0xbd502c13 main ../../gltests/test-mbfile.c:49 The cause is that setlocale has not installed an UTF-8 locale, but a CP1252 locale. This patch avoids the failure, like in some other tests. 2024-05-29 Bruno Haible <br...@clisp.org> mbfile tests: Avoid test failure on mingw. * tests/test-mbfile.c: Include <string.h>, localcharset.h. (main): Verify that setlocale() has installed an UTF-8 locale. * modules/mbfile-tests (Depends-on): Add localcharset. diff --git a/modules/mbfile-tests b/modules/mbfile-tests index 246702fc04..d52b9d4975 100644 --- a/modules/mbfile-tests +++ b/modules/mbfile-tests @@ -4,6 +4,7 @@ tests/test-mbfile.c tests/macros.h Depends-on: +localcharset setlocale configure.ac: diff --git a/tests/test-mbfile.c b/tests/test-mbfile.c index 1d857a819b..3565404294 100644 --- a/tests/test-mbfile.c +++ b/tests/test-mbfile.c @@ -21,13 +21,20 @@ #include "mbfile.h" #include <locale.h> +#include <string.h> +#include "localcharset.h" #include "macros.h" int main () { - if (setlocale (LC_ALL, "en_US.UTF-8") == NULL) + /* Switch to an UTF-8 locale. */ + if (!(setlocale (LC_ALL, "en_US.UTF-8") != NULL + /* Check whether it's really an UTF-8 locale. + On native Windows, this setlocale call succeeds but the encoding + of this locale is CP1252, not UTF-8. */ + && strcmp (locale_charset (), "UTF-8") == 0)) { fprintf (stderr, "Skipping test: English Unicode locale is not installed\n"); return 77;