commit
c406e68e7d
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
@ -11,7 +11,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14.x
|
||||
go-version: 1.16.x
|
||||
- name: compile and release
|
||||
run: |
|
||||
./hack/release.sh
|
||||
@ -28,7 +28,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14.x
|
||||
go-version: 1.16.x
|
||||
- name: compile and release
|
||||
run: |
|
||||
./hack/release.sh
|
||||
@ -45,7 +45,7 @@ jobs:
|
||||
- name: Install Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.14.x
|
||||
go-version: 1.16.x
|
||||
- name: compile and release
|
||||
run: |
|
||||
./hack/release.sh
|
||||
|
55
cmd/merge.go
Normal file
55
cmd/merge.go
Normal file
@ -0,0 +1,55 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/qiniu/goc/v2/pkg/log"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/tools/cover"
|
||||
"k8s.io/test-infra/gopherage/pkg/cov"
|
||||
"k8s.io/test-infra/gopherage/pkg/util"
|
||||
)
|
||||
|
||||
var mergeCmd = &cobra.Command{
|
||||
Use: "merge [files...]",
|
||||
Short: "Merge multiple coherent Go coverage files into a single file.",
|
||||
Long: `merge will merge multiple Go coverage files into a single coverage file.
|
||||
merge requires that the files are 'coherent', meaning that if they both contain references to the
|
||||
same paths, then the contents of those source files were identical for the binary that generated
|
||||
each file.
|
||||
`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
runMerge(args, outputMergeProfile)
|
||||
},
|
||||
}
|
||||
|
||||
var outputMergeProfile string
|
||||
|
||||
func init() {
|
||||
mergeCmd.Flags().StringVarP(&outputMergeProfile, "output", "o", "mergeprofile.cov", "output file")
|
||||
|
||||
rootCmd.AddCommand(mergeCmd)
|
||||
}
|
||||
|
||||
func runMerge(args []string, output string) {
|
||||
if len(args) == 0 {
|
||||
log.Fatalf("Expected at least one coverage file.")
|
||||
}
|
||||
|
||||
profiles := make([][]*cover.Profile, len(args))
|
||||
for _, path := range args {
|
||||
profile, err := util.LoadProfile(path)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to open %s: %v", path, err)
|
||||
}
|
||||
profiles = append(profiles, profile)
|
||||
}
|
||||
|
||||
merged, err := cov.MergeMultipleProfiles(profiles)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to merge files: %v", err)
|
||||
}
|
||||
|
||||
err = util.DumpProfile(output, merged)
|
||||
if err != nil {
|
||||
log.Fatalf("fail to dump the merged file: %v", err)
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ func (b *Build) readProjectMetaInfo() {
|
||||
log.Fatalf("Go module is not enabled, please set GO111MODULE=auto or on")
|
||||
}
|
||||
// 工程根目录
|
||||
config.GocConfig.CurModProjectDir = pkg.Root
|
||||
config.GocConfig.CurModProjectDir = pkg.Module.Dir
|
||||
config.GocConfig.ImportPath = pkg.Module.Path
|
||||
|
||||
break
|
||||
|
@ -80,8 +80,8 @@ func init() {
|
||||
cov := fmt.Sprintf("%s:%d.%d,%d.%d %d %d", block.name,
|
||||
block.pos[3*i+0], uint16(block.pos[3*i+2]),
|
||||
block.pos[3*i+1], uint16(block.pos[3*i+2] >> 16),
|
||||
1,
|
||||
0)
|
||||
block.stmts,
|
||||
1)
|
||||
|
||||
err = ws.WriteMessage(websocket.TextMessage, []byte(cov))
|
||||
if err != nil {
|
||||
@ -128,13 +128,14 @@ func getRegisterInfo() (*processInfo, error) {
|
||||
//
|
||||
|
||||
type blockInfo struct {
|
||||
name string
|
||||
pos []uint32
|
||||
i int
|
||||
name string
|
||||
pos []uint32
|
||||
i int
|
||||
stmts int
|
||||
}
|
||||
|
||||
// UploadCoverChangeEvent_{{.Random}} is non-blocking
|
||||
func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int) {
|
||||
func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int, stmts uint16) {
|
||||
|
||||
if watchEnabled == false {
|
||||
return
|
||||
@ -143,9 +144,10 @@ func UploadCoverChangeEvent_{{.Random}}(name string, pos []uint32, i int) {
|
||||
// make sure send is non-blocking
|
||||
select {
|
||||
case watchChannel <- &blockInfo{
|
||||
name: name,
|
||||
pos: pos,
|
||||
i: i,
|
||||
name: name,
|
||||
pos: pos,
|
||||
i: i,
|
||||
stmts: int(stmts),
|
||||
}:
|
||||
default:
|
||||
}
|
||||
|
@ -419,7 +419,8 @@ func atomicCounterStmt(f *File, counter string) string {
|
||||
|
||||
// watchCounterStmt returns the expression: __count[23]++;UploadCoverChangeEvent(blockname, pos[:], index)
|
||||
func watchCounterStmt(f *File, counter string) string {
|
||||
return fmt.Sprintf("%s++; UploadCoverChangeEvent_%v(%s.BlockName, %s.Pos[:], %v)", counter, f.random, f.varVar, f.varVar, len(f.blocks))
|
||||
index := len(f.blocks)
|
||||
return fmt.Sprintf("%s++; UploadCoverChangeEvent_%v(%s.BlockName, %s.Pos[:], %v, %s.NumStmt[%v])", counter, f.random, f.varVar, f.varVar, index, f.varVar, index)
|
||||
}
|
||||
|
||||
// QINIU
|
||||
|
@ -43,6 +43,10 @@ func BuildCmdArgsParse(cmd *cobra.Command, args []string, cmdType int) []string
|
||||
allFlagSets := cmd.Flags()
|
||||
// 因为 args 里面含有 go 的 flag,所以需要忽略解析 go flag 的错误
|
||||
allFlagSets.Init("GOC", pflag.ContinueOnError)
|
||||
// 忽略 go flag 在 goc 中的解析错误
|
||||
allFlagSets.ParseErrorsWhitelist = pflag.ParseErrorsWhitelist{
|
||||
UnknownFlags: true,
|
||||
}
|
||||
allFlagSets.Parse(args)
|
||||
|
||||
// 重写 help
|
||||
@ -109,7 +113,7 @@ func findAndDelGocFlag(a []string, x string, v string) []string {
|
||||
x = "--" + x
|
||||
x_v := x + "=" + v
|
||||
for i := 0; i < len(a); i++ {
|
||||
if a[i] == "--debug" {
|
||||
if a[i] == "--gocdebug" {
|
||||
// debug 是 bool,就一个元素
|
||||
continue
|
||||
} else if a[i] == x {
|
||||
|
Loading…
Reference in New Issue
Block a user