go/loader: in stdlib_test, skip packages that depend on vendoring
until vendoring support is added (soon). Change-Id: I954514b5c6b82622c0c831a289ccdcc16dbd37f8 Reviewed-on: https://go-review.googlesource.com/14130 Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
parent
b48dc8da98
commit
b9f1f6a3c1
|
@ -28,6 +28,17 @@ import (
|
|||
"golang.org/x/tools/go/types"
|
||||
)
|
||||
|
||||
// The set of packages that transitively depend on cmd/internal/objfile,
|
||||
// which uses vendoring, which go/loader does not yet support.
|
||||
// TODO(adonovan): add support for vendoring and delete this.
|
||||
var skip = map[string]bool{
|
||||
"cmd/addr2line": true,
|
||||
"cmd/internal/objfile": true,
|
||||
"cmd/nm": true,
|
||||
"cmd/objdump": true,
|
||||
"cmd/pprof": true,
|
||||
}
|
||||
|
||||
func TestStdlib(t *testing.T) {
|
||||
if runtime.GOOS == "android" {
|
||||
t.Skipf("incomplete std lib on %s", runtime.GOOS)
|
||||
|
@ -44,6 +55,9 @@ func TestStdlib(t *testing.T) {
|
|||
ctxt.GOPATH = "" // disable GOPATH
|
||||
conf := loader.Config{Build: &ctxt}
|
||||
for _, path := range buildutil.AllPackages(conf.Build) {
|
||||
if skip[path] {
|
||||
continue
|
||||
}
|
||||
conf.ImportWithTests(path)
|
||||
}
|
||||
|
||||
|
|
|
@ -113,15 +113,15 @@ func ExampleBuildPackage() {
|
|||
// return
|
||||
}
|
||||
|
||||
// This program shows how to load a main package (cmd/nm) and all its
|
||||
// This program shows how to load a main package (cmd/cover) and all its
|
||||
// dependencies from source, using the loader, and then build SSA code
|
||||
// for the entire program. This is what you'd typically use for a
|
||||
// whole-program analysis.
|
||||
//
|
||||
func ExampleLoadProgram() {
|
||||
// Load cmd/nm and its dependencies.
|
||||
// Load cmd/cover and its dependencies.
|
||||
var conf loader.Config
|
||||
conf.Import("cmd/nm")
|
||||
conf.Import("cmd/cover")
|
||||
lprog, err := conf.Load()
|
||||
if err != nil {
|
||||
fmt.Print(err) // type error in some package
|
||||
|
@ -131,7 +131,7 @@ func ExampleLoadProgram() {
|
|||
// Create SSA-form program representation.
|
||||
prog := ssautil.CreateProgram(lprog, ssa.SanityCheckFunctions)
|
||||
|
||||
// Build SSA code for the entire cmd/nm program.
|
||||
// Build SSA code for the entire cmd/cover program.
|
||||
prog.BuildAll()
|
||||
|
||||
// Output:
|
||||
|
|
|
@ -27,6 +27,18 @@ import (
|
|||
"golang.org/x/tools/go/ssa/ssautil"
|
||||
)
|
||||
|
||||
// Skip the set of packages that transitively depend on
|
||||
// cmd/internal/objfile, which uses vendoring,
|
||||
// which go/loader does not yet support.
|
||||
// TODO(adonovan): add support for vendoring and delete this.
|
||||
var skip = map[string]bool{
|
||||
"cmd/addr2line": true,
|
||||
"cmd/internal/objfile": true,
|
||||
"cmd/nm": true,
|
||||
"cmd/objdump": true,
|
||||
"cmd/pprof": true,
|
||||
}
|
||||
|
||||
func bytesAllocated() uint64 {
|
||||
runtime.GC()
|
||||
var stats runtime.MemStats
|
||||
|
@ -43,9 +55,11 @@ func TestStdlib(t *testing.T) {
|
|||
ctxt := build.Default // copy
|
||||
ctxt.GOPATH = "" // disable GOPATH
|
||||
conf := loader.Config{Build: &ctxt}
|
||||
if _, err := conf.FromArgs(buildutil.AllPackages(conf.Build), true); err != nil {
|
||||
t.Errorf("FromArgs failed: %v", err)
|
||||
return
|
||||
for _, path := range buildutil.AllPackages(conf.Build) {
|
||||
if skip[path] {
|
||||
continue
|
||||
}
|
||||
conf.ImportWithTests(path)
|
||||
}
|
||||
|
||||
iprog, err := conf.Load()
|
||||
|
|
Loading…
Reference in New Issue