summaryrefslogtreecommitdiffstats
path: root/xt/lib/Bugzilla/Test
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-16 08:26:06 +0200
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-07-16 08:26:06 +0200
commit2bd4ef390187c2d793d1167df4bc2424a3c66d80 (patch)
treeac6459ebf19c711445b511f26e8dfda49f5dfb71 /xt/lib/Bugzilla/Test
parentdbaf1c3aaf975ed78d8e8538b2df18ab9f47654b (diff)
downloadbugzilla-2bd4ef390187c2d793d1167df4bc2424a3c66d80.tar.gz
bugzilla-2bd4ef390187c2d793d1167df4bc2424a3c66d80.tar.xz
Bug 579243: Also test NOT (negated) charts in xt/search.t
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'xt/lib/Bugzilla/Test')
-rw-r--r--xt/lib/Bugzilla/Test/Search.pm4
-rw-r--r--xt/lib/Bugzilla/Test/Search/Constants.pm265
-rw-r--r--xt/lib/Bugzilla/Test/Search/FieldTest.pm16
-rw-r--r--xt/lib/Bugzilla/Test/Search/OperatorTest.pm3
4 files changed, 281 insertions, 7 deletions
diff --git a/xt/lib/Bugzilla/Test/Search.pm b/xt/lib/Bugzilla/Test/Search.pm
index 87df927ca..624db8e2c 100644
--- a/xt/lib/Bugzilla/Test/Search.pm
+++ b/xt/lib/Bugzilla/Test/Search.pm
@@ -99,7 +99,9 @@ sub num_tests {
? ($top_combinations * $all_combinations) : 0;
# And AND tests, which means we run 2x $join_tests;
$join_tests = $join_tests * 2;
- my $operator_field_tests = ($top_combinations + $join_tests) * TESTS_PER_RUN;
+ # Also, because of NOT tests, we run 2x $top_combinations.
+ my $basic_tests = $top_combinations * 2;
+ my $operator_field_tests = ($basic_tests + $join_tests) * TESTS_PER_RUN;
# Then we test each field/operator combination for SQL injection.
my @injection_values = INJECTION_TESTS;
diff --git a/xt/lib/Bugzilla/Test/Search/Constants.pm b/xt/lib/Bugzilla/Test/Search/Constants.pm
index 11a7760e2..b03ed30db 100644
--- a/xt/lib/Bugzilla/Test/Search/Constants.pm
+++ b/xt/lib/Bugzilla/Test/Search/Constants.pm
@@ -31,6 +31,7 @@ use Bugzilla::Constants;
our @EXPORT = qw(
ATTACHMENT_FIELDS
+ BROKEN_NOT
COLUMN_TRANSLATION
COMMENT_FIELDS
CUSTOM_FIELDS
@@ -494,6 +495,270 @@ use constant PG_BROKEN => {
},
};
+###################
+# Broken NotTests #
+###################
+
+# These are fields that are broken in the same way for pretty much every
+# NOT test that is broken.
+use constant COMMON_BROKEN_NOT => (
+ "attach_data.thedata" => { contains => [5] },
+ "attachments.description" => { contains => [5] },
+ "attachments.filename" => { contains => [5] },
+ "attachments.isobsolete" => { contains => [5] },
+ "attachments.ispatch" => { contains => [5] },
+ "attachments.isprivate" => { contains => [5] },
+ "attachments.mimetype" => { contains => [5] },
+ "attachments.submitter" => { contains => [5] },
+ "bug_file_loc" => { contains => [5] },
+ "deadline" => { contains => [5] },
+ "flagtypes.name" => { contains => [5] },
+ "keywords" => { contains => [5] },
+ "longdescs.isprivate" => { contains => [1] },
+ "percentage_complete" => { contains => [1 .. 5] },
+ "requestees.login_name" => { contains => [3, 4, 5] },
+ "see_also" => { contains => [5] },
+ "setters.login_name" => { contains => [5] },
+ FIELD_TYPE_BUG_ID, { contains => [5] },
+ FIELD_TYPE_DATETIME, { contains => [5] },
+ FIELD_TYPE_FREETEXT, { contains => [5] },
+ FIELD_TYPE_MULTI_SELECT, { contains => [1, 5] },
+ FIELD_TYPE_TEXTAREA, { contains => [5] },
+);
+
+# Common BROKEN_NOT values for the changed* fields.
+use constant CHANGED_BROKEN_NOT => (
+ "attach_data.thedata" => { contains => [1] },
+ "classification" => { contains => [1] },
+ "commenter" => { contains => [1] },
+ "delta_ts" => { contains => [1] },
+ "percentage_complete" => { contains => [1] },
+ "requestees.login_name" => { contains => [1] },
+ "setters.login_name" => { contains => [1] },
+ "work_time" => { contains => [1] },
+);
+
+# For changedfrom and changedto.
+use constant CHANGED_FROM_TO_BROKEN_NOT => (
+ "bug_group" => { contains => [1] },
+ "cc" => { contains => [1] },
+ "cf_multi_select" => { contains => [1] },
+ "estimated_time" => { contains => [1] },
+ "flagtypes.name" => { contains => [1] },
+ "keywords" => { contains => [1] },
+);
+
+# Common broken tests for the "not" or "no" operators.
+use constant NEGATIVE_BROKEN_NOT => (
+ "blocked" => { contains => [3, 4, 5] },
+ "bug_group" => { contains => [5] },
+ "cc" => { contains => [1, 5] },
+ "dependson" => { contains => [2, 4, 5] },
+ "flagtypes.name" => { contains => [1 .. 5] },
+ "percentage_complete" => { contains => [1 .. 5] },
+);
+
+# These are field/operator combinations that are broken when run under NOT().
+use constant BROKEN_NOT => {
+ allwords => {
+ COMMON_BROKEN_NOT,
+ "attach_data.thedata" => { contains => [1,5] },
+ bug_group => { contains => [1] },
+ cc => { contains => [1] },
+ "flagtypes.name" => { contains => [1,5] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ 'see_also' => { },
+ work_time => { contains => [1] },
+ FIELD_TYPE_MULTI_SELECT, { },
+ },
+ 'allwords-<1> <2>' => {
+ 'attach_data.thedata' => { contains => [5] },
+ bug_group => { },
+ cc => { },
+ 'flagtypes.name' => { contains => [5] },
+ 'keywords' => { contains => [5] },
+ 'longdesc' => { },
+ 'longdescs.isprivate' => { },
+ work_time => { },
+ },
+ allwordssubstr => {
+ COMMON_BROKEN_NOT,
+ bug_group => { contains => [1] },
+ cc => { contains => [1] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ see_also => { },
+ work_time => { contains => [1] },
+ FIELD_TYPE_MULTI_SELECT, { },
+ },
+ 'allwordssubstr-<1>,<2>' => {
+ bug_group => { },
+ "cc" => { },
+ FIELD_TYPE_MULTI_SELECT, { },
+ keywords => { contains => [5] },
+ "longdesc" => { },
+ "longdescs.isprivate" => { },
+ "see_also" => { },
+ "work_time" => { },
+ },
+ anyexact => {
+ COMMON_BROKEN_NOT,
+ "flagtypes.name" => { contains => [1, 2, 5] },
+ "longdesc" => { contains => [1, 2] },
+ "work_time" => { contains => [1, 2] }
+ },
+ 'anyexact-<1>, <2>' => {
+ bug_group => { contains => [1] },
+ percentage_complete => { contains => [1,3,4,5] },
+ keywords => { contains => [1,5] },
+ see_also => { },
+ FIELD_TYPE_MULTI_SELECT, { },
+ },
+ anywords => {
+ COMMON_BROKEN_NOT,
+ "attach_data.thedata" => { contains => [1, 5] },
+ "work_time" => { contains => [1, 2] },
+ "work_time" => { contains => [1] },
+ FIELD_TYPE_MULTI_SELECT, { contains => [5] },
+ },
+ 'anywords-<1> <2>' => {
+ 'attach_data.thedata' => { contains => [1,2,5] },
+ "percentage_complete" => { contains => [1,3,4,5] },
+ work_time => { contains => [1,2] },
+ },
+ anywordssubstr => {
+ COMMON_BROKEN_NOT,
+ "work_time" => { contains => [1, 2] },
+ },
+ 'anywordssubstr-<1> <2>' => {
+ percentage_complete => { contains => [1,3,4,5] },
+ FIELD_TYPE_MULTI_SELECT, { contains => [5] },
+ },
+ casesubstring => {
+ COMMON_BROKEN_NOT,
+ bug_group => { contains => [1] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ work_time => { contains => [1] } ,
+ FIELD_TYPE_MULTI_SELECT, { contains => [1,5] },
+ },
+ 'casesubstring-<1>-lc' => {
+ bug_group => { },
+ keywords => { contains => [5] },
+ longdesc => { },
+ FIELD_TYPE_MULTI_SELECT, { contains => [5] },
+ },
+ changedafter => {
+ "attach_data.thedata" => { contains => [2, 3, 4] },
+ "classification" => { contains => [2, 3, 4] },
+ "commenter" => { contains => [2, 3, 4] },
+ "creation_ts" => { contains => [2, 3, 4] },
+ "delta_ts" => { contains => [2, 3, 4] },
+ "percentage_complete" => { contains => [2, 3, 4] },
+ "requestees.login_name" => { contains => [2, 3, 4] },
+ "setters.login_name" => { contains => [2, 3, 4] },
+ },
+ changedbefore=> {
+ CHANGED_BROKEN_NOT,
+ creation_ts => { contains => [1, 2, 5] },
+ work_time => { }
+ },
+ changedby => {
+ CHANGED_BROKEN_NOT,
+ creation_ts => { contains => [1] },
+ },
+ changedfrom => {
+ CHANGED_BROKEN_NOT,
+ CHANGED_FROM_TO_BROKEN_NOT,
+ 'attach_data.thedata' => { },
+ blocked => { contains => [1, 2] },
+ dependson => { contains => [1, 3] },
+ longdesc => { },
+ FIELD_TYPE_BUG_ID, { contains => [1 .. 4] },
+
+ },
+ changedto => {
+ CHANGED_BROKEN_NOT,
+ CHANGED_FROM_TO_BROKEN_NOT,
+ longdesc => { contains => [1] },
+ "remaining_time" => { contains => [1] },
+ },
+ equals => {
+ COMMON_BROKEN_NOT,
+ bug_group => { contains => [1] },
+ "flagtypes.name" => { contains => [1, 5] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ work_time => { contains => [1] }
+ },
+ greaterthan => {
+ COMMON_BROKEN_NOT,
+ cc => { contains => [1] },
+ work_time => { contains => [2, 3, 4] },
+ FIELD_TYPE_MULTI_SELECT, { contains => [5] },
+ },
+ greaterthaneq => {
+ COMMON_BROKEN_NOT,
+ cc => { contains => [1] },
+ "flagtypes.name" => { contains => [2, 5] },
+ "work_time" => { contains => [2, 3, 4] },
+ percentage_complete => { contains => [1,3,4,5] },,
+ FIELD_TYPE_MULTI_SELECT, { contains => [5] },
+ },
+ lessthan => {
+ COMMON_BROKEN_NOT,
+ longdesc => { contains => [1] },
+ 'longdescs.isprivate' => { },
+ },
+ 'lessthan-2' => {
+ bug_group => { contains => [1] },
+ keywords => { contains => [1,5] },
+ },
+ lessthaneq => {
+ COMMON_BROKEN_NOT,
+ bug_group => { contains => [1] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ 'longdescs.isprivate' => { },
+ },
+ notequals => { NEGATIVE_BROKEN_NOT },
+ notregexp => { NEGATIVE_BROKEN_NOT },
+ notsubstring => { NEGATIVE_BROKEN_NOT },
+ nowords => {
+ NEGATIVE_BROKEN_NOT,
+ "attach_data.thedata" => { contains => [1] },
+ "work_time" => { contains => [2, 3, 4] },
+ "cc" => { contains => [5] },
+ "flagtypes.name" => { },
+ },
+ nowordssubstr => {
+ NEGATIVE_BROKEN_NOT,
+ "attach_data.thedata" => { },
+ "cc" => { contains => [5] },
+ "flagtypes.name" => { },
+ "work_time" => { contains => [2, 3, 4] },
+ },
+ regexp => {
+ COMMON_BROKEN_NOT,
+ bug_group => { contains => [1] },
+ "flagtypes.name" => { contains => [1,5] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ work_time => { contains => [1] },
+ },
+ 'regexp-^1-' => {
+ "flagtypes.name" => { contains => [5] },
+ },
+ substring => {
+ COMMON_BROKEN_NOT,
+ bug_group => { contains => [1] },
+ keywords => { contains => [1,5] },
+ longdesc => { contains => [1] },
+ work_time => { contains => [1] },
+ },
+};
+
#############
# Overrides #
#############
diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
index 558742f71..f8186c5b3 100644
--- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm
@@ -178,25 +178,29 @@ sub bug_is_contained {
# The tests we know are broken for this operator/field combination.
sub _known_broken {
- my $self = shift;
+ my ($self, $constant, $skip_pg_check) = @_;
+ $constant ||= KNOWN_BROKEN;
my $field = $self->field;
my $type = $self->field_object->type;
my $operator = $self->operator;
my $value = $self->main_value;
my $value_name = "$operator-$value";
+ if (my $extra_name = $self->test->{extra_name}) {
+ $value_name .= "-$extra_name";
+ }
- if (Bugzilla->dbh->isa('Bugzilla::DB::Pg')) {
+ if (!$skip_pg_check and Bugzilla->dbh->isa('Bugzilla::DB::Pg')) {
my $field_broken = PG_BROKEN->{$field}->{$operator};
return $field_broken if $field_broken;
my $pg_value_broken = PG_BROKEN->{$field}->{$value_name};
return $pg_value_broken if $pg_value_broken;
}
- my $value_broken = KNOWN_BROKEN->{$value_name}->{$field};
- $value_broken ||= KNOWN_BROKEN->{$value_name}->{$type};
+ my $value_broken = $constant->{$value_name}->{$field};
+ $value_broken ||= $constant->{$value_name}->{$type};
return $value_broken if $value_broken;
- my $operator_broken = KNOWN_BROKEN->{$operator}->{$field};
- $operator_broken ||= KNOWN_BROKEN->{$operator}->{$type};
+ my $operator_broken = $constant->{$operator}->{$field};
+ $operator_broken ||= $constant->{$operator}->{$type};
return $operator_broken if $operator_broken;
return {};
}
diff --git a/xt/lib/Bugzilla/Test/Search/OperatorTest.pm b/xt/lib/Bugzilla/Test/Search/OperatorTest.pm
index 6291fbac1..5ebba00c4 100644
--- a/xt/lib/Bugzilla/Test/Search/OperatorTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/OperatorTest.pm
@@ -30,6 +30,7 @@ use Bugzilla::Test::Search::FieldTest;
use Bugzilla::Test::Search::InjectionTest;
use Bugzilla::Test::Search::OrTest;
use Bugzilla::Test::Search::AndTest;
+use Bugzilla::Test::Search::NotTest;
###############
# Constructor #
@@ -63,6 +64,8 @@ sub run {
my $field_test =
new Bugzilla::Test::Search::FieldTest($self, $field, $test);
$field_test->run();
+ my $not_test = new Bugzilla::Test::Search::NotTest($field_test);
+ $not_test->run();
next if !$self->search_test->option('long');