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