Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
0f4ea890
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
10 个月 前同步成功
通知
29
Star
144
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Unity
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
0f4ea890
编写于
2月 11, 2015
作者:
A
Alexander Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a port of unity_test_summary.rb to Python
Useful in environments without access to ruby
上级
fb5793e0
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
135 addition
and
0 deletion
+135
-0
auto/unity_test_summary.py
auto/unity_test_summary.py
+135
-0
未找到文件。
auto/unity_test_summary.py
0 → 100644
浏览文件 @
0f4ea890
#! python3
# ==========================================
# Unity Project - A Test Framework for C
# Copyright (c) 2015 Alexander Mueller / XelaRellum@web.de
# [Released under MIT License. Please refer to license.txt for details]
# Based on the ruby script by Mike Karlesky, Mark VanderVoord, Greg Williams
# ==========================================
import
sys
import
os
import
re
from
glob
import
glob
class
UnityTestSummary
:
def
__init__
(
self
):
self
.
report
=
''
self
.
total_tests
=
0
self
.
failures
=
0
self
.
ignored
=
0
def
run
(
self
):
# Clean up result file names
results
=
[]
for
target
in
self
.
targets
:
results
.
append
(
target
.
replace
(
'
\\
'
,
'/'
))
# Dig through each result file, looking for details on pass/fail:
failure_output
=
[]
ignore_output
=
[]
for
result_file
in
results
:
lines
=
list
(
map
(
lambda
line
:
line
.
rstrip
(),
open
(
result_file
,
"r"
).
read
().
split
(
'
\n
'
)))
if
len
(
lines
)
==
0
:
raise
Exception
(
"Empty test result file: %s"
%
result_file
)
details
=
self
.
get_details
(
result_file
,
lines
)
failures
=
details
[
'failures'
]
ignores
=
details
[
'ignores'
]
if
len
(
failures
)
>
0
:
failure_output
.
append
(
'
\n
'
.
join
(
failures
))
if
len
(
ignores
)
>
0
:
ignore_output
.
append
(
'n'
.
join
(
ignores
))
tests
,
failures
,
ignored
=
self
.
parse_test_summary
(
'
\n
'
.
join
(
lines
))
self
.
total_tests
+=
tests
self
.
failures
+=
failures
self
.
ignored
+=
ignored
if
self
.
ignored
>
0
:
self
.
report
+=
"
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"UNITY IGNORED TEST SUMMARY
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"
\n
"
.
join
(
ignore_output
)
if
self
.
failures
>
0
:
self
.
report
+=
"
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"UNITY FAILED TEST SUMMARY
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
'
\n
'
.
join
(
failure_output
)
self
.
report
+=
"
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"OVERALL UNITY TEST SUMMARY
\n
"
self
.
report
+=
"--------------------------
\n
"
self
.
report
+=
"{total_tests} TOTAL TESTS {failures} TOTAL FAILURES {ignored} IGNORED
\n
"
.
format
(
total_tests
=
self
.
total_tests
,
failures
=
self
.
failures
,
ignored
=
self
.
ignored
)
self
.
report
+=
"
\n
"
return
self
.
report
def
set_targets
(
self
,
target_array
):
self
.
targets
=
target_array
def
set_root_path
(
self
,
path
):
self
.
root
=
path
def
usage
(
self
,
err_msg
=
None
):
print
(
"
\n
ERROR: "
)
if
err_msg
:
print
(
err_msg
)
print
(
"
\n
Usage: unity_test_summary.rb result_file_directory/ root_path/"
)
print
(
" result_file_directory - The location of your results files."
)
print
(
" Defaults to current directory if not specified."
)
print
(
" Should end in / if specified."
)
print
(
" root_path - Helpful for producing more verbose output if using relative paths."
)
sys
.
exit
(
1
)
def
get_details
(
self
,
result_file
,
lines
):
results
=
{
'failures'
:
[],
'ignores'
:
[],
'successes'
:
[]
}
for
line
in
lines
:
parts
=
line
.
split
(
':'
)
if
len
(
parts
)
!=
5
:
continue
src_file
,
src_line
,
test_name
,
status
,
msg
=
parts
if
len
(
self
.
root
)
>
0
:
line_out
=
"%s%s"
%
(
self
.
root
,
line
)
else
:
line_out
=
line
if
status
==
'IGNORE'
:
results
[
'ignores'
].
append
(
line_out
)
elif
status
==
'FAIL'
:
results
[
'failures'
].
append
(
line_out
)
elif
status
==
'PASS'
:
results
[
'successes'
].
append
(
line_out
)
return
results
def
parse_test_summary
(
self
,
summary
):
m
=
re
.
search
(
r
"([0-9]+) Tests ([0-9]+) Failures ([0-9]+) Ignored"
,
summary
)
if
not
m
:
raise
Exception
(
"Couldn't parse test results: %s"
%
summary
)
return
int
(
m
.
group
(
1
)),
int
(
m
.
group
(
2
)),
int
(
m
.
group
(
3
))
if
__name__
==
'__main__'
:
uts
=
UnityTestSummary
()
try
:
#look in the specified or current directory for result files
if
len
(
sys
.
argv
)
>
1
:
targets_dir
=
sys
.
argv
[
1
]
else
:
targets_dir
=
'./'
targets
=
list
(
map
(
lambda
x
:
x
.
replace
(
'
\\
'
,
'/'
),
glob
(
targets_dir
+
'*.test*'
)))
if
len
(
targets
)
==
0
:
raise
Exception
(
"No *.testpass or *.testfail files found in '%s'"
%
targets_dir
)
uts
.
set_targets
(
targets
)
#set the root path
if
len
(
sys
.
argv
)
>
2
:
root_path
=
sys
.
argv
[
2
]
else
:
root_path
=
os
.
path
.
split
(
__file__
)[
0
]
uts
.
set_root_path
(
root_path
)
#run the summarizer
print
(
uts
.
run
())
except
Exception
as
e
:
uts
.
usage
(
e
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录