提交 4460fc50 编写于 作者: S shellyniz

Update generate_test_runner.rb

Bug - compilation error when using parametrized tests with user defined types. When using TEST_CASE and parametrised test and passing parameters which are of user defined types, the test_runner does not compile because it does not recognize the user defined types.
Test runner should copy the include statements from the test file
上级 770789e9
...@@ -45,7 +45,7 @@ class UnityTestRunnerGenerator ...@@ -45,7 +45,7 @@ class UnityTestRunnerGenerator
end end
#build runner file #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 #determine which files were used to return them
all_files_used = [input_file, output_file] all_files_used = [input_file, output_file]
...@@ -54,9 +54,9 @@ class UnityTestRunnerGenerator ...@@ -54,9 +54,9 @@ class UnityTestRunnerGenerator
return all_files_used.uniq return all_files_used.uniq
end 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| 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_externs(output, tests, used_mocks)
create_mock_management(output, used_mocks) create_mock_management(output, used_mocks)
create_suite_setup_and_teardown(output) create_suite_setup_and_teardown(output)
...@@ -121,7 +121,10 @@ class UnityTestRunnerGenerator ...@@ -121,7 +121,10 @@ class UnityTestRunnerGenerator
source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain) source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain)
#parse out includes #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 end
def find_mocks(includes) def find_mocks(includes)
...@@ -132,7 +135,7 @@ class UnityTestRunnerGenerator ...@@ -132,7 +135,7 @@ class UnityTestRunnerGenerator
return mock_headers return mock_headers
end end
def create_header(output, mocks) def create_header(output, mocks, testfile_includes)
output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */') output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
create_runtest(output, mocks) create_runtest(output, mocks)
output.puts("\n//=======Automagically Detected Files To Include=====") output.puts("\n//=======Automagically Detected Files To Include=====")
...@@ -144,6 +147,11 @@ class UnityTestRunnerGenerator ...@@ -144,6 +147,11 @@ class UnityTestRunnerGenerator
output.puts('#include <setjmp.h>') output.puts('#include <setjmp.h>')
output.puts('#include <stdio.h>') output.puts('#include <stdio.h>')
output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception) 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| mocks.each do |mock|
output.puts("#include \"#{mock.gsub('.h','')}.h\"") output.puts("#include \"#{mock.gsub('.h','')}.h\"")
end end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册