File tree 6 files changed +71
-0
lines changed
6 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ Revision history for Rex
23
23
[REVISION]
24
24
- Use author tests to check tidiness of bin files
25
25
- Use Symbol to manipulate Perl symbols
26
+ - Add initial rsync tests
26
27
27
28
1.11.0 2020-06-05 Ferenc Erki <
[email protected] >
28
29
[BUG FIXES]
Original file line number Diff line number Diff line change
1
+ use strict;
2
+ use warnings;
3
+ use autodie;
4
+
5
+ use Cwd qw( getcwd) ;
6
+ use File::Find;
7
+ use File::Spec::Functions qw( catfile rel2abs) ;
8
+ use File::Temp qw( tempdir) ;
9
+ use Test::More tests => 1;
10
+
11
+ use Rex::Commands::Rsync;
12
+ use Rex::Task;
13
+
14
+ sub setup {
15
+ my $target_dir = tempdir( CLEANUP => 1 );
16
+
17
+ ok( -d $target_dir , " $target_dir is a directory" );
18
+
19
+ opendir ( my $DIR , $target_dir );
20
+ my @contents = readdir $DIR ;
21
+ closedir $DIR ;
22
+
23
+ my @empty = qw( . ..) ;
24
+
25
+ is_deeply( \@contents , \@empty , " $target_dir is empty" );
26
+
27
+ return $target_dir ;
28
+ }
29
+
30
+ sub test_results {
31
+ my $target_dir = shift ;
32
+
33
+ my @expected ;
34
+ find(
35
+ {
36
+ wanted => sub {
37
+ s / t// ;
38
+ push @expected , $_ ;
39
+ },
40
+ no_chdir => 1
41
+ },
42
+ ' t/sync'
43
+ );
44
+
45
+ my @result ;
46
+ find(
47
+ {
48
+ wanted => sub {
49
+ s / $target_dir// ;
50
+ push @result , $_ if length ($_ );
51
+ },
52
+ no_chdir => 1
53
+ },
54
+ $target_dir
55
+ );
56
+
57
+ is_deeply( \@result , \@expected , ' synced dir matches' );
58
+ }
59
+
60
+ subtest ' local rsync' => sub {
61
+ my $target_dir = setup();
62
+ my $cwd = getcwd;
63
+
64
+ my $task = Rex::Task-> new( name => ' local_rsync' );
65
+ isa_ok( $task , ' Rex::Task' , ' create task object' );
66
+
67
+ sync catfile( $cwd , ' t/sync' ), $target_dir ;
68
+
69
+ test_results($target_dir );
70
+ };
You can’t perform that action at this time.
0 commit comments