mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-07 21:55:12 +08:00
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.
This commit is contained in:
@ -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
|
|||||||
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
|
|||||||
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();")
|
||||||
|
Reference in New Issue
Block a user