提交 f5e2ed76 编写于 作者: M Mark VanderVoord

Merge pull request #44 from shellyniz/master

copy include statements from test file to test runner (excluding cmock.h and unity.h) to better handle custom types in parameterized tests (Thanks Shelly)
......@@ -45,7 +45,7 @@ class UnityTestRunnerGenerator
end
#build runner file
generate(input_file, output_file, tests, used_mocks)
generate(input_file, output_file, tests, used_mocks, testfile_includes)
#determine which files were used to return them
all_files_used = [input_file, output_file]
......@@ -54,9 +54,9 @@ class UnityTestRunnerGenerator
return all_files_used.uniq
end
def generate(input_file, output_file, tests, used_mocks)
def generate(input_file, output_file, tests, used_mocks, testfile_includes)
File.open(output_file, 'w') do |output|
create_header(output, used_mocks)
create_header(output, used_mocks, testfile_includes)
create_externs(output, tests, used_mocks)
create_mock_management(output, used_mocks)
create_suite_setup_and_teardown(output)
......@@ -121,7 +121,10 @@ class UnityTestRunnerGenerator
source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain)
#parse out includes
return source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten
includes = source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten
brackets_includes = source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten
brackets_includes.each { |inc| includes << '<' + inc +'>' }
return includes
end
def find_mocks(includes)
......@@ -132,7 +135,7 @@ class UnityTestRunnerGenerator
return mock_headers
end
def create_header(output, mocks)
def create_header(output, mocks, testfile_includes)
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
create_runtest(output, mocks)
output.puts("\n//=======Automagically Detected Files To Include=====")
......@@ -144,6 +147,11 @@ class UnityTestRunnerGenerator
output.puts('#include <setjmp.h>')
output.puts('#include <stdio.h>')
output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
testfile_includes.delete("unity").delete("cmock")
testrunner_includes = testfile_includes - mocks
testrunner_includes.each do |inc|
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
end
mocks.each do |mock|
output.puts("#include \"#{mock.gsub('.h','')}.h\"")
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册