Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/go/ssa: add support to CreateTestMainPackage for testing.M #9553

Closed
alandonovan opened this issue Jan 9, 2015 · 2 comments
Closed

Comments

@alandonovan
Copy link
Contributor

The generated code for packages using *testing.M is slightly different than for other tests.
The ssa package's function to synthesize testmain packages needs updating.

@alandonovan alandonovan self-assigned this Jan 9, 2015
@mikioh mikioh changed the title tools/go/ssa: add support to CreateTestMainPackage for testing.M go/ssa: add support to CreateTestMainPackage for testing.M Jan 10, 2015
@rsc rsc added this to the Unplanned milestone Apr 10, 2015
@rsc rsc changed the title go/ssa: add support to CreateTestMainPackage for testing.M x/tools/go/ssa: add support to CreateTestMainPackage for testing.M Apr 14, 2015
@rsc rsc modified the milestones: Unreleased, Unplanned Apr 14, 2015
@rsc rsc removed the repo-tools label Apr 14, 2015
@alandonovan
Copy link
Contributor Author

Note to self: do this after Go 1.6.

Also, think about an alternative approach to generating the testmain package. Half of the work can be done in a way that doesn't depend on SSA. For example, in typeutil, we could add utility functions that, given a *types.Package, return a struct describing the tests within it, or a generated source file containing a main function like what go test would generate. go/loader could be extended to create and type-check these packages automatically, and then the SSA package wouldn't need to know about them.

@gopherbot
Copy link
Contributor

CL https://golang.org/cl/25102 mentions this issue.

@golang golang locked and limited conversation to collaborators Oct 19, 2017
henderjon pushed a commit to oggodoc/godoc that referenced this issue Jun 13, 2024
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>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants