1
0
mirror of https://github.com/ThrowTheSwitch/Unity.git synced 2026-01-23 08:25:58 +01:00

Merge pull request #472 from jlindgren90/master

auto: Only create run_test() function if it's needed.
This commit is contained in:
Mark VanderVoord
2020-03-17 15:35:47 -04:00
committed by GitHub
2 changed files with 7 additions and 6 deletions

View File

@@ -94,7 +94,7 @@ class UnityTestRunnerGenerator
create_suite_setup(output) create_suite_setup(output)
create_suite_teardown(output) create_suite_teardown(output)
create_reset(output) create_reset(output)
create_run_test(output) create_run_test(output) unless tests.empty?
create_args_wrappers(output, tests) create_args_wrappers(output, tests)
create_main(output, input_file, tests, used_mocks) create_main(output, input_file, tests, used_mocks)
end end
@@ -341,8 +341,8 @@ class UnityTestRunnerGenerator
def create_run_test(output) def create_run_test(output)
require 'erb' require 'erb'
template = ERB.new(File.read(File.join(__dir__, 'run_test.erb'))) template = ERB.new(File.read(File.join(__dir__, 'run_test.erb')), nil, '<>')
output.puts(template.result(binding)) output.puts("\n" + template.result(binding))
end end
def create_args_wrappers(output, tests) def create_args_wrappers(output, tests)
@@ -362,7 +362,7 @@ class UnityTestRunnerGenerator
end end
def create_main(output, filename, tests, used_mocks) def create_main(output, filename, tests, used_mocks)
output.puts("\n\n/*=======MAIN=====*/") output.puts("\n/*=======MAIN=====*/")
main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s
if @options[:cmdline_args] if @options[:cmdline_args]
if main_name != 'main' if main_name != 'main'

View File

@@ -16,13 +16,14 @@ static void run_test(UnityTestFunction func, const char* name, int line_num)
<% if @options[:plugins].include?(:cexception) %> <% if @options[:plugins].include?(:cexception) %>
CEXCEPTION_T e; CEXCEPTION_T e;
Try { Try {
<% end %>
<%= @options[:setup_name] %>(); <%= @options[:setup_name] %>();
func(); func();
<% if @options[:plugins].include?(:cexception) %>
} Catch(e) { } Catch(e) {
TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!");
} }
<% else %>
<%= @options[:setup_name] %>();
func();
<% end %> <% end %>
} }
if (TEST_PROTECT()) if (TEST_PROTECT())