Module: tools Branch: master Commit: 2d261b12f25ce5622e73a2c37ccc3a03f14813fd URL: https://source.winehq.org/git/tools.git/?a=commit;h=2d261b12f25ce5622e73a2c3...
Author: Francois Gouget fgouget@codeweavers.com Date: Mon Nov 19 00:53:32 2018 +0100
testbot: Add a 'lang' option for the Wine missions.
Appending ',lang=xxx' sets $LANG when running the Wine tests. This allows running the Wine tests in multiple locales by creating multiple missions with different lang values.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/lib/Build/Utils.pm | 7 +++++ testbot/lib/WineTestBot/LogUtils.pm | 59 +++++++++++++++++++++++++---------- testbot/lib/WineTestBot/Missions.pm | 45 ++++++++++++++++++++++++-- testbot/lib/WineTestBot/StepsTasks.pm | 18 +---------- testbot/lib/WineTestBot/Utils.pm | 15 ++++++++- testbot/web/admin/VMDetails.pl | 1 + 6 files changed, 108 insertions(+), 37 deletions(-)
diff --git a/testbot/lib/Build/Utils.pm b/testbot/lib/Build/Utils.pm index 06fb3d8..4dda8d5 100644 --- a/testbot/lib/Build/Utils.pm +++ b/testbot/lib/Build/Utils.pm @@ -334,6 +334,13 @@ sub SetupWineEnvironment($) $ENV{WINEPREFIX} = "$DataDir/wineprefix-$BaseName"; $ENV{DISPLAY} ||= ":0.0";
+ my $Lang = $Mission->{lang} || "en_US"; + if ($Lang =~ /^[a-zA-Z0-9@_.-]+$/) + { + $Lang .= ".UTF-8" if ($Lang !~ /./); + $ENV{LANG} = $Lang; + } + return $BaseName; }
diff --git a/testbot/lib/WineTestBot/LogUtils.pm b/testbot/lib/WineTestBot/LogUtils.pm index f142982..fee4278 100644 --- a/testbot/lib/WineTestBot/LogUtils.pm +++ b/testbot/lib/WineTestBot/LogUtils.pm @@ -36,6 +36,7 @@ use Algorithm::Diff; use File::Basename;
use WineTestBot::Config; # For $MaxUnitSize +use WineTestBot::Utils; # For LocaleName()
# @@ -578,31 +579,47 @@ sub GetLogFileNames($;$) { my ($Dir, $IncludeOld) = @_;
- my @Candidates = ("exe32.report", "exe64.report", - "win32.report", "wow32.report", "wow64.report", - "log"); - push @Candidates, "old_log" if ($IncludeOld); + my @Globs = qw(exe32.report exe32_*.report + exe64.report exe64_*.report + win32.report win32_*.report + wow32.report wow32_*.report + wow64.report wow64_*.report + log); + push @Globs, "old_log" if ($IncludeOld);
- my @Logs; - foreach my $FileName (@Candidates) + my (@Logs, %Seen); + foreach my $Glob (@Globs) { - if ((-f "$Dir/$FileName" and !-z "$Dir/$FileName") or - (-f "$Dir/$FileName.err" and !-z "$Dir/$FileName.err")) + foreach my $FileName (glob("'$Dir/$Glob*'")) { - push @Logs, $FileName; + my $LogName = basename($FileName); + if ($LogName !~ s/.err$// and $LogName !~ /.report$/ and + $LogName ne $Glob) # 'log' case + { + # Not a valid log filename (where does this file come from?) + next; + } + next if ($Seen{$LogName}); + $Seen{$LogName} = 1; + + if ((-f "$Dir/$LogName" and !-z "$Dir/$LogName") or + (-f "$Dir/$LogName.err" and !-z "$Dir/$LogName.err")) + { + push @Logs, $LogName; + } } } return @Logs; }
my %_LogFileLabels = ( - "exe32.report" => "32 bit report", - "exe64.report" => "64 bit report", - "win32.report" => "32 bit report", - "wow32.report" => "32 bit WoW report", - "wow64.report" => "64 bit WoW report", - "log" => "task log", - "old_log" => "old logs", + "exe32.report" => '32 bit%s report', + "exe64.report" => '64 bit%s report', + "win32.report" => '32 bit%s report', + "wow32.report" => '32 bit%s WoW report', + "wow64.report" => '64 bit%s WoW report', + "log" => 'task%s log', + "old_log" => 'old%s logs', );
=pod @@ -618,7 +635,15 @@ Returns a user-friendly description of the content of the specified log file. sub GetLogLabel($) { my ($LogFileName) = @_; - return $_LogFileLabels{$LogFileName}; + + my $Extra = ""; + if ($LogFileName =~ /^([^_]+)_(.*).report$/) + { + $LogFileName = "$1.report"; + $Extra = " ". LocaleName($2); + } + my $Label = $_LogFileLabels{$LogFileName}; + return defined $Label ? sprintf($Label, $Extra) : $LogFileName; }
diff --git a/testbot/lib/WineTestBot/Missions.pm b/testbot/lib/WineTestBot/Missions.pm index 0dc812d..dcaeb31 100644 --- a/testbot/lib/WineTestBot/Missions.pm +++ b/testbot/lib/WineTestBot/Missions.pm @@ -26,9 +26,12 @@ WineTestBot::Missions - Missions parser and helper functions =cut
use Exporter 'import'; -our @EXPORT = qw(DumpMissions GetMissionBaseName ParseMissionStatement +our @EXPORT = qw(DumpMissions GetMissionBaseName GetTaskMissionDescription + ParseMissionStatement MergeMissionStatementTasks SplitMissionStatementTasks);
+use WineTestBot::Utils; +
sub DumpMissions($$) { @@ -89,7 +92,45 @@ sub ParseMissionStatement($) sub GetMissionBaseName($) { my ($Mission) = @_; - return $Mission->{Build}; + + my $BaseName = $Mission->{Build}; + + # Option values may be tainted if they come from the command line + my $Lang = $Mission->{lang} || ""; + $BaseName .= "_$1" if ($Lang =~ /^([a-zA-Z0-9@_.-]+)$/); # untaint + + return $BaseName; +} + +sub GetTaskMissionDescription($) +{ + my ($TaskMission) = @_; + + my $Builds = $TaskMission->{Builds}; + my $Description = + $Builds->{build} ? "build" : + ($Builds->{exe64} and ($Builds->{exe32} or $Builds->{exe32})) ? "32 & 64 bit executable" : + $Builds->{exe32} ? "32 bit executable" : + $Builds->{exe64} ? "64 bit executable" : + ($Builds->{wow64} and ($Builds->{win32} or $Builds->{wow32})) ? "32 & 64 bit" : + $Builds->{win32} ? "32 bit" : + $Builds->{wow32} ? "32 bit WoW" : + "64 bit WoW"; + + my $Lang; + foreach my $Mission (@{$TaskMission->{Missions}}) + { + next if (!$Mission->{lang}); + if (defined $Lang) + { + $Description .= " + Locales"; + $Lang = undef; + last; + } + $Lang = $Mission->{lang}; + } + $Description .= " ". LocaleName($Lang) if ($Lang); + return $Description; }
sub MergeMissionStatementTasks($) diff --git a/testbot/lib/WineTestBot/StepsTasks.pm b/testbot/lib/WineTestBot/StepsTasks.pm index 8128bf9..4a803e7 100644 --- a/testbot/lib/WineTestBot/StepsTasks.pm +++ b/testbot/lib/WineTestBot/StepsTasks.pm @@ -91,23 +91,7 @@ sub GetTitle($) my ($ErrMessage, $Missions) = ParseMissionStatement($self->Missions); if (!defined $ErrMessage and @$Missions == 1) { - my $Builds = $Missions->[0]->{Builds}; - if ($Builds->{build}) - { - push @TitleParts, "build"; - } - elsif ($Builds->{wow64} and ($Builds->{win32} or $Builds->{wow32})) - { - push @TitleParts, "32 & 64 bit"; - } - elsif ($Builds->{win32} or $Builds->{wow32}) - { - push @TitleParts, "32 bit"; - } - elsif ($Builds->{wow64}) - { - push @TitleParts, "64 bit"; - } + push @TitleParts, GetTaskMissionDescription($Missions->[0]); } } if ($self->Type ne "suite" and $self->CmdLineArg) diff --git a/testbot/lib/WineTestBot/Utils.pm b/testbot/lib/WineTestBot/Utils.pm index 6fa0ccc..6681072 100644 --- a/testbot/lib/WineTestBot/Utils.pm +++ b/testbot/lib/WineTestBot/Utils.pm @@ -30,9 +30,11 @@ use Exporter 'import'; our @EXPORT = qw(MakeSecureURL SecureConnection GenerateRandomString OpenNewFile CreateNewFile CreateNewLink CreateNewDir DurationToString BuildEMailRecipient IsValidFileName - BuildTag SanitizeTag ShQuote ShArgv2Cmd); + BuildTag SanitizeTag LocaleName ShQuote ShArgv2Cmd);
use Fcntl; +use Locale::Language; +use Locale::Country;
use WineTestBot::Config;
@@ -104,6 +106,17 @@ sub BuildEMailRecipient($$) return $Recipient; }
+sub LocaleName($) +{ + my ($Locale) = @_; + + if ($Locale =~ /^([a-z]+)_([A-Z]+)(?:.|$)/) + { + return (code2language($1) || $1) .":". (code2country($2) || $2); + } + return $Locale; +} +
# # Temporary file helpers diff --git a/testbot/web/admin/VMDetails.pl b/testbot/web/admin/VMDetails.pl index 4b7799a..4dd9e25 100644 --- a/testbot/web/admin/VMDetails.pl +++ b/testbot/web/admin/VMDetails.pl @@ -79,6 +79,7 @@ sub GenerateFooter($) print "The supported builds are <i>build</i> for build VMs; <i>exe32</i> and <i>exe64</i> for Windows VMs;<i> win32</i>, <i>wow32</i> and <i>wow64</i> for Wine VMs.</p>\n"; print "<p>On Wine VMs:<br>\n"; print "The <i>test</i> option can be set to <i>build</i> to only test building, <i>test</i> to only rerun patched tests, <i>module</i> to rerun all of a patched dll or program's tests, or <i>all</i> to always rerun all the tests.<br>\n"; + print "The <i>lang</i> option can be set to run the tests in the specified $LANG locale. The default is en_US (<i>.UTF-8</i> can be omitted).<br>\n"; print "If set, the <i>nosubmit</i> option specifies that the WineTest results should not be published online.</p>\n"; print "</td></tr></tbody>\n"; print "</table></div>\n";