]> Cypherpunks repositories - gostls13.git/commitdiff
internal/coverage/cfile: remove //go:linkname into testing
authorRuss Cox <rsc@golang.org>
Wed, 15 May 2024 23:03:42 +0000 (19:03 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 22 May 2024 09:58:07 +0000 (09:58 +0000)
This is just looking at a command-line flag. Look directly.

For #67401.

Change-Id: I7a1c3fc2d9cc85e5ffc5731444bf6db87abf6901
Reviewed-on: https://go-review.googlesource.com/c/go/+/585916
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
src/internal/coverage/cfile/ts_test.go
src/testing/newcover.go

index edbc603a1b8fbfccc146482fc0fce44ef1eae134..621a79de43cfd5606d2be33b1086a7862f76e2be 100644 (file)
@@ -6,6 +6,7 @@ package cfile
 
 import (
        "encoding/json"
+       "flag"
        "internal/coverage"
        "internal/goexperiment"
        "internal/testenv"
@@ -17,13 +18,11 @@ import (
        _ "unsafe"
 )
 
-//go:linkname testing_testGoCoverDir testing.testGoCoverDir
-func testing_testGoCoverDir() string
-
 func testGoCoverDir(t *testing.T) string {
-       tgcd := testing_testGoCoverDir()
-       if tgcd != "" {
-               return tgcd
+       if f := flag.Lookup("test.gocoverdir"); f != nil {
+               if dir := f.Value.String(); dir != "" {
+                       return dir
+               }
        }
        return t.TempDir()
 }
index a7dbcfc65a19982f571c503689d309fb9dfb5a17..ad2f622640e4d9746b48bb4ecb1371731b0f0838 100644 (file)
@@ -46,16 +46,6 @@ func coverReport2() {
        }
 }
 
-// testGoCoverDir is used in runtime/coverage tests.
-//go:linkname testGoCoverDir
-
-// testGoCoverDir returns the value passed to the -test.gocoverdir
-// flag by the Go command, if goexperiment.CoverageRedesign is
-// in effect.
-func testGoCoverDir() string {
-       return *gocoverdir
-}
-
 // coverage2 returns a rough "coverage percentage so far"
 // number to support the testing.Coverage() function.
 func coverage2() float64 {