-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
go/ssa: support custom TestMain functions in test packages
Supporting user-defined TestMain functions requires that we generate a "testmain" package for each testable package, rather than a single one for the entire program. This entails these API changes: 1. (*ssa.Program).{CreateTestMainPackage,FindTests} both now accept only a single package. Existing clients that pass them multiple packages must call them from a loop. 2. (*ssa.Program).FindTests returns an additional result, the the optional TestMain *ssa.Function. Existing clients may discard it. Also: - Test the new logic using the SSA interpreter - add ssautil.MainPackages helper - callgraph: allow multiple main packages, and analyze them all - ssadump -run: allow multiple main/test packages, and run each in a new interpreter - minor simplifications to some callers (e.g. guru) Fixes golang/go#9553 Change-Id: Ia7de9bd27448fb08b8d172ba5cdbcf37a762b7a0 Reviewed-on: https://go-review.googlesource.com/25102 Reviewed-by: Robert Griesemer <gri@golang.org>
- Loading branch information
Showing
11 changed files
with
220 additions
and
177 deletions.
There are no files selected for viewing
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
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,17 @@ | ||
package c_test | ||
|
||
import ( | ||
"os" | ||
"testing" | ||
) | ||
|
||
func TestC(t *testing.T) { | ||
println("TestC") | ||
} | ||
|
||
func TestMain(m *testing.M) { | ||
println("TestMain start") | ||
code := m.Run() | ||
println("TestMain end") | ||
os.Exit(code) | ||
} |
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
Oops, something went wrong.