go/gcexportdata: fix example test for changes in net/rpc
Apparently this frozen package is not so frozen. A change in the imports has changed the line numbers, causing the test to break. Switch to another test case in the hopes that it is less fragile. Change-Id: I8d5203417b8bd73a9e837060d40980a09a767869 Reviewed-on: https://go-review.googlesource.com/c/tools/+/172285 Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
3e7148b2fa
commit
52f869c107
|
@ -80,7 +80,7 @@ func ExampleNewImporter() {
|
|||
// choosing a package that doesn't change across releases
|
||||
import "net/rpc"
|
||||
|
||||
const defaultRPCPath = rpc.DefaultRPCPath
|
||||
const serverError rpc.ServerError = ""
|
||||
`
|
||||
fset := token.NewFileSet()
|
||||
f, err := parser.ParseFile(fset, "myrpc.go", src, 0)
|
||||
|
@ -97,17 +97,16 @@ const defaultRPCPath = rpc.DefaultRPCPath
|
|||
}
|
||||
|
||||
// object from imported package
|
||||
pi := packages["net/rpc"].Scope().Lookup("DefaultRPCPath")
|
||||
fmt.Printf("const %s.%s %s = %s // %s\n",
|
||||
pi := packages["net/rpc"].Scope().Lookup("ServerError")
|
||||
fmt.Printf("type %s.%s %s // %s\n",
|
||||
pi.Pkg().Path(),
|
||||
pi.Name(),
|
||||
pi.Type(),
|
||||
pi.(*types.Const).Val(),
|
||||
pi.Type().Underlying(),
|
||||
slashify(fset.Position(pi.Pos())),
|
||||
)
|
||||
|
||||
// object in source package
|
||||
twopi := pkg.Scope().Lookup("defaultRPCPath")
|
||||
twopi := pkg.Scope().Lookup("serverError")
|
||||
fmt.Printf("const %s %s = %s // %s\n",
|
||||
twopi.Name(),
|
||||
twopi.Type(),
|
||||
|
@ -117,8 +116,8 @@ const defaultRPCPath = rpc.DefaultRPCPath
|
|||
|
||||
// Output:
|
||||
//
|
||||
// const net/rpc.DefaultRPCPath untyped string = "/_goRPC_" // $GOROOT/src/net/rpc/server.go:146:1
|
||||
// const defaultRPCPath untyped string = "/_goRPC_" // myrpc.go:6:7
|
||||
// type net/rpc.ServerError string // $GOROOT/src/net/rpc/client.go:20:1
|
||||
// const serverError net/rpc.ServerError = "" // myrpc.go:6:7
|
||||
}
|
||||
|
||||
func slashify(posn token.Position) token.Position {
|
||||
|
|
Loading…
Reference in New Issue