diff --git a/lib/Simba/DA.pm b/lib/Simba/DA.pm index dbde8ca..2d1efda 100644 --- a/lib/Simba/DA.pm +++ b/lib/Simba/DA.pm @@ -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"); diff --git a/t/00_da.t b/t/00_da.t index 23ad78e..f2dc581 100644 --- a/t/00_da.t +++ b/t/00_da.t @@ -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');