]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 579243: Also test NOT (negated) charts in xt/search.t
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Fri, 16 Jul 2010 06:26:06 +0000 (23:26 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Fri, 16 Jul 2010 06:26:06 +0000 (23:26 -0700)
r=mkanat, a=mkanat (module owner)

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

index 87df927ca078e23e1810ada964cdbc41e3418657..624db8e2c560c166ee29ef71f07615fcc0e8a5c0 100644 (file)
@@ -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;
index 11a7760e2f84393c4f27d2fb6454564a1e3f3414..b03ed30dbbebcd46f5d134d73ee301688a86e732 100644 (file)
@@ -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 #
 #############
index 558742f71a1e948a2bc2f142df5136c2e375600b..f8186c5b3b649aaa529d318e094c1e726c0af78e 100644 (file)
@@ -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 {};
 }
index 6291fbac10ddc0863bf2874cb2e6408f32be7926..5ebba00c4b8a1597662ea3f0034c59e370bf5597 100644 (file)
@@ -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');