-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
runner.go
49 lines (38 loc) · 836 Bytes
/
runner.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package script
import (
"errors"
"fmt"
)
var (
failedRun = errors.New("failed run")
skipRun = errors.New("skip")
)
type Runner struct {
LogLevel string
}
func (r Runner) Skip(is ...interface{}) {
// panic(skipRun)
}
func (r Runner) Fatal(is ...interface{}) {
r.Log(is...)
r.FailNow()
}
func (r Runner) Parallel() {
// No-op for now; we are currently only running a single script in a
// testscript instance.
}
func (r Runner) Log(is ...interface{}) {
fmt.Print(is...)
}
func (r Runner) FailNow() {
panic(failedRun)
}
func (r Runner) Run(n string, f func(T)) {
// For now we we don't top/tail the run of a subtest. We are currently only
// running a single script in a cript instance, which means that we
// will only have a single subtest.
f(r)
}
func (r Runner) Verbose() bool {
return r.LogLevel != ""
}