diff --git a/auto/generate_test_runner.rb b/auto/generate_test_runner.rb index e67fb852e99416c683beb3100c98e529054a45c4..f78faee6da53967ccc9669fa078488cf72199749 100644 --- a/auto/generate_test_runner.rb +++ b/auto/generate_test_runner.rb @@ -62,7 +62,7 @@ class UnityTestRunnerGenerator create_mock_management(output, used_mocks) create_suite_setup_and_teardown(output) create_reset(output, used_mocks) - create_main(output, input_file, tests) + create_main(output, input_file, tests, used_mocks) end end @@ -142,11 +142,11 @@ class UnityTestRunnerGenerator output.puts('#include ') output.puts('#include ') 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 + 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 @@ -261,7 +261,7 @@ class UnityTestRunnerGenerator output.puts("}") end - def create_main(output, filename, tests) + def create_main(output, filename, tests, used_mocks) output.puts("\n\n//=======MAIN=====") output.puts("int main(void)") output.puts("{") @@ -280,6 +280,7 @@ class UnityTestRunnerGenerator tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") } end output.puts() + output.puts(" CMock_Guts_MemFreeFinal();") unless used_mocks.empty? output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());") output.puts("}") end diff --git a/test/expectdata/testsample_mock_cmd.c b/test/expectdata/testsample_mock_cmd.c index 2b5b8b8996a9adc2abad27deb7c76f8bcd82cfeb..aa6137244fef514ab98f31d20416cb33051ad7d8 100644 --- a/test/expectdata/testsample_mock_cmd.c +++ b/test/expectdata/testsample_mock_cmd.c @@ -74,5 +74,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return (UnityEnd()); } diff --git a/test/expectdata/testsample_mock_def.c b/test/expectdata/testsample_mock_def.c index 7f90d875d158bf9f11563475cdac1ce40df439e7..801b002d146cab1db7f356f332200b3b650890b3 100644 --- a/test/expectdata/testsample_mock_def.c +++ b/test/expectdata/testsample_mock_def.c @@ -70,5 +70,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return (UnityEnd()); } diff --git a/test/expectdata/testsample_mock_new1.c b/test/expectdata/testsample_mock_new1.c index ab7b67600bcb8ebb3651db1e11ea0eb155303208..62f344f34299ab57e4ffdeab1d5c644becec6cc4 100644 --- a/test/expectdata/testsample_mock_new1.c +++ b/test/expectdata/testsample_mock_new1.c @@ -83,5 +83,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return (UnityEnd()); } diff --git a/test/expectdata/testsample_mock_new2.c b/test/expectdata/testsample_mock_new2.c index ed5d890009168f18c3bef5b0b0cbdf709b997417..e1216763a6af80b979a8d853107a9eafc18976ff 100644 --- a/test/expectdata/testsample_mock_new2.c +++ b/test/expectdata/testsample_mock_new2.c @@ -83,5 +83,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return suite_teardown(UnityEnd()); } diff --git a/test/expectdata/testsample_mock_param.c b/test/expectdata/testsample_mock_param.c index f73ea83512af571794d28c4c948c98fae62aae0a..1ceb98fc379d5150e1932c9bcaf024f0cc30eee1 100644 --- a/test/expectdata/testsample_mock_param.c +++ b/test/expectdata/testsample_mock_param.c @@ -71,5 +71,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); + CMock_Guts_MemFreeFinal(); return (UnityEnd()); } diff --git a/test/expectdata/testsample_mock_run1.c b/test/expectdata/testsample_mock_run1.c index ab7b67600bcb8ebb3651db1e11ea0eb155303208..62f344f34299ab57e4ffdeab1d5c644becec6cc4 100644 --- a/test/expectdata/testsample_mock_run1.c +++ b/test/expectdata/testsample_mock_run1.c @@ -83,5 +83,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return (UnityEnd()); } diff --git a/test/expectdata/testsample_mock_run2.c b/test/expectdata/testsample_mock_run2.c index ed5d890009168f18c3bef5b0b0cbdf709b997417..e1216763a6af80b979a8d853107a9eafc18976ff 100644 --- a/test/expectdata/testsample_mock_run2.c +++ b/test/expectdata/testsample_mock_run2.c @@ -83,5 +83,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return suite_teardown(UnityEnd()); } diff --git a/test/expectdata/testsample_mock_yaml.c b/test/expectdata/testsample_mock_yaml.c index 9f5f5b165e5090a0141582cd1ce424515bd04bfe..ad40188b59d0fc1e6e53105235163803ccbfbf15 100644 --- a/test/expectdata/testsample_mock_yaml.c +++ b/test/expectdata/testsample_mock_yaml.c @@ -84,5 +84,6 @@ int main(void) RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheSecondThingToTest, 43); + CMock_Guts_MemFreeFinal(); return (UnityEnd()); }