github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/covdata/doc.go (about)

     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は、アプリケーションや統合テストを実行することによって生成される、2世代のカバレッジテストの出力ファイルを操作し、レポートを生成するためのプログラムです。例えば、
     7  
     8  	$ mkdir ./profiledir
     9  	$ go build -cover -o myapp.exe .
    10  	$ GOCOVERDIR=./profiledir ./myapp.exe <arguments>
    11  	$ ls ./profiledir
    12  	covcounters.cce1b350af34b6d0fb59cc1725f0ee27.821598.1663006712821344241
    13  	covmeta.cce1b350af34b6d0fb59cc1725f0ee27
    14  	$
    15  
    16  Run covdata via "go tool covdata <mode>", where 'mode' is a subcommand
    17  selecting a specific reporting, merging, or data manipulation operation.
    18  Descriptions on the various modes (run "go tool cover <mode> -help" for
    19  specifics on usage of a given mode):
    20  
    21  1. プロファイルされたパッケージごとのステートメントのカバー率を報告する:
    22  
    23  	$ go tool covdata percent -i=profiledir
    24  	cov-example/p	カバレッジ:ステートメントの41.1%
    25  	main	カバレッジ:ステートメントの87.5%
    26  	$
    27  
    28  2. プロファイルされたパッケージのインポートパスを報告する:
    29  
    30  	$ go tool covdata pkglist -i=profiledir
    31  	cov-example/p
    32  	main
    33  	$
    34  
    35  3. 関数ごとのステートメントのカバー率を報告する:
    36  
    37  	$ go tool covdata func -i=profiledir
    38  	cov-example/p/p.go:12:		emptyFn			0.0%
    39  	cov-example/p/p.go:32:		Small			100.0%
    40  	cov-example/p/p.go:47:		Medium			90.9%
    41  	...
    42  	$
    43  
    44  4. カバレッジデータを古いテキスト形式に変換する:
    45  
    46  	$ go tool covdata textfmt -i=profiledir -o=cov.txt
    47  	$ head cov.txt
    48  	mode: set
    49  	cov-example/p/p.go:12.22,13.2 0 0
    50  	cov-example/p/p.go:15.31,16.2 1 0
    51  	cov-example/p/p.go:16.3,18.3 0 0
    52  	cov-example/p/p.go:19.3,21.3 0 0
    53  	...
    54  	$ go tool cover -html=cov.txt
    55  	$
    56  
    57  5. プロファイルをマージする:
    58  
    59  	$ go tool covdata merge -i=indir1,indir2 -o=outdir -modpaths=github.com/go-delve/delve
    60  	$
    61  
    62  6. プロファイルから別のプロファイルを差し引く:
    63  
    64  	$ go tool covdata subtract -i=indir1,indir2 -o=outdir
    65  	$
    66  
    67  7. プロファイルの交差点を求める:
    68  
    69  	$ go tool covdata intersect -i=indir1,indir2 -o=outdir
    70  	$
    71  
    72  8. デバッグ目的でプロファイルをダンプする:
    73  
    74  	$ go tool covdata debugdump -i=indir
    75  	<人間に読みやすい出力>
    76  	$
    77  */package main