From 105b7fde1c49c3f398394d19cee80740cdd4be27 Mon Sep 17 00:00:00 2001 From: Issac Trotts Date: Mon, 6 Aug 2018 13:35:16 -0700 Subject: [PATCH] wire: respect -record flag for tests (google/go-cloud#282) Fixes google/go-cloud#281 --- .../{out.txt => want/program_out.txt} | 0 .../BuildTagsMainOnly/want/wire_gen.go | 17 + .../{out.txt => want/program_out.txt} | 0 .../BuildTagsRelativePkg/want/wire_gen.go | 17 + .../Chain/{out.txt => want/program_out.txt} | 0 internal/wire/testdata/Chain/want/wire_gen.go | 14 + .../Cleanup/{out.txt => want/program_out.txt} | 0 .../wire/testdata/Cleanup/want/wire_gen.go | 17 + .../{out.txt => want/program_out.txt} | 0 .../testdata/CopyOtherDecls/want/wire_gen.go | 27 ++ .../Cycle/{out.txt => want/wire_errs.txt} | 1 - .../EmptyVar/{out.txt => want/wire_errs.txt} | 1 - .../{out.txt => want/program_out.txt} | 0 .../testdata/ExportedValue/want/wire_gen.go | 21 ++ .../{out.txt => want/program_out.txt} | 0 .../want/wire_gen.go | 21 ++ .../{out.txt => want/program_out.txt} | 0 .../ImportedInterfaceBinding/want/wire_gen.go | 17 + .../{out.txt => want/program_out.txt} | 0 .../testdata/InjectInput/want/wire_gen.go | 14 + .../{out.txt => want/wire_errs.txt} | 1 - .../{out.txt => want/program_out.txt} | 0 .../testdata/InjectWithPanic/want/wire_gen.go | 13 + .../{out.txt => want/program_out.txt} | 0 .../InterfaceBinding/want/wire_gen.go | 13 + .../{out.txt => want/program_out.txt} | 0 .../InterfaceBindingReuse/want/wire_gen.go | 14 + .../{out.txt => want/wire_errs.txt} | 1 - .../{out.txt => want/program_out.txt} | 0 .../testdata/NamingWorstCase/want/wire_gen.go | 20 ++ .../{out.txt => want/program_out.txt} | 0 .../NamingWorstCaseAllInOne/want/wire_gen.go | 50 +++ .../{out.txt => want/program_out.txt} | 0 .../testdata/NiladicIdentity/want/wire_gen.go | 13 + .../{out.txt => want/program_out.txt} | 0 .../testdata/NiladicValue/want/wire_gen.go | 17 + .../{out.txt => want/wire_errs.txt} | 1 - .../{out.txt => want/program_out.txt} | 0 .../NoInjectParamNames/want/wire_gen.go | 20 ++ .../{out.txt => want/program_out.txt} | 0 .../wire/testdata/NoopBuild/want/wire_gen.go | 0 .../{out.txt => want/program_out.txt} | 0 .../testdata/PartialCleanup/want/wire_gen.go | 27 ++ .../{out.txt => want/program_out.txt} | 0 .../wire/testdata/PkgImport/want/wire_gen.go | 19 ++ .../{out.txt => want/program_out.txt} | 0 .../testdata/ReturnError/want/wire_gen.go | 16 + .../Struct/{out.txt => want/program_out.txt} | 0 .../wire/testdata/Struct/want/wire_gen.go | 18 ++ .../{out.txt => want/program_out.txt} | 0 .../testdata/StructPointer/want/wire_gen.go | 18 ++ .../TwoDeps/{out.txt => want/program_out.txt} | 0 .../wire/testdata/TwoDeps/want/wire_gen.go | 15 + .../{out.txt => want/wire_errs.txt} | 1 - .../{out.txt => want/wire_errs.txt} | 1 - .../{out.txt => want/program_out.txt} | 0 .../wire/testdata/ValueChain/want/wire_gen.go | 18 ++ .../{out.txt => want/program_out.txt} | 0 .../testdata/ValueConversion/want/wire_gen.go | 17 + .../{out.txt => want/program_out.txt} | 0 .../wire/testdata/VarValue/want/wire_gen.go | 17 + .../Vendor/{out.txt => want/program_out.txt} | 0 .../wire/testdata/Vendor/want/wire_gen.go | 17 + internal/wire/wire_test.go | 298 +++++++++--------- 64 files changed, 662 insertions(+), 150 deletions(-) rename internal/wire/testdata/BuildTagsMainOnly/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/BuildTagsMainOnly/want/wire_gen.go rename internal/wire/testdata/BuildTagsRelativePkg/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/BuildTagsRelativePkg/want/wire_gen.go rename internal/wire/testdata/Chain/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/Chain/want/wire_gen.go rename internal/wire/testdata/Cleanup/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/Cleanup/want/wire_gen.go rename internal/wire/testdata/CopyOtherDecls/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/CopyOtherDecls/want/wire_gen.go rename internal/wire/testdata/Cycle/{out.txt => want/wire_errs.txt} (50%) rename internal/wire/testdata/EmptyVar/{out.txt => want/wire_errs.txt} (71%) rename internal/wire/testdata/ExportedValue/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/ExportedValue/want/wire_gen.go rename internal/wire/testdata/ExportedValueDifferentPackage/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go rename internal/wire/testdata/ImportedInterfaceBinding/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go rename internal/wire/testdata/InjectInput/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/InjectInput/want/wire_gen.go rename internal/wire/testdata/InjectInputConflict/{out.txt => want/wire_errs.txt} (84%) rename internal/wire/testdata/InjectWithPanic/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/InjectWithPanic/want/wire_gen.go rename internal/wire/testdata/InterfaceBinding/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/InterfaceBinding/want/wire_gen.go rename internal/wire/testdata/InterfaceBindingReuse/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go rename internal/wire/testdata/MultipleMissingInputs/{out.txt => want/wire_errs.txt} (90%) rename internal/wire/testdata/NamingWorstCase/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/NamingWorstCase/want/wire_gen.go rename internal/wire/testdata/NamingWorstCaseAllInOne/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go rename internal/wire/testdata/NiladicIdentity/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/NiladicIdentity/want/wire_gen.go rename internal/wire/testdata/NiladicValue/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/NiladicValue/want/wire_gen.go rename internal/wire/testdata/NoImplicitInterface/{out.txt => want/wire_errs.txt} (80%) rename internal/wire/testdata/NoInjectParamNames/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/NoInjectParamNames/want/wire_gen.go rename internal/wire/testdata/NoopBuild/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/NoopBuild/want/wire_gen.go rename internal/wire/testdata/PartialCleanup/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/PartialCleanup/want/wire_gen.go rename internal/wire/testdata/PkgImport/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/PkgImport/want/wire_gen.go rename internal/wire/testdata/ReturnError/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/ReturnError/want/wire_gen.go rename internal/wire/testdata/Struct/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/Struct/want/wire_gen.go rename internal/wire/testdata/StructPointer/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/StructPointer/want/wire_gen.go rename internal/wire/testdata/TwoDeps/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/TwoDeps/want/wire_gen.go rename internal/wire/testdata/UnexportedValue/{out.txt => want/wire_errs.txt} (84%) rename internal/wire/testdata/UnusedProviders/{out.txt => want/wire_errs.txt} (95%) rename internal/wire/testdata/ValueChain/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/ValueChain/want/wire_gen.go rename internal/wire/testdata/ValueConversion/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/ValueConversion/want/wire_gen.go rename internal/wire/testdata/VarValue/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/VarValue/want/wire_gen.go rename internal/wire/testdata/Vendor/{out.txt => want/program_out.txt} (100%) create mode 100644 internal/wire/testdata/Vendor/want/wire_gen.go diff --git a/internal/wire/testdata/BuildTagsMainOnly/out.txt b/internal/wire/testdata/BuildTagsMainOnly/want/program_out.txt similarity index 100% rename from internal/wire/testdata/BuildTagsMainOnly/out.txt rename to internal/wire/testdata/BuildTagsMainOnly/want/program_out.txt diff --git a/internal/wire/testdata/BuildTagsMainOnly/want/wire_gen.go b/internal/wire/testdata/BuildTagsMainOnly/want/wire_gen.go new file mode 100644 index 0000000..2cb12ac --- /dev/null +++ b/internal/wire/testdata/BuildTagsMainOnly/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := _wireStringValue + return string2 +} + +var ( + _wireStringValue = "Hello, World!" +) diff --git a/internal/wire/testdata/BuildTagsRelativePkg/out.txt b/internal/wire/testdata/BuildTagsRelativePkg/want/program_out.txt similarity index 100% rename from internal/wire/testdata/BuildTagsRelativePkg/out.txt rename to internal/wire/testdata/BuildTagsRelativePkg/want/program_out.txt diff --git a/internal/wire/testdata/BuildTagsRelativePkg/want/wire_gen.go b/internal/wire/testdata/BuildTagsRelativePkg/want/wire_gen.go new file mode 100644 index 0000000..2cb12ac --- /dev/null +++ b/internal/wire/testdata/BuildTagsRelativePkg/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := _wireStringValue + return string2 +} + +var ( + _wireStringValue = "Hello, World!" +) diff --git a/internal/wire/testdata/Chain/out.txt b/internal/wire/testdata/Chain/want/program_out.txt similarity index 100% rename from internal/wire/testdata/Chain/out.txt rename to internal/wire/testdata/Chain/want/program_out.txt diff --git a/internal/wire/testdata/Chain/want/wire_gen.go b/internal/wire/testdata/Chain/want/wire_gen.go new file mode 100644 index 0000000..f91b68b --- /dev/null +++ b/internal/wire/testdata/Chain/want/wire_gen.go @@ -0,0 +1,14 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar() FooBar { + foo := provideFoo() + fooBar := provideFooBar(foo) + return fooBar +} diff --git a/internal/wire/testdata/Cleanup/out.txt b/internal/wire/testdata/Cleanup/want/program_out.txt similarity index 100% rename from internal/wire/testdata/Cleanup/out.txt rename to internal/wire/testdata/Cleanup/want/program_out.txt diff --git a/internal/wire/testdata/Cleanup/want/wire_gen.go b/internal/wire/testdata/Cleanup/want/wire_gen.go new file mode 100644 index 0000000..0d7f2e9 --- /dev/null +++ b/internal/wire/testdata/Cleanup/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectBar() (*Bar, func()) { + foo, cleanup := provideFoo() + bar, cleanup2 := provideBar(foo) + return bar, func() { + cleanup2() + cleanup() + } +} diff --git a/internal/wire/testdata/CopyOtherDecls/out.txt b/internal/wire/testdata/CopyOtherDecls/want/program_out.txt similarity index 100% rename from internal/wire/testdata/CopyOtherDecls/out.txt rename to internal/wire/testdata/CopyOtherDecls/want/program_out.txt diff --git a/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go b/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go new file mode 100644 index 0000000..2e64e56 --- /dev/null +++ b/internal/wire/testdata/CopyOtherDecls/want/wire_gen.go @@ -0,0 +1,27 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + fmt "fmt" +) + +// Injectors from foo.go: + +func injectedMessage() string { + string2 := provideMessage() + return string2 +} + +// foo.go: + +func main() { + fmt.Println(injectedMessage()) +} + +func provideMessage() string { + return "Hello, World!" +} diff --git a/internal/wire/testdata/Cycle/out.txt b/internal/wire/testdata/Cycle/want/wire_errs.txt similarity index 50% rename from internal/wire/testdata/Cycle/out.txt rename to internal/wire/testdata/Cycle/want/wire_errs.txt index d48ed29..88b2d48 100644 --- a/internal/wire/testdata/Cycle/out.txt +++ b/internal/wire/testdata/Cycle/want/wire_errs.txt @@ -1,2 +1 @@ -ERROR cycle diff --git a/internal/wire/testdata/EmptyVar/out.txt b/internal/wire/testdata/EmptyVar/want/wire_errs.txt similarity index 71% rename from internal/wire/testdata/EmptyVar/out.txt rename to internal/wire/testdata/EmptyVar/want/wire_errs.txt index d5ddc95..c586bfe 100644 --- a/internal/wire/testdata/EmptyVar/out.txt +++ b/internal/wire/testdata/EmptyVar/want/wire_errs.txt @@ -1,2 +1 @@ -ERROR not a provider diff --git a/internal/wire/testdata/ExportedValue/out.txt b/internal/wire/testdata/ExportedValue/want/program_out.txt similarity index 100% rename from internal/wire/testdata/ExportedValue/out.txt rename to internal/wire/testdata/ExportedValue/want/program_out.txt diff --git a/internal/wire/testdata/ExportedValue/want/wire_gen.go b/internal/wire/testdata/ExportedValue/want/wire_gen.go new file mode 100644 index 0000000..241c560 --- /dev/null +++ b/internal/wire/testdata/ExportedValue/want/wire_gen.go @@ -0,0 +1,21 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + bar "bar" +) + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := _wireStringValue + return string2 +} + +var ( + _wireStringValue = bar.PublicMsg +) diff --git a/internal/wire/testdata/ExportedValueDifferentPackage/out.txt b/internal/wire/testdata/ExportedValueDifferentPackage/want/program_out.txt similarity index 100% rename from internal/wire/testdata/ExportedValueDifferentPackage/out.txt rename to internal/wire/testdata/ExportedValueDifferentPackage/want/program_out.txt diff --git a/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go b/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go new file mode 100644 index 0000000..859ffea --- /dev/null +++ b/internal/wire/testdata/ExportedValueDifferentPackage/want/wire_gen.go @@ -0,0 +1,21 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + os "os" +) + +// Injectors from wire.go: + +func injectedFile() *os.File { + file := _wireFileValue + return file +} + +var ( + _wireFileValue = os.Stdout +) diff --git a/internal/wire/testdata/ImportedInterfaceBinding/out.txt b/internal/wire/testdata/ImportedInterfaceBinding/want/program_out.txt similarity index 100% rename from internal/wire/testdata/ImportedInterfaceBinding/out.txt rename to internal/wire/testdata/ImportedInterfaceBinding/want/program_out.txt diff --git a/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go b/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go new file mode 100644 index 0000000..1b369d9 --- /dev/null +++ b/internal/wire/testdata/ImportedInterfaceBinding/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + foo "foo" +) + +// Injectors from wire.go: + +func injectFooer() foo.Fooer { + bar := provideBar() + return bar +} diff --git a/internal/wire/testdata/InjectInput/out.txt b/internal/wire/testdata/InjectInput/want/program_out.txt similarity index 100% rename from internal/wire/testdata/InjectInput/out.txt rename to internal/wire/testdata/InjectInput/want/program_out.txt diff --git a/internal/wire/testdata/InjectInput/want/wire_gen.go b/internal/wire/testdata/InjectInput/want/wire_gen.go new file mode 100644 index 0000000..0487fb8 --- /dev/null +++ b/internal/wire/testdata/InjectInput/want/wire_gen.go @@ -0,0 +1,14 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar(foo Foo) FooBar { + bar := provideBar() + fooBar := provideFooBar(foo, bar) + return fooBar +} diff --git a/internal/wire/testdata/InjectInputConflict/out.txt b/internal/wire/testdata/InjectInputConflict/want/wire_errs.txt similarity index 84% rename from internal/wire/testdata/InjectInputConflict/out.txt rename to internal/wire/testdata/InjectInputConflict/want/wire_errs.txt index 285f317..e2d450e 100644 --- a/internal/wire/testdata/InjectInputConflict/out.txt +++ b/internal/wire/testdata/InjectInputConflict/want/wire_errs.txt @@ -1,3 +1,2 @@ -ERROR foo.Foo conflicts with provider diff --git a/internal/wire/testdata/InjectWithPanic/out.txt b/internal/wire/testdata/InjectWithPanic/want/program_out.txt similarity index 100% rename from internal/wire/testdata/InjectWithPanic/out.txt rename to internal/wire/testdata/InjectWithPanic/want/program_out.txt diff --git a/internal/wire/testdata/InjectWithPanic/want/wire_gen.go b/internal/wire/testdata/InjectWithPanic/want/wire_gen.go new file mode 100644 index 0000000..a45f720 --- /dev/null +++ b/internal/wire/testdata/InjectWithPanic/want/wire_gen.go @@ -0,0 +1,13 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := provideMessage() + return string2 +} diff --git a/internal/wire/testdata/InterfaceBinding/out.txt b/internal/wire/testdata/InterfaceBinding/want/program_out.txt similarity index 100% rename from internal/wire/testdata/InterfaceBinding/out.txt rename to internal/wire/testdata/InterfaceBinding/want/program_out.txt diff --git a/internal/wire/testdata/InterfaceBinding/want/wire_gen.go b/internal/wire/testdata/InterfaceBinding/want/wire_gen.go new file mode 100644 index 0000000..7147bb3 --- /dev/null +++ b/internal/wire/testdata/InterfaceBinding/want/wire_gen.go @@ -0,0 +1,13 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooer() Fooer { + bar := provideBar() + return bar +} diff --git a/internal/wire/testdata/InterfaceBindingReuse/out.txt b/internal/wire/testdata/InterfaceBindingReuse/want/program_out.txt similarity index 100% rename from internal/wire/testdata/InterfaceBindingReuse/out.txt rename to internal/wire/testdata/InterfaceBindingReuse/want/program_out.txt diff --git a/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go b/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go new file mode 100644 index 0000000..12c89c6 --- /dev/null +++ b/internal/wire/testdata/InterfaceBindingReuse/want/wire_gen.go @@ -0,0 +1,14 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar() FooBar { + bar := provideBar() + fooBar := provideFooBar(bar, bar) + return fooBar +} diff --git a/internal/wire/testdata/MultipleMissingInputs/out.txt b/internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt similarity index 90% rename from internal/wire/testdata/MultipleMissingInputs/out.txt rename to internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt index e66e81f..183f6f4 100644 --- a/internal/wire/testdata/MultipleMissingInputs/out.txt +++ b/internal/wire/testdata/MultipleMissingInputs/want/wire_errs.txt @@ -1,3 +1,2 @@ -ERROR no provider found for foo.Foo no provider found for foo.Bar diff --git a/internal/wire/testdata/NamingWorstCase/out.txt b/internal/wire/testdata/NamingWorstCase/want/program_out.txt similarity index 100% rename from internal/wire/testdata/NamingWorstCase/out.txt rename to internal/wire/testdata/NamingWorstCase/want/program_out.txt diff --git a/internal/wire/testdata/NamingWorstCase/want/wire_gen.go b/internal/wire/testdata/NamingWorstCase/want/wire_gen.go new file mode 100644 index 0000000..a2801c6 --- /dev/null +++ b/internal/wire/testdata/NamingWorstCase/want/wire_gen.go @@ -0,0 +1,20 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + context2 "context" +) + +// Injectors from wire.go: + +func inject(context3 context2.Context, err2 struct{}) (context, error) { + context4, err := provide(context3) + if err != nil { + return context{}, err + } + return context4, nil +} diff --git a/internal/wire/testdata/NamingWorstCaseAllInOne/out.txt b/internal/wire/testdata/NamingWorstCaseAllInOne/want/program_out.txt similarity index 100% rename from internal/wire/testdata/NamingWorstCaseAllInOne/out.txt rename to internal/wire/testdata/NamingWorstCaseAllInOne/want/program_out.txt diff --git a/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go b/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go new file mode 100644 index 0000000..8a21ea4 --- /dev/null +++ b/internal/wire/testdata/NamingWorstCaseAllInOne/want/wire_gen.go @@ -0,0 +1,50 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + context2 "context" + fmt "fmt" + os "os" + reflect "reflect" +) + +// Injectors from foo.go: + +func inject(context3 context2.Context, err2 struct{}) (context, error) { + context4, err := Provide(context3) + if err != nil { + return context{}, err + } + return context4, nil +} + +// foo.go: + +type context struct{} + +func main() { + if _, ok := reflect.TypeOf(context{}).MethodByName("Provide"); !ok { + fmt.Println("ERROR: context.Provide renamed") + os.Exit(1) + } + c, err := inject(context2.Background(), struct{}{}) + if err != nil { + fmt.Println("ERROR:", err) + os.Exit(1) + } + fmt.Println(c) +} + +func Provide(context2_2 context2.Context) (context, error) { + var context3 = context2.Background() + _ = context2_2 + _ = context3 + return context{}, nil +} + +func (context) Provide() { +} diff --git a/internal/wire/testdata/NiladicIdentity/out.txt b/internal/wire/testdata/NiladicIdentity/want/program_out.txt similarity index 100% rename from internal/wire/testdata/NiladicIdentity/out.txt rename to internal/wire/testdata/NiladicIdentity/want/program_out.txt diff --git a/internal/wire/testdata/NiladicIdentity/want/wire_gen.go b/internal/wire/testdata/NiladicIdentity/want/wire_gen.go new file mode 100644 index 0000000..a45f720 --- /dev/null +++ b/internal/wire/testdata/NiladicIdentity/want/wire_gen.go @@ -0,0 +1,13 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := provideMessage() + return string2 +} diff --git a/internal/wire/testdata/NiladicValue/out.txt b/internal/wire/testdata/NiladicValue/want/program_out.txt similarity index 100% rename from internal/wire/testdata/NiladicValue/out.txt rename to internal/wire/testdata/NiladicValue/want/program_out.txt diff --git a/internal/wire/testdata/NiladicValue/want/wire_gen.go b/internal/wire/testdata/NiladicValue/want/wire_gen.go new file mode 100644 index 0000000..2cb12ac --- /dev/null +++ b/internal/wire/testdata/NiladicValue/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := _wireStringValue + return string2 +} + +var ( + _wireStringValue = "Hello, World!" +) diff --git a/internal/wire/testdata/NoImplicitInterface/out.txt b/internal/wire/testdata/NoImplicitInterface/want/wire_errs.txt similarity index 80% rename from internal/wire/testdata/NoImplicitInterface/out.txt rename to internal/wire/testdata/NoImplicitInterface/want/wire_errs.txt index 61b82b7..1e7c147 100644 --- a/internal/wire/testdata/NoImplicitInterface/out.txt +++ b/internal/wire/testdata/NoImplicitInterface/want/wire_errs.txt @@ -1,3 +1,2 @@ -ERROR no provider found Fooer diff --git a/internal/wire/testdata/NoInjectParamNames/out.txt b/internal/wire/testdata/NoInjectParamNames/want/program_out.txt similarity index 100% rename from internal/wire/testdata/NoInjectParamNames/out.txt rename to internal/wire/testdata/NoInjectParamNames/want/program_out.txt diff --git a/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go b/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go new file mode 100644 index 0000000..0d15c50 --- /dev/null +++ b/internal/wire/testdata/NoInjectParamNames/want/wire_gen.go @@ -0,0 +1,20 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + context2 "context" +) + +// Injectors from wire.go: + +func inject(context3 context2.Context, arg struct{}) (context, error) { + context4, err := provide(context3) + if err != nil { + return context{}, err + } + return context4, nil +} diff --git a/internal/wire/testdata/NoopBuild/out.txt b/internal/wire/testdata/NoopBuild/want/program_out.txt similarity index 100% rename from internal/wire/testdata/NoopBuild/out.txt rename to internal/wire/testdata/NoopBuild/want/program_out.txt diff --git a/internal/wire/testdata/NoopBuild/want/wire_gen.go b/internal/wire/testdata/NoopBuild/want/wire_gen.go new file mode 100644 index 0000000..e69de29 diff --git a/internal/wire/testdata/PartialCleanup/out.txt b/internal/wire/testdata/PartialCleanup/want/program_out.txt similarity index 100% rename from internal/wire/testdata/PartialCleanup/out.txt rename to internal/wire/testdata/PartialCleanup/want/program_out.txt diff --git a/internal/wire/testdata/PartialCleanup/want/wire_gen.go b/internal/wire/testdata/PartialCleanup/want/wire_gen.go new file mode 100644 index 0000000..7a2893b --- /dev/null +++ b/internal/wire/testdata/PartialCleanup/want/wire_gen.go @@ -0,0 +1,27 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectBaz() (Baz, func(), error) { + foo, cleanup := provideFoo() + bar, cleanup2, err := provideBar(foo) + if err != nil { + cleanup() + return 0, nil, err + } + baz, err := provideBaz(bar) + if err != nil { + cleanup2() + cleanup() + return 0, nil, err + } + return baz, func() { + cleanup2() + cleanup() + }, nil +} diff --git a/internal/wire/testdata/PkgImport/out.txt b/internal/wire/testdata/PkgImport/want/program_out.txt similarity index 100% rename from internal/wire/testdata/PkgImport/out.txt rename to internal/wire/testdata/PkgImport/want/program_out.txt diff --git a/internal/wire/testdata/PkgImport/want/wire_gen.go b/internal/wire/testdata/PkgImport/want/wire_gen.go new file mode 100644 index 0000000..90c41c4 --- /dev/null +++ b/internal/wire/testdata/PkgImport/want/wire_gen.go @@ -0,0 +1,19 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + bar "bar" +) + +// Injectors from wire.go: + +func injectFooBar() FooBar { + foo := provideFoo() + bar2 := bar.ProvideBar() + fooBar := provideFooBar(foo, bar2) + return fooBar +} diff --git a/internal/wire/testdata/ReturnError/out.txt b/internal/wire/testdata/ReturnError/want/program_out.txt similarity index 100% rename from internal/wire/testdata/ReturnError/out.txt rename to internal/wire/testdata/ReturnError/want/program_out.txt diff --git a/internal/wire/testdata/ReturnError/want/wire_gen.go b/internal/wire/testdata/ReturnError/want/wire_gen.go new file mode 100644 index 0000000..188ad1f --- /dev/null +++ b/internal/wire/testdata/ReturnError/want/wire_gen.go @@ -0,0 +1,16 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFoo() (Foo, error) { + foo, err := provideFoo() + if err != nil { + return 0, err + } + return foo, nil +} diff --git a/internal/wire/testdata/Struct/out.txt b/internal/wire/testdata/Struct/want/program_out.txt similarity index 100% rename from internal/wire/testdata/Struct/out.txt rename to internal/wire/testdata/Struct/want/program_out.txt diff --git a/internal/wire/testdata/Struct/want/wire_gen.go b/internal/wire/testdata/Struct/want/wire_gen.go new file mode 100644 index 0000000..3ba452e --- /dev/null +++ b/internal/wire/testdata/Struct/want/wire_gen.go @@ -0,0 +1,18 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar() FooBar { + foo := provideFoo() + bar := provideBar() + fooBar := FooBar{ + Foo: foo, + Bar: bar, + } + return fooBar +} diff --git a/internal/wire/testdata/StructPointer/out.txt b/internal/wire/testdata/StructPointer/want/program_out.txt similarity index 100% rename from internal/wire/testdata/StructPointer/out.txt rename to internal/wire/testdata/StructPointer/want/program_out.txt diff --git a/internal/wire/testdata/StructPointer/want/wire_gen.go b/internal/wire/testdata/StructPointer/want/wire_gen.go new file mode 100644 index 0000000..2ebb66d --- /dev/null +++ b/internal/wire/testdata/StructPointer/want/wire_gen.go @@ -0,0 +1,18 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar() *FooBar { + foo := provideFoo() + bar := provideBar() + fooBar := &FooBar{ + Foo: foo, + Bar: bar, + } + return fooBar +} diff --git a/internal/wire/testdata/TwoDeps/out.txt b/internal/wire/testdata/TwoDeps/want/program_out.txt similarity index 100% rename from internal/wire/testdata/TwoDeps/out.txt rename to internal/wire/testdata/TwoDeps/want/program_out.txt diff --git a/internal/wire/testdata/TwoDeps/want/wire_gen.go b/internal/wire/testdata/TwoDeps/want/wire_gen.go new file mode 100644 index 0000000..4551f39 --- /dev/null +++ b/internal/wire/testdata/TwoDeps/want/wire_gen.go @@ -0,0 +1,15 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar() FooBar { + foo := provideFoo() + bar := provideBar() + fooBar := provideFooBar(foo, bar) + return fooBar +} diff --git a/internal/wire/testdata/UnexportedValue/out.txt b/internal/wire/testdata/UnexportedValue/want/wire_errs.txt similarity index 84% rename from internal/wire/testdata/UnexportedValue/out.txt rename to internal/wire/testdata/UnexportedValue/want/wire_errs.txt index 6b1466c..8760fd1 100644 --- a/internal/wire/testdata/UnexportedValue/out.txt +++ b/internal/wire/testdata/UnexportedValue/want/wire_errs.txt @@ -1,2 +1 @@ -ERROR unexported identifier privateMsg diff --git a/internal/wire/testdata/UnusedProviders/out.txt b/internal/wire/testdata/UnusedProviders/want/wire_errs.txt similarity index 95% rename from internal/wire/testdata/UnusedProviders/out.txt rename to internal/wire/testdata/UnusedProviders/want/wire_errs.txt index 08a452d..13d8c09 100644 --- a/internal/wire/testdata/UnusedProviders/out.txt +++ b/internal/wire/testdata/UnusedProviders/want/wire_errs.txt @@ -1,4 +1,3 @@ -ERROR unused provider set "unusedSet" unused provider "provideUnused" unused value of type string diff --git a/internal/wire/testdata/ValueChain/out.txt b/internal/wire/testdata/ValueChain/want/program_out.txt similarity index 100% rename from internal/wire/testdata/ValueChain/out.txt rename to internal/wire/testdata/ValueChain/want/program_out.txt diff --git a/internal/wire/testdata/ValueChain/want/wire_gen.go b/internal/wire/testdata/ValueChain/want/wire_gen.go new file mode 100644 index 0000000..a730a00 --- /dev/null +++ b/internal/wire/testdata/ValueChain/want/wire_gen.go @@ -0,0 +1,18 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectFooBar() FooBar { + foo := _wireFooValue + fooBar := provideFooBar(foo) + return fooBar +} + +var ( + _wireFooValue = Foo(41) +) diff --git a/internal/wire/testdata/ValueConversion/out.txt b/internal/wire/testdata/ValueConversion/want/program_out.txt similarity index 100% rename from internal/wire/testdata/ValueConversion/out.txt rename to internal/wire/testdata/ValueConversion/want/program_out.txt diff --git a/internal/wire/testdata/ValueConversion/want/wire_gen.go b/internal/wire/testdata/ValueConversion/want/wire_gen.go new file mode 100644 index 0000000..beb2fbc --- /dev/null +++ b/internal/wire/testdata/ValueConversion/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() Foo { + foo := _wireFooValue + return foo +} + +var ( + _wireFooValue = Foo("Hello, World!") +) diff --git a/internal/wire/testdata/VarValue/out.txt b/internal/wire/testdata/VarValue/want/program_out.txt similarity index 100% rename from internal/wire/testdata/VarValue/out.txt rename to internal/wire/testdata/VarValue/want/program_out.txt diff --git a/internal/wire/testdata/VarValue/want/wire_gen.go b/internal/wire/testdata/VarValue/want/wire_gen.go new file mode 100644 index 0000000..7e5e190 --- /dev/null +++ b/internal/wire/testdata/VarValue/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := _wireStringValue + return string2 +} + +var ( + _wireStringValue = msg +) diff --git a/internal/wire/testdata/Vendor/out.txt b/internal/wire/testdata/Vendor/want/program_out.txt similarity index 100% rename from internal/wire/testdata/Vendor/out.txt rename to internal/wire/testdata/Vendor/want/program_out.txt diff --git a/internal/wire/testdata/Vendor/want/wire_gen.go b/internal/wire/testdata/Vendor/want/wire_gen.go new file mode 100644 index 0000000..adc0279 --- /dev/null +++ b/internal/wire/testdata/Vendor/want/wire_gen.go @@ -0,0 +1,17 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate wire +//+build !wireinject + +package main + +import ( + bar "bar" +) + +// Injectors from wire.go: + +func injectedMessage() string { + string2 := bar.ProvideMessage() + return string2 +} diff --git a/internal/wire/wire_test.go b/internal/wire/wire_test.go index c7cc719..c837665 100644 --- a/internal/wire/wire_test.go +++ b/internal/wire/wire_test.go @@ -31,6 +31,8 @@ import ( "time" "unicode" "unicode/utf8" + + "github.com/google/go-cloud/internal/testing/setup" ) func TestWire(t *testing.T) { @@ -54,121 +56,117 @@ func TestWire(t *testing.T) { test, err := loadTestCase(filepath.Join(testRoot, name), wireGo) if err != nil { t.Error(err) + continue } tests = append(tests, test) } wd := filepath.Join(magicGOPATH(), "src") - t.Run("Generate", func(t *testing.T) { + if *setup.Record { if _, err := os.Stat(filepath.Join(build.Default.GOROOT, "bin", "go")); err != nil { - t.Skip("go toolchain not available:", err) + t.Fatal("go toolchain not available:", err) } - for _, test := range tests { - test := test - t.Run(test.name, func(t *testing.T) { - t.Parallel() - - // Run Wire from a fake build context. - bctx := test.buildContext() - gen, errs := Generate(bctx, wd, test.pkg) - if len(gen) > 0 { - defer t.Logf("wire_gen.go:\n%s", gen) - } - if len(errs) > 0 { - for _, e := range errs { - t.Log(e) - } - if !test.wantError { - t.Fatal("Did not expect errors.") - } - for _, s := range test.wantErrorStrings { - if !errorListContains(errs, s) { - t.Errorf("Errors did not contain %q", s) - } - } - return - } - if len(errs) == 0 && test.wantError { - t.Fatal("wirego succeeded; want error") - } - - // Find the absolute import path, since test.pkg may be a relative - // import path. - genPkg, err := bctx.Import(test.pkg, wd, build.FindOnly) - if err != nil { - t.Fatal(err) - } - - // Run a `go build` with the generated output. - gopath, err := ioutil.TempDir("", "wire_test") - if err != nil { - t.Fatal(err) - } - defer os.RemoveAll(gopath) - if err := test.materialize(gopath); err != nil { - t.Fatal(err) - } - if len(gen) > 0 { - genPath := filepath.Join(gopath, "src", filepath.FromSlash(genPkg.ImportPath), "wire_gen.go") - if err := ioutil.WriteFile(genPath, gen, 0666); err != nil { - t.Fatal(err) - } - } - testExePath := filepath.Join(gopath, "bin", "testprog") - realBuildCtx := &build.Context{ - GOARCH: bctx.GOARCH, - GOOS: bctx.GOOS, - GOROOT: bctx.GOROOT, - GOPATH: gopath, - CgoEnabled: bctx.CgoEnabled, - Compiler: bctx.Compiler, - BuildTags: bctx.BuildTags, - ReleaseTags: bctx.ReleaseTags, - } - if err := runGo(realBuildCtx, "build", "-o", testExePath, genPkg.ImportPath); err != nil { - t.Fatal("build:", err) - } - - // Run the resulting program and compare its output to the expected - // output. - out, err := exec.Command(testExePath).Output() - if err != nil { - t.Error("run compiled program:", err) - } - if !bytes.Equal(out, test.wantOutput) { - t.Errorf("compiled program output = %q; want %q", out, test.wantOutput) - } - }) - } - }) - - t.Run("Determinism", func(t *testing.T) { - const runs = 2 - for _, test := range tests { - if test.wantError { - continue + } + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + // Run Wire from a fake build context. + bctx := test.buildContext() + gen, errs := Generate(bctx, wd, test.pkg) + if len(gen) > 0 { + defer t.Logf("wire_gen.go:\n%s", gen) } - test := test - t.Run(test.name, func(t *testing.T) { - t.Parallel() - bctx := test.buildContext() - gold, errs := Generate(bctx, wd, test.pkg) - if len(errs) > 0 { - t.Fatal("wirego:", errs) + if len(errs) > 0 { + for _, e := range errs { + t.Log(e) } - goldstr := string(gold) - for i := 0; i < runs-1; i++ { - out, errs := Generate(bctx, wd, test.pkg) - if len(errs) > 0 { - t.Fatal("wirego (on subsequent run):", errs) - } - if !bytes.Equal(gold, out) { - t.Fatalf("wirego output differs when run repeatedly on same input:\n%s", diff(goldstr, string(out))) + if !test.wantWireError { + t.Fatal("Did not expect errors.") + } + for _, s := range test.wantWireErrorStrings { + if !errorListContains(errs, s) { + t.Errorf("Errors did not contain %q", s) } } - }) + return + } + if test.wantWireError { + t.Fatal("wire succeeded; want error") + } + + if *setup.Record { + // Record ==> Build the generated Wire code, + // check that the program's output matches the + // expected output, save wire output on + // success. + if err := goBuildCheck(test, wd, bctx, gen); err != nil { + t.Fatalf("go build check failed: %v", err) + } + wireGenFile := filepath.Join(testRoot, test.name, "want", "wire_gen.go") + if err := ioutil.WriteFile(wireGenFile, gen, 0666); err != nil { + t.Fatalf("failed to write wire_gen.go file: %v", err) + } + } else { + // Replay ==> Load golden file and compare to + // generated result. This check is meant to + // detect non-deterministic behavior in the + // Generate function. + gold := test.wantWireOutput + if !bytes.Equal(gen, gold) { + t.Fatalf("wire output differs from golden file:\n%s\nIf this change is expected, run with -record to update the wire_gen.go file.", diff(string(gold), string(gen))) + } + } + }) + } +} + +func goBuildCheck(test *testCase, wd string, bctx *build.Context, gen []byte) error { + // Find the absolute import path, since test.pkg may be a relative + // import path. + genPkg, err := bctx.Import(test.pkg, wd, build.FindOnly) + if err != nil { + return err + } + + // Run a `go build` with the generated output. + gopath, err := ioutil.TempDir("", "wire_test") + if err != nil { + return err + } + defer os.RemoveAll(gopath) + if err := test.materialize(gopath); err != nil { + return err + } + if len(gen) > 0 { + genPath := filepath.Join(gopath, "src", filepath.FromSlash(genPkg.ImportPath), "wire_gen.go") + if err := ioutil.WriteFile(genPath, gen, 0666); err != nil { + return err } - }) + } + testExePath := filepath.Join(gopath, "bin", "testprog") + realBuildCtx := &build.Context{ + GOARCH: bctx.GOARCH, + GOOS: bctx.GOOS, + GOROOT: bctx.GOROOT, + GOPATH: gopath, + CgoEnabled: bctx.CgoEnabled, + Compiler: bctx.Compiler, + BuildTags: bctx.BuildTags, + ReleaseTags: bctx.ReleaseTags, + } + if err := runGo(realBuildCtx, "build", "-o", testExePath, genPkg.ImportPath); err != nil { + return fmt.Errorf("build: %v", err) + } + + // Run the resulting program and compare its output to the expected + // output. + out, err := exec.Command(testExePath).Output() + if err != nil { + return fmt.Errorf("run compiled program: %v", err) + } + if !bytes.Equal(out, test.wantProgramOutput) { + return fmt.Errorf("compiled program output = %q; want %q", out, test.wantProgramOutput) + } + return nil } func TestUnexport(t *testing.T) { @@ -284,13 +282,13 @@ func isIdent(s string) bool { } type testCase struct { - name string - pkg string - goFiles map[string][]byte - wantOutput []byte - - wantError bool - wantErrorStrings []string + name string + pkg string + goFiles map[string][]byte + wantProgramOutput []byte + wantWireOutput []byte + wantWireError bool + wantWireErrorStrings []string } // loadTestCase reads a test case from a directory. @@ -298,26 +296,52 @@ type testCase struct { // The directory structure is: // // root/ -// pkg file containing the package name containing the inject function -// (must also be package main) -// out.txt file containing the expected output, or starting with the -// magic line "ERROR" if this test should cause generation to -// fail (any subsequent lines are substrings that should -// appear in the errors). -// ... any Go files found recursively placed under GOPATH/src/... +// +// pkg +// file containing the package name containing the inject function +// (must also be package main) +// +// ... +// any Go files found recursively placed under GOPATH/src/... +// +// want/ +// +// wire_errs.txt +// expected errors from the Wire Generate function, +// missing if no errors expected +// +// wire_gen.go +// verified output of wire from a test run with +// -record, missing if wire_errs.txt is present +// +// program_out.txt +// expected output from the final compiled program, +// missing if wire_errs.txt is present +// func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) { name := filepath.Base(root) pkg, err := ioutil.ReadFile(filepath.Join(root, "pkg")) if err != nil { return nil, fmt.Errorf("load test case %s: %v", name, err) } - out, err := ioutil.ReadFile(filepath.Join(root, "out.txt")) - if err != nil { - return nil, fmt.Errorf("load test case %s: %v", name, err) - } - wantErrorStrings, wantError := parseGoldenOutput(out) - if wantError { - out = nil + var wantProgramOutput []byte + var wantWireOutput []byte + wireErrb, err := ioutil.ReadFile(filepath.Join(root, "want", "wire_errs.txt")) + wantWireError := err == nil + var wantWireErrorStrings []string + if wantWireError { + wantWireErrorStrings = strings.Split(strings.TrimSpace(string(wireErrb)), "\n") + } else { + if !*setup.Record { + wantWireOutput, err = ioutil.ReadFile(filepath.Join(root, "want", "wire_gen.go")) + if err != nil { + return nil, fmt.Errorf("load test case %s: %v. If this is a new testcase, run with -record to generate the wire_gen.go file.", name, err) + } + } + wantProgramOutput, err = ioutil.ReadFile(filepath.Join(root, "want", "program_out.txt")) + if err != nil { + return nil, fmt.Errorf("load test case %s: %v", name, err) + } } goFiles := map[string][]byte{ "github.com/google/go-cloud/wire/wire.go": wireGoSrc, @@ -344,12 +368,13 @@ func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) { return nil, fmt.Errorf("load test case %s: %v", name, err) } return &testCase{ - name: name, - pkg: string(bytes.TrimSpace(pkg)), - goFiles: goFiles, - wantOutput: out, - wantError: wantError, - wantErrorStrings: wantErrorStrings, + name: name, + pkg: string(bytes.TrimSpace(pkg)), + goFiles: goFiles, + wantWireOutput: wantWireOutput, + wantProgramOutput: wantProgramOutput, + wantWireError: wantWireError, + wantWireErrorStrings: wantWireErrorStrings, }, nil } @@ -600,19 +625,6 @@ func runDiff(a, b []byte) ([]byte, error) { return out, err } -func parseGoldenOutput(out []byte) (errorStrings []string, wantError bool) { - const errorPrefix = "ERROR\n" - if !bytes.HasPrefix(out, []byte(errorPrefix)) { - return nil, false - } - // Skip past first line. - out = out[len(errorPrefix):] - // Remove any leading or trailing blank lines. - out = bytes.Trim(out, "\n") - // Split lines. - return strings.Split(string(out), "\n"), true -} - func errorListContains(errs []error, substr string) bool { for _, e := range errs { if strings.Contains(e.Error(), substr) {