[PATCH] testbot: Make Step::FileName and FileType optional.

Francois Gouget fgouget at codeweavers.com
Tue Jun 5 03:53:39 CDT 2018


Some steps don't have an input filename (like the Reconfig tasks) so
it makes no sense to force setting FileName or FileType to a dummy
value. However enum fields cannot be left undefined so add a 'none'
value.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---

Note: This requires updating the database schema and then restarting 
the TestBot Engine and website.

 testbot/bin/CheckForWinetestUpdate.pl |  3 +--
 testbot/ddl/update35.sql              |  5 +++++
 testbot/ddl/winetestbot.sql           |  4 ++--
 testbot/lib/WineTestBot/Steps.pm      | 11 +++++++++--
 testbot/lib/WineTestBot/StepsTasks.pm |  4 +++-
 testbot/web/JobDetails.pl             |  2 +-
 6 files changed, 21 insertions(+), 8 deletions(-)
 create mode 100644 testbot/ddl/update35.sql

diff --git a/testbot/bin/CheckForWinetestUpdate.pl b/testbot/bin/CheckForWinetestUpdate.pl
index a79f60c71..f41148f12 100755
--- a/testbot/bin/CheckForWinetestUpdate.pl
+++ b/testbot/bin/CheckForWinetestUpdate.pl
@@ -251,8 +251,7 @@ sub AddReconfigJob()
   my $Steps = $NewJob->Steps;
   my $NewStep = $Steps->Add();
   $NewStep->Type("reconfig");
-  $NewStep->FileName("-");
-  $NewStep->FileType("patchdlls");
+  $NewStep->FileType("none");
   $NewStep->InStaging(!1);
 
   # Add a task for the build VM
diff --git a/testbot/ddl/update35.sql b/testbot/ddl/update35.sql
new file mode 100644
index 000000000..3ca3023f3
--- /dev/null
+++ b/testbot/ddl/update35.sql
@@ -0,0 +1,5 @@
+USE winetestbot;
+
+ALTER TABLE Steps
+  MODIFY FileName VARCHAR(100) NULL,
+  MODIFY FileType ENUM('none', 'exe32', 'exe64', 'patchdlls', 'patchprograms') NOT NULL;
diff --git a/testbot/ddl/winetestbot.sql b/testbot/ddl/winetestbot.sql
index 9ec428c04..9a28385a9 100644
--- a/testbot/ddl/winetestbot.sql
+++ b/testbot/ddl/winetestbot.sql
@@ -132,8 +132,8 @@ CREATE TABLE Steps
   PreviousNo            INT(2) NULL,
   Type                  ENUM('suite', 'single', 'build', 'reconfig') NOT NULL,
   Status                ENUM('queued', 'running', 'completed', 'badpatch', 'badbuild', 'boterror', 'canceled', 'skipped') NOT NULL,
-  FileName              VARCHAR(100) NOT NULL,
-  FileType              ENUM('exe32', 'exe64', 'patchdlls', 'patchprograms') NOT NULL,
+  FileName              VARCHAR(100) NULL,
+  FileType              ENUM('none', 'exe32', 'exe64', 'patchdlls', 'patchprograms') NOT NULL,
   InStaging             ENUM('Y', 'N') NOT NULL,
   DebugLevel            INT(2) NOT NULL,
   ReportSuccessfulTests ENUM('Y', 'N') NOT NULL,
diff --git a/testbot/lib/WineTestBot/Steps.pm b/testbot/lib/WineTestBot/Steps.pm
index 977419474..aea1aee04 100644
--- a/testbot/lib/WineTestBot/Steps.pm
+++ b/testbot/lib/WineTestBot/Steps.pm
@@ -89,6 +89,7 @@ sub InitializeNew($$)
 
   $self->Status("queued");
   $self->Type("single");
+  $self->FileType("none");
   $self->InStaging(1);
   $self->DebugLevel(1);
   $self->ReportSuccessfulTests(!1);
@@ -117,6 +118,10 @@ sub Validate($)
   {
     return ("PreviousNo", "The previous step number must be less than this one's.");
   }
+  if (defined $self->FileName and $self->FileType eq "none")
+  {
+    return ("FileType", "A file has been specified but no FileType");
+  }
   return $self->SUPER::Validate();
 }
 
