diff options
| author | Russ Cox <rsc@golang.org> | 2023-05-08 23:31:00 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2023-05-09 16:07:13 +0000 |
| commit | 134c9b2b171be3515ecef1787ef25435908c17c0 (patch) | |
| tree | a5e0f12597f437c24c40e3d3ffe70e149f4db541 /src/cmd/compile/internal/loopvar | |
| parent | da5a3146ec903cdcb779d501be4ff88fd775820e (diff) | |
| download | go-134c9b2b171be3515ecef1787ef25435908c17c0.tar.xz | |
cmd/compile: remove FS debug hash form
The FS form was only necessary for reliable hashes in tests,
and for that we can use -trimpath.
Another potential concern would be temporary work directory
names leaking into the names of files generated by cgo and the
like, but we already make sure to avoid those to ensure
reproducible builds: the compiler never sees those paths.
So the FS form is not necessary for that either.
Change-Id: Idae2c6acb22ab64dfb33bb053244d23fbe153830
Reviewed-on: https://go-review.googlesource.com/c/go/+/493737
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Diffstat (limited to 'src/cmd/compile/internal/loopvar')
| -rw-r--r-- | src/cmd/compile/internal/loopvar/loopvar_test.go | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/src/cmd/compile/internal/loopvar/loopvar_test.go b/src/cmd/compile/internal/loopvar/loopvar_test.go index 5c7e11ac69..b94f69709d 100644 --- a/src/cmd/compile/internal/loopvar/loopvar_test.go +++ b/src/cmd/compile/internal/loopvar/loopvar_test.go @@ -178,11 +178,12 @@ func TestLoopVarHashes(t *testing.T) { root := "cmd/compile/internal/loopvar/testdata/inlines" f := func(hash string) string { - // This disables the loopvar change, except for the specified package. - // The effect should follow the package, even though everything (except "c") - // is inlined. - cmd := testenv.Command(t, gocmd, "run", root) - cmd.Env = append(cmd.Env, "GOCOMPILEDEBUG=loopvarhash=FS"+hash, "HOME="+tmpdir) + // This disables the loopvar change, except for the specified hash pattern. + // -trimpath is necessary so we get the same answer no matter where the + // Go repository is checked out. This is not normally a concern since people + // do not rely on the meaning of specific hashes. + cmd := testenv.Command(t, gocmd, "run", "-trimpath", root) + cmd.Env = append(cmd.Env, "GOCOMPILEDEBUG=loopvarhash="+hash, "HOME="+tmpdir) cmd.Dir = filepath.Join("testdata", "inlines") b, _ := cmd.CombinedOutput() @@ -190,17 +191,27 @@ func TestLoopVarHashes(t *testing.T) { return string(b) } - m := f("011011011110011110111101") + m := f("001100110110110010100100") t.Logf(m) - mCount := strings.Count(m, "loopvarhash triggered main.go:27:6") + mCount := strings.Count(m, "loopvarhash triggered cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 001100110110110010100100") otherCount := strings.Count(m, "loopvarhash") if mCount < 1 { - t.Errorf("Did not see expected value of m compile") + t.Errorf("did not see triggered main.go:27:6") } if mCount != otherCount { - t.Errorf("Saw extraneous hash matches") + t.Errorf("too many matches") } + + mCount = strings.Count(m, "cmd/compile/internal/loopvar/testdata/inlines/main.go:27:6 [bisect-match 0x7802e115b9336ca4]") + otherCount = strings.Count(m, "[bisect-match ") + if mCount < 1 { + t.Errorf("did not see bisect-match for main.go:27:6") + } + if mCount != otherCount { + t.Errorf("too many matches") + } + // This next test carefully dodges a bug-to-be-fixed with inlined locations for ir.Names. if !strings.Contains(m, ", 100, 100, 100, 100") { t.Errorf("Did not see expected value of m run") |
