tsh/test learn the cmp() function to make full output compares easier

This commit is contained in:
Sitaram Chamarty 2012-03-15 10:40:27 +05:30
parent fb332a6c76
commit 446bd19de7
2 changed files with 16 additions and 1 deletions

View file

@ -11,6 +11,7 @@ package Gitolite::Test;
dump
confreset
confadd
cmp
);
#>>>
use Exporter 'import';
@ -24,6 +25,7 @@ BEGIN {
*{'try'} = \&Tsh::try;
*{'put'} = \&Tsh::put;
*{'text'} = \&Tsh::text;
*{'cmp'} = \&Tsh::cmp;
}
use strict;

View file

@ -17,7 +17,7 @@ package Tsh;
use Exporter 'import';
@EXPORT = qw(
try run AUTOLOAD
try run cmp AUTOLOAD
rc error_count text lines error_list put
cd tsh_tempdir
@ -470,6 +470,19 @@ sub fail {
exit( $rc || 74 );
}
sub cmp {
# compare input string with text()
my $text = text();
my $in = shift;
if ($text eq $in) {
ok();
} else {
fail('cmp failed', '');
dbg(4, "\n\ntext = <<<$text>>>, in = <<<$in>>>\n\n");
}
}
sub expect {
my ( $patt, $msg ) = @_;
$msg =~ s/^\s+// if $msg;