wire/internal/wire: use on-disk GOPATH in generate tests (google/go-cloud#616)

The primary motivation is to permit a move to using go/packages instead
of go/loader. go/packages runs exclusively by shelling out to the go
tool, which precludes use of the in-memory "magic" GOPATH being used
up to this point.

This has a secondary effect of removing a lot of code to support "magic"
GOPATH from the test infrastructure. This is on the whole good, but
necessitated a change in the error scrubbing: since the filenames are
no longer fixed, error scrubbing also must remove the leading
$GOPATH/src lines.

Another related change: since all callers of Generate needed to know the
package path in order to write out wire_gen.go (necessitating a
find-only import search) and Generate already has this information,
Generate now returns this information to the caller. This should further
reduce callers' coupling to Wire's load internals. It also eliminates
code duplication.

This should hopefully shake out any difference in path separators for
running on Windows, but I have not tested that yet.

Updates google/go-cloud#78
Updates google/go-cloud#323
This commit is contained in:
Ross Light
2018-11-06 08:44:51 -08:00
parent ab113bf8d1
commit 64470a2452
24 changed files with 301 additions and 367 deletions

View File

@@ -1 +1 @@
./example.com/foo
./foo

View File

@@ -1,4 +1,4 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: cycle for example.com/foo.Bar:
example.com/foo/wire.go:x:y: cycle for example.com/foo.Bar:
example.com/foo.Bar (example.com/foo.provideBar) ->
example.com/foo.Foo (example.com/foo.provideFoo) ->
example.com/foo.Baz (example.com/foo.provideBaz) ->

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: var example.com/foo.myFakeSet struct{} is not a provider or a provider set
example.com/foo/wire.go:x:y: var example.com/foo.myFakeSet struct{} is not a provider or a provider set

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectBar: input of example.com/foo.Foo conflicts with provider provideFoo at /wire_gopath/src/example.com/foo/foo.go:x:y
example.com/foo/wire.go:x:y: inject injectBar: input of example.com/foo.Foo conflicts with provider provideFoo at example.com/foo/foo.go:x:y

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectFoo: provider for example.com/foo.Foo returns cleanup but injection does not return cleanup function
example.com/foo/wire.go:x:y: inject injectFoo: provider for example.com/foo.Foo returns cleanup but injection does not return cleanup function

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectFoo: provider for example.com/foo.Foo returns error but injection not allowed to fail
example.com/foo/wire.go:x:y: inject injectFoo: provider for example.com/foo.Foo returns error but injection not allowed to fail

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: string does not implement example.com/foo.Fooer
example.com/foo/wire.go:x:y: string does not implement example.com/foo.Fooer

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: first argument to Bind must be a pointer to an interface type; found string
example.com/foo/wire.go:x:y: first argument to Bind must be a pointer to an interface type; found string

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: too few arguments in call to wire.Bind
example.com/foo/wire.go:x:y: too few arguments in call to wire.Bind

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: string does not implement io.Reader
example.com/foo/wire.go:x:y: string does not implement io.Reader

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: first argument to InterfaceValue must be a pointer to an interface type; found string
example.com/foo/wire.go:x:y: first argument to InterfaceValue must be a pointer to an interface type; found string

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: too few arguments in call to wire.InterfaceValue
example.com/foo/wire.go:x:y: too few arguments in call to wire.InterfaceValue

View File

@@ -1,41 +1,41 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
current:
<- provider "provideFooAgain" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFooAgain" (example.com/foo/foo.go:x:y)
previous:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
current:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
previous:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider set "Set" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
<- provider set "Set" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
current:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
previous:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider set "Set" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider set "SuperSet" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
<- provider set "Set" (example.com/foo/foo.go:x:y)
<- provider set "SuperSet" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/foo.go:x:y: SetWithDuplicateBindings has multiple bindings for example.com/foo.Foo
example.com/foo/foo.go:x:y: SetWithDuplicateBindings has multiple bindings for example.com/foo.Foo
current:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider set "Set" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider set "SuperSet" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
<- provider set "Set" (example.com/foo/foo.go:x:y)
<- provider set "SuperSet" (example.com/foo/foo.go:x:y)
previous:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider set "Set" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
<- provider set "Set" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Foo
current:
<- wire.Value (/wire_gopath/src/example.com/foo/wire.go:x:y)
<- wire.Value (example.com/foo/wire.go:x:y)
previous:
<- provider "provideFoo" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideFoo" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Bar
example.com/foo/wire.go:x:y: wire.Build has multiple bindings for example.com/foo.Bar
current:
<- wire.Bind (/wire_gopath/src/example.com/foo/wire.go:x:y)
<- wire.Bind (example.com/foo/wire.go:x:y)
previous:
<- provider "provideBar" (/wire_gopath/src/example.com/foo/foo.go:x:y)
<- provider "provideBar" (example.com/foo/foo.go:x:y)

View File

@@ -1,12 +1,12 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectMissingOutputType: no provider found for example.com/foo.Foo, output of injector
example.com/foo/wire.go:x:y: inject injectMissingOutputType: no provider found for example.com/foo.Foo, output of injector
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectMultipleMissingTypes: no provider found for example.com/foo.Foo
needed by example.com/foo.Baz in provider "provideBaz" (/wire_gopath/src/example.com/foo/foo.go:x:y)
example.com/foo/wire.go:x:y: inject injectMultipleMissingTypes: no provider found for example.com/foo.Foo
needed by example.com/foo.Baz in provider "provideBaz" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectMultipleMissingTypes: no provider found for example.com/foo.Bar
needed by example.com/foo.Baz in provider "provideBaz" (/wire_gopath/src/example.com/foo/foo.go:x:y)
example.com/foo/wire.go:x:y: inject injectMultipleMissingTypes: no provider found for example.com/foo.Bar
needed by example.com/foo.Baz in provider "provideBaz" (example.com/foo/foo.go:x:y)
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectMissingRecursiveType: no provider found for example.com/foo.Foo
needed by example.com/foo.Zip in provider "provideZip" (/wire_gopath/src/example.com/foo/foo.go:x:y)
needed by example.com/foo.Zap in provider "provideZap" (/wire_gopath/src/example.com/foo/foo.go:x:y)
needed by example.com/foo.Zop in provider "provideZop" (/wire_gopath/src/example.com/foo/foo.go:x:y)
example.com/foo/wire.go:x:y: inject injectMissingRecursiveType: no provider found for example.com/foo.Foo
needed by example.com/foo.Zip in provider "provideZip" (example.com/foo/foo.go:x:y)
needed by example.com/foo.Zap in provider "provideZap" (example.com/foo/foo.go:x:y)
needed by example.com/foo.Zop in provider "provideZop" (example.com/foo/foo.go:x:y)

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectFooer: no provider found for example.com/foo.Fooer, output of injector
example.com/foo/wire.go:x:y: inject injectFooer: no provider found for example.com/foo.Fooer, output of injector

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: foo not exported by package bar
example.com/foo/wire.go:x:y: foo not exported by package bar

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectedMessage: value string can't be used: uses unexported identifier privateMsg
example.com/foo/wire.go:x:y: inject injectedMessage: value string can't be used: uses unexported identifier privateMsg

View File

@@ -1,7 +1,7 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectBar: unused provider set "unusedSet"
example.com/foo/wire.go:x:y: inject injectBar: unused provider set "unusedSet"
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectBar: unused provider "provideUnused"
example.com/foo/wire.go:x:y: inject injectBar: unused provider "provideUnused"
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectBar: unused value of type string
example.com/foo/wire.go:x:y: inject injectBar: unused value of type string
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectBar: unused interface binding to type example.com/foo.Fooer
example.com/foo/wire.go:x:y: inject injectBar: unused interface binding to type example.com/foo.Fooer

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: inject injectBar: value int can't be used: f is not declared in package scope
example.com/foo/wire.go:x:y: inject injectBar: value int can't be used: f is not declared in package scope

View File

@@ -1 +1 @@
/wire_gopath/src/example.com/foo/wire.go:x:y: argument to Value may not be an interface value (found io.Reader); use InterfaceValue instead
example.com/foo/wire.go:x:y: argument to Value may not be an interface value (found io.Reader); use InterfaceValue instead