mirror of https://github.com/golang/go.git
Compare commits
10 Commits
78b8f7d20f
...
ff2f36f667
| Author | SHA1 | Date |
|---|---|---|
|
|
ff2f36f667 | |
|
|
49cdf0c42e | |
|
|
3bf1eecbd3 | |
|
|
8ed23a2936 | |
|
|
ef60769b46 | |
|
|
e0ce9653db | |
|
|
f397da8ee2 | |
|
|
77171822fc | |
|
|
090372e831 | |
|
|
b27071cd9e |
|
|
@ -1899,12 +1899,21 @@ func (b *Builder) installHeader(ctx context.Context, a *Action) error {
|
|||
// regular outputs (instrumented source files) the cover tool also
|
||||
// writes a separate file (appearing first in the list of outputs)
|
||||
// that will contain coverage counters and meta-data.
|
||||
//
|
||||
// When an overlay is in use, it ensures the coverage tool processes the overlaid
|
||||
// files rather than the original source files.
|
||||
func (b *Builder) cover(a *Action, infiles, outfiles []string, varName string, mode string) ([]string, error) {
|
||||
pkgcfg := a.Objdir + "pkgcfg.txt"
|
||||
covoutputs := a.Objdir + "coveroutfiles.txt"
|
||||
odir := filepath.Dir(outfiles[0])
|
||||
cv := filepath.Join(odir, "covervars.go")
|
||||
outfiles = append([]string{cv}, outfiles...)
|
||||
overlayInfiles := make([]string, 0, len(infiles))
|
||||
for _, f := range infiles {
|
||||
overlayPath := fsys.Actual(f)
|
||||
overlayInfiles = append(overlayInfiles, overlayPath)
|
||||
}
|
||||
|
||||
if err := b.writeCoverPkgInputs(a, pkgcfg, covoutputs, outfiles); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -1914,7 +1923,7 @@ func (b *Builder) cover(a *Action, infiles, outfiles []string, varName string, m
|
|||
"-var", varName,
|
||||
"-outfilelist", covoutputs,
|
||||
}
|
||||
args = append(args, infiles...)
|
||||
args = append(args, overlayInfiles...)
|
||||
if err := b.Shell(a).run(a.Objdir, "", nil,
|
||||
cfg.BuildToolexec, args); err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
# Test that coverage works correctly with overlays
|
||||
|
||||
env GO111MODULE=on
|
||||
|
||||
mkdir covmod
|
||||
cd covmod
|
||||
|
||||
-- go.mod --
|
||||
module example.com/covmod
|
||||
|
||||
go 1.25
|
||||
|
||||
-- a.go --
|
||||
package a
|
||||
|
||||
func Hello() string {
|
||||
return "Hello: World"
|
||||
}
|
||||
|
||||
func Helper() string {
|
||||
return "helper"
|
||||
}
|
||||
|
||||
-- a_test.go --
|
||||
package a
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHello(t *testing.T) {
|
||||
got := Hello()
|
||||
expected := "Hello: World"
|
||||
if got != expected {
|
||||
t.Fatalf("Hello() = %q, want %q", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelper(t *testing.T) {
|
||||
got := Helper()
|
||||
expected := "helper"
|
||||
if got != expected {
|
||||
t.Fatalf("Helper() = %q, want %q", got, expected)
|
||||
}
|
||||
}
|
||||
|
||||
-- overlay/a.go --
|
||||
package a
|
||||
|
||||
func Hello() string {
|
||||
panic("overlay")
|
||||
}
|
||||
|
||||
func Helper() string {
|
||||
panic("overlay helper")
|
||||
}
|
||||
|
||||
-- overlay.json --
|
||||
{"Replace": {"a.go": "overlay/a.go"}}
|
||||
|
||||
exists overlay.json
|
||||
|
||||
go mod tidy
|
||||
|
||||
go test -v
|
||||
|
||||
! exec sh -c '! go test -overlay=overlay.json -coverpkg=example.com/covmod 2>&1 | grep -q "panic: overlay"'
|
||||
|
||||
! exec sh -c '! go test -overlay=overlay.json -run=TestHello -coverpkg=example.com/covmod 2>&1 | grep -q "panic: overlay"'
|
||||
|
||||
! exec sh -c '! go test -overlay=overlay.json -run=TestHelper -coverpkg=example.com/covmod 2>&1 | grep -q "panic: overlay helper"'
|
||||
|
||||
! go test -overlay=overlay.json -coverpkg=example.com/covmod -coverprofile=coverage.txt
|
||||
|
||||
exists coverage.txt
|
||||
|
||||
! grep -q 'overlay/a\.go' coverage.txt
|
||||
|
||||
rm -f coverage.txt
|
||||
|
|
@ -82,7 +82,7 @@ func newGCM(cipher Block, nonceSize, tagSize int) (AEAD, error) {
|
|||
|
||||
// NewGCMWithRandomNonce returns the given cipher wrapped in Galois Counter
|
||||
// Mode, with randomly-generated nonces. The cipher must have been created by
|
||||
// [aes.NewCipher].
|
||||
// [crypto/aes.NewCipher].
|
||||
//
|
||||
// It generates a random 96-bit nonce, which is prepended to the ciphertext by Seal,
|
||||
// and is extracted from the ciphertext by Open. The NonceSize of the AEAD is zero,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
PACKAGE issue62640
|
||||
|
||||
IMPORTPATH
|
||||
testdata/issue62640
|
||||
|
||||
FILENAMES
|
||||
testdata/issue62640.go
|
||||
|
||||
TYPES
|
||||
//
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F()
|
||||
|
||||
//
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
//
|
||||
PACKAGE issue62640
|
||||
|
||||
IMPORTPATH
|
||||
testdata/issue62640
|
||||
|
||||
FILENAMES
|
||||
testdata/issue62640.go
|
||||
|
||||
TYPES
|
||||
//
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F()
|
||||
|
||||
//
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
//
|
||||
PACKAGE issue62640
|
||||
|
||||
IMPORTPATH
|
||||
testdata/issue62640
|
||||
|
||||
FILENAMES
|
||||
testdata/issue62640.go
|
||||
|
||||
TYPES
|
||||
//
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F()
|
||||
|
||||
//
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (S) F()
|
||||
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// 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 issue62640
|
||||
|
||||
type E struct{}
|
||||
|
||||
// F should be hidden within S because of the S.F field.
|
||||
func (E) F() {}
|
||||
|
||||
type S struct {
|
||||
E
|
||||
F int
|
||||
}
|
||||
|
|
@ -312,8 +312,10 @@ type heapArena struct {
|
|||
// during marking.
|
||||
pageSpecials [pagesPerArena / 8]uint8
|
||||
|
||||
// pageUseSpanDartboard is a bitmap that indicates which spans are
|
||||
// heap spans and also gcUsesSpanDartboard.
|
||||
// pageUseSpanInlineMarkBits is a bitmap where each bit corresponds
|
||||
// to a span, as only spans one page in size can have inline mark bits.
|
||||
// The bit indicates that the span has a spanInlineMarkBits struct
|
||||
// stored directly at the top end of the span's memory.
|
||||
pageUseSpanInlineMarkBits [pagesPerArena / 8]uint8
|
||||
|
||||
// checkmarks stores the debug.gccheckmark state. It is only
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
// 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 synctest_test
|
||||
|
||||
import "testing"
|
||||
|
||||
// helperLog is a t.Helper which logs.
|
||||
// Since it is a helper, the log prefix should contain
|
||||
// the caller's file, not helper_test.go.
|
||||
func helperLog(t *testing.T, s string) {
|
||||
t.Helper()
|
||||
t.Log(s)
|
||||
}
|
||||
|
|
@ -140,6 +140,18 @@ func TestRun(t *testing.T) {
|
|||
})
|
||||
}
|
||||
|
||||
func TestHelper(t *testing.T) {
|
||||
runTest(t, []string{"-test.v"}, func() {
|
||||
synctest.Test(t, func(t *testing.T) {
|
||||
helperLog(t, "log in helper")
|
||||
})
|
||||
}, `^=== RUN TestHelper
|
||||
synctest_test.go:.* log in helper
|
||||
--- PASS: TestHelper.*
|
||||
PASS
|
||||
$`)
|
||||
}
|
||||
|
||||
func wantPanic(t *testing.T, want string) {
|
||||
if e := recover(); e != nil {
|
||||
if got := fmt.Sprint(e); got != want {
|
||||
|
|
|
|||
|
|
@ -1261,6 +1261,9 @@ func (c *common) Skipped() bool {
|
|||
// When printing file and line information, that function will be skipped.
|
||||
// Helper may be called simultaneously from multiple goroutines.
|
||||
func (c *common) Helper() {
|
||||
if c.isSynctest {
|
||||
c = c.parent
|
||||
}
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
if c.helperPCs == nil {
|
||||
|
|
|
|||
Loading…
Reference in New Issue