From e9f1ed701ac2b3129855466c397bab843c85954d Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Thu, 9 Sep 2021 00:32:31 +0200 Subject: [PATCH] cgo: don't normalize CGo tests anymore Normalization was required because previously we supported Go 1.13 and Go 1.14 at the same time. Now we've dropped support for both so this normalization is not necessary anymore. CGo support remains the same. It's just the test outputs that aren't normalized anymore. --- cgo/cgo_test.go | 9 --------- cgo/testdata/types.out.go | 20 +++++--------------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/cgo/cgo_test.go b/cgo/cgo_test.go index 625a11f3..b1865060 100644 --- a/cgo/cgo_test.go +++ b/cgo/cgo_test.go @@ -12,7 +12,6 @@ import ( "go/types" "io/ioutil" "path/filepath" - "regexp" "runtime" "strings" "testing" @@ -25,14 +24,6 @@ var flagUpdate = flag.Bool("update", false, "Update images based on test output. // platforms and Go versions. func normalizeResult(result string) string { actual := strings.ReplaceAll(result, "\r\n", "\n") - - // Make sure all functions are wrapped, even those that would otherwise be - // single-line functions. This is necessary because Go 1.14 changed the way - // such functions are wrapped and it's important to have consistent test - // results. - re := regexp.MustCompile(`func \((.+)\)( .*?) +{ (.+) }`) - actual = re.ReplaceAllString(actual, "func ($1)$2 {\n\t$3\n}") - return actual } diff --git a/cgo/testdata/types.out.go b/cgo/testdata/types.out.go index c825d5dd..c89e9b00 100644 --- a/cgo/testdata/types.out.go +++ b/cgo/testdata/types.out.go @@ -67,9 +67,7 @@ type C.union3_t = C.union_1 type C.union_nested_t = C.union_3 type C.unionarray_t = struct{ arr [10]C.uchar } -func (s *C.struct_4) bitfield_a() C.uchar { - return s.__bitfield_1 & 0x1f -} +func (s *C.struct_4) bitfield_a() C.uchar { return s.__bitfield_1 & 0x1f } func (s *C.struct_4) set_bitfield_a(value C.uchar) { s.__bitfield_1 = s.__bitfield_1&^0x1f | value&0x1f<<0 } @@ -105,15 +103,9 @@ type C.struct_type1 struct { } type C.struct_type2 struct{ _type C.int } -func (union *C.union_1) unionfield_i() *C.int { - return (*C.int)(unsafe.Pointer(&union.$union)) -} -func (union *C.union_1) unionfield_d() *float64 { - return (*float64)(unsafe.Pointer(&union.$union)) -} -func (union *C.union_1) unionfield_s() *C.short { - return (*C.short)(unsafe.Pointer(&union.$union)) -} +func (union *C.union_1) unionfield_i() *C.int { return (*C.int)(unsafe.Pointer(&union.$union)) } +func (union *C.union_1) unionfield_d() *float64 { return (*float64)(unsafe.Pointer(&union.$union)) } +func (union *C.union_1) unionfield_s() *C.short { return (*C.short)(unsafe.Pointer(&union.$union)) } type C.union_1 struct{ $union uint64 } @@ -138,9 +130,7 @@ func (union *C.union_3) unionfield_thing() *C.union3_t { type C.union_3 struct{ $union [2]uint64 } -func (union *C.union_union2d) unionfield_i() *C.int { - return (*C.int)(unsafe.Pointer(&union.$union)) -} +func (union *C.union_union2d) unionfield_i() *C.int { return (*C.int)(unsafe.Pointer(&union.$union)) } func (union *C.union_union2d) unionfield_d() *[2]float64 { return (*[2]float64)(unsafe.Pointer(&union.$union)) }