-
Notifications
You must be signed in to change notification settings - Fork 17.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
runtime: move test programs out of source code, coalesce
Now there are just three programs to compile instead of many, and repeated tests can reuse the compilation result instead of rebuilding it. Combined, these changes reduce the time spent testing runtime during all.bash on my laptop from about 60 to about 30 seconds. (All.bash itself runs in 5½ minutes.) For #10571. Change-Id: Ie2c1798b847f1a635a860d11dcdab14375319ae9 Reviewed-on: https://go-review.googlesource.com/18085 Reviewed-by: Austin Clements <[email protected]> Run-TryBot: Austin Clements <[email protected]>
- Loading branch information
Showing
24 changed files
with
991 additions
and
817 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2015 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"runtime" | ||
) | ||
|
||
func init() { | ||
register("Crash", Crash) | ||
} | ||
|
||
func test(name string) { | ||
defer func() { | ||
if x := recover(); x != nil { | ||
fmt.Printf(" recovered") | ||
} | ||
fmt.Printf(" done\n") | ||
}() | ||
fmt.Printf("%s:", name) | ||
var s *string | ||
_ = *s | ||
fmt.Print("SHOULD NOT BE HERE") | ||
} | ||
|
||
func testInNewThread(name string) { | ||
c := make(chan bool) | ||
go func() { | ||
runtime.LockOSThread() | ||
test(name) | ||
c <- true | ||
}() | ||
<-c | ||
} | ||
|
||
func Crash() { | ||
runtime.LockOSThread() | ||
test("main") | ||
testInNewThread("new-thread") | ||
testInNewThread("second-new-thread") | ||
test("main-again") | ||
} |
Oops, something went wrong.