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