internal/trace: expose the go version read by the reader

This change adds a function to expose the version set by the trace
reader after reading the trace header (in tests). The trace validator
needs to be able to determine what version of the trace it needs to
validate against. Clock snapshot checks have been disabled for
Windows and WASM.

For #63185

Change-Id: Ia3d63e6ed7a5ecd87e63292b84cc417d982aaa5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/677695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Carlos Amedee 2025-05-30 16:05:04 -04:00 committed by Gopher Robot
parent 68b51e99f9
commit a8e99ab19c
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,12 @@
// Copyright 2025 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 trace
import "internal/trace/version"
// GoVersion is the version set in the trace header.
func (r *Reader) GoVersion() version.Version {
return r.version
}

View File

@ -11,6 +11,7 @@ import (
"io"
"os"
"path/filepath"
"runtime"
"strings"
"testing"
"time"
@ -109,6 +110,10 @@ func testReader(t *testing.T, tr io.Reader, v *testtrace.Validator, exp *testtra
if err == io.EOF {
break
}
v.GoVersion = r.GoVersion()
if runtime.GOOS == "windows" || runtime.GOARCH == "wasm" {
v.SkipClockSnapshotChecks()
}
if err != nil {
if err := exp.Check(err); err != nil {
t.Error(err)