go/gcimporter15: update importer test (fix build)
The -newexport flag is on by default for 1.7, no need to special-case it anymore. Tested against 1.6, 1.7, and 1.8. Change-Id: I9c4a31f80d1309564e2a01514fca4b17e4378b9c Reviewed-on: https://go-review.googlesource.com/32582 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
d54c98191e
commit
c3ce94f8a8
|
|
@ -1,54 +0,0 @@
|
||||||
// Copyright 2011 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.
|
|
||||||
|
|
||||||
// +build go1.7,!go1.8
|
|
||||||
|
|
||||||
package gcimporter
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"runtime"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func compileNewExport(t *testing.T, dirname, filename string) string {
|
|
||||||
/* testenv. */ MustHaveGoBuild(t)
|
|
||||||
cmd := exec.Command("go", "tool", "compile", "-newexport", filename)
|
|
||||||
cmd.Dir = dirname
|
|
||||||
out, err := cmd.CombinedOutput()
|
|
||||||
if err != nil {
|
|
||||||
t.Logf("%s", out)
|
|
||||||
t.Fatalf("go tool compile %s failed: %s", filename, err)
|
|
||||||
}
|
|
||||||
// filename should end with ".go"
|
|
||||||
return filepath.Join(dirname, filename[:len(filename)-2]+"o")
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestImportTestdataNewExport(t *testing.T) {
|
|
||||||
// This package only handles gc export data.
|
|
||||||
if runtime.Compiler != "gc" {
|
|
||||||
t.Skipf("gc-built packages not available (compiler = %s)", runtime.Compiler)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if outFn := compileNewExport(t, "testdata", testfile); outFn != "" {
|
|
||||||
defer os.Remove(outFn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// filename should end with ".go"
|
|
||||||
filename := testfile[:len(testfile)-3]
|
|
||||||
if pkg := testPath(t, "./testdata/"+filename, "."); pkg != nil {
|
|
||||||
// The package's Imports list must include all packages
|
|
||||||
// explicitly imported by testfile, plus all packages
|
|
||||||
// referenced indirectly via exported objects in testfile.
|
|
||||||
want := `[package ast ("go/ast") package token ("go/token")]`
|
|
||||||
got := fmt.Sprint(pkg.Imports())
|
|
||||||
if got != want {
|
|
||||||
t.Errorf(`Package("exports").Imports() = %s, want %s`, got, want)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -147,10 +147,12 @@ func TestImportTestdata(t *testing.T) {
|
||||||
// The package's Imports list must include all packages
|
// The package's Imports list must include all packages
|
||||||
// explicitly imported by testfile, plus all packages
|
// explicitly imported by testfile, plus all packages
|
||||||
// referenced indirectly via exported objects in testfile.
|
// referenced indirectly via exported objects in testfile.
|
||||||
// With the textual export format, the list may also include
|
// With the textual export format (when run against Go1.6),
|
||||||
// additional packages that are not strictly required for
|
// the list may also include additional packages that are
|
||||||
// import processing alone (they are exported to err "on
|
// not strictly required for import processing alone (they
|
||||||
// the safe side").
|
// are exported to err "on the safe side").
|
||||||
|
// For now, we just test the presence of a few packages
|
||||||
|
// that we know are there for sure.
|
||||||
got := fmt.Sprint(pkg.Imports())
|
got := fmt.Sprint(pkg.Imports())
|
||||||
for _, want := range []string{"go/ast", "go/token"} {
|
for _, want := range []string{"go/ast", "go/token"} {
|
||||||
if !strings.Contains(got, want) {
|
if !strings.Contains(got, want) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue