1
0
mirror of https://github.com/golang/go synced 2024-11-05 11:46:12 -07:00

rename -chatty to more conventional -v.

add -match flag to select tests.

gotest -match 'TestDeepEqual$'

R=r
DELTA=13  (12 added, 0 deleted, 1 changed)
OCL=29900
CL=29900
This commit is contained in:
Russ Cox 2009-06-04 15:40:28 -07:00
parent 424f4f0ff5
commit d30f80bad2

View File

@ -15,11 +15,14 @@ import (
"flag"; "flag";
"fmt"; "fmt";
"os"; "os";
"regexp";
"runtime"; "runtime";
) )
// Report as tests are run; default is silent for success. // Report as tests are run; default is silent for success.
var chatty = flag.Bool("chatty", false, "chatty") var chatty = flag.Bool("v", false, "verbose: print additional output")
var match = flag.String("match", "", "regular expression to select tests to run")
// Insert final newline if needed and tabs after internal newlines. // Insert final newline if needed and tabs after internal newlines.
func tabify(s string) string { func tabify(s string) string {
@ -114,11 +117,20 @@ func tRunner(t *T, test *Test) {
// of gotest. // of gotest.
func Main(tests []Test) { func Main(tests []Test) {
flag.Parse(); flag.Parse();
args := flag.Args();
ok := true; ok := true;
if len(tests) == 0 { if len(tests) == 0 {
println("testing: warning: no tests to run"); println("testing: warning: no tests to run");
} }
re, err := regexp.Compile(*match);
if err != nil {
println("invalid regexp for -match:", err.String());
os.Exit(1);
}
for i := 0; i < len(tests); i++ { for i := 0; i < len(tests); i++ {
if !re.Match(tests[i].Name) {
continue;
}
if *chatty { if *chatty {
println("=== RUN ", tests[i].Name); println("=== RUN ", tests[i].Name);
} }