Skip to content

Commit 7ba4873

Browse files
authored
Merge pull request #684 from harryphone/master
test: ci update
2 parents cc051b9 + 5e31d24 commit 7ba4873

File tree

1 file changed

+27
-2
lines changed

1 file changed

+27
-2
lines changed

AVOS/.ci/UnitTestParser/targetCoverage.rb

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,33 @@
1818

1919
# 解析覆盖率报告
2020
def 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/|/LCMPMessagePack/|/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
2348
end
2449

2550
# 格式化输出信息

0 commit comments

Comments
 (0)