1 |
dpavlin |
6 |
#!/usr/bin/perl |
2 |
|
|
use strict; |
3 |
|
|
use warnings; |
4 |
|
|
|
5 |
|
|
my $debug = shift @ARGV; |
6 |
|
|
|
7 |
|
|
use Test::More tests => 23; |
8 |
|
|
|
9 |
|
|
my ( $from, $to, $tmp ) = ( '/tmp/comp', '/tmp/no-comp', '/dev/shm' ); |
10 |
|
|
|
11 |
|
|
ok( -e $from, 'from' ); |
12 |
|
|
ok( -e $to, 'to' ); |
13 |
|
|
ok( -e $tmp, 'tmp' ); |
14 |
|
|
|
15 |
|
|
sub file { |
16 |
|
|
my ( $op, $path, $content ) = @_; |
17 |
|
|
ok( open( my $fh, $op, "$to/$path" ), "open( $op $path )"); |
18 |
|
|
if ( $content ) { |
19 |
|
|
print $fh $content; |
20 |
|
|
} else { |
21 |
|
|
local $/; |
22 |
|
|
$content = <$fh>; |
23 |
|
|
ok( $content, 'has content' ); |
24 |
|
|
} |
25 |
|
|
ok( close($fh), 'close' ); |
26 |
|
|
|
27 |
|
|
ok ( -e "$to/$path", 'exists' ); |
28 |
|
|
|
29 |
|
|
ok( -e "$from/$path" || -e "$from/${path}.gz", 'on disk' ); |
30 |
|
|
|
31 |
|
|
return $content; |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
file( '>', 'foo', 'content' ); |
35 |
|
|
cmp_ok( file( '<', 'foo' ), 'eq', 'content', 'check content' ); |
36 |
|
|
|
37 |
|
|
file( '>>', 'foo', '+more' ); |
38 |
|
|
cmp_ok( file( '<', 'foo' ), 'eq', 'content+more', 'check content' ); |
39 |
|
|
|
40 |
|
|
file( '>', 'foo', 'new' ); |
41 |
|
|
cmp_ok( file( '<', 'foo' ), 'eq', 'new', 'check content' ); |