File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 1818
1919# 解析覆盖率报告
2020def parse_xcresult_json ( cov_json_path )
21- json = File . read ( cov_json_path )
22- return JSON . parse ( json )
21+ json = JSON . parse ( File . read ( cov_json_path ) )
22+ targets = json [ 'targets' ]
23+ coveredLines_all = 0
24+ executableLines_all = 0
25+ targets . each do |target |
26+ files = target [ 'files' ]
27+ files . delete_if do |file |
28+ path = file [ 'path' ]
29+ path =~ %r{/Protobuf/|/Vendor/|\. pbobjc}
30+ end
31+ coveredLines_taget = 0
32+ executableLines_taget = 0
33+ files . each do |file |
34+ coveredLines_taget += file [ 'coveredLines' ]
35+ executableLines_taget += file [ 'executableLines' ]
36+ end
37+ target [ 'coveredLines' ] = coveredLines_taget
38+ target [ 'executableLines' ] = executableLines_taget
39+ target [ 'lineCoverage' ] = coveredLines_taget / executableLines_taget . to_f
40+ coveredLines_all += coveredLines_taget
41+ executableLines_all += executableLines_taget
42+ end
43+ json [ 'coveredLines' ] = coveredLines_all
44+ json [ 'executableLines' ] = executableLines_all
45+ json [ 'lineCoverage' ] = coveredLines_all / executableLines_all . to_f
46+
47+ return json
2348end
2449
2550# 格式化输出信息
You can’t perform that action at this time.
0 commit comments