Handle undef values in reports, and eval all reports.

This commit is contained in:
Daniel Nichter
2012-08-21 09:24:19 -06:00
parent ca9bee7ae5
commit 6397b3d897
3 changed files with 57 additions and 42 deletions

View File

@@ -8279,7 +8279,7 @@ sub get_report {
if ( $self->{underline_header} ) {
my @underlines = map { '=' x $_->{print_width} } @{$self->{cols}};
push @lines, $self->_truncate_line(
sprintf($fmt, @underlines),
sprintf($fmt, map { $_ || '' } @underlines),
mark => '',
);
}
@@ -8290,7 +8290,7 @@ sub get_report {
my @vals = map {
defined $_ ? $_ : $self->{cols}->[$i++]->{undef_value}
} @$vals;
my $line = sprintf($fmt, @vals);
my $line = sprintf($fmt, map { defined $_ ? $_ : '' } @vals);
if ( $self->{extend_right} ) {
$line;
}
@@ -8507,7 +8507,7 @@ sub event_report {
my $line = sprintf(
'# Query %d: ID 0x%s at byte %d ',
$rank || 0,
make_checksum($where),
make_checksum($where) || '0x0',
0, # $sample->{pos_in_log} || 0
);
$line .= ('_' x (LINE_LENGTH - length($line)));
@@ -8528,7 +8528,7 @@ sub event_report {
my @diffs = grep { $_ =~ m/^different_/ } keys %$class;
foreach my $diff ( sort @diffs ) {
push @result,
sprintf $fmt, ' ' . make_label($diff), $class->{$diff}->{sum};
sprintf $fmt, ' ' . (make_label($diff) || ''), ($class->{$diff}->{sum} || 0);
}
my $report = new ReportFormatter(
@@ -10864,7 +10864,7 @@ sub main {
my $item = $worst->[$rank - 1]->[0];
my $sample = $meta_ea->results->{samples}->{$item};
my $samp_query = $sample->{arg} || '';
eval {
print "\n";
print $urf->event_report(
meta_ea => $meta_ea,
@@ -10898,6 +10898,10 @@ sub main {
map {
print "/* $query_id-$_ */ $samples{$item}->{$_}\n";
} sort { $a <=> $b } keys %{$samples{$item}};
};
if ( $EVAL_ERROR ) {
warn "Error printing queries report for $item: $EVAL_ERROR";
}
} # Each worst ITEM
}
@@ -10906,19 +10910,30 @@ sub main {
# ##################################################################
if ( $o->get('reports')->{differences} ) {
foreach my $c ( @compare_modules ) {
eval {
my $report = $c->report(hosts => $hosts);
print "\n$report" if $report;
};
if ( $EVAL_ERROR ) {
warn "Error printing differences report: $EVAL_ERROR";
}
}
}
if ( $o->get('reports')->{errors} ) {
eval {
report_errors(errors => $errors);
};
if ( $EVAL_ERROR ) {
warn "Error printing errors report: $EVAL_ERROR";
}
}
if ( $o->get('reports')->{statistics} ) {
my $fmt = "# %-30s %d\n";
print "\n# Statistics\n";
map { printf $fmt, $_, $stats->{$_} } sort keys %$stats;
map { printf($fmt, ($_ || ''), ($stats->{$_} || 0)) }
sort keys %$stats;
}
# ##################################################################

View File

@@ -256,7 +256,7 @@ sub get_report {
if ( $self->{underline_header} ) {
my @underlines = map { '=' x $_->{print_width} } @{$self->{cols}};
push @lines, $self->_truncate_line(
sprintf($fmt, @underlines),
sprintf($fmt, map { $_ || '' } @underlines),
mark => '',
);
}
@@ -267,7 +267,7 @@ sub get_report {
my @vals = map {
defined $_ ? $_ : $self->{cols}->[$i++]->{undef_value}
} @$vals;
my $line = sprintf($fmt, @vals);
my $line = sprintf($fmt, map { defined $_ ? $_ : '' } @vals);
if ( $self->{extend_right} ) {
$line;
}

View File

@@ -64,7 +64,7 @@ sub event_report {
my $line = sprintf(
'# Query %d: ID 0x%s at byte %d ',
$rank || 0,
make_checksum($where),
make_checksum($where) || '0x0',
0, # $sample->{pos_in_log} || 0
);
$line .= ('_' x (LINE_LENGTH - length($line)));
@@ -89,7 +89,7 @@ sub event_report {
my @diffs = grep { $_ =~ m/^different_/ } keys %$class;
foreach my $diff ( sort @diffs ) {
push @result,
sprintf $fmt, ' ' . make_label($diff), $class->{$diff}->{sum};
sprintf $fmt, ' ' . (make_label($diff) || ''), ($class->{$diff}->{sum} || 0);
}
# Side-by-side hosts report.