Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Unity
提交
68cc45a9
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看板
提交
68cc45a9
编写于
10月 22, 2019
作者:
J
John Lindgren
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make sure setUp/tearDown are always defined.
上级
5fc72fbc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
32 addition
and
28 deletion
+32
-28
auto/generate_test_runner.rb
auto/generate_test_runner.rb
+32
-28
未找到文件。
auto/generate_test_runner.rb
浏览文件 @
68cc45a9
...
...
@@ -85,6 +85,8 @@ class UnityTestRunnerGenerator
create_header
(
output
,
used_mocks
,
testfile_includes
)
create_externs
(
output
,
tests
,
used_mocks
)
create_mock_management
(
output
,
used_mocks
)
create_setup
(
output
)
create_teardown
(
output
)
create_suite_setup
(
output
)
create_suite_teardown
(
output
)
create_reset
(
output
,
used_mocks
)
...
...
@@ -220,8 +222,8 @@ class UnityTestRunnerGenerator
def
create_externs
(
output
,
tests
,
_mocks
)
output
.
puts
(
"
\n
/*=======External Functions This Runner Calls=====*/"
)
output
.
puts
(
"extern void
#{
@options
[
:setup_name
]
}
(void);"
)
if
@options
[
:has_setup
]
output
.
puts
(
"extern void
#{
@options
[
:teardown_name
]
}
(void);"
)
if
@options
[
:has_teardown
]
output
.
puts
(
"extern void
#{
@options
[
:setup_name
]
}
(void);"
)
output
.
puts
(
"extern void
#{
@options
[
:teardown_name
]
}
(void);"
)
output
.
puts
(
"
\n
#ifdef __cplusplus
\n
extern
\"
C
\"\n
{
\n
#endif"
)
if
@options
[
:externc
]
tests
.
each
do
|
test
|
output
.
puts
(
"extern void
#{
test
[
:test
]
}
(
#{
test
[
:call
]
||
'void'
}
);"
)
...
...
@@ -267,32 +269,34 @@ class UnityTestRunnerGenerator
output
.
puts
(
"}
\n
"
)
end
def
create_setup
(
output
)
return
if
@options
[
:has_setup
]
output
.
puts
(
"
\n
/*=======Setup (stub)=====*/"
)
output
.
puts
(
"void
#{
@options
[
:setup_name
]
}
(void) {}"
)
end
def
create_teardown
(
output
)
return
if
@options
[
:has_teardown
]
output
.
puts
(
"
\n
/*=======Teardown (stub)=====*/"
)
output
.
puts
(
"void
#{
@options
[
:teardown_name
]
}
(void) {}"
)
end
def
create_suite_setup
(
output
)
if
@options
[
:has_suite_setup
]
if
!
@options
[
:suite_setup
].
nil?
output
.
puts
(
"
\n
/*=======Suite Setup=====*/"
)
output
.
puts
(
'void suiteSetUp(void)'
)
output
.
puts
(
'{'
)
output
.
puts
(
@options
[
:suite_setup
])
output
.
puts
(
'}'
)
else
output
.
puts
(
'extern void suiteSetUp(void);'
)
end
end
return
if
@options
[
:suite_setup
].
nil?
output
.
puts
(
"
\n
/*=======Suite Setup=====*/"
)
output
.
puts
(
'void suiteSetUp(void)'
)
output
.
puts
(
'{'
)
output
.
puts
(
@options
[
:suite_setup
])
output
.
puts
(
'}'
)
end
def
create_suite_teardown
(
output
)
if
@options
[
:has_suite_teardown
]
if
!
@options
[
:suite_teardown
].
nil?
output
.
puts
(
"
\n
/*=======Suite Teardown=====*/"
)
output
.
puts
(
'int suiteTearDown(int num_failures)'
)
output
.
puts
(
'{'
)
output
.
puts
(
@options
[
:suite_teardown
])
output
.
puts
(
'}'
)
else
output
.
puts
(
'extern int suiteTearDown(int num_failures);'
)
end
end
return
if
@options
[
:suite_teardown
].
nil?
output
.
puts
(
"
\n
/*=======Suite Teardown=====*/"
)
output
.
puts
(
'int suiteTearDown(int num_failures)'
)
output
.
puts
(
'{'
)
output
.
puts
(
@options
[
:suite_teardown
])
output
.
puts
(
'}'
)
end
def
create_runtest
(
output
,
used_mocks
)
...
...
@@ -314,13 +318,13 @@ class UnityTestRunnerGenerator
output
.
puts
(
' { \\'
)
output
.
puts
(
' CEXCEPTION_T e; \\'
)
if
cexception
output
.
puts
(
' Try { \\'
)
if
cexception
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();
\\
"
)
if
@options
[
:has_setup
]
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();
\\
"
)
output
.
puts
(
" TestFunc(
#{
va_args2
}
);
\\
"
)
output
.
puts
(
' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\'
)
if
cexception
output
.
puts
(
' } \\'
)
output
.
puts
(
' if (TEST_PROTECT()) \\'
)
output
.
puts
(
' { \\'
)
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();
\\
"
)
if
@options
[
:has_teardown
]
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();
\\
"
)
output
.
puts
(
' CMock_Verify(); \\'
)
unless
used_mocks
.
empty?
output
.
puts
(
' } \\'
)
output
.
puts
(
' CMock_Destroy(); \\'
)
unless
used_mocks
.
empty?
...
...
@@ -337,9 +341,9 @@ class UnityTestRunnerGenerator
output
.
puts
(
'{'
)
output
.
puts
(
' CMock_Verify();'
)
unless
used_mocks
.
empty?
output
.
puts
(
' CMock_Destroy();'
)
unless
used_mocks
.
empty?
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();"
)
if
@options
[
:has_teardown
]
output
.
puts
(
"
#{
@options
[
:teardown_name
]
}
();"
)
output
.
puts
(
' CMock_Init();'
)
unless
used_mocks
.
empty?
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();"
)
if
@options
[
:has_setup
]
output
.
puts
(
"
#{
@options
[
:setup_name
]
}
();"
)
output
.
puts
(
'}'
)
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录