Source file
src/testing/newcover.go
1
2
3
4
5
6
7 package testing
8
9 import (
10 "fmt"
11 "internal/goexperiment"
12 "os"
13 _ "unsafe"
14 )
15
16
17
18 var cover2 struct {
19 mode string
20 tearDown func(coverprofile string, gocoverdir string) (string, error)
21 snapshotcov func() float64
22 }
23
24
25
26
27 func registerCover2(mode string, tearDown func(coverprofile string, gocoverdir string) (string, error), snapcov func() float64) {
28 if mode == "" {
29 return
30 }
31 cover2.mode = mode
32 cover2.tearDown = tearDown
33 cover2.snapshotcov = snapcov
34 }
35
36
37
38
39 func coverReport2() {
40 if !goexperiment.CoverageRedesign {
41 panic("unexpected")
42 }
43 if errmsg, err := cover2.tearDown(*coverProfile, *gocoverdir); err != nil {
44 fmt.Fprintf(os.Stderr, "%s: %v\n", errmsg, err)
45 os.Exit(2)
46 }
47 }
48
49
50
51 func coverage2() float64 {
52 if cover2.mode == "" {
53 return 0.0
54 }
55 return cover2.snapshotcov()
56 }
57
View as plain text