Debian Codegraph @

go/ir/stdlib_test.go

raw
1 // Copyright 2013 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 //lint:file-ignore SA1019 go/ssa's test suite is built around the deprecated go/loader. We'll leave fixing that to upstream.
6
7 // Incomplete source tree on Android.
8
9 //go:build !android
10
11 package ir_test
12
13 // This file runs the IR builder in sanity-checking mode on all
14 // packages beneath $GOROOT and prints some summary information.
15 //
16 // Run with "go test -cpu=8 to" set GOMAXPROCS.
17
18 import (
19 "testing"
20
21 "honnef.co/go/tools/go/ir"
22 "honnef.co/go/tools/go/ir/irutil"
23
24 "golang.org/x/tools/go/packages"
25 )
26
27 func TestStdlib(t *testing.T) {
28 if testing.Short() {
29 t.Skip("skipping in short mode; too slow (golang.org/issue/14113)")
30 }
31
32 cfg := &packages.Config{
33 Mode: packages.NeedName | packages.NeedFiles | packages.NeedCompiledGoFiles | packages.NeedImports | packages.NeedDeps | packages.NeedTypes | packages.NeedSyntax | packages.NeedTypesInfo | packages.NeedTypesSizes,
34 }
35 pkgs, err := packages.Load(cfg, "std")
36 if err != nil {
37 t.Fatalf("Load failed: %v", err)
38 }
39 for _, pkg := range pkgs {
40 if len(pkg.Errors) != 0 {
41 t.Fatalf("Load failed: %v", pkg.Errors[0])
42 }
43 }
44
45 var mode ir.BuilderMode
46 mode |= ir.SanityCheckFunctions
47 mode |= ir.GlobalDebug
48 prog, _ := irutil.Packages(pkgs, mode, nil)
49 prog.Build()
50 }