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
|
// choosing a package that doesn't change across releases
|
||||||
import "net/rpc"
|
import "net/rpc"
|
||||||
|
|
||||||
const defaultRPCPath = rpc.DefaultRPCPath
|
const serverError rpc.ServerError = ""
|
||||||
`
|
`
|
||||||
fset := token.NewFileSet()
|
fset := token.NewFileSet()
|
||||||
f, err := parser.ParseFile(fset, "myrpc.go", src, 0)
|
f, err := parser.ParseFile(fset, "myrpc.go", src, 0)
|
||||||
|
@ -97,17 +97,16 @@ const defaultRPCPath = rpc.DefaultRPCPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// object from imported package
|
// object from imported package
|
||||||
pi := packages["net/rpc"].Scope().Lookup("DefaultRPCPath")
|
pi := packages["net/rpc"].Scope().Lookup("ServerError")
|
||||||
fmt.Printf("const %s.%s %s = %s // %s\n",
|
fmt.Printf("type %s.%s %s // %s\n",
|
||||||
pi.Pkg().Path(),
|
pi.Pkg().Path(),
|
||||||
pi.Name(),
|
pi.Name(),
|
||||||
pi.Type(),
|
pi.Type().Underlying(),
|
||||||
pi.(*types.Const).Val(),
|
|
||||||
slashify(fset.Position(pi.Pos())),
|
slashify(fset.Position(pi.Pos())),
|
||||||
)
|
)
|
||||||
|
|
||||||
// object in source package
|
// object in source package
|
||||||
twopi := pkg.Scope().Lookup("defaultRPCPath")
|
twopi := pkg.Scope().Lookup("serverError")
|
||||||
fmt.Printf("const %s %s = %s // %s\n",
|
fmt.Printf("const %s %s = %s // %s\n",
|
||||||
twopi.Name(),
|
twopi.Name(),
|
||||||
twopi.Type(),
|
twopi.Type(),
|
||||||
|
@ -117,8 +116,8 @@ const defaultRPCPath = rpc.DefaultRPCPath
|
||||||
|
|
||||||
// Output:
|
// Output:
|
||||||
//
|
//
|
||||||
// const net/rpc.DefaultRPCPath untyped string = "/_goRPC_" // $GOROOT/src/net/rpc/server.go:146:1
|
// type net/rpc.ServerError string // $GOROOT/src/net/rpc/client.go:20:1
|
||||||
// const defaultRPCPath untyped string = "/_goRPC_" // myrpc.go:6:7
|
// const serverError net/rpc.ServerError = "" // myrpc.go:6:7
|
||||||
}
|
}
|
||||||
|
|
||||||
func slashify(posn token.Position) token.Position {
|
func slashify(posn token.Position) token.Position {
|
||||||
|
|
Loading…
Reference in New Issue