Francois Gouget : testbot/SetWinLocale: Add support for a 'mixed' locale.

Alexandre Julliard julliard at winehq.org
Thu Feb 3 16:02:54 CST 2022


Module: tools
Branch: master
Commit: 0183cc0b42c01d149f788180a2b914d1ee771c09
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=0183cc0b42c01d149f788180a2b914d1ee771c09

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Thu Feb  3 19:25:58 2022 +0100

testbot/SetWinLocale: Add support for a 'mixed' locale.

The special 'mx-MX' locale sets all locale settings to different values
in order to detect when the Wine tests use the wrong locale API.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 testbot/bin/SetWinLocale | 40 +++++++++++++++++++++++++++++-----------
 1 file changed, 29 insertions(+), 11 deletions(-)

diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale
index 0d4c305..df0d6f7 100755
--- a/testbot/bin/SetWinLocale
+++ b/testbot/bin/SetWinLocale
@@ -416,7 +416,7 @@ while (@ARGV)
 }
 
 # Check and untaint parameters
-my $CountryId;
+my ($Keyboard, $CountryId);
 if (!defined $Usage)
 {
   if (!defined $OptHostName)
@@ -437,11 +437,31 @@ if (!defined $Usage)
   $OptLocale ||= $OptDefault;
   $OptSystem ||= $OptDefault;
   $OptMUI ||= $OptDefault;
-
+  $Keyboard = $OptKeyboard || $OptDefault;
   if (!$OptCountry and ($OptDefault || "") =~ /-([A-Z]{2})$/)
   {
     $OptCountry = $1;
   }
+
+  # The "mixed" locale is used to make sure the tests each use the right
+  # locale API. To do so set each locale setting to a different value, each
+  # producing different results (e.g. different date format, decimal separator,
+  # etc).
+  my $MXStr = "";
+  sub SetMX($$$)
+  {
+    my ($Value, $Option, $MXValue) = @_;
+    return $Value if (!$Value or $Value !~ /^(?:mx-|MX$)/);
+    $MXStr .= " $Option $MXValue";
+    return $MXValue;
+  }
+  $OptLocale = SetMX($OptLocale, "--locale", "fr-FR");
+  $OptCountry = SetMX($OptCountry, "--country", "TO");
+  $OptSystem = SetMX($OptSystem, "--system", "ja-JP");
+  $OptMUI = SetMX($OptMUI, "--mui", "ko-KR");
+  $Keyboard = SetMX($Keyboard, "--keyboard", "es-ES");
+  Info("using$MXStr\n") if ($MXStr);
+
   if ($OptCountry)
   {
     $CountryId = $Countries{$OptCountry};
@@ -453,8 +473,7 @@ if (!defined $Usage)
   }
 
   if (!$OptLocale and !$OptCountry and !$OptSystem and !$OptUTF8 and
-      !$OptMUI and !$OptKeyboard and !defined $OptSysCopy and
-      !defined $OptDefCopy)
+      !$OptMUI and !$Keyboard and !defined $OptSysCopy and !defined $OptDefCopy)
   {
     if (!$OptShow)
     {
@@ -468,7 +487,7 @@ if (!defined $Usage)
     }
   }
   if ($OptShow and ($OptLocale or $OptCountry or $OptSystem or $OptUTF8 or
-                    $OptMUI or $OptKeyboard or defined $OptSysCopy or
+                    $OptMUI or $Keyboard or defined $OptSysCopy or
                     defined $OptDefCopy or defined $OptUseIntl or
                     defined $OptReboot))
   {
@@ -822,8 +841,8 @@ sub GetKeyboardIds($)
 my $LCIDLocale = GetLCID($OptLocale);
 my $LCIDSystem = GetLCID($OptSystem);
 
-my $KeyboardIds = GetKeyboardIds($OptKeyboard || $OptDefault);
-if (!$KeyboardIds and ($OptKeyboard or $OptDefault))
+my $KeyboardIds = GetKeyboardIds($Keyboard);
+if (!$KeyboardIds and $Keyboard)
 {
   if ($OptKeyboard)
   {
@@ -832,9 +851,8 @@ if (!$KeyboardIds and ($OptKeyboard or $OptDefault))
   # intl.cpl automatically pick the appropriate keyboard but, unlike
   # for Windows' initial installation, it does not make it the
   # default since the system has a keyboard already.
-  Warning("no known keyboard for the $OptDefault locale. Letting intl.cpl use its default.\n");
+  Warning("no known keyboard for the $Keyboard locale. Letting intl.cpl use its default.\n");
 }
-$OptKeyboard ||= $OptDefault;
 
 
 #
@@ -1001,7 +1019,7 @@ if ($OptMUI)
 }
 if ($KeyboardIds)
 {
-  CheckSetting($Settings, "InputMethod", $KeyboardIds->[0], "for --keyboard $OptKeyboard", 1);
+  CheckSetting($Settings, "InputMethod", $KeyboardIds->[0], "for --keyboard $Keyboard", 1);
 }
 
 if ($OptSysCopy)
@@ -1022,7 +1040,7 @@ if ($OptSysCopy)
   }
   if ($KeyboardIds)
   {
-    CheckSetting($Settings, "DefInputMethod", $KeyboardIds->[0], "for --keyboard $OptKeyboard", 1);
+    CheckSetting($Settings, "DefInputMethod", $KeyboardIds->[0], "for --keyboard $Keyboard", 1);
   }
 }
 if (!$OptReboot and ($OptSystem or $OptMUI))




More information about the wine-cvs mailing list