Changed DA::list to return relative paths.
This commit is contained in:
parent
6cc428c1c9
commit
0dedd18b8e
|
@ -80,6 +80,7 @@ sub list {
|
||||||
|
|
||||||
my $fh_out = $self->{fh_out};
|
my $fh_out = $self->{fh_out};
|
||||||
|
|
||||||
|
chdir $path or return;
|
||||||
find({
|
find({
|
||||||
preprocess
|
preprocess
|
||||||
=> sub {
|
=> sub {
|
||||||
|
@ -106,7 +107,7 @@ sub list {
|
||||||
},
|
},
|
||||||
no_chdir => 1,
|
no_chdir => 1,
|
||||||
},
|
},
|
||||||
$path
|
"."
|
||||||
);
|
);
|
||||||
$fh_out->flush();
|
$fh_out->flush();
|
||||||
$self->log(10, "$cmd done");
|
$self->log(10, "$cmd done");
|
||||||
|
|
18
t/00_da.t
18
t/00_da.t
|
@ -14,14 +14,14 @@ $da->fh_out($fh);
|
||||||
$da->list('list', 't/root');
|
$da->list('list', 't/root');
|
||||||
close($fh);
|
close($fh);
|
||||||
ok($list);
|
ok($list);
|
||||||
cmp_ok($list, '=~', qr{t/root .* t=d }, 'root is a directory');
|
cmp_ok($list, '=~', qr{^\. .* t=d }m, 'root is a directory');
|
||||||
cmp_ok($list, '=~', qr{t/root/test.txt .* t=f s=14 }, 'text file found');
|
cmp_ok($list, '=~', qr{^\./test.txt .* t=f s=14 }m, 'text file found');
|
||||||
cmp_ok($list, '=~', qr{t/root/test.bin .* t=f s=1024 }, 'binary file found');
|
cmp_ok($list, '=~', qr{^\./test.bin .* t=f s=1024 }m, 'binary file found');
|
||||||
|
|
||||||
my $result;
|
my $result;
|
||||||
open($fh, '>', \$result);
|
open($fh, '>', \$result);
|
||||||
$da->fh_out($fh);
|
$da->fh_out($fh);
|
||||||
$da->get('get', 't/root/test.txt');
|
$da->get('get', './test.txt');
|
||||||
ok($result, 'get returned something');
|
ok($result, 'get returned something');
|
||||||
|
|
||||||
my ($header, $content, $trailer);
|
my ($header, $content, $trailer);
|
||||||
|
@ -30,7 +30,7 @@ if ($result =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \z/xs) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ok($header, 'header found');
|
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');
|
ok($content, 'content found');
|
||||||
cmp_ok(length($content), '==', 14, 'text file is 14 bytes long');
|
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);
|
open($fh, '>', \$result);
|
||||||
$da->fh_out($fh);
|
$da->fh_out($fh);
|
||||||
$da->get('get', 't/root/test.bin');
|
$da->get('get', './test.bin');
|
||||||
|
|
||||||
($header, $content, $trailer)
|
($header, $content, $trailer)
|
||||||
= $result =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \z/xs;
|
= $result =~ /\A ([^\n]*) \n (.*) \n ([^\n]*) \n \z/xs;
|
||||||
|
|
||||||
ok($header, 'header found');
|
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');
|
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');
|
cmp_ok(length($content), '==', 1024, 'binary file is 1024 bytes long');
|
||||||
|
|
||||||
ok($trailer, 'trailer found');
|
ok($trailer, 'trailer found');
|
||||||
|
|
Loading…
Reference in New Issue