-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
69 lines (55 loc) · 1.85 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package main
import (
"os"
"github.com/chakrit/smoke/internal/p"
"github.com/spf13/pflag"
)
var (
lockFile string
shouldShowHelp bool
shouldList bool
shouldPrint bool
shouldCommit bool
noColors bool
trackTime bool
verbosity int
quietness int
includes []string
excludes []string
)
func main() {
pflag.BoolVarP(&shouldShowHelp, "help", "h", false, "Show help on usages.")
pflag.BoolVarP(&shouldList, "list", "l", false, "List all discovered tests and exit.")
pflag.BoolVarP(&shouldPrint, "print", "p", false, "Print results but don't do any comparison.")
pflag.BoolVarP(&shouldCommit, "commit", "c", false, "Commit all test output.")
pflag.StringVarP(&lockFile, "lockfile", "f", "", "Filename to read lock result from (or write to, when committing).")
pflag.BoolVar(&noColors, "no-color", false, "Turns off console coloring.")
pflag.BoolVar(&trackTime, "time", false, "Log timestamps.")
pflag.CountVarP(&verbosity, "verbose", "v", "Increase log output chattiness.")
pflag.CountVarP(&quietness, "quiet", "q", "Decrease log output chattiness.")
pflag.StringSliceVarP(&includes, "include", "i", nil, "Only run tests matching the given pattern")
pflag.StringSliceVarP(&excludes, "exclude", "x", nil, "Do not run tests matching the given pattern")
pflag.Parse()
if shouldShowHelp {
pflag.Usage()
return
}
// TODO: Make possible? Might need to overhaul test and result collection to allow
// partial tests/modifications
if shouldCommit && (len(includes) > 0 || len(excludes) > 0) {
p.Usage("cannot commit partial results when using --include or --exclude")
os.Exit(1)
return
}
filenames := pflag.Args()
if len(filenames) < 1 {
p.Usage("requires a spec filename.")
os.Exit(1)
return
}
p.Configure(!noColors, trackTime, verbosity, quietness)
defer p.Bye()
for _, filename := range filenames {
processFile(filename)
}
}