Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
1dc01adf
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
1dc01adf
编写于
1月 24, 2019
作者:
C
Chinmay Garde
提交者:
GitHub
1月 24, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Allow generating coverage reports for all unit-tests in the engine. (#7576)
上级
23b7e29f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
151 addition
and
1 deletion
+151
-1
DEPS
DEPS
+1
-1
build/generate_coverage.py
build/generate_coverage.py
+146
-0
tools/gn
tools/gn
+4
-0
未找到文件。
DEPS
浏览文件 @
1dc01adf
...
...
@@ -116,7 +116,7 @@ allowed_hosts = [
]
deps = {
'src': 'https://github.com/flutter/buildroot.git' + '@' + '
ad6c0a07231e416bb3f96886b50778c70c491778
',
'src': 'https://github.com/flutter/buildroot.git' + '@' + '
85da9493a0584289b0b392ff2fb8d30e6b44e6a6
',
# Fuchsia compatibility
#
...
...
build/generate_coverage.py
0 → 100755
浏览文件 @
1dc01adf
#!/usr/bin/env python
#
# Copyright 2013 The Flutter Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import
sys
import
subprocess
import
os
import
argparse
import
errno
import
shutil
def
GetLLVMBinDirectory
():
buildtool_dir
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
)),
"../../buildtools"
)
platform_dir
=
""
if
sys
.
platform
.
startswith
(
'linux'
):
platform_dir
=
"linux-x64"
elif
sys
.
platform
==
'darwin'
:
platform_dir
=
"mac-x64"
else
:
raise
Exception
(
"Unknown/Unsupported platform."
)
llvm_bin_dir
=
os
.
path
.
abspath
(
os
.
path
.
join
(
buildtool_dir
,
platform_dir
,
"clang/bin"
))
if
not
os
.
path
.
exists
(
llvm_bin_dir
):
raise
Exception
(
"LLVM directory %s double not be located."
%
llvm_bin_dir
)
return
llvm_bin_dir
def
MakeDirs
(
new_dir
):
"""A wrapper around os.makedirs() that emulates "mkdir -p"."""
try
:
os
.
makedirs
(
new_dir
)
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EEXIST
:
raise
def
RemoveIfExists
(
path
):
if
os
.
path
.
isdir
(
path
)
and
not
os
.
path
.
islink
(
path
):
shutil
.
rmtree
(
path
)
elif
os
.
path
.
exists
(
path
):
os
.
remove
(
path
)
def
main
():
parser
=
argparse
.
ArgumentParser
();
parser
.
add_argument
(
'-t'
,
'--tests'
,
nargs
=
'+'
,
dest
=
'tests'
,
required
=
True
,
help
=
'The unit tests to run and gather coverage data on.'
)
parser
.
add_argument
(
'-o'
,
'--output'
,
dest
=
'output'
,
required
=
True
,
help
=
'The output directory for coverage results.'
)
parser
.
add_argument
(
'-f'
,
'--format'
,
type
=
str
,
choices
=
[
'all'
,
'html'
,
'summary'
],
required
=
True
,
help
=
'The type of coverage information to be displayed.'
)
args
=
parser
.
parse_args
()
output
=
os
.
path
.
abspath
(
args
.
output
)
MakeDirs
(
output
)
generate_all_reports
=
args
.
format
==
"all"
raw_profiles
=
[]
binaries
=
[]
# Run all unit tests and collect raw profiles.
for
test
in
args
.
tests
:
absolute_test_path
=
os
.
path
.
abspath
(
test
)
if
not
os
.
path
.
exists
(
absolute_test_path
):
print
(
"Path %s does not exist."
%
absolute_test_path
)
return
-
1
binaries
.
append
(
absolute_test_path
)
raw_profile
=
absolute_test_path
+
".rawprofile"
RemoveIfExists
(
raw_profile
)
print
"Running test %s to gather profile."
%
os
.
path
.
basename
(
absolute_test_path
)
subprocess
.
check_call
([
absolute_test_path
],
shell
=
True
,
env
=
{
"LLVM_PROFILE_FILE"
:
raw_profile
})
if
not
os
.
path
.
exists
(
raw_profile
):
print
(
"Could not find raw profile data for unit test run %s."
%
test
)
print
(
"Did you build with the --coverage flag?"
)
return
-
1
raw_profiles
.
append
(
raw_profile
)
if
len
(
raw_profiles
)
==
0
:
print
(
"No raw profiles could be generated."
)
return
-
1
binaries_flag
=
[]
for
binary
in
binaries
:
binaries_flag
.
append
(
'-object'
)
binaries_flag
.
append
(
binary
)
llvm_bin_dir
=
GetLLVMBinDirectory
()
# Merge all raw profiles into a single profile.
profdata_binary
=
os
.
path
.
join
(
llvm_bin_dir
,
"llvm-profdata"
)
print
(
"Merging %d raw profile(s) into single profile."
%
len
(
raw_profiles
))
merged_profile_path
=
os
.
path
.
join
(
output
,
"all.profile"
)
RemoveIfExists
(
merged_profile_path
)
merge_command
=
[
profdata_binary
,
"merge"
,
"-sparse"
]
+
raw_profiles
+
[
"-o"
,
merged_profile_path
]
subprocess
.
check_call
(
merge_command
)
print
(
"Done."
)
if
not
os
.
path
.
exists
(
merged_profile_path
):
print
(
"Could not generate or find merged profile %s."
%
merged_profile_path
)
return
-
1
llvm_cov_binary
=
os
.
path
.
join
(
llvm_bin_dir
,
"llvm-cov"
)
instr_profile_flag
=
"-instr-profile=%s"
%
merged_profile_path
ignore_flags
=
"-ignore-filename-regex=third_party|unittest|fixture"
# Generate the HTML report if specified.
if
generate_all_reports
or
args
.
format
==
'html'
:
print
(
"Generating HTML report."
)
show_command
=
[
llvm_cov_binary
,
"show"
]
+
binaries_flag
+
[
instr_profile_flag
,
"-format=html"
,
"-output-dir=%s"
%
output
,
"-tab-size=2"
,
ignore_flags
,
]
subprocess
.
check_call
(
show_command
)
print
(
"Done."
)
# Generate a report summary if specified.
if
generate_all_reports
or
args
.
format
==
'summary'
:
print
(
"Generating a summary report."
)
report_command
=
[
llvm_cov_binary
,
"report"
]
+
binaries_flag
+
[
instr_profile_flag
,
ignore_flags
,
]
subprocess
.
check_call
(
report_command
)
print
(
"Done."
)
return
0
if
__name__
==
'__main__'
:
sys
.
exit
(
main
())
tools/gn
浏览文件 @
1dc01adf
...
...
@@ -93,6 +93,8 @@ def to_gn_args(args):
gn_args
[
'embedder_for_target'
]
=
args
.
embedder_for_target
gn_args
[
'enable_coverage'
]
=
args
.
coverage
if
args
.
operator_new_alignment
is
not
None
:
gn_args
[
'operator_new_alignment'
]
=
args
.
operator_new_alignment
...
...
@@ -261,6 +263,8 @@ def parse_args(args):
parser
.
add_argument
(
'--embedder-for-target'
,
dest
=
'embedder_for_target'
,
action
=
'store_true'
,
default
=
False
)
parser
.
add_argument
(
'--coverage'
,
default
=
False
,
action
=
'store_true'
)
return
parser
.
parse_args
(
args
)
def
main
(
argv
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录