changes in response to review
diff --git a/gocheck.go b/gocheck.go
index c34d5cf..adbbd7d 100644
--- a/gocheck.go
+++ b/gocheck.go
@@ -53,10 +53,22 @@
return method.Info.Func.Pointer()
}
-// The result of String is used as the pattern to match the
-// gocheck.run filter.
+func (method *methodType) suiteName() string {
+ t := method.Info.Type.In(0)
+ if t.Kind() == reflect.Ptr {
+ t = t.Elem()
+ }
+ return t.Name()
+}
+
func (method *methodType) String() string {
- return fmt.Sprintf("%v.%s", method.Info.Type.In(0), method.Info.Name)
+ return fmt.Sprintf("%v.%s", method.suiteName(), method.Info.Name)
+}
+
+func (method *methodType) matches(re *regexp.Regexp) bool {
+ return re.MatchString(method.Info.Name) ||
+ re.MatchString(method.suiteName()) ||
+ re.MatchString(method.String())
}
type C struct {
@@ -523,7 +535,7 @@
if !strings.HasPrefix(method.Info.Name, "Test") {
continue
}
- if filterRegexp == nil || filterRegexp.MatchString(method.String()) {
+ if filterRegexp == nil || method.matches(filterRegexp) {
runner.tests[testsLen] = method
testsLen += 1
}
diff --git a/run.go b/run.go
index 97348bc..48a20c9 100644
--- a/run.go
+++ b/run.go
@@ -25,7 +25,7 @@
// Public running interface.
var filterFlag = flag.String("gocheck.f", "",
- "Regular expression selecting what to run (use -gocheck.list to see what this matches against)")
+ "Regular expression selecting which tests and/or suites to run")
var verboseFlag = flag.Bool("gocheck.v", false,
"Verbose mode")
var streamFlag = flag.Bool("gocheck.vv", false,
diff --git a/run_test.go b/run_test.go
index f48107a..be1fdf9 100644
--- a/run_test.go
+++ b/run_test.go
@@ -285,15 +285,15 @@
func (s *RunS) TestListFiltered(c *C) {
names := List(&FixtureHelper{}, &RunConf{Filter: "1"})
c.Assert(names, DeepEquals, []string{
- "*gocheck_test.FixtureHelper.Test1",
+ "FixtureHelper.Test1",
})
}
func (s *RunS) TestList(c *C) {
names := List(&FixtureHelper{}, &RunConf{})
c.Assert(names, DeepEquals, []string{
- "*gocheck_test.FixtureHelper.Test1",
- "*gocheck_test.FixtureHelper.Test2",
+ "FixtureHelper.Test1",
+ "FixtureHelper.Test2",
})
}