Source file src/cmd/covdata/doc.go
1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 /* 6 Covdata is a program for manipulating and generating reports 7 from 2nd-generation coverage testing output files, those produced 8 from running applications or integration tests. E.g. 9 10 $ mkdir ./profiledir 11 $ go build -cover -o myapp.exe . 12 $ GOCOVERDIR=./profiledir ./myapp.exe <arguments> 13 $ ls ./profiledir 14 covcounters.cce1b350af34b6d0fb59cc1725f0ee27.821598.1663006712821344241 15 covmeta.cce1b350af34b6d0fb59cc1725f0ee27 16 $ 17 18 Run covdata via "go tool covdata <mode>", where 'mode' is a subcommand 19 selecting a specific reporting, merging, or data manipulation operation. 20 Descriptions on the various modes (run "go tool cover <mode> -help" for 21 specifics on usage of a given mode): 22 23 1. Report percent of statements covered in each profiled package 24 25 $ go tool covdata percent -i=profiledir 26 cov-example/p coverage: 41.1% of statements 27 main coverage: 87.5% of statements 28 $ 29 30 2. Report import paths of packages profiled 31 32 $ go tool covdata pkglist -i=profiledir 33 cov-example/p 34 main 35 $ 36 37 3. Report percent statements covered by function: 38 39 $ go tool covdata func -i=profiledir 40 cov-example/p/p.go:12: emptyFn 0.0% 41 cov-example/p/p.go:32: Small 100.0% 42 cov-example/p/p.go:47: Medium 90.9% 43 ... 44 $ 45 46 4. Convert coverage data to legacy textual format: 47 48 $ go tool covdata textfmt -i=profiledir -o=cov.txt 49 $ head cov.txt 50 mode: set 51 cov-example/p/p.go:12.22,13.2 0 0 52 cov-example/p/p.go:15.31,16.2 1 0 53 cov-example/p/p.go:16.3,18.3 0 0 54 cov-example/p/p.go:19.3,21.3 0 0 55 ... 56 $ go tool cover -html=cov.txt 57 $ 58 59 5. Merge profiles together: 60 61 $ go tool covdata merge -i=indir1,indir2 -o=outdir -modpaths=github.com/go-delve/delve 62 $ 63 64 6. Subtract one profile from another 65 66 $ go tool covdata subtract -i=indir1,indir2 -o=outdir 67 $ 68 69 7. Intersect profiles 70 71 $ go tool covdata intersect -i=indir1,indir2 -o=outdir 72 $ 73 74 8. Dump a profile for debugging purposes. 75 76 $ go tool covdata debugdump -i=indir 77 <human readable output> 78 $ 79 */ 80 package main 81