Update RunTest to handle locales better.

This commit is contained in:
Philip.Hazel 2015-02-07 17:45:55 +00:00
parent 9059444834
commit 3e253d04de
2 changed files with 47 additions and 38 deletions

View File

@ -65,6 +65,13 @@ undefined outcome.
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
-----------------------------

78
RunTest
View File

@ -459,45 +459,47 @@ for bmode in "$test8" "$test16" "$test32"; do
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 @@ for bmode in "$test8" "$test16" "$test32"; do
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