whenever 1.1.3 → 1.1.4
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/CHANGELOG.md +3 -0
- data/lib/whenever/version.rb +1 -1
- data/whenever.gemspec +1 -2
- metadata +3 -33
- data/test/functional/command_line_test.rb +0 -458
- data/test/functional/output_at_test.rb +0 -246
- data/test/functional/output_default_defined_jobs_test.rb +0 -310
- data/test/functional/output_defined_job_test.rb +0 -113
- data/test/functional/output_description_test.rb +0 -25
- data/test/functional/output_env_test.rb +0 -29
- data/test/functional/output_jobs_for_roles_test.rb +0 -65
- data/test/functional/output_jobs_with_mailto_test.rb +0 -168
- data/test/functional/output_jobs_with_sequence_test.rb +0 -187
- data/test/functional/output_redirection_test.rb +0 -248
- data/test/test_case.rb +0 -32
- data/test/test_helper.rb +0 -51
- data/test/unit/capistrano_support_test.rb +0 -147
- data/test/unit/cron_test.rb +0 -418
- data/test/unit/executable_test.rb +0 -142
- data/test/unit/job_test.rb +0 -114
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class OutputEnvTest < Whenever::TestCase
|
|
4
|
-
setup do
|
|
5
|
-
@output = Whenever.cron \
|
|
6
|
-
<<-file
|
|
7
|
-
env :MYVAR, 'blah'
|
|
8
|
-
env 'MAILTO', "someone@example.com"
|
|
9
|
-
env :BLANKVAR, ''
|
|
10
|
-
env :NILVAR, nil
|
|
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
|
-
|
|
22
|
-
should "output BLANKVAR environment variable" do
|
|
23
|
-
assert_match "BLANKVAR=\"\"", @output
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
should "output NILVAR environment variable" do
|
|
27
|
-
assert_match "NILVAR=\"\"", @output
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class OutputJobsForRolesTest < Whenever::TestCase
|
|
4
|
-
test "one role requested and specified on the job" do
|
|
5
|
-
output = Whenever.cron :roles => [:role1], :string => \
|
|
6
|
-
<<-file
|
|
7
|
-
every 2.hours, :roles => [:role1] do
|
|
8
|
-
command "blahblah"
|
|
9
|
-
end
|
|
10
|
-
file
|
|
11
|
-
|
|
12
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
test "one role requested but none specified on the job" do
|
|
16
|
-
output = Whenever.cron :roles => [:role1], :string => \
|
|
17
|
-
<<-file
|
|
18
|
-
every 2.hours do
|
|
19
|
-
command "blahblah"
|
|
20
|
-
end
|
|
21
|
-
file
|
|
22
|
-
|
|
23
|
-
# this should output the job because not specifying a role means "all roles"
|
|
24
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
test "no roles requested but one specified on the job" do
|
|
28
|
-
output = Whenever.cron \
|
|
29
|
-
<<-file
|
|
30
|
-
every 2.hours, :roles => [:role1] do
|
|
31
|
-
command "blahblah"
|
|
32
|
-
end
|
|
33
|
-
file
|
|
34
|
-
|
|
35
|
-
# this should output the job because not requesting roles means "all roles"
|
|
36
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'\n\n", output
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
test "a different role requested than the one specified on the job" do
|
|
40
|
-
output = Whenever.cron :roles => [:role1], :string => \
|
|
41
|
-
<<-file
|
|
42
|
-
every 2.hours, :roles => [:role2] do
|
|
43
|
-
command "blahblah"
|
|
44
|
-
end
|
|
45
|
-
file
|
|
46
|
-
|
|
47
|
-
assert_equal "", output
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
test "with 2 roles requested and a job defined for each" do
|
|
51
|
-
output = Whenever.cron :roles => [:role1, :role2], :string => \
|
|
52
|
-
<<-file
|
|
53
|
-
every 2.hours, :roles => [:role1] do
|
|
54
|
-
command "role1_cmd"
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
every :hour, :roles => [:role2] do
|
|
58
|
-
command "role2_cmd"
|
|
59
|
-
end
|
|
60
|
-
file
|
|
61
|
-
|
|
62
|
-
assert_match two_hours + " /bin/bash -l -c 'role1_cmd'", output
|
|
63
|
-
assert_match "0 * * * * /bin/bash -l -c 'role2_cmd'", output
|
|
64
|
-
end
|
|
65
|
-
end
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class OutputJobsWithMailtoTest < Whenever::TestCase
|
|
4
|
-
test "defined job with a mailto argument" do
|
|
5
|
-
output = Whenever.cron \
|
|
6
|
-
<<-file
|
|
7
|
-
every 2.hours do
|
|
8
|
-
command "blahblah", mailto: 'someone@example.com'
|
|
9
|
-
end
|
|
10
|
-
file
|
|
11
|
-
|
|
12
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
13
|
-
|
|
14
|
-
assert_equal 'MAILTO=someone@example.com', output_without_empty_line.shift
|
|
15
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
test "defined job with every method's block and a mailto argument" do
|
|
19
|
-
output = Whenever.cron \
|
|
20
|
-
<<-file
|
|
21
|
-
every 2.hours, mailto: 'someone@example.com' do
|
|
22
|
-
command "blahblah"
|
|
23
|
-
end
|
|
24
|
-
file
|
|
25
|
-
|
|
26
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
27
|
-
|
|
28
|
-
assert_equal 'MAILTO=someone@example.com', output_without_empty_line.shift
|
|
29
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
test "defined job which overrided mailto argument in the block" do
|
|
33
|
-
output = Whenever.cron \
|
|
34
|
-
<<-file
|
|
35
|
-
every 2.hours, mailto: 'of_the_block@example.com' do
|
|
36
|
-
command "blahblah", mailto: 'overrided_in_the_block@example.com'
|
|
37
|
-
end
|
|
38
|
-
file
|
|
39
|
-
|
|
40
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
41
|
-
|
|
42
|
-
assert_equal 'MAILTO=overrided_in_the_block@example.com', output_without_empty_line.shift
|
|
43
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
test "defined some jobs with various mailto argument" do
|
|
47
|
-
output = Whenever.cron \
|
|
48
|
-
<<-file
|
|
49
|
-
every 2.hours do
|
|
50
|
-
command "blahblah"
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
every 2.hours, mailto: 'john@example.com' do
|
|
54
|
-
command "blahblah_of_john"
|
|
55
|
-
command "blahblah2_of_john"
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
every 2.hours, mailto: 'sarah@example.com' do
|
|
59
|
-
command "blahblah_of_sarah"
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
every 2.hours do
|
|
63
|
-
command "blahblah_of_martin", mailto: 'martin@example.com'
|
|
64
|
-
command "blahblah2_of_sarah", mailto: 'sarah@example.com'
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
every 2.hours do
|
|
68
|
-
command "blahblah2"
|
|
69
|
-
end
|
|
70
|
-
file
|
|
71
|
-
|
|
72
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
73
|
-
|
|
74
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
75
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah2'", output_without_empty_line.shift
|
|
76
|
-
|
|
77
|
-
assert_equal 'MAILTO=john@example.com', output_without_empty_line.shift
|
|
78
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah_of_john'", output_without_empty_line.shift
|
|
79
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah2_of_john'", output_without_empty_line.shift
|
|
80
|
-
|
|
81
|
-
assert_equal 'MAILTO=sarah@example.com', output_without_empty_line.shift
|
|
82
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah_of_sarah'", output_without_empty_line.shift
|
|
83
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah2_of_sarah'", output_without_empty_line.shift
|
|
84
|
-
|
|
85
|
-
assert_equal 'MAILTO=martin@example.com', output_without_empty_line.shift
|
|
86
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah_of_martin'", output_without_empty_line.shift
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
test "defined some jobs with no mailto argument jobs and mailto argument jobs(no mailto jobs should be first line of cron output" do
|
|
90
|
-
output = Whenever.cron \
|
|
91
|
-
<<-file
|
|
92
|
-
every 2.hours, mailto: 'john@example.com' do
|
|
93
|
-
command "blahblah_of_john"
|
|
94
|
-
command "blahblah2_of_john"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
every 2.hours do
|
|
98
|
-
command "blahblah"
|
|
99
|
-
end
|
|
100
|
-
file
|
|
101
|
-
|
|
102
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
103
|
-
|
|
104
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
105
|
-
|
|
106
|
-
assert_equal 'MAILTO=john@example.com', output_without_empty_line.shift
|
|
107
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah_of_john'", output_without_empty_line.shift
|
|
108
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah2_of_john'", output_without_empty_line.shift
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
test "defined some jobs with environment mailto define and various mailto argument" do
|
|
112
|
-
output = Whenever.cron \
|
|
113
|
-
<<-file
|
|
114
|
-
env 'MAILTO', 'default@example.com'
|
|
115
|
-
|
|
116
|
-
every 2.hours do
|
|
117
|
-
command "blahblah"
|
|
118
|
-
end
|
|
119
|
-
|
|
120
|
-
every 2.hours, mailto: 'sarah@example.com' do
|
|
121
|
-
command "blahblah_by_sarah"
|
|
122
|
-
end
|
|
123
|
-
|
|
124
|
-
every 2.hours do
|
|
125
|
-
command "blahblah_by_john", mailto: 'john@example.com'
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
every 2.hours do
|
|
129
|
-
command "blahblah2"
|
|
130
|
-
end
|
|
131
|
-
file
|
|
132
|
-
|
|
133
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
134
|
-
|
|
135
|
-
assert_equal 'MAILTO=default@example.com', output_without_empty_line.shift
|
|
136
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
137
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah2'", output_without_empty_line.shift
|
|
138
|
-
|
|
139
|
-
assert_equal 'MAILTO=sarah@example.com', output_without_empty_line.shift
|
|
140
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah_by_sarah'", output_without_empty_line.shift
|
|
141
|
-
|
|
142
|
-
assert_equal 'MAILTO=john@example.com', output_without_empty_line.shift
|
|
143
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah_by_john'", output_without_empty_line.shift
|
|
144
|
-
end
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
class OutputJobsWithMailtoForRolesTest < Whenever::TestCase
|
|
148
|
-
test "one role requested and specified on the job with mailto argument" do
|
|
149
|
-
output = Whenever.cron roles: [:role1], :string => \
|
|
150
|
-
<<-file
|
|
151
|
-
env 'MAILTO', 'default@example.com'
|
|
152
|
-
|
|
153
|
-
every 2.hours, :roles => [:role1] do
|
|
154
|
-
command "blahblah"
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
every 2.hours, mailto: 'sarah@example.com', :roles => [:role2] do
|
|
158
|
-
command "blahblah_by_sarah"
|
|
159
|
-
end
|
|
160
|
-
file
|
|
161
|
-
|
|
162
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
163
|
-
|
|
164
|
-
assert_equal 'MAILTO=default@example.com', output_without_empty_line.shift
|
|
165
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
166
|
-
assert_nil output_without_empty_line.shift
|
|
167
|
-
end
|
|
168
|
-
end
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class OutputJobsWithSequenceTest < Whenever::TestCase
|
|
4
|
-
test "defined jobs with a sequence argument specified per-job" do
|
|
5
|
-
output = Whenever.cron \
|
|
6
|
-
<<-file
|
|
7
|
-
every 2.hours do
|
|
8
|
-
command "blahblah", sequence: 'backups'
|
|
9
|
-
command "foofoo", sequence: 'backups'
|
|
10
|
-
command "barbar"
|
|
11
|
-
end
|
|
12
|
-
file
|
|
13
|
-
|
|
14
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
15
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
16
|
-
assert_equal two_hours + " /bin/bash -l -c 'barbar'", output_without_empty_line.shift
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
test "defined jobs with a sequence argument specified on the group" do
|
|
20
|
-
output = Whenever.cron \
|
|
21
|
-
<<-file
|
|
22
|
-
every 2.hours, sequence: 'backups' do
|
|
23
|
-
command "blahblah"
|
|
24
|
-
command "foofoo"
|
|
25
|
-
end
|
|
26
|
-
file
|
|
27
|
-
|
|
28
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
29
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
test "defined jobs with a sequence argument and a job that halts the sequence on failure" do
|
|
33
|
-
output = Whenever.cron \
|
|
34
|
-
<<-file
|
|
35
|
-
every 2.hours, sequence: 'backups' do
|
|
36
|
-
command "blahblah", halt_sequence_on_failure: true
|
|
37
|
-
command "foofoo"
|
|
38
|
-
end
|
|
39
|
-
file
|
|
40
|
-
|
|
41
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
42
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah' && /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
test "defined jobs with a sequences specified on the group and jobs" do
|
|
46
|
-
output = Whenever.cron \
|
|
47
|
-
<<-file
|
|
48
|
-
every 2.hours, sequence: 'backups' do
|
|
49
|
-
command "blahblah"
|
|
50
|
-
command "barbar", sequence: nil
|
|
51
|
-
command "foofoo"
|
|
52
|
-
command "bazbaz", sequence: 'bees'
|
|
53
|
-
command "buzzbuzz", sequence: 'bees'
|
|
54
|
-
end
|
|
55
|
-
file
|
|
56
|
-
|
|
57
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
58
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
59
|
-
assert_equal two_hours + " /bin/bash -l -c 'barbar'", output_without_empty_line.shift
|
|
60
|
-
assert_equal two_hours + " /bin/bash -l -c 'bazbaz' ; /bin/bash -l -c 'buzzbuzz'", output_without_empty_line.shift
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
test "defined jobs with a multiple groups with sequences specified on the group and jobs" do
|
|
64
|
-
output = Whenever.cron \
|
|
65
|
-
<<-file
|
|
66
|
-
every 2.hours, sequence: 'backups' do
|
|
67
|
-
command "blahblah"
|
|
68
|
-
command "barbar", sequence: nil
|
|
69
|
-
command "bazbaz", sequence: 'bees'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
every 2.hours, sequence: 'backups' do
|
|
73
|
-
command "foofoo"
|
|
74
|
-
command "buzzbuzz", sequence: 'bees'
|
|
75
|
-
end
|
|
76
|
-
file
|
|
77
|
-
|
|
78
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
79
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
80
|
-
assert_equal two_hours + " /bin/bash -l -c 'barbar'", output_without_empty_line.shift
|
|
81
|
-
assert_equal two_hours + " /bin/bash -l -c 'bazbaz' ; /bin/bash -l -c 'buzzbuzz'", output_without_empty_line.shift
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
test "defined jobs with a multiple groups with sequences specified on the group and jobs" do
|
|
85
|
-
output = Whenever.cron \
|
|
86
|
-
<<-file
|
|
87
|
-
every 2.hours, sequence: 'backups' do
|
|
88
|
-
command "blahblah"
|
|
89
|
-
command "barbar", sequence: nil
|
|
90
|
-
command "bazbaz", sequence: 'bees'
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
every 3.hours, sequence: 'backups' do
|
|
94
|
-
command "foofoo"
|
|
95
|
-
command "buzzbuzz", sequence: 'bees'
|
|
96
|
-
end
|
|
97
|
-
file
|
|
98
|
-
|
|
99
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
100
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
101
|
-
assert_equal two_hours + " /bin/bash -l -c 'barbar'", output_without_empty_line.shift
|
|
102
|
-
assert_equal two_hours + " /bin/bash -l -c 'bazbaz'", output_without_empty_line.shift
|
|
103
|
-
assert_equal three_hours + " /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
104
|
-
assert_equal three_hours + " /bin/bash -l -c 'buzzbuzz'", output_without_empty_line.shift
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
test "defined jobs with a multiple groups with sequences specified on the group and jobs" do
|
|
108
|
-
assert_raises ArgumentError do
|
|
109
|
-
Whenever.cron \
|
|
110
|
-
<<-file
|
|
111
|
-
every 2.hours, sequence: 'backups' do
|
|
112
|
-
command "blahblah", at: 1
|
|
113
|
-
command "barbar", at: 2
|
|
114
|
-
end
|
|
115
|
-
file
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
test "defined jobs with a sequence argument and a description on the group" do
|
|
120
|
-
output = Whenever.cron \
|
|
121
|
-
<<-file
|
|
122
|
-
every 2.hours, sequence: 'backups', description: "Nightly backups" do
|
|
123
|
-
command "blahblah"
|
|
124
|
-
command "foofoo"
|
|
125
|
-
end
|
|
126
|
-
file
|
|
127
|
-
|
|
128
|
-
assert_match "# Nightly backups\n" + two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
test "defined jobs with a sequence argument and a description on each job" do
|
|
132
|
-
output = Whenever.cron \
|
|
133
|
-
<<-file
|
|
134
|
-
every 2.hours, sequence: 'backups' do
|
|
135
|
-
command "blahblah", description: "Dump the database"
|
|
136
|
-
command "foofoo", description: "Upload the dump"
|
|
137
|
-
end
|
|
138
|
-
file
|
|
139
|
-
|
|
140
|
-
assert_match "# Dump the database\n# Upload the dump\n" + two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output
|
|
141
|
-
end
|
|
142
|
-
|
|
143
|
-
test "defined jobs with a sequence argument and descriptions padded with whitespace" do
|
|
144
|
-
output = Whenever.cron \
|
|
145
|
-
<<-file
|
|
146
|
-
every 2.hours, sequence: 'backups' do
|
|
147
|
-
command "blahblah", description: " Dump the database "
|
|
148
|
-
command "foofoo", description: " Upload the dump "
|
|
149
|
-
end
|
|
150
|
-
file
|
|
151
|
-
|
|
152
|
-
assert_match "# Dump the database\n# Upload the dump\n" + two_hours, output
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
def three_hours
|
|
156
|
-
"0 0,3,6,9,12,15,18,21 * * *"
|
|
157
|
-
end
|
|
158
|
-
end
|
|
159
|
-
|
|
160
|
-
class OutputJobsWithSequentialTest < Whenever::TestCase
|
|
161
|
-
test "defined jobs with a sequential argument" do
|
|
162
|
-
output = Whenever.cron \
|
|
163
|
-
<<-file
|
|
164
|
-
every 2.hours, sequential: true do
|
|
165
|
-
command "blahblah"
|
|
166
|
-
command "foofoo"
|
|
167
|
-
end
|
|
168
|
-
file
|
|
169
|
-
|
|
170
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
171
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah' ; /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
test "defined jobs with a sequential argument" do
|
|
175
|
-
output = Whenever.cron \
|
|
176
|
-
<<-file
|
|
177
|
-
every 2.hours, sequential: true do
|
|
178
|
-
command "blahblah"
|
|
179
|
-
command "foofoo", sequence: false
|
|
180
|
-
end
|
|
181
|
-
file
|
|
182
|
-
|
|
183
|
-
output_without_empty_line = lines_without_empty_line(output.lines)
|
|
184
|
-
assert_equal two_hours + " /bin/bash -l -c 'blahblah'", output_without_empty_line.shift
|
|
185
|
-
assert_equal two_hours + " /bin/bash -l -c 'foofoo'", output_without_empty_line.shift
|
|
186
|
-
end
|
|
187
|
-
end
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
require 'test_helper'
|
|
2
|
-
|
|
3
|
-
class OutputRedirectionTest < Whenever::TestCase
|
|
4
|
-
test "command when the output is set to nil" do
|
|
5
|
-
output = Whenever.cron \
|
|
6
|
-
<<-file
|
|
7
|
-
set :job_template, nil
|
|
8
|
-
set :output, nil
|
|
9
|
-
every 2.hours do
|
|
10
|
-
command "blahblah"
|
|
11
|
-
end
|
|
12
|
-
file
|
|
13
|
-
|
|
14
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> \/dev\/null 2>&1$/, output)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
test "command when the output is set" do
|
|
19
|
-
output = Whenever.cron \
|
|
20
|
-
<<-file
|
|
21
|
-
set :job_template, nil
|
|
22
|
-
set :output, 'logfile.log'
|
|
23
|
-
every 2.hours do
|
|
24
|
-
command "blahblah"
|
|
25
|
-
end
|
|
26
|
-
file
|
|
27
|
-
|
|
28
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> logfile.log 2>&1$/, output)
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
test "command when the error and standard output is set by the command" do
|
|
32
|
-
output = Whenever.cron \
|
|
33
|
-
<<-file
|
|
34
|
-
set :job_template, nil
|
|
35
|
-
every 2.hours do
|
|
36
|
-
command "blahblah", :output => {:standard => 'dev_null', :error => 'dev_err'}
|
|
37
|
-
end
|
|
38
|
-
file
|
|
39
|
-
|
|
40
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output)
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
test "command when the output is set and the comand overrides it" do
|
|
44
|
-
output = Whenever.cron \
|
|
45
|
-
<<-file
|
|
46
|
-
set :job_template, nil
|
|
47
|
-
set :output, 'logfile.log'
|
|
48
|
-
every 2.hours do
|
|
49
|
-
command "blahblah", :output => 'otherlog.log'
|
|
50
|
-
end
|
|
51
|
-
file
|
|
52
|
-
|
|
53
|
-
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
|
54
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1$/, output)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
test "command when the output is set and the comand overrides with standard and error" 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 => {:error => 'dev_err', :standard => 'dev_null' }
|
|
64
|
-
end
|
|
65
|
-
file
|
|
66
|
-
|
|
67
|
-
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
|
68
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
test "command when the output is set and the comand rejects it" do
|
|
72
|
-
output = Whenever.cron \
|
|
73
|
-
<<-file
|
|
74
|
-
set :job_template, nil
|
|
75
|
-
set :output, 'logfile.log'
|
|
76
|
-
every 2.hours do
|
|
77
|
-
command "blahblah", :output => false
|
|
78
|
-
end
|
|
79
|
-
file
|
|
80
|
-
|
|
81
|
-
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
|
82
|
-
assert_match(/^.+ .+ .+ .+ blahblah$/, output)
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
test "command when the output is set and is overridden by the :set option" do
|
|
86
|
-
output = Whenever.cron :set => 'output=otherlog.log', :string => \
|
|
87
|
-
<<-file
|
|
88
|
-
set :job_template, nil
|
|
89
|
-
set :output, 'logfile.log'
|
|
90
|
-
every 2.hours do
|
|
91
|
-
command "blahblah"
|
|
92
|
-
end
|
|
93
|
-
file
|
|
94
|
-
|
|
95
|
-
assert_no_match(/.+ .+ .+ .+ blahblah >> logfile.log 2>&1/, output)
|
|
96
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> otherlog.log 2>&1/, output)
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
test "command when the error and standard output is set" do
|
|
100
|
-
output = Whenever.cron \
|
|
101
|
-
<<-file
|
|
102
|
-
set :job_template, nil
|
|
103
|
-
set :output, {:error => 'dev_err', :standard => 'dev_null' }
|
|
104
|
-
every 2.hours do
|
|
105
|
-
command "blahblah"
|
|
106
|
-
end
|
|
107
|
-
file
|
|
108
|
-
|
|
109
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> dev_null 2>> dev_err$/, output)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
test "command when error output is set" do
|
|
113
|
-
output = Whenever.cron \
|
|
114
|
-
<<-file
|
|
115
|
-
set :job_template, nil
|
|
116
|
-
set :output, {:error => 'dev_null'}
|
|
117
|
-
every 2.hours do
|
|
118
|
-
command "blahblah"
|
|
119
|
-
end
|
|
120
|
-
file
|
|
121
|
-
|
|
122
|
-
assert_match(/^.+ .+ .+ .+ blahblah 2>> dev_null$/, output)
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
test "command when the standard output is set" do
|
|
126
|
-
output = Whenever.cron \
|
|
127
|
-
<<-file
|
|
128
|
-
set :job_template, nil
|
|
129
|
-
set :output, {:standard => 'dev_out'}
|
|
130
|
-
every 2.hours do
|
|
131
|
-
command "blahblah"
|
|
132
|
-
end
|
|
133
|
-
file
|
|
134
|
-
|
|
135
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> dev_out$/, output)
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
test "command when error output is set by the command" do
|
|
139
|
-
output = Whenever.cron \
|
|
140
|
-
<<-file
|
|
141
|
-
set :job_template, nil
|
|
142
|
-
every 2.hours do
|
|
143
|
-
command "blahblah", :output => {:error => 'dev_err'}
|
|
144
|
-
end
|
|
145
|
-
file
|
|
146
|
-
|
|
147
|
-
assert_match(/^.+ .+ .+ .+ blahblah 2>> dev_err$/, output)
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
test "command when standard output is set by the command" do
|
|
151
|
-
output = Whenever.cron \
|
|
152
|
-
<<-file
|
|
153
|
-
set :job_template, nil
|
|
154
|
-
every 2.hours do
|
|
155
|
-
command "blahblah", :output => {:standard => 'dev_out'}
|
|
156
|
-
end
|
|
157
|
-
file
|
|
158
|
-
|
|
159
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> dev_out$/, output)
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
test "command when standard output is set to nil" do
|
|
163
|
-
output = Whenever.cron \
|
|
164
|
-
<<-file
|
|
165
|
-
set :job_template, nil
|
|
166
|
-
every 2.hours do
|
|
167
|
-
command "blahblah", :output => {:standard => nil}
|
|
168
|
-
end
|
|
169
|
-
file
|
|
170
|
-
|
|
171
|
-
assert_match(/^.+ .+ .+ .+ blahblah > \/dev\/null$/, output)
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
test "command when standard error is set to nil" do
|
|
175
|
-
output = Whenever.cron \
|
|
176
|
-
<<-file
|
|
177
|
-
set :job_template, nil
|
|
178
|
-
every 2.hours do
|
|
179
|
-
command "blahblah", :output => {:error => nil}
|
|
180
|
-
end
|
|
181
|
-
file
|
|
182
|
-
|
|
183
|
-
assert_match(/^.+ .+ .+ .+ blahblah 2> \/dev\/null$/, output)
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
test "command when standard output and standard error is set to nil" do
|
|
187
|
-
output = Whenever.cron \
|
|
188
|
-
<<-file
|
|
189
|
-
set :job_template, nil
|
|
190
|
-
every 2.hours do
|
|
191
|
-
command "blahblah", :output => {:error => nil, :standard => nil}
|
|
192
|
-
end
|
|
193
|
-
file
|
|
194
|
-
|
|
195
|
-
assert_match(/^.+ .+ .+ .+ blahblah > \/dev\/null 2>&1$/, output)
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
test "command when standard output is set and standard error is set to nil" do
|
|
199
|
-
output = Whenever.cron \
|
|
200
|
-
<<-file
|
|
201
|
-
set :job_template, nil
|
|
202
|
-
every 2.hours do
|
|
203
|
-
command "blahblah", :output => {:error => nil, :standard => 'my.log'}
|
|
204
|
-
end
|
|
205
|
-
file
|
|
206
|
-
|
|
207
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> my.log 2> \/dev\/null$/, output)
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
test "command when standard output is nil and standard error is set" do
|
|
211
|
-
output = Whenever.cron \
|
|
212
|
-
<<-file
|
|
213
|
-
set :job_template, nil
|
|
214
|
-
every 2.hours do
|
|
215
|
-
command "blahblah", :output => {:error => 'my_error.log', :standard => nil}
|
|
216
|
-
end
|
|
217
|
-
file
|
|
218
|
-
|
|
219
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> \/dev\/null 2>> my_error.log$/, output)
|
|
220
|
-
end
|
|
221
|
-
|
|
222
|
-
test "command when the deprecated :cron_log is set" do
|
|
223
|
-
output = Whenever.cron \
|
|
224
|
-
<<-file
|
|
225
|
-
set :job_template, nil
|
|
226
|
-
set :cron_log, "cron.log"
|
|
227
|
-
every 2.hours do
|
|
228
|
-
command "blahblah"
|
|
229
|
-
end
|
|
230
|
-
file
|
|
231
|
-
|
|
232
|
-
assert_match(/^.+ .+ .+ .+ blahblah >> cron.log 2>&1$/, output)
|
|
233
|
-
end
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
test "a command when the standard output is set to a lambda" do
|
|
237
|
-
output = Whenever.cron \
|
|
238
|
-
<<-file
|
|
239
|
-
set :job_template, nil
|
|
240
|
-
set :output, lambda { "2>&1 | logger -t whenever_cron" }
|
|
241
|
-
every 2.hours do
|
|
242
|
-
command "blahblah"
|
|
243
|
-
end
|
|
244
|
-
file
|
|
245
|
-
|
|
246
|
-
assert_match(/^.+ .+ .+ .+ blahblah 2>&1 | logger -t whenever_cron$/, output)
|
|
247
|
-
end
|
|
248
|
-
end
|