diff --git a/bin/pt-query-digest b/bin/pt-query-digest index 58457a7f..c3bc7bc5 100755 --- a/bin/pt-query-digest +++ b/bin/pt-query-digest @@ -1369,7 +1369,7 @@ sub print_usage { $desc .= ". Optional suffix s=seconds, m=minutes, h=hours, " . "d=days; if no suffix, $s is used."; } - $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol})(?:\s+|$)/g); + $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol}(?!\W))(?:\s+|(?<=\W)|$)/g); $desc =~ s/ +$//mg; if ( $short ) { $usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc); @@ -8106,16 +8106,20 @@ $Data::Dumper::Indent = 1; $Data::Dumper::Sortkeys = 1; $Data::Dumper::Quotekeys = 0; +local $EVAL_ERROR; +eval { + require Quoter; +}; + sub new { my ( $class, %args ) = @_; - my @required_args = qw(Quoter); - foreach my $arg ( @required_args ) { - die "I need a $arg argument" unless $args{$arg}; - } my $self = { %args }; + $self->{Quoter} ||= Quoter->new(); return bless $self, $class; } +sub Quoter { shift->{Quoter} } + sub get_create_table { my ( $self, $dbh, $db, $tbl ) = @_; die "I need a dbh parameter" unless $dbh; diff --git a/lib/OptionParser.pm b/lib/OptionParser.pm index c61ab321..263c21be 100644 --- a/lib/OptionParser.pm +++ b/lib/OptionParser.pm @@ -1076,7 +1076,7 @@ sub print_usage { . "d=days; if no suffix, $s is used."; } # Wrap long descriptions - $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol})(?:\s+|$)/g); + $desc = join("\n$rpad", grep { $_ } $desc =~ m/(.{0,$rcol}(?!\W))(?:\s+|(?<=\W)|$)/g); $desc =~ s/ +$//mg; if ( $short ) { $usage .= sprintf(" --%-${maxs}s -%s %s\n", $long, $short, $desc); diff --git a/t/pt-query-digest/option_sanity.t b/t/pt-query-digest/option_sanity.t index 328247ca..5e4cf18a 100644 --- a/t/pt-query-digest/option_sanity.t +++ b/t/pt-query-digest/option_sanity.t @@ -9,7 +9,7 @@ BEGIN { use strict; use warnings FATAL => 'all'; use English qw(-no_match_vars); -use Test::More tests => 6; +use Test::More; use PerconaTest; @@ -57,8 +57,24 @@ $output = `$trunk/bin/pt-query-digest @options --embedded-attributes '-- .*,[:al like $output, qr/\Q--embedded-attributes POSIX syntax [: :] belongs inside character/, "Bug 885382: --embedded-attributes rejects warning patterns early";; - + +# ############################################################################# +# pt-query-digest help output mangled +# https://bugs.launchpad.net/percona-toolkit/+bug/831525 +# ############################################################################# + +$output = `$trunk/bin/pt-query-digest --help`; + +like( + $output, + qr/\Q--report-format=A\E\s* + \QPrint these sections of the query analysis\E\s* + \Qreport (default rusage,date,hostname,files,\E\s* + \Qheader,profile,query_report,prepared)\E/x, + "Bug 831525: pt-query-digest help output mangled" +); + # ############################################################################# # Done. # ############################################################################# -exit; +done_testing;