Commit cb7f9ec4 authored by Cherry Zhang's avatar Cherry Zhang

cmd/compile: add a test for reproducible build with anonymous interfaces

Duplicated anonymous interfaces caused nondeterministic build.
The fix is CL 129515. This CL adds a test.

Updates #27013.

Change-Id: I6b7e1bbfc943c22e8e6f32c145f7aebb567cef15
Reviewed-on: https://go-review.googlesource.com/129680
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent c7271c0c
...@@ -15,11 +15,20 @@ import ( ...@@ -15,11 +15,20 @@ import (
) )
func TestReproducibleBuilds(t *testing.T) { func TestReproducibleBuilds(t *testing.T) {
tests := []string{
"issue20272.go",
"issue27013.go",
}
testenv.MustHaveGoBuild(t) testenv.MustHaveGoBuild(t)
iters := 10 iters := 10
if testing.Short() { if testing.Short() {
iters = 4 iters = 4
} }
t.Parallel()
for _, test := range tests {
test := test
t.Run(test, func(t *testing.T) {
t.Parallel() t.Parallel()
var want []byte var want []byte
tmp, err := ioutil.TempFile("", "") tmp, err := ioutil.TempFile("", "")
...@@ -29,7 +38,7 @@ func TestReproducibleBuilds(t *testing.T) { ...@@ -29,7 +38,7 @@ func TestReproducibleBuilds(t *testing.T) {
defer os.Remove(tmp.Name()) defer os.Remove(tmp.Name())
defer tmp.Close() defer tmp.Close()
for i := 0; i < iters; i++ { for i := 0; i < iters; i++ {
out, err := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-o", tmp.Name(), filepath.Join("testdata", "reproducible", "issue20272.go")).CombinedOutput() out, err := exec.Command(testenv.GoToolPath(t), "tool", "compile", "-o", tmp.Name(), filepath.Join("testdata", "reproducible", test)).CombinedOutput()
if err != nil { if err != nil {
t.Fatalf("failed to compile: %v\n%s", err, out) t.Fatalf("failed to compile: %v\n%s", err, out)
} }
...@@ -45,4 +54,6 @@ func TestReproducibleBuilds(t *testing.T) { ...@@ -45,4 +54,6 @@ func TestReproducibleBuilds(t *testing.T) {
} }
} }
} }
})
}
} }
// Copyright 2018 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
func A(arg interface{}) {
_ = arg.(interface{ Func() int32 })
_ = arg.(interface{ Func() int32 })
_ = arg.(interface{ Func() int32 })
_ = arg.(interface{ Func() int32 })
_ = arg.(interface{ Func() int32 })
_ = arg.(interface{ Func() int32 })
_ = arg.(interface{ Func() int32 })
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment