From a52a6869f9570af76046aa2feca1215da02f2b26 Mon Sep 17 00:00:00 2001 From: hjp Date: Mon, 2 Oct 2006 12:18:30 +0000 Subject: [PATCH] Added Build.PL Added some testcases for DA::list and DA::get --- Build.PL | 12 ++++++++++++ lib/Simba/DA.pm | 4 ++++ t/00_da.t | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ t/root/test.bin | Bin 0 -> 1024 bytes t/root/test.txt | 3 +++ 5 files changed, 68 insertions(+) create mode 100644 Build.PL create mode 100644 t/00_da.t create mode 100644 t/root/test.bin create mode 100644 t/root/test.txt diff --git a/Build.PL b/Build.PL new file mode 100644 index 0000000..10dd602 --- /dev/null +++ b/Build.PL @@ -0,0 +1,12 @@ +use Module::Build; +my $build = Module::Build->new + ( + module_name => 'Simba', + license => 'perl', + requires => { + }, + script_files => [ + 'da', + ], + ); +$build->create_build_script; diff --git a/lib/Simba/DA.pm b/lib/Simba/DA.pm index 5fd7bed..b43f52b 100644 --- a/lib/Simba/DA.pm +++ b/lib/Simba/DA.pm @@ -82,6 +82,8 @@ sub list { $fn = quote($fn); print $fn; + print metastr($fn, $st); + print "\n"; }, no_chdir => 1, @@ -178,6 +180,8 @@ sub metastr { $s .= " " . 'setgid=1' if $mode & 02000; $s .= " " . 'sticky=1' if $mode & 01000; $s .= " " . 'rdev=' . $st->rdev if ($mode & 0120000) == 0020000; + + return $s; } 1; diff --git a/t/00_da.t b/t/00_da.t new file mode 100644 index 0000000..72a3184 --- /dev/null +++ b/t/00_da.t @@ -0,0 +1,49 @@ +#!/usr/bin/perl +use warnings; +use strict; + +use Test::More 'no_plan'; + +BEGIN { use_ok( 'Simba::DA' ); } + +my $da = Simba::DA->new(); +ok($da, 'new DA'); +my $list; +open(my $fh, '>', \$list); +select $fh; +$da->list('list', 't/root'); +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'); + +my $content; +open($fh, '>', \$content); +select $fh; +$da->get('get', 't/root/test.txt'); +my ($header, $trailer); +($header, $content, $trailer) + = $content =~ /\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'); + +ok($content, 'content found'); +cmp_ok($header, '==', 14, 'text file is 14 bytes long'); + +ok($trailer, 'trailer found'); +is($trailer, 'chk sha1 e3b9312f5f7afbe0bfff5c49ab5e9a160b2b04f4', 'trailer contains correct checksum'); + +$content=""; +$da->get('get', 't/root/test.txt'); +($header, $content, $trailer) + = $content =~ /\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'); + +ok($content, 'content found'); +cmp_ok($header, '==', 1024, 'binary file is 1024 bytes long'); + +ok($trailer, 'trailer found'); +is($trailer, 'chk sha1 97253f25fc3945cd6293e3dfad2a322041b14164', 'trailer contains correct checksum'); diff --git a/t/root/test.bin b/t/root/test.bin new file mode 100644 index 0000000000000000000000000000000000000000..c81b942b3fe6c2bd2f52d391149c7be0a34f03fc GIT binary patch literal 1024 zcmV+b1poV>k~9=A)LK}!Xt+#;mefI9VyLn2zX!tn0XMXfX zk0~v}{5b!UX!QfR{K++uEbR`uB&&?@R=)`RRo^-BjTMofyP`7iq^PoH|7L75RKoUR zE76^GG&(-%wPIqLa+VQGJ*Tb)cYp)B{YDb1tF>HvdD5g*tGh7K+<~4-E@)-{k}-k^ zYj(T-lZ^tj)6BN9I;PNyq`wvp*BAO!KBavdP`be-e{_V0mM}0!Q;dlf^=JDeSwH91 z4(5A49o4@^4#;K@-o0KrcvcA_jqY4}01-e~?I-*VGBq~J1Y<+0bIdeEKQH-qQ~Ah#7Yvd8|jI4Xgnb@_cXUD*r!hcQ+1{d#TR- z3&T=w$F%!ZwN9JYFs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