LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 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 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "bufio" | 8 "bufio" |
9 "exec" | 9 "exec" |
10 "fmt" | 10 "fmt" |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 if err != nil { | 306 if err != nil { |
307 Fatalf("can't read output from command: %s", err) | 307 Fatalf("can't read output from command: %s", err) |
308 } | 308 } |
309 return string(b) | 309 return string(b) |
310 } | 310 } |
311 return "" | 311 return "" |
312 } | 312 } |
313 | 313 |
314 // writeTestmainGo generates the test program to be compiled, "./_testmain.go". | 314 // writeTestmainGo generates the test program to be compiled, "./_testmain.go". |
315 func writeTestmainGo() { | 315 func writeTestmainGo() { |
316 » f, err := os.OpenFile("_testmain.go", os.O_WRONLY|os.O_CREATE|os.O_TRUNC
, 0666) | 316 » f, err := os.Create("_testmain.go") |
317 if err != nil { | 317 if err != nil { |
318 Fatalf("can't create _testmain.go: %s", err) | 318 Fatalf("can't create _testmain.go: %s", err) |
319 } | 319 } |
320 defer f.Close() | 320 defer f.Close() |
321 b := bufio.NewWriter(f) | 321 b := bufio.NewWriter(f) |
322 defer b.Flush() | 322 defer b.Flush() |
323 | 323 |
324 // Package and imports. | 324 // Package and imports. |
325 fmt.Fprint(b, "package main\n\n") | 325 fmt.Fprint(b, "package main\n\n") |
326 // Are there tests from a package other than the one we're testing? | 326 // Are there tests from a package other than the one we're testing? |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 if err != nil { | 403 if err != nil { |
404 return | 404 return |
405 } | 405 } |
406 } | 406 } |
407 return matchRe.MatchString(str), nil | 407 return matchRe.MatchString(str), nil |
408 } | 408 } |
409 | 409 |
410 func main() { | 410 func main() { |
411 testing.Main(matchString, tests, benchmarks) | 411 testing.Main(matchString, tests, benchmarks) |
412 }` | 412 }` |
LEFT | RIGHT |