-
Notifications
You must be signed in to change notification settings - Fork 222
/
needs.t
executable file
·134 lines (94 loc) · 1.72 KB
/
needs.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/usr/bin/env perl
use v5.12.5;
use warnings;
our $VERSION = '9999.99.99_99'; # VERSION
use Test::More;
use Rex::Commands;
{
package MyTest;
use warnings;
use Rex::Commands;
$::QUIET = 1;
task "test1", sub {
open( my $fh, ">", "test1.txt" );
close($fh);
};
task "test2", sub {
open( my $fh, ">", "test2.txt" );
close($fh);
};
1;
}
{
package Nested::Module;
use warnings;
use Rex::Commands;
task "test", sub {
open( my $fh, ">", "test.txt" );
close($fh);
};
}
{
package Rex::Module;
use warnings;
use Rex::Commands;
task "test", sub {
open( my $fh, ">", "test.txt" );
close($fh);
};
}
task "test", sub {
needs MyTest;
if ( -f "test1.txt" && -f "test2.txt" ) {
unlink("test1.txt");
unlink("test2.txt");
return 1;
}
die;
};
task "test2", sub {
needs MyTest "test2";
if ( -f "test2.txt" ) {
unlink("test2.txt");
return 1;
}
die;
};
task "test3", sub {
needs("test4");
if ( -f "test4.txt" ) {
unlink("test4.txt");
return 1;
}
die;
};
task "test4", sub {
open( my $fh, ">", "test4.txt" );
close($fh);
};
task "test5", sub {
needs Nested::Module "test";
if ( -f "test.txt" ) {
unlink("test.txt");
return 1;
}
die;
};
task "test6", sub {
needs Rex::Module "test";
if ( -f "test.txt" ) {
unlink("test.txt");
return 1;
}
die;
};
my $task_list = Rex::TaskList->create;
my $run_list = Rex::RunList->instance;
$run_list->parse_opts(qw/test test2 test3 test5 test6/);
for my $task ( $run_list->tasks ) {
$task_list->run($task);
my @summary = $task_list->get_summary;
is_deeply $summary[-1]->{exit_code}, 0, $task->name;
$run_list->increment_current_index;
}
done_testing;