[Pcre-svn] [195] code/trunk: Update RunTest to handle locale…

トップ ページ
このメッセージを削除
著者: Subversion repository
日付:  
To: pcre-svn
題目: [Pcre-svn] [195] code/trunk: Update RunTest to handle locales better.
Revision: 195
          http://www.exim.org/viewvc/pcre2?view=rev&revision=195
Author:   ph10
Date:     2015-02-07 17:45:55 +0000 (Sat, 07 Feb 2015)


Log Message:
-----------
Update RunTest to handle locales better.

Modified Paths:
--------------
    code/trunk/ChangeLog
    code/trunk/RunTest


Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog    2015-02-07 16:22:48 UTC (rev 194)
+++ code/trunk/ChangeLog    2015-02-07 17:45:55 UTC (rev 195)
@@ -65,7 +65,14 @@
 12. A UTF pattern containing a "not" match of a non-ASCII character and a 
 subroutine reference could loop at compile time. Example: /[^\xff]((?1))/.


+13. The locale test (RunTest 3) has been upgraded. It now checks that a locale
+that is found in the output of "locale -a" can actually be set by pcre2test
+before it is accepted. Previously, in an environment where a locale was listed
+but would not set (an example does exist), the test would "pass" without
+actually doing anything. Also the fr_CA locale has been added to the list of
+locales that can be used.

+
Version 10.00 05-January-2015
-----------------------------


Modified: code/trunk/RunTest
===================================================================
--- code/trunk/RunTest    2015-02-07 16:22:48 UTC (rev 194)
+++ code/trunk/RunTest    2015-02-07 17:45:55 UTC (rev 195)
@@ -459,45 +459,47 @@
     done
   fi


- # Locale-specific tests, provided that either the "fr_FR" or the "french"
- # locale is available. The former is the Unix-like standard; the latter is
- # for Windows. Another possibility is "fr". Unfortunately, different versions
- # of the French locale give different outputs for some items. This test passes
- # if the output matches any one of the alternative output files.
+ # Locale-specific tests, provided that either the "fr_FR", "fr_CA", "french"
+ # or "fr" locale is available. The first two are Unix-like standards; the
+ # last two are for Windows. Unfortunately, different versions of the French
+ # locale give different outputs for some items. This test passes if the
+ # output matches any one of the alternative output files.

   if [ $do3 = yes ] ; then
-    locale -a | grep '^fr_FR$' >/dev/null
-    if [ $? -eq 0 ] ; then
-      locale=fr_FR
-      infile=$testdata/testinput3
-      outfile=$testdata/testoutput3
-      outfile2=$testdata/testoutput3A
-      outfile3=$testdata/testoutput3B
-    else
-      infile=test3input
-      outfile=test3output
-      outfile2=test3outputA
-      outfile3=test3outputB
-      locale -a | grep '^french$' >/dev/null
+    locale= 
+      
+    # In some environments locales that are listed by the "locale -a"
+    # command do not seem to work with setlocale(). Therefore, we do
+    # a preliminary test to see if pcre2test can set one before going
+    # on to use it.   
+
+    for loc in 'fr_FR' 'french' 'fr' 'fr_CA'; do 
+      locale -a | grep "^$loc\$" >/dev/null
       if [ $? -eq 0 ] ; then
-        locale=french
-        sed 's/fr_FR/french/' $testdata/testinput3 >test3input
-        sed 's/fr_FR/french/' $testdata/testoutput3 >test3output
-        sed 's/fr_FR/french/' $testdata/testoutput3A >test3outputA
-        sed 's/fr_FR/french/' $testdata/testoutput3B >test3outputB
-      else
-        locale -a | grep '^fr$' >/dev/null
-        if [ $? -eq 0 ] ; then
-          locale=fr
-          sed 's/fr_FR/fr/' $testdata/intestinput3 >test3input
-          sed 's/fr_FR/fr/' $testdata/intestoutput3 >test3output
-          sed 's/fr_FR/fr/' $testdata/intestoutput3A >test3outputA
-          sed 's/fr_FR/fr/' $testdata/intestoutput3B >test3outputB
-        else
-          locale=
-        fi
+        echo "/a/locale=$loc" | \
+          $sim $valgrind ./pcre2test -q $bmode | \
+            grep "Failed to set locale" >/dev/null
+        if [ $? -ne 0 ] ; then    
+          locale=$loc
+          if [ "$locale" = "fr_FR" ] ; then
+            infile=$testdata/testinput3
+            outfile=$testdata/testoutput3
+            outfile2=$testdata/testoutput3A
+            outfile3=$testdata/testoutput3B
+          else
+            infile=test3input
+            outfile=test3output
+            outfile2=test3outputA
+            outfile3=test3outputB
+            sed "s/fr_FR/$loc/" $testdata/testinput3 >test3input
+            sed "s/fr_FR/$loc/" $testdata/testoutput3 >test3output
+            sed "s/fr_FR/$loc/" $testdata/testoutput3A >test3outputA
+            sed "s/fr_FR/$loc/" $testdata/testoutput3B >test3outputB
+          fi   
+          break 
+        fi    
       fi
-    fi
+    done   


     if [ "$locale" != "" ] ; then
       echo $title3 "(using '$locale' locale)"
@@ -524,9 +526,9 @@
         fi
       done
     else
-      echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr' or"
-      echo "'french' locales exist, or the \"locale\" command is not available"
-      echo "to check for them."
+      echo "Cannot test locale-specific features - none of the 'fr_FR', 'fr_CA',"
+      echo "'fr' or 'french' locales can be set, or the \"locale\" command is"
+      echo "not available to check for them." 
       echo " "
     fi
   fi