mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 08:25:58 +01:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user