Fix for 903379

This commit is contained in:
Brian Fraser fraserb@gmail.com
2012-05-28 04:59:04 -03:00
2 changed files with 64 additions and 11 deletions

View File

@@ -23,7 +23,7 @@ if ( !$dbh ) {
plan skip_all => 'Cannot connect to sandbox master';
}
else {
plan tests => 5;
plan tests => 11;
}
my $output;
@@ -71,6 +71,47 @@ EOF
, 'File has the right stuff with only some columns');
`rm -f archive.test.table_1`;
# #############################################################################
# Bug #903379: --file & --charset could cause warnings and exceptions
# #############################################################################
sub test_charset {
my ($charset) = @_;
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
local $@;
eval {
pt_archiver::main("-c", "b,c", qw(--where 1=1 --header),
"--source", "D=test,t=table_1,F=$cnf",
'--file', '/tmp/%Y-%m-%d-%D_%H:%i:%s.%t',
'--no-check-charset',
'--charset', $charset,
);
};
ok !$@, "--charset $charset works";
}
for my $charset (qw(latin1 iso-8859-1 utf8 UTF-8 )) {
test_charset($charset);
}
my $warning;
local $SIG{__WARN__} = sub { $warning .= shift };
my $out = output( sub {
$sb->load_file('master', 't/pt-archiver/samples/table1.sql');
pt_archiver::main("-c", "b,c", qw(--where 1=1 --header),
"--source", "D=test,t=table_1,F=$cnf",
'--file', '/tmp/%Y-%m-%d-%D_%H:%i:%s.%t',
'--no-check-charset',
'--charset', "some_charset_that_doesn't_exist",
);
},
);
like($out, qr/\QCannot open :encoding(some_chars/, "..but an unknown charset fails");
like($warning, qr/Cannot find encoding/, "..and throws a useful warning");
# #############################################################################
# Done.
# #############################################################################