--- t/fs.t 2007/07/08 17:03:12 6 +++ t/fs.t 2007/07/08 21:03:26 10 @@ -4,9 +4,10 @@ my $debug = shift @ARGV; -use Test::More tests => 23; +use Test::More tests => 135; +use File::Slurp; -my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm' ); +my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm/comp' ); ok( -e $from, 'from' ); ok( -e $to, 'to' ); @@ -15,7 +16,7 @@ sub file { my ( $op, $path, $content ) = @_; ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )"); - if ( $content ) { + if ( $op =~ m/>/ ) { print $fh $content; } else { local $/; @@ -28,14 +29,29 @@ ok( -e "$from/$path" || -e "$from/${path}.gz", 'on disk' ); + ok( -e "$tmp/$path" , 'in tmp' ) if ( $op =~ m/', 'foo', 'content' ); -cmp_ok( file( '<', 'foo' ), 'eq', 'content', 'check content' ); +my $buff = '<<--just a chunk of data-->>'; + +for my $i ( 1 .. 3 ) { + my $content = $buff x int(3 + $i * rand(15)); + $content =~ s/\s+/ /gs; + + my $file = "test.$i"; + + file( '>', $file, $content ); + cmp_ok( file( '<', $file ), 'eq', $content, "$file content" ); -file( '>>', 'foo', '+more' ); -cmp_ok( file( '<', 'foo' ), 'eq', 'content+more', 'check content' ); + file( '>>', $file, '+append' ); + cmp_ok( file( '<', $file ), 'eq', $content . '+append', "$file append" ); -file( '>', 'foo', 'new' ); -cmp_ok( file( '<', 'foo' ), 'eq', 'new', 'check content' ); + file( '>', $file, '' ); + cmp_ok( file( '<', $file ), 'eq', '', "$file empty" ); + + file( '>', $file, $content ); + cmp_ok( file( '<', $file ), 'eq', $content, "$file content" ); + +}