seisuke-whenever 0.6.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.
- data/CHANGELOG.md +142 -0
- data/README.md +139 -0
- data/Rakefile +35 -0
- data/bin/whenever +38 -0
- data/bin/wheneverize +69 -0
- data/lib/whenever.rb +21 -0
- data/lib/whenever/capistrano.rb +31 -0
- data/lib/whenever/command_line.rb +125 -0
- data/lib/whenever/cron.rb +132 -0
- data/lib/whenever/job.rb +47 -0
- data/lib/whenever/job_list.rb +156 -0
- data/lib/whenever/output_redirection.rb +58 -0
- data/lib/whenever/setup.rb +18 -0
- data/lib/whenever/version.rb +3 -0
- data/test/functional/command_line_test.rb +310 -0
- data/test/functional/output_at_test.rb +251 -0
- data/test/functional/output_default_defined_jobs_test.rb +164 -0
- data/test/functional/output_defined_job_test.rb +111 -0
- data/test/functional/output_env_test.rb +23 -0
- data/test/functional/output_redirection_test.rb +307 -0
- data/test/test_helper.rb +20 -0
- data/test/unit/cron_test.rb +226 -0
- data/test/unit/job_test.rb +77 -0
- data/whenever.gemspec +83 -0
- metadata +162 -0
@@ -0,0 +1,164 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
|
3
|
+
class OutputDefaultDefinedJobsTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
# command
|
6
|
+
|
7
|
+
context "A plain command with the job template set to nil" do
|
8
|
+
setup do
|
9
|
+
@output = Whenever.cron \
|
10
|
+
<<-file
|
11
|
+
set :job_template, nil
|
12
|
+
every 2.hours do
|
13
|
+
command "blahblah"
|
14
|
+
end
|
15
|
+
file
|
16
|
+
end
|
17
|
+
|
18
|
+
should "output the command" do
|
19
|
+
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "A plain command with no job template set" do
|
24
|
+
setup do
|
25
|
+
@output = Whenever.cron \
|
26
|
+
<<-file
|
27
|
+
every 2.hours do
|
28
|
+
command "blahblah"
|
29
|
+
end
|
30
|
+
file
|
31
|
+
end
|
32
|
+
|
33
|
+
should "output the command with the default job template" do
|
34
|
+
assert_match /^.+ .+ .+ .+ \/bin\/bash -l -c 'blahblah'$/, @output
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "A plain command that overrides the job_template set" do
|
39
|
+
setup do
|
40
|
+
@output = Whenever.cron \
|
41
|
+
<<-file
|
42
|
+
set :job_template, "/bin/bash -l -c ':job'"
|
43
|
+
every 2.hours do
|
44
|
+
command "blahblah", :job_template => "/bin/sh -l -c ':job'"
|
45
|
+
end
|
46
|
+
file
|
47
|
+
end
|
48
|
+
|
49
|
+
should "output the command using that job_template" do
|
50
|
+
assert_match /^.+ .+ .+ .+ \/bin\/sh -l -c 'blahblah'$/, @output
|
51
|
+
assert_no_match /bash/, @output
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context "A plain command that is conditional on default environent and path" do
|
56
|
+
setup do
|
57
|
+
Whenever.expects(:path).at_least_once.returns('/what/you/want')
|
58
|
+
@output = Whenever.cron \
|
59
|
+
<<-file
|
60
|
+
set :job_template, nil
|
61
|
+
if environment == 'production' && path == '/what/you/want'
|
62
|
+
every 2.hours do
|
63
|
+
command "blahblah"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
file
|
67
|
+
end
|
68
|
+
|
69
|
+
should "output the command" do
|
70
|
+
assert_match /blahblah/, @output
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# runner
|
75
|
+
|
76
|
+
context "A runner with path set" do
|
77
|
+
setup do
|
78
|
+
@output = Whenever.cron \
|
79
|
+
<<-file
|
80
|
+
set :job_template, nil
|
81
|
+
set :path, '/my/path'
|
82
|
+
every 2.hours do
|
83
|
+
runner 'blahblah'
|
84
|
+
end
|
85
|
+
file
|
86
|
+
end
|
87
|
+
|
88
|
+
should "output the runner using that path" do
|
89
|
+
assert_match two_hours + %( cd /my/path && script/runner -e production 'blahblah'), @output
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
context "A runner that overrides the path set" do
|
94
|
+
setup do
|
95
|
+
@output = Whenever.cron \
|
96
|
+
<<-file
|
97
|
+
set :job_template, nil
|
98
|
+
set :path, '/my/path'
|
99
|
+
every 2.hours do
|
100
|
+
runner "blahblah", :path => '/some/other/path'
|
101
|
+
end
|
102
|
+
file
|
103
|
+
end
|
104
|
+
|
105
|
+
should "output the runner using that path" do
|
106
|
+
assert_match two_hours + %( cd /some/other/path && script/runner -e production 'blahblah'), @output
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "A runner for a Rails 3 app" do
|
111
|
+
setup do
|
112
|
+
Whenever.expects(:path).at_least_once.returns('/my/path')
|
113
|
+
File.expects(:exists?).with('/my/path/script/rails').returns(true)
|
114
|
+
@output = Whenever.cron \
|
115
|
+
<<-file
|
116
|
+
set :job_template, nil
|
117
|
+
every 2.hours do
|
118
|
+
runner 'blahblah'
|
119
|
+
end
|
120
|
+
file
|
121
|
+
end
|
122
|
+
|
123
|
+
should "use the Rails 3 runner job by default" do
|
124
|
+
assert_match two_hours + %( cd /my/path && script/rails runner -e production 'blahblah'), @output
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
# rake
|
129
|
+
|
130
|
+
context "A rake command with path set" do
|
131
|
+
setup do
|
132
|
+
@output = Whenever.cron \
|
133
|
+
<<-file
|
134
|
+
set :job_template, nil
|
135
|
+
set :path, '/my/path'
|
136
|
+
every 2.hours do
|
137
|
+
rake "blahblah"
|
138
|
+
end
|
139
|
+
file
|
140
|
+
end
|
141
|
+
|
142
|
+
should "output the rake command using that path" do
|
143
|
+
assert_match two_hours + ' cd /my/path && RAILS_ENV=production rake blahblah --silent', @output
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
context "A rake command that overrides the path set" do
|
148
|
+
setup do
|
149
|
+
@output = Whenever.cron \
|
150
|
+
<<-file
|
151
|
+
set :job_template, nil
|
152
|
+
set :path, '/my/path'
|
153
|
+
every 2.hours do
|
154
|
+
rake "blahblah", :path => '/some/other/path'
|
155
|
+
end
|
156
|
+
file
|
157
|
+
end
|
158
|
+
|
159
|
+
should "output the rake command using that path" do
|
160
|
+
assert_match two_hours + ' cd /some/other/path && RAILS_ENV=production rake blahblah --silent', @output
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
|
3
|
+
class OutputDefinedJobTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A defined job with a :task" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
set :job_template, nil
|
10
|
+
job_type :some_job, "before :task after"
|
11
|
+
every 2.hours do
|
12
|
+
some_job "during"
|
13
|
+
end
|
14
|
+
file
|
15
|
+
end
|
16
|
+
|
17
|
+
should "output the defined job with the task" do
|
18
|
+
assert_match /^.+ .+ .+ .+ before during after$/, @output
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context "A defined job with a :task and some options" do
|
23
|
+
setup do
|
24
|
+
@output = Whenever.cron \
|
25
|
+
<<-file
|
26
|
+
set :job_template, nil
|
27
|
+
job_type :some_job, "before :task after :option1 :option2"
|
28
|
+
every 2.hours do
|
29
|
+
some_job "during", :option1 => 'happy', :option2 => 'birthday'
|
30
|
+
end
|
31
|
+
file
|
32
|
+
end
|
33
|
+
|
34
|
+
should "output the defined job with the task and options" do
|
35
|
+
assert_match /^.+ .+ .+ .+ before during after happy birthday$/, @output
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "A defined job with a :task and an option where the option is set globally" do
|
40
|
+
setup do
|
41
|
+
@output = Whenever.cron \
|
42
|
+
<<-file
|
43
|
+
set :job_template, nil
|
44
|
+
job_type :some_job, "before :task after :option1"
|
45
|
+
set :option1, 'happy'
|
46
|
+
every 2.hours do
|
47
|
+
some_job "during"
|
48
|
+
end
|
49
|
+
file
|
50
|
+
end
|
51
|
+
|
52
|
+
should "output the defined job with the task and options" do
|
53
|
+
assert_match /^.+ .+ .+ .+ before during after happy$/, @output
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
context "A defined job with a :task and an option where the option is set globally and locally" do
|
58
|
+
setup do
|
59
|
+
@output = Whenever.cron \
|
60
|
+
<<-file
|
61
|
+
set :job_template, nil
|
62
|
+
job_type :some_job, "before :task after :option1"
|
63
|
+
set :option1, 'global'
|
64
|
+
every 2.hours do
|
65
|
+
some_job "during", :option1 => 'local'
|
66
|
+
end
|
67
|
+
file
|
68
|
+
end
|
69
|
+
|
70
|
+
should "output the defined job using the local option" do
|
71
|
+
assert_match /^.+ .+ .+ .+ before during after local$/, @output
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "A defined job with a :task and an option that is not set" do
|
76
|
+
setup do
|
77
|
+
@output = Whenever.cron \
|
78
|
+
<<-file
|
79
|
+
set :job_template, nil
|
80
|
+
job_type :some_job, "before :task after :option1"
|
81
|
+
every 2.hours do
|
82
|
+
some_job "during", :option2 => 'happy'
|
83
|
+
end
|
84
|
+
file
|
85
|
+
end
|
86
|
+
|
87
|
+
should "output the defined job with that option removed" do
|
88
|
+
assert_match /^.+ .+ .+ .+ before during after$/, @output
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "A defined job that uses a :path where none is explicitly set" do
|
93
|
+
setup do
|
94
|
+
Whenever.stubs(:path).returns('/my/path')
|
95
|
+
|
96
|
+
@output = Whenever.cron \
|
97
|
+
<<-file
|
98
|
+
set :job_template, nil
|
99
|
+
job_type :some_job, "cd :path && :task"
|
100
|
+
every 2.hours do
|
101
|
+
some_job 'blahblah'
|
102
|
+
end
|
103
|
+
file
|
104
|
+
end
|
105
|
+
|
106
|
+
should "default to using the Whenever.path" do
|
107
|
+
assert_match two_hours + %( cd /my/path && blahblah), @output
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
|
3
|
+
class OutputEnvTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "The output from Whenever with environment variables set" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
env :MYVAR, 'blah'
|
10
|
+
env 'MAILTO', "someone@example.com"
|
11
|
+
file
|
12
|
+
end
|
13
|
+
|
14
|
+
should "output MYVAR environment variable" do
|
15
|
+
assert_match "MYVAR=blah", @output
|
16
|
+
end
|
17
|
+
|
18
|
+
should "output MAILTO environment variable" do
|
19
|
+
assert_match "MAILTO=someone@example.com", @output
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,307 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
2
|
+
|
3
|
+
class OutputRedirectionTest < Test::Unit::TestCase
|
4
|
+
|
5
|
+
context "A command when the output is set to nil" do
|
6
|
+
setup do
|
7
|
+
@output = Whenever.cron \
|
8
|
+
<<-file
|
9
|
+
set :job_template, nil
|
10
|
+
set :output, nil
|
11
|
+
every 2.hours do
|
12
|
+
command "blahblah"
|
13
|
+
end
|
14
|
+
file
|
15
|
+
end
|
16
|
+
|
17
|
+
should "output the command with the log syntax appended" do
|
18
|
+
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, @output
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
context "A command when the output is set" do
|
24
|
+
setup do
|
25
|
+
@output = Whenever.cron \
|
26
|
+
<<-file
|
27
|
+
set :job_template, nil
|
28
|
+
set :output, 'logfile.log'
|
29
|
+
every 2.hours do
|
30
|
+
command "blahblah"
|
31
|
+
end
|
32
|
+
file
|
33
|
+
end
|
34
|
+
|
35
|
+
should "output the command with the log syntax appended" do
|
36
|
+
assert_match /^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, @output
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "A command when the error and standard output is set by the command" do
|
41
|
+
setup do
|
42
|
+
@output = Whenever.cron \
|
43
|
+
<<-file
|
44
|
+
set :job_template, nil
|
45
|
+
every 2.hours do
|
46
|
+
command "blahblah", :output => {:standard => 'dev_null', :error => 'dev_err'}
|
47
|
+
end
|
48
|
+
file
|
49
|
+
end
|
50
|
+
|
51
|
+
should "output the command without the log syntax appended" do
|
52
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context "A command when the output is set and the comand overrides it" do
|
57
|
+
setup do
|
58
|
+
@output = Whenever.cron \
|
59
|
+
<<-file
|
60
|
+
set :job_template, nil
|
61
|
+
set :output, 'logfile.log'
|
62
|
+
every 2.hours do
|
63
|
+
command "blahblah", :output => 'otherlog.log'
|
64
|
+
end
|
65
|
+
file
|
66
|
+
end
|
67
|
+
|
68
|
+
should "output the command with the command syntax appended" do
|
69
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
70
|
+
assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, @output
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
context "A command when the output is set and the comand overrides with standard and error" do
|
75
|
+
setup do
|
76
|
+
@output = Whenever.cron \
|
77
|
+
<<-file
|
78
|
+
set :job_template, nil
|
79
|
+
set :output, 'logfile.log'
|
80
|
+
every 2.hours do
|
81
|
+
command "blahblah", :output => {:error => 'dev_err', :standard => 'dev_null' }
|
82
|
+
end
|
83
|
+
file
|
84
|
+
end
|
85
|
+
|
86
|
+
should "output the command with the overridden redirection syntax appended" do
|
87
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
88
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "A command when the output is set and the comand rejects it" do
|
93
|
+
setup do
|
94
|
+
@output = Whenever.cron \
|
95
|
+
<<-file
|
96
|
+
set :job_template, nil
|
97
|
+
set :output, 'logfile.log'
|
98
|
+
every 2.hours do
|
99
|
+
command "blahblah", :output => false
|
100
|
+
end
|
101
|
+
file
|
102
|
+
end
|
103
|
+
|
104
|
+
should "output the command without the log syntax appended" do
|
105
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
106
|
+
assert_match /^.+ .+ .+ .+ blahblah$/, @output
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
context "A command when the output is set and is overridden by the :set option" do
|
111
|
+
setup do
|
112
|
+
@output = Whenever.cron :set => 'output=otherlog.log', :string => \
|
113
|
+
<<-file
|
114
|
+
set :job_template, nil
|
115
|
+
set :output, 'logfile.log'
|
116
|
+
every 2.hours do
|
117
|
+
command "blahblah"
|
118
|
+
end
|
119
|
+
file
|
120
|
+
end
|
121
|
+
|
122
|
+
should "output the otherlog.log as the log file" do
|
123
|
+
assert_no_match /.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, @output
|
124
|
+
assert_match /^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1/, @output
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context "A command when the error and standard output is set" do
|
129
|
+
setup do
|
130
|
+
@output = Whenever.cron \
|
131
|
+
<<-file
|
132
|
+
set :job_template, nil
|
133
|
+
set :output, {:error => 'dev_err', :standard => 'dev_null' }
|
134
|
+
every 2.hours do
|
135
|
+
command "blahblah"
|
136
|
+
end
|
137
|
+
file
|
138
|
+
end
|
139
|
+
|
140
|
+
should "output the command without the redirection syntax appended" do
|
141
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, @output
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context "A command when error output is set" do
|
146
|
+
setup do
|
147
|
+
@output = Whenever.cron \
|
148
|
+
<<-file
|
149
|
+
set :job_template, nil
|
150
|
+
set :output, {:error => 'dev_null'}
|
151
|
+
every 2.hours do
|
152
|
+
command "blahblah"
|
153
|
+
end
|
154
|
+
file
|
155
|
+
end
|
156
|
+
|
157
|
+
should "output the command without the standard error syntax appended" do
|
158
|
+
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_null$/, @output
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
context "A command when the standard output is set" do
|
163
|
+
setup do
|
164
|
+
@output = Whenever.cron \
|
165
|
+
<<-file
|
166
|
+
set :job_template, nil
|
167
|
+
set :output, {:standard => 'dev_out'}
|
168
|
+
every 2.hours do
|
169
|
+
command "blahblah"
|
170
|
+
end
|
171
|
+
file
|
172
|
+
end
|
173
|
+
|
174
|
+
should "output the command with standard output syntax appended" do
|
175
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_out$/, @output
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
context "A command when error output is set by the command" do
|
180
|
+
setup do
|
181
|
+
@output = Whenever.cron \
|
182
|
+
<<-file
|
183
|
+
set :job_template, nil
|
184
|
+
every 2.hours do
|
185
|
+
command "blahblah", :output => {:error => 'dev_err'}
|
186
|
+
end
|
187
|
+
file
|
188
|
+
end
|
189
|
+
|
190
|
+
should "output the command without the log syntax appended" do
|
191
|
+
assert_match /^.+ .+ .+ .+ blahblah 2>> dev_err$/, @output
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
context "A command when standard output is set by the command" do
|
196
|
+
setup do
|
197
|
+
@output = Whenever.cron \
|
198
|
+
<<-file
|
199
|
+
set :job_template, nil
|
200
|
+
every 2.hours do
|
201
|
+
command "blahblah", :output => {:standard => 'dev_out'}
|
202
|
+
end
|
203
|
+
file
|
204
|
+
end
|
205
|
+
|
206
|
+
should "output the command without the log syntax appended" do
|
207
|
+
assert_match /^.+ .+ .+ .+ blahblah >> dev_out$/, @output
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
context "A command when standard output is set to nil" do
|
212
|
+
setup do
|
213
|
+
@output = Whenever.cron \
|
214
|
+
<<-file
|
215
|
+
set :job_template, nil
|
216
|
+
every 2.hours do
|
217
|
+
command "blahblah", :output => {:standard => nil}
|
218
|
+
end
|
219
|
+
file
|
220
|
+
end
|
221
|
+
|
222
|
+
should "output the command with stdout directed to /dev/null" do
|
223
|
+
assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null$/, @output
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
context "A command when standard error is set to nil" do
|
228
|
+
setup do
|
229
|
+
@output = Whenever.cron \
|
230
|
+
<<-file
|
231
|
+
set :job_template, nil
|
232
|
+
every 2.hours do
|
233
|
+
command "blahblah", :output => {:error => nil}
|
234
|
+
end
|
235
|
+
file
|
236
|
+
end
|
237
|
+
|
238
|
+
should "output the command with stderr directed to /dev/null" do
|
239
|
+
assert_match /^.+ .+ .+ .+ blahblah 2> \/dev\/null$/, @output
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
context "A command when standard output and standard error is set to nil" do
|
244
|
+
setup do
|
245
|
+
@output = Whenever.cron \
|
246
|
+
<<-file
|
247
|
+
set :job_template, nil
|
248
|
+
every 2.hours do
|
249
|
+
command "blahblah", :output => {:error => nil, :standard => nil}
|
250
|
+
end
|
251
|
+
file
|
252
|
+
end
|
253
|
+
|
254
|
+
should "output the command with stderr directed to /dev/null" do
|
255
|
+
assert_match /^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, @output
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
context "A command when standard output is set and standard error is set to nil" do
|
260
|
+
setup do
|
261
|
+
@output = Whenever.cron \
|
262
|
+
<<-file
|
263
|
+
set :job_template, nil
|
264
|
+
every 2.hours do
|
265
|
+
command "blahblah", :output => {:error => nil, :standard => 'my.log'}
|
266
|
+
end
|
267
|
+
file
|
268
|
+
end
|
269
|
+
|
270
|
+
should "output the command with stderr directed to /dev/null" do
|
271
|
+
assert_match /^.+ .+ .+ .+ blahblah >> my.log 2> \/dev\/null$/, @output
|
272
|
+
end
|
273
|
+
end
|
274
|
+
|
275
|
+
context "A command when standard output is nil and standard error is set" do
|
276
|
+
setup do
|
277
|
+
@output = Whenever.cron \
|
278
|
+
<<-file
|
279
|
+
set :job_template, nil
|
280
|
+
every 2.hours do
|
281
|
+
command "blahblah", :output => {:error => 'my_error.log', :standard => nil}
|
282
|
+
end
|
283
|
+
file
|
284
|
+
end
|
285
|
+
|
286
|
+
should "output the command with stderr directed to /dev/null" do
|
287
|
+
assert_match /^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, @output
|
288
|
+
end
|
289
|
+
end
|
290
|
+
|
291
|
+
context "A command when the deprecated :cron_log is set" do
|
292
|
+
setup do
|
293
|
+
@output = Whenever.cron \
|
294
|
+
<<-file
|
295
|
+
set :job_template, nil
|
296
|
+
set :cron_log, "cron.log"
|
297
|
+
every 2.hours do
|
298
|
+
command "blahblah"
|
299
|
+
end
|
300
|
+
file
|
301
|
+
end
|
302
|
+
|
303
|
+
should "output the command with with the stdout and stderr going to the log" do
|
304
|
+
assert_match /^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, @output
|
305
|
+
end
|
306
|
+
end
|
307
|
+
end
|