LEFT | RIGHT |
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 Loading... |
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 Loading... |
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 Loading... |
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 Loading... |
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 } |
LEFT | RIGHT |