On 2023-01-12 21:54, Carlo Arenas wrote:
On Thu, Jan 12, 2023 at 7:38 PM Paul Eggert <egg...@cs.ucla.edu> wrote:

Fair enough, this will likely need a new test though, and of course
changes to the current ones as well.

Right now they will report that grep doesn't have '-P' support instead
of reporting that unicode is missing, and take into consideration
those tests that set multibyte locale were successful after my change,
so they will also need changes as they would misbehave silently
otherwise.

OK, I installed it with the attached additional patch, which attempts to address these issues. The new test is done by init.cfg each time you run require_pcre_ in a UTF-8 locale. The current tests are changed by altering require_pcre_ to do the right thing in the en_US.UTF-8 locale (I also tightened up the other locales' testing slightly). The new require_pcre_ uses a different diagnostic when checking en_US.UTF-8 locale. Since all the PCRE tests are done in either the C or the en_US.UTF-8 locale, this should be good enough.
From 231a3ea66d556c709b53ecc93bdc072be3e8f7ce Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Thu, 12 Jan 2023 23:11:59 -0800
Subject: [PATCH] tests: better diagnostic for -P sans Unicode

* tests/init.cfg (require_pcre_): When in a UTF-8 locale, test
also for Unicode support so that it can be diagnosed differently
(Bug#60708).
---
 tests/init.cfg | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/init.cfg b/tests/init.cfg
index 515482c..4aa56ea 100644
--- a/tests/init.cfg
+++ b/tests/init.cfg
@@ -48,10 +48,18 @@ require_timeout_()
 
 require_pcre_()
 {
-  echo . | grep -P . 2>err || {
-    test $? -eq 1 && fail_ PCRE available, but does not work.
-    skip_ no PCRE support
-  }
+  case $LC_ALL in
+    *.UTF-8)
+      printf '\303\241\n' | grep -P '^.$' 2>err || {
+        test $? -eq 1 && fail_ PCRE available, but does not work
+        skip_ no PCRE Unicode support
+      };;
+    *)
+      echo . | grep -P '^.$' 2>err || {
+        test $? -eq 1 && fail_ PCRE available, but does not work.
+        skip_ no PCRE support
+      };;
+  esac
   compare /dev/null err || fail_ PCRE available, but stderr not empty.
 }
 
-- 
2.37.2

Reply via email to