Changed DA::list to return relative paths.

This commit is contained in:
hjp 2006-11-19 23:31:07 +00:00
parent 6cc428c1c9
commit 0dedd18b8e
2 changed files with 10 additions and 11 deletions

View File

@ -80,6 +80,7 @@ sub list {
my $fh_out = $self->{fh_out};
chdir $path or return;
find({
preprocess
=> sub {
@ -106,7 +107,7 @@ sub list {
},
no_chdir => 1,
},
$path
"."
);
$fh_out->flush();
$self->log(10, "$cmd done");

View File

@ -14,14 +14,14 @@ $da->fh_out($fh);
$da->list('list', 't/root');
close($fh);
ok($list);
cmp_ok($list, '=~', qr{t/root .* t=d }, 'root is a directory');
cmp_ok($list, '=~', qr{t/root/test.txt .* t=f s=14 }, 'text file found');
cmp_ok($list, '=~', qr{t/root/test.bin .* t=f s=1024 }, 'binary file found');
cmp_ok($list, '=~', qr{^\. .* t=d }m, 'root is a directory');
cmp_ok($list, '=~', qr{^\./test.txt .* t=f s=14 }m, 'text file found');
cmp_ok($list, '=~', qr{^\./test.bin .* t=f s=1024 }m, 'binary file found');
my $result;
open($fh, '>', \$result);
$da->fh_out($fh);
$da->get('get', 't/root/test.txt');
$da->get('get', './test.txt');
ok($result, 'get returned something');
my ($header, $content, $trailer);
@ -30,7 +30,7 @@ if ($result =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \z/xs) {
}
ok($header, 'header found');
cmp_ok($header, '=~', qr{t/root/test.txt .* t=f s=14 }, 'text file found');
cmp_ok($header, '=~', qr{./test.txt .* t=f s=14 }, 'text file found');
ok($content, 'content found');
cmp_ok(length($content), '==', 14, 'text file is 14 bytes long');
@ -40,18 +40,16 @@ is($trailer, 'chk sha1 e3b9312f5f7afbe0bfff5c49ab5e9a160b2b04f4', 'trailer conta
open($fh, '>', \$result);
$da->fh_out($fh);
$da->get('get', 't/root/test.bin');
$da->get('get', './test.bin');
($header, $content, $trailer)
= $result =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \z/xs;
ok($header, 'header found');
cmp_ok($header, '=~', qr{t/root/test.bin .* t=f s=1024 }, 'binary file found');
cmp_ok($header, '=~', qr{./test.bin .* t=f s=1024 }, 'binary file found');
ok($content, 'content found');
open($fh, '>:raw', "t/tmp/test.$$.bin");
print $fh $content;
close($fh);
cmp_ok(length($content), '==', 1024, 'binary file is 1024 bytes long');
ok($trailer, 'trailer found');