code review 5701051: testing: don't run examples if -test.run is set (issue 5701051)

10 views
Skip to first unread message

r...@golang.org

unread,
Feb 26, 2012, 7:25:55 PM2/26/12
to golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
Reviewers: golang-dev_googlegroups.com,

Message:
Hello golan...@googlegroups.com,

I'd like you to review this change to
https://code.google.com/p/go/


Description:
testing: don't run examples if -test.run is set
If we're restricting tests, don't blindly include examples; things can
get noisy.

Please review this at http://codereview.appspot.com/5701051/

Affected files:
M src/pkg/testing/example.go


Index: src/pkg/testing/example.go
===================================================================
--- a/src/pkg/testing/example.go
+++ b/src/pkg/testing/example.go
@@ -20,6 +20,9 @@
}

func RunExamples(examples []InternalExample) (ok bool) {
+ if *match != "" {
+ return // Don't run examples if testing is restricted: we're debugging.
+ }
ok = true

var eg InternalExample


Brad Fitzpatrick

unread,
Feb 26, 2012, 7:27:56 PM2/26/12
to r...@golang.org, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
LGTM

But what if we're debugging an example?  Maybe just apply the same filtering rules to the names of ExampleFoo?

Rob 'Commander' Pike

unread,
Feb 26, 2012, 7:46:47 PM2/26/12
to Brad Fitzpatrick, golan...@googlegroups.com, re...@codereview-hr.appspotmail.com
A better solution might be to mimic -test.run and -test.bench and add
-test.example

r...@golang.org

unread,
Feb 26, 2012, 8:03:59 PM2/26/12
to golan...@googlegroups.com, brad...@golang.org, re...@codereview-hr.appspotmail.com
Reply all
Reply to author
Forward
0 new messages