Commit Graph

91 Commits

Author SHA1 Message Date
Ross Light
c3ea2961cb wire: in tests, don't copy want/wire_gen.go into the temporary GOPATH (google/go-cloud#646)
This does not change the results of the test, but should not be
happening.
2018-11-13 13:16:46 -08:00
Ross Light
64470a2452 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
2018-11-13 13:16:46 -08:00
Robert van Gent
ab113bf8d1 wire: allow wire.Value to use values with no parent (i.e., struct fields) (google/go-cloud#596) 2018-11-13 13:16:46 -08:00
Ross Light
b4218146b9 wire: expand on package documentation (google/go-cloud#587) 2018-11-13 13:16:46 -08:00
Ross Light
c4f6234106 wire: add FAQ section (google/go-cloud#573)
Fixes google/go-cloud#555
Updates google/go-cloud#513
2018-11-13 13:16:46 -08:00
Robert van Gent
b7c4e8db66 wire: use multiline errors instead of one single line for errors with traces (google/go-cloud#571) 2018-11-13 13:16:46 -08:00
ktr
cf9080e300 wire: remove duplicated "a" (google/go-cloud#561) 2018-11-13 13:16:46 -08:00
ktr
0a4cc23d20 wire: fix typo in example code (google/go-cloud#560) 2018-11-13 13:16:46 -08:00
Robert van Gent
97e5c83e18 wire/test: support multi-line errors and -record mode in tests (google/go-cloud#550) 2018-11-13 13:16:46 -08:00
Robert van Gent
a8825fef58 wire: add info from the dependency graph when a type is not provided 2018-11-13 13:16:46 -08:00
Yoichiro Shimizu
b84ad6154f wire/readme: wire.InterfaceValue should not return Foo{} (google/go-cloud#504) 2018-11-13 13:16:46 -08:00
Robert van Gent
b1fd26c92a wire: improve error message for provider set conflicts (google/go-cloud#500) 2018-11-13 13:16:46 -08:00
Robert van Gent
be8ecba636 wire: fix error messages for Bind and InterfaceValue when the arg doesn't implement the interface (google/go-cloud#491)
Fixes google/go-cloud#490
2018-11-13 13:16:46 -08:00
Robert van Gent
2c50843322 wire: add an example and document how to use wire with mocks (google/go-cloud#488) 2018-11-13 13:16:46 -08:00
Robert van Gent
32c3dc8578 wire/doc: reformat README.md (google/go-cloud#495) 2018-11-13 13:16:46 -08:00
Robert van Gent
ec7cb36215 wire: report an error if a func with wire.Build in it is an invalid injector (google/go-cloud#487) 2018-11-13 13:16:46 -08:00
Robert van Gent
3bc7933406 wire: avoid making variable names that are Go reserved keywords (google/go-cloud#486) 2018-11-13 13:16:46 -08:00
Robert van Gent
26169ca726 wire/test: add tests for missing error and cleanup func in injector (google/go-cloud#484) 2018-11-13 13:16:46 -08:00
shantuo
fbcb6a82cb wire: make Vendor test work with Go module (google/go-cloud#469) 2018-11-13 13:16:46 -08:00
Robert van Gent
a8c7c0b8e1 wire: omit the local package identifier if it matches the package name (google/go-cloud#385)
Fixes google/go-cloud#424
2018-11-13 13:16:46 -08:00
Robert van Gent
c999a4d1b5 wire: use package names to disambiguate variables (google/go-cloud#386) 2018-11-13 13:16:46 -08:00
Robert van Gent
fab79bd5bd wire: add a test that fails due to wire.Value on a value from function scope (google/go-cloud#405)
Fixes google/go-cloud#378
2018-11-13 13:16:46 -08:00
Robert van Gent
46248162d7 wire: add a testcase with multiple similar packages (google/go-cloud#387)
This is based on the description in google/go-cloud#372. It will be useful if we add wire.FieldsOf, and also for the disambiguation-using-package.

Updates google/go-cloud#372
Updates google/go-cloud#386
2018-11-13 13:16:46 -08:00
Robert van Gent
e93f33129e wire: update Provider.Out to be a slice of provided types, and keep track of the provided concrete type in ProviderSet.providerMap (google/go-cloud#332)
Update Provider.Out to be a slice of provided types, and keep track
of the provided concrete type in ProviderSet.providerMap, to more
clearly model-named struct providers (which provide both the struct
type and a pointer to the struct type).

Fixes google/go-cloud#325.
2018-11-13 13:16:46 -08:00
shantuo
86725a2b3f wire: make tests work with Go modules (google/go-cloud#331)
Generates go.mod files for test cases to support Go modules.
2018-11-13 13:16:46 -08:00
Robert van Gent
cd32a686b1 wire: Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value (google/go-cloud#322)
* Add wire.InterfaceValue, required instead of wire.Value if the value is an interface value.

* Update guestbook sample to use InterfaceValue where appropriate.

* Remove unnecessary ok := true

* Addressing comments from code review.
2018-11-13 13:16:46 -08:00
Ross Light
eedae3d8d0 all: change copyright notice to The Go Cloud Authors (google/go-cloud#306)
Added AUTHORS+CONTRIBUTORS files with the contributors already present
from the Git log.

Fixes google/go-cloud#225
2018-11-13 13:16:46 -08:00
shantuo
4328970c68 wire/internal/wire: run wire tests in parallel (google/go-cloud#309) 2018-11-13 13:16:46 -08:00
Robert van Gent
0e97bcaf0c wire: use cmp.Diff instead of shelling out to "diff" to compare against golden strings in tests (google/go-cloud#287) 2018-11-13 13:16:46 -08:00
Oleg Kovalov
0559d22dfe all: simplify and clarify some expressions (google/go-cloud#260) 2018-11-13 13:16:46 -08:00
Issac Trotts
105b7fde1c wire: respect -record flag for tests (google/go-cloud#282)
Fixes google/go-cloud#281
2018-11-13 13:16:46 -08:00
Robert van Gent
3a3760180d wire: fill in ProviderSet.VarName when the set is a package variable (google/go-cloud#279)
Rename ProviderSet.Name to ProviderSet.VarName.

Fixes google/go-cloud#277
2018-11-13 13:16:46 -08:00
Robert van Gent
85deb53791 wire: Build now returns an error if it has any unused arguments (google/go-cloud#268)
Fixes google/go-cloud#164
2018-11-13 13:16:46 -08:00
Robert van Gent
b348a78000 wire: use providerMap.Iterate instead of providerMap.Keys() + At() (google/go-cloud#265) 2018-11-13 13:16:46 -08:00
Issac Trotts
707f33ee6c all: replace more panic(wire.Build(...)) calls with wire.Build(...); return stuff (google/go-cloud#248)
Fixes google/go-cloud#246
2018-11-13 13:16:45 -08:00
Issac Trotts
d870f380dd Wire: fix typo in README: App -> Baz (google/go-cloud#239)
A function called initializeApp was returning a foobarbaz.Baz.
2018-11-13 13:16:45 -08:00
Issac Trotts
d214fc499d wire: show help when requested (google/go-cloud#238)
For now, it just shows usage.
2018-11-13 13:16:45 -08:00
Zachary Romero
0a45f324c7 wire: fix example in the ProvideBaz section (google/go-cloud#229) 2018-11-13 13:16:45 -08:00
Ross Light
1de1d101c7 wire/cmd/wire: rename from gowire (google/go-cloud#217)
@cflewis and @bradfitz were right: drop the "go". It's cleaner.
2018-11-13 13:16:45 -08:00
Ross Light
5f0dd9ee8f wire: add check command (google/go-cloud#207)
In the internal package, this expands the wire.Load function to run
the same solver as wire.Generate would on any injector function. For
completeness, I also print the injector functions in the gowire show
command.

A subsequent PR will add this as a step to Go Cloud CI.

Updates google/go-cloud#30
2018-11-13 13:16:45 -08:00
Ross Light
2943de1153 docs: remove references to vgo (google/go-cloud#206)
We should be instructing users to run stable things, and more
adventurous folks can adapt to use Go modules. I just ran the test suite
locally from a `go get` and it compiled and ran fine.

Updates google/go-cloud#78
Updates google/go-cloud#208
2018-11-13 13:16:45 -08:00
Ross Light
765b0228ac wire: don't fail at first error (google/go-cloud#204)
This changes both Generate and Load to try to advance as far as possible
while collecting errors. A small helper type, errorCollector, is used to
make control flow easier to read.

Fixes google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
a2540bae2a wire: update internal functions to return []error (google/go-cloud#197)
This represents no functional change, it purely changes the signature
used for functions that can possibly return multiple errors. A
follow-up commit will change the control flow to proceed in the face
of errors.
2018-11-13 13:16:45 -08:00
Ross Light
fda05073e3 wire: add best practices for provider set compatibility (google/go-cloud#191) 2018-11-13 13:16:45 -08:00
Ross Light
777c1c4331 wire: handle build tags with relative paths correctly (google/go-cloud#188)
5cfd0141dd95acd1a98a1b7f6de5b8b304077634 worked correctly with
absolute import paths, but would fail with relative import paths
(most commonly when passing "." in the default invocation of
gowire). This commit introduces test infrastructure to allow
relative import paths to be given as test inputs, along with a test
case that addresses the regression.
2018-11-13 13:16:45 -08:00
Ross Light
0b7bb585fd wire: remove extra trim in parsing golden test output (google/go-cloud#185) 2018-11-13 13:16:45 -08:00
Ross Light
e1df90c68f wire: only apply wireinject build tag to generated package (google/go-cloud#176) 2018-11-13 13:16:45 -08:00
Ross Light
9537acefc2 wire: use return in tests instead of panic (google/go-cloud#169)
Fixes google/go-cloud#105
2018-11-13 13:16:45 -08:00
Ross Light
5e442802c0 wire: fix test data race (google/go-cloud#168)
This was introduced in 7d83fb8532c1455d4e81b587f31d090320f5eb9f and is
surprisingly not caught by the race detector. I suspect that the testing
package makes it not a strict data race, but the result is still
undefined.
2018-11-13 13:16:45 -08:00
Ross Light
54cdfee544 wire: speed up test execution (google/go-cloud#163)
1.  Runs subtests in parallel.
2.  Decreases the number of runs of the Determinism test to a constant 2.
2018-11-13 13:16:45 -08:00