From: Bruno Haible <bruno@clisp.org>
Date: Tue, 21 May 2024 19:20:15 +0000 (+0200)
Subject: mcel tests: Run the test in several locales.
X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=1bd954b3a186b3e0ea33f9b8c0bd435017e2a9b2;p=gnulib.git

mcel tests: Run the test in several locales.

* tests/test-mcel-1.sh: New file, based on tests/test-mbrtowc-1.sh.
* tests/test-mcel-2.sh: New file, based on tests/test-mbrtowc-2.sh.
* tests/test-mcel-3.sh: New file, based on tests/test-mbrtowc-3.sh.
* tests/test-mcel-4.sh: New file, based on tests/test-mbrtowc-4.sh.
* tests/test-mcel-5.sh: New file, based on tests/test-mbrtowc-5.sh.
* modules/mcel-tests (Files): Add them. Add tests/macros.h,
m4/locale-fr.m4, m4/locale-ja.m4, m4/locale-zh.m4, m4/codeset.m4.
(Depends-on): Remove assert-h.
(configure.ac, Makefile.am): Essentially copy from
modules/mbrtowc-tests.
---

diff --git a/ChangeLog b/ChangeLog
index 2935af0691..1dd38d2fb4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2024-05-21  Bruno Haible  <bruno@clisp.org>
+
+	mcel tests: Run the test in several locales.
+	* tests/test-mcel-1.sh: New file, based on tests/test-mbrtowc-1.sh.
+	* tests/test-mcel-2.sh: New file, based on tests/test-mbrtowc-2.sh.
+	* tests/test-mcel-3.sh: New file, based on tests/test-mbrtowc-3.sh.
+	* tests/test-mcel-4.sh: New file, based on tests/test-mbrtowc-4.sh.
+	* tests/test-mcel-5.sh: New file, based on tests/test-mbrtowc-5.sh.
+	* modules/mcel-tests (Files): Add them. Add tests/macros.h,
+	m4/locale-fr.m4, m4/locale-ja.m4, m4/locale-zh.m4, m4/codeset.m4.
+	(Depends-on): Remove assert-h.
+	(configure.ac, Makefile.am): Essentially copy from
+	modules/mbrtowc-tests.
+
 2024-05-21  Bruno Haible  <bruno@clisp.org>
 
 	flock tests: Mark as expected failure on Solaris 11.
diff --git a/modules/mcel-tests b/modules/mcel-tests
index d157608ce3..cc993657d9 100644
--- a/modules/mcel-tests
+++ b/modules/mcel-tests
@@ -1,13 +1,32 @@
 Files:
+tests/test-mcel-1.sh
+tests/test-mcel-2.sh
+tests/test-mcel-3.sh
+tests/test-mcel-4.sh
+tests/test-mcel-5.sh
 tests/test-mcel.c
+tests/macros.h
+m4/locale-fr.m4
+m4/locale-ja.m4
+m4/locale-zh.m4
+m4/codeset.m4
 
 Depends-on:
-assert-h
 setlocale
 
 configure.ac:
+gt_LOCALE_FR
+gt_LOCALE_FR_UTF8
+gt_LOCALE_JA
+gt_LOCALE_ZH_CN
 
 Makefile.am:
-TESTS += test-mcel
+TESTS += \
+  test-mcel-1.sh test-mcel-2.sh test-mcel-3.sh test-mcel-4.sh test-mcel-5.sh
+TESTS_ENVIRONMENT += \
+  LOCALE_FR='@LOCALE_FR@' \
+  LOCALE_FR_UTF8='@LOCALE_FR_UTF8@' \
+  LOCALE_JA='@LOCALE_JA@' \
+  LOCALE_ZH_CN='@LOCALE_ZH_CN@'
 check_PROGRAMS += test-mcel
 test_mcel_LDADD = $(LDADD) $(LIBUNISTRING) $(SETLOCALE_LIB) $(MBRTOWC_LIB) $(LIBC32CONV)
diff --git a/tests/test-mcel-1.sh b/tests/test-mcel-1.sh
new file mode 100755
index 0000000000..132824d369
--- /dev/null
+++ b/tests/test-mcel-1.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+# Test whether the POSIX locale has encoding errors.
+LC_ALL=C \
+${CHECKER} ./test-mcel${EXEEXT} 1 || exit 1
+LC_ALL=POSIX \
+${CHECKER} ./test-mcel${EXEEXT} 1 || exit 1
+
+exit 0
diff --git a/tests/test-mcel-2.sh b/tests/test-mcel-2.sh
new file mode 100755
index 0000000000..fd85e90a1a
--- /dev/null
+++ b/tests/test-mcel-2.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test in an ISO-8859-1 or ISO-8859-15 locale.
+: "${LOCALE_FR=fr_FR}"
+if test $LOCALE_FR = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional french locale is installed"
+  else
+    echo "Skipping test: no traditional french locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR \
+${CHECKER} ./test-mcel${EXEEXT} 2
diff --git a/tests/test-mcel-3.sh b/tests/test-mcel-3.sh
new file mode 100755
index 0000000000..a1f21a7a50
--- /dev/null
+++ b/tests/test-mcel-3.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific UTF-8 locale is installed.
+: "${LOCALE_FR_UTF8=fr_FR.UTF-8}"
+if test $LOCALE_FR_UTF8 = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no french Unicode locale is installed"
+  else
+    echo "Skipping test: no french Unicode locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_FR_UTF8 \
+${CHECKER} ./test-mcel${EXEEXT} 3
diff --git a/tests/test-mcel-4.sh b/tests/test-mcel-4.sh
new file mode 100755
index 0000000000..229bb3451e
--- /dev/null
+++ b/tests/test-mcel-4.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific EUC-JP locale is installed.
+: "${LOCALE_JA=ja_JP}"
+if test $LOCALE_JA = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no traditional japanese locale is installed"
+  else
+    echo "Skipping test: no traditional japanese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_JA \
+${CHECKER} ./test-mcel${EXEEXT} 4
diff --git a/tests/test-mcel-5.sh b/tests/test-mcel-5.sh
new file mode 100755
index 0000000000..8e42b993a6
--- /dev/null
+++ b/tests/test-mcel-5.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+# Test whether a specific GB18030 locale is installed.
+: "${LOCALE_ZH_CN=zh_CN.GB18030}"
+if test $LOCALE_ZH_CN = none; then
+  if test -f /usr/bin/localedef; then
+    echo "Skipping test: no transitional chinese locale is installed"
+  else
+    echo "Skipping test: no transitional chinese locale is supported"
+  fi
+  exit 77
+fi
+
+LC_ALL=$LOCALE_ZH_CN \
+${CHECKER} ./test-mcel${EXEEXT} 5