[tools] testbot: Tweak the Failure::Validate() error message.

Francois Gouget fgouget at codeweavers.com
Tue Jul 5 10:51:23 CDT 2022


The error message should indicate why the regular expression is invalid.
Also use the field's actual display name instead of making one up.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 testbot/lib/WineTestBot/Failures.pm | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/testbot/lib/WineTestBot/Failures.pm b/testbot/lib/WineTestBot/Failures.pm
index 6190ef25da..8d41bfcc93 100644
--- a/testbot/lib/WineTestBot/Failures.pm
+++ b/testbot/lib/WineTestBot/Failures.pm
@@ -98,20 +98,21 @@ sub Validate($)
   {
     return ("TestUnit", "The test unit '". $self->TestUnit ."' contains invalid characters");
   }
-  foreach my $Pair (["ConfigRegExp", "configuration"],
-                    ["FailureRegExp", "failure"])
+  foreach my $Field ("ConfigRegExp", "FailureRegExp")
   {
-    my ($Field, $Name) = @$Pair;
     my $RegExp = $self->$Field;
     my $ErrMessage = eval {
       use warnings FATAL => qw(regexp);
       if ($RegExp and "" =~ /$RegExp/)
       {
-        return "The $Name regular expression should not match empty strings";
+        return "The regular expression should not match empty strings";
       }
-    };
-    $ErrMessage = "The $Name regular expression is invalid" if ($@);
-    return ($Field, $ErrMessage) if ($ErrMessage);
+    } || "$@";
+    if ($ErrMessage)
+    {
+      my $DisplayName = $self->GetPropertyDescriptorByName($Field)->GetDisplayName();
+      return ($Field, "$DisplayName: $ErrMessage");
+    }
   }
   return $self->SUPER::Validate();
 }
-- 
2.30.2




More information about the wine-devel mailing list