summaryrefslogtreecommitdiffstats
path: root/xt
diff options
context:
space:
mode:
Diffstat (limited to 'xt')
-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 bd5fd905a..a625127c9 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;
@@ -600,12 +618,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);
}
}
}