Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1282)

Side by Side Diff: src/pkg/testing/testing.go

Issue 3831041: code review 3831041: testing: fix error message on invalid regexp (Closed)
Patch Set: code review 3831041: testing: fix error message on invalid regexp Created 13 years, 3 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/testing/benchmark.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // The testing package provides support for automated testing of Go packages. 5 // The testing package provides support for automated testing of Go packages.
6 // It is intended to be used in concert with the ``gotest'' utility, which autom ates 6 // It is intended to be used in concert with the ``gotest'' utility, which autom ates
7 // execution of any function of the form 7 // execution of any function of the form
8 // func TestXxx(*testing.T) 8 // func TestXxx(*testing.T)
9 // where Xxx can be any alphanumeric string (but the first letter must not be in 9 // where Xxx can be any alphanumeric string (but the first letter must not be in
10 // [a-z]) and serves to identify the test routine. 10 // [a-z]) and serves to identify the test routine.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // of gotest. 137 // of gotest.
138 func Main(matchString func(pat, str string) (bool, os.Error), tests []InternalTe st) { 138 func Main(matchString func(pat, str string) (bool, os.Error), tests []InternalTe st) {
139 flag.Parse() 139 flag.Parse()
140 ok := true 140 ok := true
141 if len(tests) == 0 { 141 if len(tests) == 0 {
142 println("testing: warning: no tests to run") 142 println("testing: warning: no tests to run")
143 } 143 }
144 for i := 0; i < len(tests); i++ { 144 for i := 0; i < len(tests); i++ {
145 matched, err := matchString(*match, tests[i].Name) 145 matched, err := matchString(*match, tests[i].Name)
146 if err != nil { 146 if err != nil {
147 » » » println("invalid regexp for -match:", err) 147 » » » println("invalid regexp for -match:", err.String())
148 os.Exit(1) 148 os.Exit(1)
149 } 149 }
150 if !matched { 150 if !matched {
151 continue 151 continue
152 } 152 }
153 if *chatty { 153 if *chatty {
154 println("=== RUN ", tests[i].Name) 154 println("=== RUN ", tests[i].Name)
155 } 155 }
156 t := new(T) 156 t := new(T)
157 t.ch = make(chan *T) 157 t.ch = make(chan *T)
158 go tRunner(t, &tests[i]) 158 go tRunner(t, &tests[i])
159 <-t.ch 159 <-t.ch
160 if t.failed { 160 if t.failed {
161 println("--- FAIL:", tests[i].Name) 161 println("--- FAIL:", tests[i].Name)
162 print(t.errors) 162 print(t.errors)
163 ok = false 163 ok = false
164 } else if *chatty { 164 } else if *chatty {
165 println("--- PASS:", tests[i].Name) 165 println("--- PASS:", tests[i].Name)
166 print(t.errors) 166 print(t.errors)
167 } 167 }
168 } 168 }
169 if !ok { 169 if !ok {
170 println("FAIL") 170 println("FAIL")
171 os.Exit(1) 171 os.Exit(1)
172 } 172 }
173 println("PASS") 173 println("PASS")
174 } 174 }
OLDNEW
« no previous file with comments | « src/pkg/testing/benchmark.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b