Commit 0fcceb47 authored by Byron Jones's avatar Byron Jones

Bug 828344: "contains all of the words" no longer looks for all words within the…

Bug 828344: "contains all of the words" no longer looks for all words within the same comment or flag r=LpSolit, a=LpSolit
parent 2cb3f811
...@@ -183,11 +183,14 @@ use constant GREATERTHAN_BROKEN => ( ...@@ -183,11 +183,14 @@ use constant GREATERTHAN_BROKEN => (
); );
# allwords and allwordssubstr have these broken tests in common. # 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 => ( 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] }, 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 # Fields that don't generally work at all with changed* searches, but
...@@ -312,6 +315,24 @@ use constant KNOWN_BROKEN => { ...@@ -312,6 +315,24 @@ use constant KNOWN_BROKEN => {
# This should probably search the reporter. # This should probably search the reporter.
creation_ts => { contains => [1] }, 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 => ( ...@@ -342,17 +363,34 @@ use constant CHANGED_FROM_TO_BROKEN_NOT => (
# These are field/operator combinations that are broken when run under NOT(). # These are field/operator combinations that are broken when run under NOT().
use constant BROKEN_NOT => { use constant BROKEN_NOT => {
allwords => { allwords => {
cc => { contains => [1] }, cc => { contains => [1] },
'flagtypes.name' => { contains => [1, 5] },
longdesc => { contains => [1] },
}, },
'allwords-<1> <2>' => { 'allwords-<1> <2>' => {
cc => { }, cc => { },
}, },
allwordssubstr => { allwordssubstr => {
cc => { contains => [1] }, cc => { contains => [1] },
'flagtypes.name' => { contains => [5, 6] },
longdesc => { contains => [1] },
}, },
'allwordssubstr-<1>,<2>' => { '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 => { changedafter => {
"attach_data.thedata" => { contains => [2, 3, 4] }, "attach_data.thedata" => { contains => [2, 3, 4] },
...@@ -379,7 +417,6 @@ use constant BROKEN_NOT => { ...@@ -379,7 +417,6 @@ use constant BROKEN_NOT => {
dependson => { contains => [1, 3] }, dependson => { contains => [1, 3] },
work_time => { contains => [1] }, work_time => { contains => [1] },
FIELD_TYPE_BUG_ID, { contains => [1 .. 4] }, FIELD_TYPE_BUG_ID, { contains => [1 .. 4] },
}, },
changedto => { changedto => {
CHANGED_BROKEN_NOT, CHANGED_BROKEN_NOT,
...@@ -388,10 +425,38 @@ use constant BROKEN_NOT => { ...@@ -388,10 +425,38 @@ use constant BROKEN_NOT => {
"remaining_time" => { contains => [1] }, "remaining_time" => { contains => [1] },
}, },
greaterthan => { greaterthan => {
cc => { contains => [1] }, cc => { contains => [1] },
'flagtypes.name' => { contains => [5] },
}, },
greaterthaneq => { greaterthaneq => {
cc => { contains => [1] }, 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] },
}, },
}; };
......
...@@ -14,6 +14,7 @@ use strict; ...@@ -14,6 +14,7 @@ use strict;
use warnings; use warnings;
use Bugzilla::Search; use Bugzilla::Search;
use Bugzilla::Test::Search::Constants; use Bugzilla::Test::Search::Constants;
use Bugzilla::Util qw(trim);
use Data::Dumper; use Data::Dumper;
use Scalar::Util qw(blessed); use Scalar::Util qw(blessed);
...@@ -58,6 +59,13 @@ sub bug { ...@@ -58,6 +59,13 @@ sub bug {
my $self = shift; my $self = shift;
return $self->search_test->bug(@_); 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. # The name displayed for this test by Test::More. Used in test descriptions.
sub name { sub name {
...@@ -133,9 +141,18 @@ sub translated_value { ...@@ -133,9 +141,18 @@ sub translated_value {
return $self->{translated_value}; return $self->{translated_value};
} }
# Used in failure diagnostic messages. # Used in failure diagnostic messages.
sub debug_value { sub debug_fail {
my ($self) = @_; my ($self, $number, $results, $sql) = @_;
return "Value: '" . $self->translated_value . "'"; 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 # True for a bug if we ran the "transform" function on it and the
...@@ -170,6 +187,7 @@ sub bug_is_contained { ...@@ -170,6 +187,7 @@ sub bug_is_contained {
# The tests we know are broken for this operator/field combination. # The tests we know are broken for this operator/field combination.
sub _known_broken { sub _known_broken {
my ($self, $constant, $skip_pg_check) = @_; my ($self, $constant, $skip_pg_check) = @_;
$constant ||= KNOWN_BROKEN; $constant ||= KNOWN_BROKEN;
my $field = $self->field; my $field = $self->field;
my $type = $self->field_object->type; my $type = $self->field_object->type;
...@@ -178,8 +196,8 @@ sub _known_broken { ...@@ -178,8 +196,8 @@ sub _known_broken {
my $value_name = "$operator-$value"; my $value_name = "$operator-$value";
if (my $extra_name = $self->test->{extra_name}) { if (my $extra_name = $self->test->{extra_name}) {
$value_name .= "-$extra_name"; $value_name .= "-$extra_name";
} }
my $value_broken = $constant->{$value_name}->{$field}; my $value_broken = $constant->{$value_name}->{$field};
$value_broken ||= $constant->{$value_name}->{$type}; $value_broken ||= $constant->{$value_name}->{$type};
return $value_broken if $value_broken; return $value_broken if $value_broken;
...@@ -586,12 +604,12 @@ sub _test_content_for_bug { ...@@ -586,12 +604,12 @@ sub _test_content_for_bug {
if ($self->bug_is_contained($number)) { if ($self->bug_is_contained($number)) {
ok($result_ids{$bug_id}, ok($result_ids{$bug_id},
"$name: contains bug $number ($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 { else {
ok(!$result_ids{$bug_id}, ok(!$result_ids{$bug_id},
"$name: does not contain bug $number ($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);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment