File tree 4 files changed +28
-0
lines changed
4 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -204,6 +204,13 @@ WARN[2017-07-11T12:24:32+02:00] job took too long to run: it should have started
204
204
```
205
205
206
206
207
+ ## Testing your crontab
208
+
209
+ Use the ` -test ` flag to prompt Supercronic to verify your crontab, but not
210
+ execute it. This is useful as part of e.g. a build process to verify the syntax
211
+ of your crontab.
212
+
213
+
207
214
## Questions and Support ###
208
215
209
216
Please feel free to open an issue in this repository if you have any question
Original file line number Diff line number Diff line change
1
+ oops
Original file line number Diff line number Diff line change @@ -77,3 +77,16 @@ wait_for() {
77
77
78
78
wait_for grep " $canary " " $out "
79
79
}
80
+
81
+ @test " it tests a valid crontab" {
82
+ timeout 1s " ${BATS_TEST_DIRNAME} /../supercronic" -test " ${BATS_TEST_DIRNAME} /noop.crontab"
83
+ }
84
+
85
+ @test " it tests an invalid crontab" {
86
+ run timeout 1s " ${BATS_TEST_DIRNAME} /../supercronic" -test " ${BATS_TEST_DIRNAME} /invalid.crontab"
87
+ [[ " $status " -eq 1 ]]
88
+ }
89
+
90
+ @test " it errors on an invalid crontab" {
91
+ ! run_supercronic -test " ${BATS_TEST_DIRNAME} /invalid.crontab"
92
+ }
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ var Usage = func() {
21
21
func main () {
22
22
debug := flag .Bool ("debug" , false , "enable debug logging" )
23
23
json := flag .Bool ("json" , false , "enable JSON logging" )
24
+ test := flag .Bool ("test" , false , "test crontab (does not run jobs)" )
24
25
flag .Parse ()
25
26
26
27
if * debug {
@@ -49,6 +50,12 @@ func main() {
49
50
return
50
51
}
51
52
53
+ if * test {
54
+ logrus .Info ("crontab is valid" )
55
+ os .Exit (0 )
56
+ return
57
+ }
58
+
52
59
var wg sync.WaitGroup
53
60
exitCtx , notifyExit := context .WithCancel (context .Background ())
54
61
You can’t perform that action at this time.
0 commit comments