travis-ci
884 of 884 new or added lines in 19 files covered. (100.0%)
1380 of 1447 relevant lines covered (95.37%)
3.21 hits per line
1 |
package flow
|
|
2 |
|
|
3 |
type ExitCode int |
|
4 |
|
|
5 |
type Step struct { |
|
6 |
Do func()
|
|
7 |
Success *Step |
|
8 |
Error *Step |
|
9 |
Desc string
|
|
10 |
Exiter func(code int) |
|
11 |
} |
|
12 |
|
|
|
func (s *Step) Run(p interface{}) { |
3✔ |
|
s.callDo(p) |
3✔ |
|
|
3✔ |
|
switch {
|
3✔ |
|
case s.Success != nil: |
3✔ |
|
s.Success.Run(p) |
3✔ |
|
case p == nil: |
3✔ |
|
return
|
3✔ |
|
default:
|
3✔ |
|
if code, ok := p.(ExitCode); ok {
|
6✔ |
|
if s.Exiter != nil { |
6✔ |
|
s.Exiter(int(code))
|
3✔ |
|
} |
3✔ |
|
return
|
3✔ |
27 |
} |
|
|
panic(p)
|
3✔ |
29 |
} |
|
30 |
} |
|
31 |
|
|
|
func (s *Step) callDo(p interface{}) { |
3✔ |
|
if s.Do == nil { |
6✔ |
|
return
|
3✔ |
|
} |
3✔ |
|
defer func() { |
6✔ |
|
if e := recover(); e != nil { |
6✔ |
|
if s.Error == nil { |
3✔ |
|
panic(p)
|
× |
40 |
} |
|
|
s.Error.Run(e) |
3✔ |
42 |
} |
|
43 |
}() |
|
|
s.Do() |
3✔ |
45 |
} |