]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 828344: "contains all of the words" no longer looks for all words within the...
authorByron Jones <bjones@mozilla.com>
Mon, 20 May 2013 17:54:43 +0000 (01:54 +0800)
committerByron Jones <bjones@mozilla.com>
Mon, 20 May 2013 17:54:43 +0000 (01:54 +0800)
r=LpSolit, a=LpSolit

xt/lib/Bugzilla/Test/Search/Constants.pm
xt/lib/Bugzilla/Test/Search/FieldTest.pm

index bfcc439e403a95d1ea27c75317ed89c56d1a696f..ae4db5b11e41e805496fbfae28ed517f69d4aec2 100644 (file)
@@ -183,11 +183,14 @@ use constant GREATERTHAN_BROKEN => (
 );
 
 # allwords and allwordssubstr have these broken tests in common.
-#
-# allwordssubstr on cc fields matches against a single cc,
-# instead of matching against all ccs on a bug.
 use constant ALLWORDS_BROKEN => (
+    # allwordssubstr on cc fields matches against a single cc,
+    # instead of matching against all ccs on a bug.
     cc        => { contains => [1] },
+    # bug 828344 changed how these searches operate to revert back to the 4.0
+    # behavour, so these tests need to be updated (bug 849117).
+    'flagtypes.name' => { contains => [1] },
+    longdesc         => { contains => [1] },
 );
 
 # Fields that don't generally work at all with changed* searches, but
@@ -312,6 +315,24 @@ use constant KNOWN_BROKEN => {
         # This should probably search the reporter.
         creation_ts => { contains => [1] },
     },
+    notequals => {
+        'flagtypes.name' => { contains => [1, 5] },
+        longdesc         => { contains => [1] },
+    },
+    notregexp => {
+        'flagtypes.name' => { contains => [1, 5] },
+        longdesc         => { contains => [1] },
+    },
+    notsubstring => {
+        'flagtypes.name' => { contains => [5] },
+        longdesc         => { contains => [1] },
+    },
+    nowords => {
+        'flagtypes.name' => { contains => [1, 5] },
+    },
+    nowordssubstr => {
+        'flagtypes.name' => { contains => [5] },
+    },
 };
 
 ###################
