File tree 6 files changed +80
-0
lines changed
6 files changed +80
-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
+ BEGIN {
6
+ use Test::More;
7
+ use Rex::Commands::Run;
8
+
9
+ can_run(' rsync' ) or plan skip_all => ' Could not find rsync command' ;
10
+
11
+ eval ' use Rex::Commands::Rsync; 1'
12
+ or plan skip_all => ' Could not load Rex::Commands::Rsync module' ;
13
+ }
14
+
15
+ use Cwd qw( getcwd) ;
16
+ use File::Find;
17
+ use File::Spec::Functions qw( catfile rel2abs) ;
18
+ use File::Temp qw( tempdir) ;
19
+ use Rex::Task;
20
+
21
+ plan tests => 1;
22
+
23
+ sub setup {
24
+ my $target_dir = tempdir( CLEANUP => 1 );
25
+
26
+ ok( -d $target_dir , " $target_dir is a directory" );
27
+
28
+ opendir ( my $DIR , $target_dir );
29
+ my @contents = readdir $DIR ;
30
+ closedir $DIR ;
31
+
32
+ my @empty = qw( . ..) ;
33
+
34
+ is_deeply( \@contents , \@empty , " $target_dir is empty" );
35
+
36
+ return $target_dir ;
37
+ }
38
+
39
+ sub test_results {
40
+ my $target_dir = shift ;
41
+
42
+ my @expected ;
43
+ find(
44
+ {
45
+ wanted => sub {
46
+ s / t// ;
47
+ push @expected , $_ ;
48
+ },
49
+ no_chdir => 1
50
+ },
51
+ ' t/sync'
52
+ );
53
+
54
+ my @result ;
55
+ find(
56
+ {
57
+ wanted => sub {
58
+ s / $target_dir// ;
59
+ push @result , $_ if length ($_ );
60
+ },
61
+ no_chdir => 1
62
+ },
63
+ $target_dir
64
+ );
65
+
66
+ is_deeply( \@result , \@expected , ' synced dir matches' );
67
+ }
68
+
69
+ subtest ' local rsync' => sub {
70
+ my $target_dir = setup();
71
+ my $cwd = getcwd;
72
+
73
+ my $task = Rex::Task-> new( name => ' local_rsync' );
74
+ isa_ok( $task , ' Rex::Task' , ' create task object' );
75
+
76
+ sync catfile( $cwd , ' t/sync' ), $target_dir ;
77
+
78
+ test_results($target_dir );
79
+ };
You can’t perform that action at this time.
0 commit comments