提交 4ea563e6 编写于 作者: P Peter Mendham

Added support for mocks in sub-directories.

This supports mock headers of the form:
    #include "some/dir/MockMyCode.h"
Where the mock name is actually MockMyCode.

I *think* this is the most common scenario when working with mocks
in subdirectories but if not this could be modified to support
alternate schemes.
上级 9a9d6c75
...@@ -146,8 +146,9 @@ class UnityTestRunnerGenerator ...@@ -146,8 +146,9 @@ class UnityTestRunnerGenerator
def find_mocks(includes) def find_mocks(includes)
mock_headers = [] mock_headers = []
includes.each do |include_file| includes.each do |include_path|
mock_headers << File.basename(include_file) if (include_file =~ /^mock/i) include_file = File.basename(include_path)
mock_headers << include_path if (include_file =~ /^mock/i)
end end
return mock_headers return mock_headers
end end
...@@ -192,8 +193,8 @@ class UnityTestRunnerGenerator ...@@ -192,8 +193,8 @@ class UnityTestRunnerGenerator
output.puts('') output.puts('')
end end
def create_mock_management(output, mocks) def create_mock_management(output, mock_headers)
unless (mocks.empty?) unless (mock_headers.empty?)
output.puts("\n//=======Mock Management=====") output.puts("\n//=======Mock Management=====")
output.puts("static void CMock_Init(void)") output.puts("static void CMock_Init(void)")
output.puts("{") output.puts("{")
...@@ -202,6 +203,10 @@ class UnityTestRunnerGenerator ...@@ -202,6 +203,10 @@ class UnityTestRunnerGenerator
output.puts(" GlobalVerifyOrder = 0;") output.puts(" GlobalVerifyOrder = 0;")
output.puts(" GlobalOrderError = NULL;") output.puts(" GlobalOrderError = NULL;")
end end
mocks = []
mock_headers.each do |mock|
mocks << File.basename(mock)
end
mocks.each do |mock| mocks.each do |mock|
mock_clean = TypeSanitizer.sanitize_c_identifier(mock) mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
output.puts(" #{mock_clean}_Init();") output.puts(" #{mock_clean}_Init();")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册