@@ -146,6 +151,8 @@ sub GetFullFileName($)
 {
   my ($self) = @_;
 
+  return undef if (!defined $self->FileName);
+
   my ($JobId, $StepNo) = @{$self->GetMasterKey()};
   # FIXME: Remove legacy support once no such job remains (so after
   #        $JobPurgeDays).
@@ -256,8 +263,8 @@ my @PropertyDescriptors = (
   CreateBasicPropertyDescriptor("PreviousNo", "Previous step", !1, !1, "N", 2),
   CreateEnumPropertyDescriptor("Status", "Status",  !1,  1, ['queued', 'running', 'completed', 'badpatch', 'badbuild', 'boterror', 'canceled', 'skipped']),
   CreateEnumPropertyDescriptor("Type", "Step type",  !1,  1, ['suite', 'single', 'build', 'reconfig']),
-  CreateBasicPropertyDescriptor("FileName", "File name",  !1,  1, "A", 100),
-  CreateEnumPropertyDescriptor("FileType", "File type",  !1,  1, ['exe32', 'exe64', 'patchdlls', 'patchprograms']),
+  CreateBasicPropertyDescriptor("FileName", "File name",  !1, !1, "A", 100),
+  CreateEnumPropertyDescriptor("FileType", "File type",  !1,  1, ['none', 'exe32', 'exe64', 'patchdlls', 'patchprograms']),
   CreateBasicPropertyDescriptor("InStaging", "File is in staging area", !1, 1, "B", 1),
   CreateBasicPropertyDescriptor("DebugLevel", "Debug level (WINETEST_DEBUG)", !1, 1, "N", 2),
   CreateBasicPropertyDescriptor("ReportSuccessfulTests", "Report successful tests (WINETEST_REPORT_SUCCESS)", !1, 1, "B", 1),
diff --git a/testbot/lib/WineTestBot/StepsTasks.pm b/testbot/lib/WineTestBot/StepsTasks.pm
index b9f70d768..84c5a005f 100644
--- a/testbot/lib/WineTestBot/StepsTasks.pm
+++ b/testbot/lib/WineTestBot/StepsTasks.pm
@@ -44,6 +44,8 @@ sub GetFullFileName($)
 {
   my ($self) = @_;
 
+  return undef if (!defined $self->FileName);
+
   my ($JobId, $_StepTaskId) = @{$self->GetMasterKey()};
   # FIXME: Remove legacy support once no such job remains (so after
   #        $JobPurgeDays).
@@ -189,7 +191,7 @@ my @PropertyDescriptors = (
   CreateBasicPropertyDescriptor("Status", "Status", !1, 1, "A", 32),
   CreateItemrefPropertyDescriptor("VM", "VM", !1, 1, \&CreateVMs, ["VMName"]),
   CreateBasicPropertyDescriptor("Timeout", "Timeout", !1, 1, "N", 4),
-  CreateBasicPropertyDescriptor("FileName", "File name", !1, 1, "A", 100),
+  CreateBasicPropertyDescriptor("FileName", "File name", !1, !1, "A", 100),
   CreateBasicPropertyDescriptor("FileType", "File Type", !1, 1, "A", 32),
   CreateBasicPropertyDescriptor("CmdLineArg", "Command line args", !1, !1, "A", 256),
   CreateBasicPropertyDescriptor("Started", "Execution started", !1, !1, "DT", 19),
diff --git a/testbot/web/JobDetails.pl b/testbot/web/JobDetails.pl
index 6bf4a12e8..3e638f717 100644
--- a/testbot/web/JobDetails.pl
+++ b/testbot/web/JobDetails.pl
@@ -486,7 +486,7 @@ sub GenerateDataCell($$$$$)
   elsif ($PropertyName eq "FileName")
   {
     my $FileName = $StepTask->GetFullFileName();
-    if (-r $FileName)
+    if ($FileName and -r $FileName)
     {
       my $URI = "/GetFile.pl?JobKey=" . uri_escape($self->{JobId}) .
                   "&StepKey=" . uri_escape($StepTask->StepNo);
-- 
2.17.0



More information about the wine-devel mailing list