forked from cweill/gotests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
55 lines (51 loc) · 1.9 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
// A commandline tool for generating table-driven Go tests.
//
// This tool can generate tests for specific Go source files or an entire
// directory. By default, it prints its output to stdout.
//
// Usage:
//
// $ gotests [options] PATH ...
//
// Available options:
//
// -all generate tests for all functions and methods
//
// -excl regexp. generate tests for functions and methods that don't
// match. Takes precedence over -only, -exported, and -all
//
// -exported generate tests for exported functions and methods. Takes
// precedence over -only and -all
//
// -i print test inputs in error messages
//
// -only regexp. generate tests for functions and methods that match only.
// Takes precedence over -all
//
// -w write output to (test) files instead of stdout
package main
import (
"flag"
"os"
"github.com/cweill/gotests/gotests/process"
)
var (
onlyFuncs = flag.String("only", "", `regexp. generate tests for functions and methods that match only. Takes precedence over -all`)
exclFuncs = flag.String("excl", "", `regexp. generate tests for functions and methods that don't match. Takes precedence over -only, -exported, and -all`)
exportedFuncs = flag.Bool("exported", false, `generate tests for exported functions and methods. Takes precedence over -only and -all`)
allFuncs = flag.Bool("all", false, "generate tests for all functions and methods")
printInputs = flag.Bool("i", false, "print test inputs in error messages")
writeOutput = flag.Bool("w", false, "write output to (test) files instead of stdout")
)
func main() {
flag.Parse()
args := flag.Args()
process.Run(os.Stdout, args, &process.Options{
OnlyFuncs: *onlyFuncs,
ExclFuncs: *exclFuncs,
ExportedFuncs: *exportedFuncs,
AllFuncs: *allFuncs,
PrintInputs: *printInputs,
WriteOutput: *writeOutput,
})
}