Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
2d8a69e0
T
Third Party Unity
项目概览
OpenHarmony
/
Third Party Unity
1 年多 前同步成功
通知
36
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看板
提交
2d8a69e0
编写于
10月 22, 2019
作者:
M
Mark VanderVoord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update handling of when suite_setup/teardown in use
上级
cb8744c4
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
27 addition
and
18 deletion
+27
-18
auto/generate_test_runner.rb
auto/generate_test_runner.rb
+27
-18
未找到文件。
auto/generate_test_runner.rb
浏览文件 @
2d8a69e0
...
@@ -8,10 +8,19 @@ class UnityTestRunnerGenerator
...
@@ -8,10 +8,19 @@ class UnityTestRunnerGenerator
def
initialize
(
options
=
nil
)
def
initialize
(
options
=
nil
)
@options
=
UnityTestRunnerGenerator
.
default_options
@options
=
UnityTestRunnerGenerator
.
default_options
case
options
case
options
when
NilClass
then
@options
when
NilClass
when
String
then
@options
.
merge!
(
UnityTestRunnerGenerator
.
grab_config
(
options
))
@options
when
Hash
then
@options
.
merge!
(
options
)
when
String
else
raise
'If you specify arguments, it should be a filename or a hash of options'
@options
.
merge!
(
UnityTestRunnerGenerator
.
grab_config
(
options
))
when
Hash
# Check if some of these have been specified
@options
[
:has_setup
]
=
!
options
[
:setup_name
].
nil?
@options
[
:has_teardown
]
=
!
options
[
:teardown_name
].
nil?
@options
[
:has_suite_setup
]
=
!
options
[
:suite_setup
].
nil?
@options
[
:has_suite_teardown
]
=
!
options
[
:suite_teardown
].
nil?
@options
.
merge!
(
options
)
else
raise
'If you specify arguments, it should be a filename or a hash of options'
end
end
require_relative
'type_sanitizer'
require_relative
'type_sanitizer'
end
end
...
@@ -167,10 +176,10 @@ class UnityTestRunnerGenerator
...
@@ -167,10 +176,10 @@ class UnityTestRunnerGenerator
end
end
def
find_setup_and_teardown
(
source
)
def
find_setup_and_teardown
(
source
)
@
has_setup
=
source
=~
/void\s+
#{
@options
[
:setup_name
]
}
\s*\(/
@
options
[
:has_setup
]
=
source
=~
/void\s+
#{
@options
[
:setup_name
]
}
\s*\(/
@
has_teardown
=
source
=~
/void\s+
#{
@options
[
:teardown_name
]
}
\s*\(/
@
options
[
:has_teardown
]
=
source
=~
/void\s+
#{
@options
[
:teardown_name
]
}
\s*\(/
@
has_suite_setup
=
(
!
@options
[
:suite_setup
].
nil?
)
||
(
source
=~
/void\s+suiteSetUp\s*\(/
)
@
options
[
:has_suite_setup
]
||=
(
source
=~
/void\s+suiteSetUp\s*\(/
)
@
has_suite_teardown
=
(
!
@options
[
:suite_teardown
].
nil?
)
||
(
source
=~
/void\s+suiteTearDown\s*\(/
)
@
options
[
:has_suite_teardown
]
||=
(
source
=~
/void\s+suiteTearDown\s*\(/
)
end
end
def
create_header
(
output
,
mocks
,
testfile_includes
=
[])
def
create_header
(
output
,
mocks
,
testfile_includes
=
[])
...
@@ -211,8 +220,8 @@ class UnityTestRunnerGenerator
...
@@ -211,8 +220,8 @@ class UnityTestRunnerGenerator
def
create_externs
(
output
,
tests
,
_mocks
)
def
create_externs
(
output
,
tests
,
_mocks
)
output
.
puts
(
"
\n
/*=======External Functions This Runner Calls=====*/"
)
output
.
puts
(
"
\n
/*=======External Functions This Runner Calls=====*/"
)
output
.
puts
(
"extern void
#{
@options
[
:setup_name
]
}
(void);"
)
if
@
has_setup
output
.
puts
(
"extern void
#{
@options
[
:setup_name
]
}
(void);"
)
if
@
options
[
:has_setup
]
output
.
puts
(
"extern void
#{
@options
[
:teardown_name
]
}
(void);"
)
if
@
has_teardown
output
.
puts
(
"extern void
#{
@options
[
:teardown_name
]
}
(void);"
)
if
@
options
[
:has_teardown
]
output
.
puts
(
"
\n
#ifdef __cplusplus
\n
extern
\"
C
\"\n
{
\n
#endif"
)
if
@options
[
:externc
]
output
.
puts
(
"
\n
#ifdef __cplusplus
\n
extern
\"
C
\"\n
{
\n
#endif"
)
if
@options
[
:externc
]
tests
.
each
do
|
test
|
tests
.
each
do
|
test
|
output
.
puts
(
"extern void
#{
test
[
:test
]
}
(
#{
test
[
:call
]
||
'void'
}
);"
)
output
.
puts
(
"extern void
#{
test
[
:test
]
}
(
#{
test
[
:call
]
||
'void'
}
);"
)
...
@@ -259,7 +268,7 @@ class UnityTestRunnerGenerator
...
@@ -259,7 +268,7 @@ class UnityTestRunnerGenerator
end
end
def
create_suite_setup
(
output
)
def
create_suite_setup
(
output
)
if
@
has_suite_setup
if
@
options
[
:has_suite_setup
]
if
@options
[
:suite_setup
].
nil?
if
@options
[
:suite_setup
].
nil?
output
.
puts
(
"
\n
/*=======Suite Setup=====*/"
)
output
.
puts
(
"
\n
/*=======Suite Setup=====*/"
)
output
.
puts
(
'static void suiteSetUp(void)'
)
output
.
puts
(
'static void suiteSetUp(void)'
)
...
@@ -273,7 +282,7 @@ class UnityTestRunnerGenerator
...
@@ -273,7 +282,7 @@ class UnityTestRunnerGenerator
end
end
def
create_suite_teardown
(
output
)
def
create_suite_teardown
(
output
)
if
(
@has_suite_teardown
)
if
@options
[
:has_suite_teardown
]
if
@options
[
:suite_teardown
].
nil?
if
@options
[
:suite_teardown
].
nil?
output
.
puts
(
"
\n
/*=======Suite Teardown=====*/"
)
output
.
puts
(
"
\n
/*=======Suite Teardown=====*/"
)
output
.
puts
(
'static int suite_teardown(int num_failures)'
)
output
.
puts
(
'static int suite_teardown(int num_failures)'
)
...
@@ -305,13 +314,13 @@ class UnityTestRunnerGenerator
...
@@ -305,13 +314,13 @@ class UnityTestRunnerGenerator
output
.
puts
(
' { \\'
)
output
.
puts
(
' { \\'
)
output
.
puts
(
' CEXCEPTION_T e; \\'
)
if
cexception
output
.
puts
(
' CEXCEPTION_T e; \\'
)
if
cexception
output
.
puts
(
' Try { \\'
)
if
cexception
output
.
puts
(
' Try { \\'
)
if
cexception
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();
\\
"
)
if
@
has_setup
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();
\\
"
)
if
@
options
[
:has_setup
]
output
.
puts
(
" TestFunc(
#{
va_args2
}
);
\\
"
)
output
.
puts
(
" TestFunc(
#{
va_args2
}
);
\\
"
)
output
.
puts
(
' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\'
)
if
cexception
output
.
puts
(
' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\'
)
if
cexception
output
.
puts
(
' } \\'
)
output
.
puts
(
' } \\'
)
output
.
puts
(
' if (TEST_PROTECT()) \\'
)
output
.
puts
(
' if (TEST_PROTECT()) \\'
)
output
.
puts
(
' { \\'
)
output
.
puts
(
' { \\'
)
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();
\\
"
)
if
@
has_teardown
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();
\\
"
)
if
@
options
[
:has_teardown
]
output
.
puts
(
' CMock_Verify(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Verify(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' } \\'
)
output
.
puts
(
' } \\'
)
output
.
puts
(
' CMock_Destroy(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Destroy(); \\'
)
unless
used_mocks
.
empty?
...
@@ -328,9 +337,9 @@ class UnityTestRunnerGenerator
...
@@ -328,9 +337,9 @@ class UnityTestRunnerGenerator
output
.
puts
(
'{'
)
output
.
puts
(
'{'
)
output
.
puts
(
' CMock_Verify();'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Verify();'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Destroy();'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Destroy();'
)
unless
used_mocks
.
empty?
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();"
)
if
@
has_teardown
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();"
)
if
@
options
[
:has_teardown
]
output
.
puts
(
' CMock_Init();'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Init();'
)
unless
used_mocks
.
empty?
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();"
)
if
@
has_setup
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();"
)
if
@
options
[
:has_setup
]
output
.
puts
(
'}'
)
output
.
puts
(
'}'
)
end
end
...
@@ -376,7 +385,7 @@ class UnityTestRunnerGenerator
...
@@ -376,7 +385,7 @@ class UnityTestRunnerGenerator
output
.
puts
(
"int
#{
main_name
}
(void)"
)
output
.
puts
(
"int
#{
main_name
}
(void)"
)
output
.
puts
(
'{'
)
output
.
puts
(
'{'
)
end
end
output
.
puts
(
' suiteSetUp();'
)
if
@
has_suite_setup
output
.
puts
(
' suiteSetUp();'
)
if
@
options
[
:has_suite_setup
]
output
.
puts
(
" UnityBegin(
\"
#{
filename
.
gsub
(
/\\/
,
'\\\\\\'
)
}
\"
);"
)
output
.
puts
(
" UnityBegin(
\"
#{
filename
.
gsub
(
/\\/
,
'\\\\\\'
)
}
\"
);"
)
if
@options
[
:use_param_tests
]
if
@options
[
:use_param_tests
]
tests
.
each
do
|
test
|
tests
.
each
do
|
test
|
...
@@ -391,7 +400,7 @@ class UnityTestRunnerGenerator
...
@@ -391,7 +400,7 @@ class UnityTestRunnerGenerator
end
end
output
.
puts
output
.
puts
output
.
puts
(
' CMock_Guts_MemFreeFinal();'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Guts_MemFreeFinal();'
)
unless
used_mocks
.
empty?
if
(
@has_suite_teardown
)
if
@options
[
:has_suite_teardown
]
output
.
puts
(
' return suiteTearDown(UnityEnd());'
)
output
.
puts
(
' return suiteTearDown(UnityEnd());'
)
else
else
output
.
puts
(
' return UnityEnd();'
)
output
.
puts
(
' return UnityEnd();'
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录