@@ -342,17 +363,34 @@ use constant CHANGED_FROM_TO_BROKEN_NOT => (
 
 # These are field/operator combinations that are broken when run under NOT().
 use constant BROKEN_NOT => {
-    allwords       => {
-        cc => { contains => [1] },
+    allwords => {
+        cc               => { contains => [1] },
+        'flagtypes.name' => { contains => [1, 5] },
+        longdesc         => { contains => [1] },
     },
     'allwords-<1> <2>' => {
         cc => { },
     },
     allwordssubstr => {
-        cc => { contains => [1] },
+        cc               => { contains => [1] },
+        'flagtypes.name' => { contains => [5, 6] },
+        longdesc         => { contains => [1] },
     },
     'allwordssubstr-<1>,<2>' => {
-        cc => { },
+        cc               => { },
+        longdesc         => { contains => [1] },
+    },
+    anyexact => {
+        'flagtypes.name' => { contains => [1, 2, 5] },
+    },
+    anywords => {
+        'flagtypes.name' => { contains => [1, 2, 5] },
+    },
+    anywordssubstr => {
+        'flagtypes.name' => { contains => [5] },
+    },
+    casesubstring => {
+        'flagtypes.name' => { contains => [5] },
     },
     changedafter => {
         "attach_data.thedata"   => { contains => [2, 3, 4] },
@@ -379,7 +417,6 @@ use constant BROKEN_NOT => {
         dependson       => { contains => [1, 3] },
         work_time       => { contains => [1] },
         FIELD_TYPE_BUG_ID, { contains => [1 .. 4] },
-        
     },
     changedto => {
         CHANGED_BROKEN_NOT,
@@ -388,10 +425,38 @@ use constant BROKEN_NOT => {
         "remaining_time" => { contains => [1] },
     },
     greaterthan => {
-        cc        => { contains => [1] },
+        cc               => { contains => [1] },
+        'flagtypes.name' => { contains => [5] },
     },
     greaterthaneq => {
         cc               => { contains => [1] },
+        'flagtypes.name' => { contains => [2, 5] },
+    },
+    equals => {
+        'flagtypes.name' => { contains => [1, 5] },
+    },
+    notequals => {
+        longdesc         => { contains => [1] },
+    },
+    notregexp => {
+        longdesc         => { contains => [1] },
+    },
+    notsubstring => {
+        longdesc         => { contains => [1] },
+    },
+    lessthan => {
+        'flagtypes.name' => { contains => [5] },
+    },
+    lessthaneq => {
+        'flagtypes.name' => { contains => [1, 5] },
+    },
+    regexp => {
+        'flagtypes.name' => { contains => [1, 5] },
+        longdesc         => { contains => [1] },
+    },
+    substring => {
+        'flagtypes.name' => { contains => [5] },
+        longdesc         => { contains => [1] },
     },
 };
 
index c92a6a7b644640aaa9e74336cdd7bd0cefc1f673..5e86d92e2b45a724a80c190e007a4de42aca8545 100644 (file)
@@ -14,6 +14,7 @@ use strict;
 use warnings;
 use Bugzilla::Search;
 use Bugzilla::Test::Search::Constants;
+use Bugzilla::Util qw(trim);
 
 use Data::Dumper;
 use Scalar::Util qw(blessed);
@@ -58,6 +59,13 @@ sub bug {
     my $self = shift;
     return $self->search_test->bug(@_);
 }
+sub number {
+    my ($self, $id) = @_;
+    foreach my $number (1..NUM_BUGS) {
+        return $number if $self->search_test->bug($number)->id == $id;
+    }
+    return 0;
+}
 
 # The name displayed for this test by Test::More. Used in test descriptions.
 sub name {
@@ -133,9 +141,18 @@ sub translated_value {
     return $self->{translated_value};
 }
 # Used in failure diagnostic messages.
-sub debug_value {
-    my ($self) = @_;
-    return "Value: '" . $self->translated_value . "'";
+sub debug_fail {
+    my ($self, $number, $results, $sql) = @_;
+    my @expected = @{ $self->test->{contains} };
+    my @results = sort
+                  map { $self->number($_) }
+                  map { $_->[0] }
+                  @$results;
+    return
+        "   Value: '" . $self->translated_value . "'\n" .
+        "Expected: [" . join(',', @expected) . "]\n" .
+        " Results: [" . join(',', @results) . "]\n" .
+        trim($sql) . "\n";
 }
 
 # True for a bug if we ran the "transform" function on it and the
@@ -170,6 +187,7 @@ sub bug_is_contained {
 # The tests we know are broken for this operator/field combination.
 sub _known_broken {
     my ($self, $constant, $skip_pg_check) = @_;
+
     $constant ||= KNOWN_BROKEN;
     my $field = $self->field;
     my $type = $self->field_object->type;
@@ -178,8 +196,8 @@ sub _known_broken {
     my $value_name = "$operator-$value";
     if (my $extra_name = $self->test->{extra_name}) {
         $value_name .= "-$extra_name";
-    }    
-    
+    }
+
     my $value_broken = $constant->{$value_name}->{$field};
     $value_broken ||= $constant->{$value_name}->{$type};
     return $value_broken if $value_broken;
@@ -586,12 +604,12 @@ sub _test_content_for_bug {
         if ($self->bug_is_contained($number)) {
             ok($result_ids{$bug_id},
                "$name: contains bug $number ($bug_id)")
-                or diag Dumper($results) . $self->debug_value . "\n\nSQL: $sql";
+                or diag $self->debug_fail($number, $results, $sql);
         }
         else {
             ok(!$result_ids{$bug_id},
                "$name: does not contain bug $number ($bug_id)")
-                or diag Dumper($results) . $self->debug_value . "\n\nSQL: $sql";
+                or diag $self->debug_fail($number, $results, $sql);
         }
     }
 }