aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2020-01-29 06:50:00 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2020-01-29 06:56:28 -0800
commit976f4aa6d3e82e568149dd58a0197b36641b7b81 (patch)
tree5df93d3bd42ed5eebfce726bdf559d45d2684075 /xt/lib/Bugzilla/Test/Search/OrTest.pm
parentMerge remote-tracking branch 'origin/master' into bugstest (diff)
parentMerge tag 'release-5.0.6' into bugstest (diff)
downloadbugzilla-976f4aa6d3e82e568149dd58a0197b36641b7b81.tar.gz
bugzilla-976f4aa6d3e82e568149dd58a0197b36641b7b81.tar.bz2
bugzilla-976f4aa6d3e82e568149dd58a0197b36641b7b81.zip
Merge branch 'bugstest-5.0.6' into bugstest
Merge my 5.0.6 import changes. This is specifically a merge to make it easier to merge upstream changes again after the code reformatting. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to 'xt/lib/Bugzilla/Test/Search/OrTest.pm')
-rw-r--r--xt/lib/Bugzilla/Test/Search/OrTest.pm139
1 files changed, 72 insertions, 67 deletions
diff --git a/xt/lib/Bugzilla/Test/Search/OrTest.pm b/xt/lib/Bugzilla/Test/Search/OrTest.pm
index 1b948f38d..ebb16089d 100644
--- a/xt/lib/Bugzilla/Test/Search/OrTest.pm
+++ b/xt/lib/Bugzilla/Test/Search/OrTest.pm
@@ -20,36 +20,36 @@ use constant type => 'OR';
###############
sub new {
- my $class = shift;
- my $self = { field_tests => [@_] };
- return bless $self, $class;
+ my $class = shift;
+ my $self = {field_tests => [@_]};
+ return bless $self, $class;
}
#############
# Accessors #
#############
-sub field_tests { return @{ $_[0]->{field_tests} } }
+sub field_tests { return @{$_[0]->{field_tests}} }
sub search_test { ($_[0]->field_tests)[0]->search_test }
sub name {
- my ($self) = @_;
- my @names = map { $_->name } $self->field_tests;
- return join('-' . $self->type . '-', @names);
+ my ($self) = @_;
+ my @names = map { $_->name } $self->field_tests;
+ return join('-' . $self->type . '-', @names);
}
# In an OR test, bugs ARE supposed to be contained if they are contained
# by ANY test.
sub bug_is_contained {
- my ($self, $number) = @_;
- return any { $_->bug_is_contained($number) } $self->field_tests;
+ my ($self, $number) = @_;
+ return any { $_->bug_is_contained($number) } $self->field_tests;
}
# Needed only for failure messages
sub debug_value {
- my ($self) = @_;
- my @values = map { $_->field . ' ' . $_->debug_value } $self->field_tests;
- return join(' ' . $self->type . ' ', @values);
+ my ($self) = @_;
+ my @values = map { $_->field . ' ' . $_->debug_value } $self->field_tests;
+ return join(' ' . $self->type . ' ', @values);
}
########################
@@ -57,61 +57,66 @@ sub debug_value {
########################
sub field_not_yet_implemented {
- my ($self) = @_;
- return $self->_join_messages('field_not_yet_implemented');
+ my ($self) = @_;
+ return $self->_join_messages('field_not_yet_implemented');
}
+
sub invalid_field_operator_combination {
- my ($self) = @_;
- return $self->_join_messages('invalid_field_operator_combination');
+ my ($self) = @_;
+ return $self->_join_messages('invalid_field_operator_combination');
}
+
sub search_known_broken {
- my ($self) = @_;
- return $self->_join_messages('search_known_broken');
+ my ($self) = @_;
+ return $self->_join_messages('search_known_broken');
}
sub _join_messages {
- my ($self, $message_method) = @_;
- my @messages = map { $_->$message_method } $self->field_tests;
- @messages = grep { $_ } @messages;
- return join(' AND ', @messages);
+ my ($self, $message_method) = @_;
+ my @messages = map { $_->$message_method } $self->field_tests;
+ @messages = grep {$_} @messages;
+ return join(' AND ', @messages);
}
sub _bug_will_actually_be_contained {
- my ($self, $number) = @_;
-
- foreach my $test ($self->field_tests) {
- # Some tests are broken in such a way that they actually
- # generate no criteria in the SQL. In this case, the only way
- # the test contains the bug is if *another* test contains it.
- next if $test->_known_broken->{no_criteria};
- return 1 if $test->will_actually_contain_bug($number);
- }
- return 0;
+ my ($self, $number) = @_;
+
+ foreach my $test ($self->field_tests) {
+
+ # Some tests are broken in such a way that they actually
+ # generate no criteria in the SQL. In this case, the only way
+ # the test contains the bug is if *another* test contains it.
+ next if $test->_known_broken->{no_criteria};
+ return 1 if $test->will_actually_contain_bug($number);
+ }
+ return 0;
}
sub contains_known_broken {
- my ($self, $number) = @_;
-
- if ( ( $self->bug_is_contained($number)
- and !$self->_bug_will_actually_be_contained($number) )
- or ( !$self->bug_is_contained($number)
- and $self->_bug_will_actually_be_contained($number) ) )
- {
- my @messages = map { $_->contains_known_broken($number) }
- $self->field_tests;
- @messages = grep { $_ } @messages;
- # Sometimes, with things that break because of no_criteria, there won't
- # be anything in @messages even though we need to print out a message.
- if (!@messages) {
- my @no_criteria = grep { $_->_known_broken->{no_criteria} }
- $self->field_tests;
- @messages = map { "No criteria generated by " . $_->name }
- @no_criteria;
- }
- die "broken test with no message" if !@messages;
- return join(' AND ', @messages);
+ my ($self, $number) = @_;
+
+ if (
+ (
+ $self->bug_is_contained($number)
+ and !$self->_bug_will_actually_be_contained($number)
+ )
+ or ( !$self->bug_is_contained($number)
+ and $self->_bug_will_actually_be_contained($number))
+ )
+ {
+ my @messages = map { $_->contains_known_broken($number) } $self->field_tests;
+ @messages = grep {$_} @messages;
+
+ # Sometimes, with things that break because of no_criteria, there won't
+ # be anything in @messages even though we need to print out a message.
+ if (!@messages) {
+ my @no_criteria = grep { $_->_known_broken->{no_criteria} } $self->field_tests;
+ @messages = map { "No criteria generated by " . $_->name } @no_criteria;
}
- return undef;
+ die "broken test with no message" if !@messages;
+ return join(' AND ', @messages);
+ }
+ return undef;
}
##############################
@@ -119,23 +124,23 @@ sub contains_known_broken {
##############################
sub search_columns {
- my ($self) = @_;
- my @columns = map { @{ $_->search_columns } } $self->field_tests;
- return [uniq @columns];
+ my ($self) = @_;
+ my @columns = map { @{$_->search_columns} } $self->field_tests;
+ return [uniq @columns];
}
sub search_params {
- my ($self) = @_;
- my @all_params = map { $_->search_params } $self->field_tests;
- my %params;
- my $chart = 0;
- foreach my $item (@all_params) {
- $params{"field0-0-$chart"} = $item->{'field0-0-0'};
- $params{"type0-0-$chart"} = $item->{'type0-0-0'};
- $params{"value0-0-$chart"} = $item->{'value0-0-0'};
- $chart++;
- }
- return \%params;
+ my ($self) = @_;
+ my @all_params = map { $_->search_params } $self->field_tests;
+ my %params;
+ my $chart = 0;
+ foreach my $item (@all_params) {
+ $params{"field0-0-$chart"} = $item->{'field0-0-0'};
+ $params{"type0-0-$chart"} = $item->{'type0-0-0'};
+ $params{"value0-0-$chart"} = $item->{'value0-0-0'};
+ $chart++;
+ }
+ return \%params;
}
1;