Commit 132e55c9 authored by Philip Chimento's avatar Philip Chimento Committed by Philip Chimento

build: Look for suitable locale to run tests in

Apparently only newer libcs define a C.UTF-8 locale (see Notably, in
the Freedesktop SDK there is no C.UTF-8 locale.

This tests using "locale -a" if the C.UTF-8 locale is available, before
selecting it. If it is not available, we try to find a reasonable
fallback, preferring English locales in order to make it easier to share
debug output in bug reports.
parent 0336a67b
......@@ -286,7 +286,7 @@ AM_TESTS_ENVIRONMENT = \
export G_FILENAME_ENCODING=latin1; \
export LSAN_OPTIONS="suppressions=$(abs_top_srcdir)/installed-tests/extra/lsan.supp"; \
export NO_AT_BRIDGE=1; \
export LC_ALL=C.UTF-8; \
export LC_ALL=$(TESTS_LOCALE); \
......@@ -337,6 +337,26 @@ AS_IF([test "x$with_dbus_tests" != "xno"], [
AM_CONDITIONAL([DBUS_TESTS], [test "x$with_dbus_tests" != "xno"])
AC_MSG_CHECKING([for a suitable UTF-8 locale to run the tests in])
LOCALES=$(locale -a)
dnl Prefer C.UTF-8 although it is only available with newer libc
dnl Most systems will probably have this
[*en_US.UTF-8*], [TESTS_LOCALE=en_US.UTF-8],
[*en_US.utf8*], [TESTS_LOCALE=en_US.utf8],
dnl If not, fall back to any English UTF-8 locale or any UTF-8 locale at all
[*en_*.UTF-8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 en_.\*\\.UTF-8)],
[*en_*.utf8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 en_.\*\\.utf8)],
[*.UTF-8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 \\.UTF-8)],
[*.utf8*], [TESTS_LOCALE=$(echo $LOCALES | grep -m1 \\.utf8)],
AC_SUBST([gjsjsdir], [\${datadir}/gjs-1.0])
dnl automake 1.11/1.12 defines this but does not substitute it
......@@ -362,6 +382,12 @@ PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 1.57.2], [], [
gobject-introspection to run the tests. You can still build GJS, but some
tests will fail.])])
AS_IF([test "$TESTS_LOCALE" = "C"], [
AC_MSG_WARN([Your libc does not have the C.UTF-8 locale and no other
suitable UTF-8 fallback locale could be found. You can still build GJS, but
some tests will fail.])
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment