whenever 0.9.2 → 0.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +0 -5
- data/README.md +3 -1
- data/lib/whenever.rb +10 -11
- data/lib/whenever/capistrano/v3/tasks/whenever.rake +2 -2
- data/lib/whenever/command_line.rb +9 -9
- data/lib/whenever/cron.rb +11 -11
- data/lib/whenever/job.rb +2 -2
- data/lib/whenever/job_list.rb +18 -7
- data/lib/whenever/numeric_seconds.rb +54 -0
- data/lib/whenever/tasks/whenever.rake +2 -2
- data/lib/whenever/version.rb +1 -1
- data/test/functional/command_line_test.rb +221 -224
- data/test/functional/output_at_test.rb +188 -249
- data/test/functional/output_default_defined_jobs_test.rb +214 -290
- data/test/functional/output_defined_job_test.rb +65 -91
- data/test/functional/output_env_test.rb +22 -26
- data/test/functional/output_jobs_for_roles_test.rb +46 -66
- data/test/functional/output_redirection_test.rb +231 -309
- data/test/test_case.rb +39 -0
- data/test/test_helper.rb +33 -14
- data/test/unit/capistrano_support_test.rb +126 -148
- data/test/unit/cron_test.rb +188 -215
- data/test/unit/job_test.rb +111 -121
- data/whenever.gemspec +0 -2
- metadata +15 -41
@@ -1,268 +1,207 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
class OutputAtTest <
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
should "output the command using that time" do
|
17
|
-
assert_match '2 5 * * 1-5 blahblah', @output
|
18
|
-
end
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class OutputAtTest < Whenever::TestCase
|
4
|
+
test "weekday at a (single) given time" do
|
5
|
+
output = Whenever.cron \
|
6
|
+
<<-file
|
7
|
+
set :job_template, nil
|
8
|
+
every "weekday", :at => '5:02am' do
|
9
|
+
command "blahblah"
|
10
|
+
end
|
11
|
+
file
|
12
|
+
|
13
|
+
assert_match '2 5 * * 1-5 blahblah', output
|
19
14
|
end
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
should "output the commands for both times given" do
|
33
|
-
assert_match '2 5 * * 1-5 blahblah', @output
|
34
|
-
assert_match '52 15 * * 1-5 blahblah', @output
|
35
|
-
end
|
15
|
+
|
16
|
+
test "weekday at a multiple diverse times, via an array" do
|
17
|
+
output = Whenever.cron \
|
18
|
+
<<-file
|
19
|
+
set :job_template, nil
|
20
|
+
every "weekday", :at => %w(5:02am 3:52pm) do
|
21
|
+
command "blahblah"
|
22
|
+
end
|
23
|
+
file
|
24
|
+
|
25
|
+
assert_match '2 5 * * 1-5 blahblah', output
|
26
|
+
assert_match '52 15 * * 1-5 blahblah', output
|
36
27
|
end
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
should "output the commands for both times given" do
|
50
|
-
assert_match '2 5 * * 1-5 blahblah', @output
|
51
|
-
assert_match '52 15 * * 1-5 blahblah', @output
|
52
|
-
end
|
28
|
+
|
29
|
+
test "weekday at a multiple diverse times, comma separated" do
|
30
|
+
output = Whenever.cron \
|
31
|
+
<<-file
|
32
|
+
set :job_template, nil
|
33
|
+
every "weekday", :at => '5:02am, 3:52pm' do
|
34
|
+
command "blahblah"
|
35
|
+
end
|
36
|
+
file
|
37
|
+
|
38
|
+
assert_match '2 5 * * 1-5 blahblah', output
|
39
|
+
assert_match '52 15 * * 1-5 blahblah', output
|
53
40
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
should "output the command using one entry because the times are aligned" do
|
67
|
-
assert_match '2 5,15 * * 1-5 blahblah', @output
|
68
|
-
end
|
41
|
+
|
42
|
+
test "weekday at a multiple aligned times" do
|
43
|
+
output = Whenever.cron \
|
44
|
+
<<-file
|
45
|
+
set :job_template, nil
|
46
|
+
every "weekday", :at => '5:02am, 3:02pm' do
|
47
|
+
command "blahblah"
|
48
|
+
end
|
49
|
+
file
|
50
|
+
|
51
|
+
assert_match '2 5,15 * * 1-5 blahblah', output
|
69
52
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
should "output the command using one entry because the times are aligned" do
|
83
|
-
assert_match '2 5,15 * * 1,3,5 blahblah', @output
|
84
|
-
end
|
53
|
+
|
54
|
+
test "various days at a various aligned times" do
|
55
|
+
output = Whenever.cron \
|
56
|
+
<<-file
|
57
|
+
set :job_template, nil
|
58
|
+
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
59
|
+
command "blahblah"
|
60
|
+
end
|
61
|
+
file
|
62
|
+
|
63
|
+
assert_match '2 5,15 * * 1,3,5 blahblah', output
|
85
64
|
end
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
should "output the runner using one entry because the times are aligned" do
|
100
|
-
assert_match %(2 5,15 * * 1,3,5 cd /your/path && script/runner -e production 'blahblah'), @output
|
101
|
-
end
|
65
|
+
|
66
|
+
test "various days at a various aligned times using a runner" do
|
67
|
+
output = Whenever.cron \
|
68
|
+
<<-file
|
69
|
+
set :job_template, nil
|
70
|
+
set :path, '/your/path'
|
71
|
+
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
72
|
+
runner "blahblah"
|
73
|
+
end
|
74
|
+
file
|
75
|
+
|
76
|
+
assert_match %(2 5,15 * * 1,3,5 cd /your/path && script/runner -e production 'blahblah'), output
|
102
77
|
end
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
should "output the rake task using one entry because the times are aligned" do
|
117
|
-
assert_match '2 5,15 * * 1,3,5 cd /your/path && RAILS_ENV=production bundle exec rake blah:blah --silent', @output
|
118
|
-
end
|
78
|
+
|
79
|
+
test "various days at a various aligned times using a rake task" do
|
80
|
+
output = Whenever.cron \
|
81
|
+
<<-file
|
82
|
+
set :job_template, nil
|
83
|
+
set :path, '/your/path'
|
84
|
+
every "mon,wed,fri", :at => '5:02am, 3:02pm' do
|
85
|
+
rake "blah:blah"
|
86
|
+
end
|
87
|
+
file
|
88
|
+
|
89
|
+
assert_match '2 5,15 * * 1,3,5 cd /your/path && RAILS_ENV=production bundle exec rake blah:blah --silent', output
|
119
90
|
end
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
assert_match '2 5 * * * blahblah', @output
|
140
|
-
assert_match '22 14 * * * blahblah', @output
|
141
|
-
assert_match '33 3 * * * blahblah', @output
|
142
|
-
end
|
91
|
+
|
92
|
+
test "A command every 1.month at very diverse times" do
|
93
|
+
output = Whenever.cron \
|
94
|
+
<<-file
|
95
|
+
set :job_template, nil
|
96
|
+
every [1.month, 1.day], :at => 'january 5:02am, june 17th at 2:22pm, june 3rd at 3:33am' do
|
97
|
+
command "blahblah"
|
98
|
+
end
|
99
|
+
file
|
100
|
+
|
101
|
+
# The 1.month commands
|
102
|
+
assert_match '2 5 1 * * blahblah', output
|
103
|
+
assert_match '22 14 17 * * blahblah', output
|
104
|
+
assert_match '33 3 3 * * blahblah', output
|
105
|
+
|
106
|
+
# The 1.day commands
|
107
|
+
assert_match '2 5 * * * blahblah', output
|
108
|
+
assert_match '22 14 * * * blahblah', output
|
109
|
+
assert_match '33 3 * * * blahblah', output
|
143
110
|
end
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
should "output both commands @reboot" do
|
158
|
-
assert_match "@reboot command_1", @output
|
159
|
-
assert_match "@reboot command_2", @output
|
160
|
-
end
|
111
|
+
|
112
|
+
test "Multiple commands output every :reboot" do
|
113
|
+
output = Whenever.cron \
|
114
|
+
<<-file
|
115
|
+
set :job_template, nil
|
116
|
+
every :reboot do
|
117
|
+
command "command_1"
|
118
|
+
command "command_2"
|
119
|
+
end
|
120
|
+
file
|
121
|
+
|
122
|
+
assert_match "@reboot command_1", output
|
123
|
+
assert_match "@reboot command_2", output
|
161
124
|
end
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
assert_match '@daily command_1', @output
|
183
|
-
assert_match %(@daily cd /your/path && script/runner -e production 'runner_2'), @output
|
184
|
-
assert_match '@daily command_2', @output
|
185
|
-
end
|
125
|
+
|
126
|
+
test "Many different job types output every :day" do
|
127
|
+
output = Whenever.cron \
|
128
|
+
<<-file
|
129
|
+
set :job_template, nil
|
130
|
+
set :path, '/your/path'
|
131
|
+
every :daily do
|
132
|
+
rake "blah:blah"
|
133
|
+
runner "runner_1"
|
134
|
+
command "command_1"
|
135
|
+
runner "runner_2"
|
136
|
+
command "command_2"
|
137
|
+
end
|
138
|
+
file
|
139
|
+
|
140
|
+
assert_match '@daily cd /your/path && RAILS_ENV=production bundle exec rake blah:blah --silent', output
|
141
|
+
assert_match %(@daily cd /your/path && script/runner -e production 'runner_1'), output
|
142
|
+
assert_match '@daily command_1', output
|
143
|
+
assert_match %(@daily cd /your/path && script/runner -e production 'runner_2'), output
|
144
|
+
assert_match '@daily command_2', output
|
186
145
|
end
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
should "output the command using that time" do
|
200
|
-
assert_match '1,6,11,16,21,26,31,36,41,46,51,56 * * * * blahblah', @output
|
201
|
-
end
|
146
|
+
|
147
|
+
test "every 5 minutes but but starting at 1" do
|
148
|
+
output = Whenever.cron \
|
149
|
+
<<-file
|
150
|
+
set :job_template, nil
|
151
|
+
every 5.minutes, :at => 1 do
|
152
|
+
command "blahblah"
|
153
|
+
end
|
154
|
+
file
|
155
|
+
|
156
|
+
assert_match '1,6,11,16,21,26,31,36,41,46,51,56 * * * * blahblah', output
|
202
157
|
end
|
203
158
|
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
should "output the command using that time" do
|
216
|
-
assert_match '2,6,10,14,18,22,26,30,34,38,42,46,50,54,58 * * * * blahblah', @output
|
217
|
-
end
|
159
|
+
test "every 4 minutes but starting at 2" do
|
160
|
+
output = Whenever.cron \
|
161
|
+
<<-file
|
162
|
+
set :job_template, nil
|
163
|
+
every 4.minutes, :at => 2 do
|
164
|
+
command "blahblah"
|
165
|
+
end
|
166
|
+
file
|
167
|
+
|
168
|
+
assert_match '2,6,10,14,18,22,26,30,34,38,42,46,50,54,58 * * * * blahblah', output
|
218
169
|
end
|
219
170
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
should "output the command using that time" do
|
232
|
-
assert_match '7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * blahblah', @output
|
233
|
-
end
|
171
|
+
test "every 3 minutes but starting at 7" do
|
172
|
+
output = Whenever.cron \
|
173
|
+
<<-file
|
174
|
+
set :job_template, nil
|
175
|
+
every 3.minutes, :at => 7 do
|
176
|
+
command "blahblah"
|
177
|
+
end
|
178
|
+
file
|
179
|
+
|
180
|
+
|
181
|
+
assert_match '7,10,13,16,19,22,25,28,31,34,37,40,43,46,49,52,55,58 * * * * blahblah', output
|
234
182
|
end
|
235
183
|
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
should "output the command using that time" do
|
248
|
-
assert_match '27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * blahblah', @output
|
249
|
-
end
|
184
|
+
test "every 2 minutes but starting at 27" do
|
185
|
+
output = Whenever.cron \
|
186
|
+
<<-file
|
187
|
+
set :job_template, nil
|
188
|
+
every 2.minutes, :at => 27 do
|
189
|
+
command "blahblah"
|
190
|
+
end
|
191
|
+
file
|
192
|
+
|
193
|
+
assert_match '27,29,31,33,35,37,39,41,43,45,47,49,51,53,55,57,59 * * * * blahblah', output
|
250
194
|
end
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
should "output the command using the same cron syntax" do
|
264
|
-
assert_match '0 0 27,31 * * blahblah', @output
|
265
|
-
end
|
195
|
+
|
196
|
+
test "using raw cron syntax" do
|
197
|
+
output = Whenever.cron \
|
198
|
+
<<-file
|
199
|
+
set :job_template, nil
|
200
|
+
every '0 0 27,31 * *' do
|
201
|
+
command "blahblah"
|
202
|
+
end
|
203
|
+
file
|
204
|
+
|
205
|
+
assert_match '0 0 27,31 * * blahblah', output
|
266
206
|
end
|
267
|
-
|
268
207
|
end
|