LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 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 runtime_test | 5 package runtime_test |
6 | 6 |
7 import ( | 7 import ( |
8 "io/ioutil" | 8 "io/ioutil" |
9 "os" | 9 "os" |
10 "os/exec" | 10 "os/exec" |
11 "path/filepath" | 11 "path/filepath" |
| 12 "runtime" |
12 "strings" | 13 "strings" |
13 "testing" | 14 "testing" |
14 "text/template" | 15 "text/template" |
15 ) | 16 ) |
16 | 17 |
17 // testEnv excludes GODEBUG from the environment | 18 // testEnv excludes GODEBUG from the environment |
18 // to prevent its output from breaking tests that | 19 // to prevent its output from breaking tests that |
19 // are trying to parse other command output. | 20 // are trying to parse other command output. |
20 func testEnv(cmd *exec.Cmd) *exec.Cmd { | 21 func testEnv(cmd *exec.Cmd) *exec.Cmd { |
21 if cmd.Env != nil { | 22 if cmd.Env != nil { |
22 panic("environment already set") | 23 panic("environment already set") |
23 } | 24 } |
24 for _, env := range os.Environ() { | 25 for _, env := range os.Environ() { |
25 if strings.HasPrefix(env, "GODEBUG=") { | 26 if strings.HasPrefix(env, "GODEBUG=") { |
26 continue | 27 continue |
27 } | 28 } |
28 cmd.Env = append(cmd.Env, env) | 29 cmd.Env = append(cmd.Env, env) |
29 } | 30 } |
30 return cmd | 31 return cmd |
31 } | 32 } |
32 | 33 |
33 func executeTest(t *testing.T, templ string, data interface{}) string { | 34 func executeTest(t *testing.T, templ string, data interface{}) string { |
| 35 if runtime.GOOS == "nacl" { |
| 36 t.Skip("skipping on nacl") |
| 37 } |
| 38 |
34 checkStaleRuntime(t) | 39 checkStaleRuntime(t) |
35 | 40 |
36 st := template.Must(template.New("crashSource").Parse(templ)) | 41 st := template.Must(template.New("crashSource").Parse(templ)) |
37 | 42 |
38 dir, err := ioutil.TempDir("", "go-build") | 43 dir, err := ioutil.TempDir("", "go-build") |
39 if err != nil { | 44 if err != nil { |
40 t.Fatalf("failed to create temp directory: %v", err) | 45 t.Fatalf("failed to create temp directory: %v", err) |
41 } | 46 } |
42 defer os.RemoveAll(dir) | 47 defer os.RemoveAll(dir) |
43 | 48 |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 func main() { | 336 func main() { |
332 go func() { | 337 go func() { |
333 time.Sleep(time.Millisecond) | 338 time.Sleep(time.Millisecond) |
334 }() | 339 }() |
335 i := 0 | 340 i := 0 |
336 runtime.SetFinalizer(&i, func(p *int) {}) | 341 runtime.SetFinalizer(&i, func(p *int) {}) |
337 runtime.GC() | 342 runtime.GC() |
338 runtime.Goexit() | 343 runtime.Goexit() |
339 } | 344 } |
340 ` | 345 ` |
LEFT | RIGHT |