diff options
-rw-r--r-- | tools/go_marshal/gomarshal/generator.go | 8 | ||||
-rw-r--r-- | tools/go_marshal/gomarshal/generator_tests.go | 12 |
2 files changed, 10 insertions, 10 deletions
diff --git a/tools/go_marshal/gomarshal/generator.go b/tools/go_marshal/gomarshal/generator.go index abd6f69ea..634abd1af 100644 --- a/tools/go_marshal/gomarshal/generator.go +++ b/tools/go_marshal/gomarshal/generator.go @@ -427,7 +427,7 @@ func (g *Generator) generateOne(t *marshallableType, fset *token.FileSet) *inter // implementations type t. func (g *Generator) generateOneTestSuite(t *marshallableType) *testGenerator { i := newTestGenerator(t.spec, t.recv) - i.emitTests(t.slice, t.dynamic) + i.emitTests(t.slice) return i } @@ -488,7 +488,11 @@ func (g *Generator) Run() error { panic(fmt.Sprintf("Generated code for '%s' referenced a non-existent import with local name '%s'. Either go-marshal needs to add an import to the generated file, or a package in an input source file has a package name differ from the final component of its path, which go-marshal doesn't know how to detect; use an import alias to work around this limitation.", impl.typeName(), name)) } } - ts = append(ts, g.generateOneTestSuite(t)) + // Do not generate tests for dynamic types because they inherently + // violate some go_marshal requirements. + if !t.dynamic { + ts = append(ts, g.generateOneTestSuite(t)) + } } } diff --git a/tools/go_marshal/gomarshal/generator_tests.go b/tools/go_marshal/gomarshal/generator_tests.go index ca3e15c16..6cf00843f 100644 --- a/tools/go_marshal/gomarshal/generator_tests.go +++ b/tools/go_marshal/gomarshal/generator_tests.go @@ -216,16 +216,12 @@ func (g *testGenerator) emitTestSizeBytesOnTypedNilPtr() { }) } -func (g *testGenerator) emitTests(slice *sliceAPI, isDynamic bool) { +func (g *testGenerator) emitTests(slice *sliceAPI) { g.emitTestNonZeroSize() g.emitTestSuspectAlignment() - if !isDynamic { - // Do not test these for dynamic structs because they violate some - // assumptions that these tests make. - g.emitTestMarshalUnmarshalPreservesData() - g.emitTestWriteToUnmarshalPreservesData() - g.emitTestSizeBytesOnTypedNilPtr() - } + g.emitTestMarshalUnmarshalPreservesData() + g.emitTestWriteToUnmarshalPreservesData() + g.emitTestSizeBytesOnTypedNilPtr() if slice != nil { g.emitTestMarshalUnmarshalSlicePreservesData(slice) |