diff options
Diffstat (limited to 'xt/lib/Bugzilla/Test/Search')
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/Constants.pm | 29 | ||||
-rw-r--r-- | xt/lib/Bugzilla/Test/Search/FieldTest.pm | 18 |
2 files changed, 36 insertions, 11 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/Constants.pm b/xt/lib/Bugzilla/Test/Search/Constants.pm index 248b59f53..2b3534f8b 100644 --- a/xt/lib/Bugzilla/Test/Search/Constants.pm +++ b/xt/lib/Bugzilla/Test/Search/Constants.pm @@ -48,6 +48,7 @@ our @EXPORT = qw( OR_SKIP PG_BROKEN SKIP_FIELDS + SUBSTR_NO_FIELD_ADD SUBSTR_SIZE TESTS TESTS_PER_RUN @@ -158,22 +159,35 @@ use constant USER_FIELDS => qw( ); # For the "substr"-type searches, how short of a substring should -# we use? +# we use? The goal is to be shorter than the full string, but +# long enough to still be globally unique. use constant SUBSTR_SIZE => 20; # However, for some fields, we use a different size. use constant FIELD_SUBSTR_SIZE => { - alias => 12, - bug_file_loc => 30, + alias => 11, # Just the month and day. deadline => -5, creation_ts => -8, delta_ts => -8, + percentage_complete => 7, work_time => 3, remaining_time => 3, - see_also => 30, - target_milestone => 12, + target_milestone => 15, + longdesc => 25, + # Just the hour and minute. + FIELD_TYPE_DATETIME, -5, }; +# For most fields, we add the length of the name of the field plus +# the SUBSTR_SIZE specified above to determine how large of a substring +# we're going to use. However, for some fields, it doesn't make sense to +# add in their field name this way. +use constant SUBSTR_NO_FIELD_ADD => FIELD_TYPE_DATETIME, qw( + target_milestone remaining_time percentage_complete work_time + attachments.mimetype attachments.submitter attachments.filename + attachments.description flagtypes.name +); + ################ # Known Broken # ################ @@ -364,9 +378,6 @@ use constant KNOWN_BROKEN => { anyexact => { percentage_complete => { contains => [2] }, }, - anywordssubstr => { - percentage_complete => { contains => [2] }, - }, 'allwordssubstr-<1>' => { ALLWORDS_BROKEN }, # flagtypes.name does not work here, probably because they all try to @@ -623,7 +634,7 @@ use constant BROKEN_NOT => { "work_time" => { contains => [1, 2] }, }, 'anywordssubstr-<1> <2>' => { - percentage_complete => { contains => [1,3,4,5] }, + percentage_complete => { contains => [1,2,3,4,5] }, FIELD_TYPE_MULTI_SELECT, { contains => [5] }, }, casesubstring => { diff --git a/xt/lib/Bugzilla/Test/Search/FieldTest.pm b/xt/lib/Bugzilla/Test/Search/FieldTest.pm index f8186c5b3..b5f6d2334 100644 --- a/xt/lib/Bugzilla/Test/Search/FieldTest.pm +++ b/xt/lib/Bugzilla/Test/Search/FieldTest.pm @@ -461,13 +461,27 @@ sub _translate_value_for_bug { sub _substr_value { my ($self, $value) = @_; my $field = $self->field; + my $type = $self->field_object->type; my $substr_size = SUBSTR_SIZE; if (exists FIELD_SUBSTR_SIZE->{$field}) { $substr_size = FIELD_SUBSTR_SIZE->{$field}; } - + elsif (exists FIELD_SUBSTR_SIZE->{$type}) { + $substr_size = FIELD_SUBSTR_SIZE->{$type}; + } if ($substr_size > 0) { - return substr($value, 0, $substr_size); + # The field name is included in every field value, and if it's + # long, it might take up the whole substring, and we don't want that. + if (!grep { $_ eq $field or $_ eq $type } SUBSTR_NO_FIELD_ADD) { + $substr_size += length($field); + } + my $string = substr($value, 0, $substr_size); + # Make percentage_complete substrings strings match integers uniquely, + # by searching for the full decimal number. + if ($field eq 'percentage_complete' and length($string) < $substr_size) { + $string .= ".000"; + } + return $string; } return substr($value, $substr_size); } |