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

Delta Between Two Patch Sets: test/run.go

Issue 5869049: code review 5869049: test: use testlib in a few more cases (part 2) (Closed)
Left Patch Set: diff -r 74edd315eec5 https://code.google.com/p/go/ Created 13 years ago
Right Patch Set: diff -r f4f63fb397c6 https://code.google.com/p/go/ Created 12 years, 11 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:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/run ('k') | test/testlib » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // skip 1 // skip
2 2
3 // Copyright 2012 The Go Authors. All rights reserved. 3 // Copyright 2012 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style 4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file. 5 // license that can be found in the LICENSE file.
6 6
7 // Run runs tests in the test directory. 7 // Run runs tests in the test directory.
8 //· 8 //·
9 // TODO(bradfitz): docs of some sort, once we figure out how we're changing 9 // TODO(bradfitz): docs of some sort, once we figure out how we're changing
10 // headers of files 10 // headers of files
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 log.Fatal(err) 165 log.Fatal(err)
166 } 166 }
167 } 167 }
168 168
169 // test holds the state of a test. 169 // test holds the state of a test.
170 type test struct { 170 type test struct {
171 dir, gofile string 171 dir, gofile string
172 donec chan bool // closed when done 172 donec chan bool // closed when done
173 173
174 src string 174 src string
175 » action string // "compile", "build", "run", "errorcheck", "skip", "run|r un" 175 » action string // "compile", "build", "run", "errorcheck", "skip", "runou tput"
176 176
177 tempDir string 177 tempDir string
178 err error 178 err error
179 } 179 }
180 180
181 // startTest· 181 // startTest·
182 func startTest(dir, gofile string) *test { 182 func startTest(dir, gofile string) *test {
183 t := &test{ 183 t := &test{
184 dir: dir, 184 dir: dir,
185 gofile: gofile, 185 gofile: gofile,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 f := strings.Fields(action) 244 f := strings.Fields(action)
245 if len(f) > 0 { 245 if len(f) > 0 {
246 action = f[0] 246 action = f[0]
247 args = f[1:] 247 args = f[1:]
248 } 248 }
249 249
250 switch action { 250 switch action {
251 case "cmpout": 251 case "cmpout":
252 action = "run" // the run case already looks for <dir>/<test>.ou t files 252 action = "run" // the run case already looks for <dir>/<test>.ou t files
253 fallthrough 253 fallthrough
254 » case "compile", "build", "run", "errorcheck", "run|run": 254 » case "compile", "build", "run", "errorcheck", "runoutput":
255 t.action = action 255 t.action = action
256 case "skip": 256 case "skip":
257 t.action = "skip" 257 t.action = "skip"
258 return 258 return
259 default: 259 default:
260 t.err = skipError("skipped; unknown pattern: " + action) 260 t.err = skipError("skipped; unknown pattern: " + action)
261 t.action = "??" 261 t.action = "??"
262 return 262 return
263 } 263 }
264 264
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 case "run": 310 case "run":
311 useTmp = false 311 useTmp = false
312 out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...) 312 out, err := runcmd(append([]string{"go", "run", t.goFileName()}, args...)...)
313 if err != nil { 313 if err != nil {
314 t.err = fmt.Errorf("%s\n%s", err, out) 314 t.err = fmt.Errorf("%s\n%s", err, out)
315 } 315 }
316 if string(out) != t.expectedOutput() { 316 if string(out) != t.expectedOutput() {
317 t.err = fmt.Errorf("incorrect output\n%s", out) 317 t.err = fmt.Errorf("incorrect output\n%s", out)
318 } 318 }
319 319
320 » case "run|run": 320 » case "runoutput":
321 useTmp = false 321 useTmp = false
322 out, err := runcmd("go", "run", t.goFileName()) 322 out, err := runcmd("go", "run", t.goFileName())
323 if err != nil { 323 if err != nil {
324 t.err = fmt.Errorf("%s\n%s", err, out) 324 t.err = fmt.Errorf("%s\n%s", err, out)
325 } 325 }
326 tfile := filepath.Join(t.tempDir, "tmp__.go") 326 tfile := filepath.Join(t.tempDir, "tmp__.go")
327 err = ioutil.WriteFile(tfile, out, 0666) 327 err = ioutil.WriteFile(tfile, out, 0666)
328 if err != nil { 328 if err != nil {
329 t.err = fmt.Errorf("write tempfile:%s", err) 329 t.err = fmt.Errorf("write tempfile:%s", err)
330 return 330 return
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 re: regexp.MustCompile(rx), 476 re: regexp.MustCompile(rx),
477 filterRe: regexp.MustCompile(filterPattern), 477 filterRe: regexp.MustCompile(filterPattern),
478 lineNum: lineNum, 478 lineNum: lineNum,
479 file: t.gofile, 479 file: t.gofile,
480 }) 480 })
481 } 481 }
482 } 482 }
483 483
484 return 484 return
485 } 485 }
LEFTRIGHT

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