tsh/test learn the cmp() function to make full output compares easier
This commit is contained in:
parent
fb332a6c76
commit
446bd19de7
|
@ -11,6 +11,7 @@ package Gitolite::Test;
|
||||||
dump
|
dump
|
||||||
confreset
|
confreset
|
||||||
confadd
|
confadd
|
||||||
|
cmp
|
||||||
);
|
);
|
||||||
#>>>
|
#>>>
|
||||||
use Exporter 'import';
|
use Exporter 'import';
|
||||||
|
@ -24,6 +25,7 @@ BEGIN {
|
||||||
*{'try'} = \&Tsh::try;
|
*{'try'} = \&Tsh::try;
|
||||||
*{'put'} = \&Tsh::put;
|
*{'put'} = \&Tsh::put;
|
||||||
*{'text'} = \&Tsh::text;
|
*{'text'} = \&Tsh::text;
|
||||||
|
*{'cmp'} = \&Tsh::cmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
|
|
@ -17,7 +17,7 @@ package Tsh;
|
||||||
|
|
||||||
use Exporter 'import';
|
use Exporter 'import';
|
||||||
@EXPORT = qw(
|
@EXPORT = qw(
|
||||||
try run AUTOLOAD
|
try run cmp AUTOLOAD
|
||||||
rc error_count text lines error_list put
|
rc error_count text lines error_list put
|
||||||
cd tsh_tempdir
|
cd tsh_tempdir
|
||||||
|
|
||||||
|
@ -470,6 +470,19 @@ sub fail {
|
||||||
exit( $rc || 74 );
|
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 {
|
sub expect {
|
||||||
my ( $patt, $msg ) = @_;
|
my ( $patt, $msg ) = @_;
|
||||||
$msg =~ s/^\s+// if $msg;
|
$msg =~ s/^\s+// if $msg;
|
||||||
|
|
Loading…
Reference in a new issue