summaryrefslogtreecommitdiffstats
path: root/xt/lib/Bugzilla
diff options
context:
space:
mode:
authorByron Jones <bjones@mozilla.com>2013-05-20 19:54:06 +0200
committerByron Jones <bjones@mozilla.com>2013-05-20 19:54:06 +0200
commit0b1e410c81430711a602adc56e4fc7667d1c841e (patch)
treea538bc9da4cef2440a16e5f64c634daa6e8c1305 /xt/lib/Bugzilla
parent1f7cfaeb0ce976e5f7ec4ec9b8b02c47cd01b45e (diff)
downloadbugzilla-0b1e410c81430711a602adc56e4fc7667d1c841e.tar.gz
bugzilla-0b1e410c81430711a602adc56e4fc7667d1c841e.tar.xz
Bug 828344: "contains all of the words" no longer looks for all words within the same comment or flag
r=LpSolit, a=LpSolit
Diffstat (limited to 'xt/lib/Bugzilla')
-rw-r--r--xt/lib/Bugzilla/Test/Search/Constants.pm83
-rw-r--r--xt/lib/Bugzilla/Test/Search/FieldTest.pm32
2 files changed, 99 insertions, 16 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/Constants.pm b/xt/lib/Bugzilla/Test/Search/Constants.pm
index 512d180d9..051570ff8 100644
--- a/xt/lib/Bugzilla/Test/Search/Constants.pm
+++ b/xt/lib/Bugzilla/Test/Search/Constants.pm
@@ -197,11 +197,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
@@ -330,6 +333,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] },
+ },
};
###################
@@ -360,17 +381,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] },
@@ -397,7 +435,6 @@ use constant BROKEN_NOT => {
dependson => { contains => [1, 3] },
work_time => { contains => [1] },
FIELD_TYPE_BUG_ID, { contains => [1 .. 4] },
-
},
changedto => {
CHANGED_BROKEN_NOT,
@@ -406,10 +443,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] },
},
};
diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
index 283a90d16..ee25f2dc6 100644
--- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
@@ -28,6 +28,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);
@@ -72,6 +73,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 {
@@ -147,9 +155,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
@@ -184,6 +201,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;
@@ -192,8 +210,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;
@@ -601,12 +619,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);
}
}
}