Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
a18b8946
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 搜索 >>
提交
a18b8946
编写于
12月 20, 2013
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #55 from Jcarnage/master
Initial import of report parser.
上级
d9ac0e10
5cdd6b67
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
189 addition
and
0 deletion
+189
-0
auto/parseOutput.rb
auto/parseOutput.rb
+189
-0
未找到文件。
auto/parseOutput.rb
0 → 100644
浏览文件 @
a18b8946
#============================================================
# Author: John Theofanopoulos
# A simple parser. Takes the output files generated during the build process and
# extracts information relating to the tests.
#
# Notes:
# To capture an output file under VS builds use the following:
# devenv [build instructions] > Output.txt & type Output.txt
#
# To capture an output file under GCC/Linux builds use the following:
# make | tee Output.txt
#
# To use this parser use the following command
# ruby parseOutput.rb [options] [file]
# options: -xml : produce a JUnit compatible XML file
# file : file to scan for results
#============================================================
class
ParseOutput
# The following flag is set to true when a test is found or false otherwise.
@testFlag
@xmlOut
@arrayList
@totalTests
@classIndex
# Set the flag to indicate if there will be an XML output file or not
def
setXmlOutput
()
@xmlOut
=
true
end
# if write our output to XML
def
writeXmlOuput
()
output
=
File
.
open
(
"report.xml"
,
"w"
)
output
<<
"<?xml version=
\"
1.0
\"
encoding=
\"
UTF-8
\"
?>
\n
"
@arrayList
.
each
do
|
item
|
output
<<
item
<<
"
\n
"
end
output
<<
"</testsuite>
\n
"
end
# This function will try and determine when the suite is changed. This is
# is the name that gets added to the classname parameter.
def
testSuiteVerify
(
testSuiteName
)
if
@testFlag
==
false
@testFlag
=
true
;
# Split the path name
testName
=
testSuiteName
.
split
(
"/"
)
# Remove the extension
baseName
=
testName
[
testName
.
size
-
1
].
split
(
"."
)
@testSuite
=
"test."
+
baseName
[
0
]
printf
"New Test: %s
\n
"
,
@testSuite
end
end
# Test was flagged as having passed so format the output
def
testPassed
(
array
)
lastItem
=
array
.
length
-
1
testName
=
array
[
lastItem
-
1
]
testSuiteVerify
(
array
[
@className
])
printf
"%-40s PASS
\n
"
,
testName
if
@xmlOut
==
true
@arrayList
.
push
" <testcase classname=
\"
"
+
@testSuite
+
"
\"
name=
\"
"
+
testName
+
"
\"
/>"
end
end
# Test was flagged as being ingored so format the output
def
testIgnored
(
array
)
lastItem
=
array
.
length
-
1
testName
=
array
[
lastItem
-
2
]
reason
=
array
[
lastItem
].
chomp
testSuiteVerify
(
array
[
@className
])
printf
"%-40s IGNORED
\n
"
,
testName
if
@xmlOut
==
true
@arrayList
.
push
" <testcase classname=
\"
"
+
@testSuite
+
"
\"
name=
\"
"
+
testName
+
"
\"
>"
@arrayList
.
push
" <skipped type=
\"
TEST IGNORED
\"
> "
+
reason
+
" </skipped>"
@arrayList
.
push
" </testcase>"
end
end
# Test was flagged as having failed so format the line
def
testFailed
(
array
)
lastItem
=
array
.
length
-
1
testName
=
array
[
lastItem
-
2
]
reason
=
array
[
lastItem
].
chomp
+
" at line: "
+
array
[
lastItem
-
3
]
testSuiteVerify
(
array
[
@className
])
printf
"%-40s FAILED
\n
"
,
testName
if
@xmlOut
==
true
@arrayList
.
push
" <testcase classname=
\"
"
+
@testSuite
+
"
\"
name=
\"
"
+
testName
+
"
\"
>"
@arrayList
.
push
" <failure type=
\"
ASSERT FAILED
\"
> "
+
reason
+
" </failure>"
@arrayList
.
push
" </testcase>"
end
end
# Figure out what OS we are running on. For now we are assuming if it's not Windows it must
# be Unix based.
def
detectOS
()
myOS
=
RUBY_PLATFORM
.
split
(
"-"
)
if
myOS
.
size
==
2
if
myOS
[
1
]
==
"mingw32"
@className
=
1
else
@className
=
0
end
end
end
# Main function used to parse the file that was captured.
def
process
(
name
)
@testFlag
=
false
@arrayList
=
Array
.
new
detectOS
()
puts
"Parsing file: "
+
name
testPass
=
0
testFail
=
0
testIgnore
=
0
puts
""
puts
"=================== RESULTS ====================="
puts
""
File
.
open
(
name
).
each
do
|
line
|
# Typical test lines look like this:
# <path>/<test_file>.c:36:test_tc1000_opsys:FAIL: Expected 1 Was 0
# <path>/<test_file>.c:112:test_tc5004_initCanChannel:IGNORE: Not Yet Implemented
# <path>/<test_file>.c:115:test_tc5100_initCanVoidPtrs:PASS
#
# where path is different on Unix vs Windows devices (Windows leads with a drive letter)
lineArray
=
line
.
split
(
":"
)
lineSize
=
lineArray
.
size
# If we were able to split the line then we can look to see if any of our target words
# were found. Case is important.
if
lineSize
>=
4
# Determine if this test passed
if
line
.
include?
":PASS"
testPassed
(
lineArray
)
testPass
+=
1
elsif
line
.
include?
":FAIL:"
testFailed
(
lineArray
)
testFail
+=
1
elsif
line
.
include?
":IGNORE:"
testIgnored
(
lineArray
)
testIgnore
+=
1
# If none of the keywords are found there are no more tests for this suite so clear
# the test flag
else
@testFlag
=
false
end
else
@testFlag
=
false
end
end
puts
""
puts
"=================== SUMMARY ====================="
puts
""
puts
"Tests Passed : "
+
testPass
.
to_s
puts
"Tests Failed : "
+
testFail
.
to_s
puts
"Tests Ignored : "
+
testIgnore
.
to_s
@totalTests
=
testPass
+
testFail
+
testIgnore
if
@xmlOut
==
true
heading
=
"<testsuite tests=
\"
"
+
@totalTests
.
to_s
+
"
\"
failures=
\"
"
+
testFail
.
to_s
+
"
\"
"
+
" skips=
\"
"
+
testIgnore
.
to_s
+
"
\"
>"
@arrayList
.
insert
(
0
,
heading
)
writeXmlOuput
()
end
# return result
end
end
# If the command line has no values in, used a default value of Output.txt
parseMyFile
=
ParseOutput
.
new
if
ARGV
.
size
>=
1
ARGV
.
each
do
|
a
|
if
a
==
"-xml"
parseMyFile
.
setXmlOutput
();
else
parseMyFile
.
process
(
a
)
break
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录