support cmock's need to destroy all of its memory at the end of the suite

This commit is contained in:
Mark VanderVoord
2014-05-21 19:29:44 -04:00
parent 124bfd8027
commit 1cf02f8bf3
9 changed files with 16 additions and 7 deletions
+8 -7
View File
@@ -62,7 +62,7 @@ class UnityTestRunnerGenerator
create_mock_management(output, used_mocks) create_mock_management(output, used_mocks)
create_suite_setup_and_teardown(output) create_suite_setup_and_teardown(output)
create_reset(output, used_mocks) create_reset(output, used_mocks)
create_main(output, input_file, tests) create_main(output, input_file, tests, used_mocks)
end end
end end
@@ -142,11 +142,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") testfile_includes.delete("unity").delete("cmock")
testrunner_includes = testfile_includes - mocks testrunner_includes = testfile_includes - mocks
testrunner_includes.each do |inc| testrunner_includes.each do |inc|
output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}") output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
end 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
@@ -261,7 +261,7 @@ class UnityTestRunnerGenerator
output.puts("}") output.puts("}")
end end
def create_main(output, filename, tests) def create_main(output, filename, tests, used_mocks)
output.puts("\n\n//=======MAIN=====") output.puts("\n\n//=======MAIN=====")
output.puts("int main(void)") output.puts("int main(void)")
output.puts("{") output.puts("{")
@@ -280,6 +280,7 @@ class UnityTestRunnerGenerator
tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") } tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") }
end end
output.puts() output.puts()
output.puts(" CMock_Guts_MemFreeFinal();") unless used_mocks.empty?
output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());") output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());")
output.puts("}") output.puts("}")
end end
+1
View File
@@ -74,5 +74,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd()); return (UnityEnd());
} }
+1
View File
@@ -70,5 +70,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd()); return (UnityEnd());
} }
+1
View File
@@ -83,5 +83,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd()); return (UnityEnd());
} }
+1
View File
@@ -83,5 +83,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return suite_teardown(UnityEnd()); return suite_teardown(UnityEnd());
} }
+1
View File
@@ -71,5 +71,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS); RUN_TEST(test_TheFirstThingToTest, 21, RUN_TEST_NO_ARGS);
RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS); RUN_TEST(test_TheSecondThingToTest, 43, RUN_TEST_NO_ARGS);
CMock_Guts_MemFreeFinal();
return (UnityEnd()); return (UnityEnd());
} }
+1
View File
@@ -83,5 +83,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd()); return (UnityEnd());
} }
+1
View File
@@ -83,5 +83,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return suite_teardown(UnityEnd()); return suite_teardown(UnityEnd());
} }
+1
View File
@@ -84,5 +84,6 @@ int main(void)
RUN_TEST(test_TheFirstThingToTest, 21); RUN_TEST(test_TheFirstThingToTest, 21);
RUN_TEST(test_TheSecondThingToTest, 43); RUN_TEST(test_TheSecondThingToTest, 43);
CMock_Guts_MemFreeFinal();
return (UnityEnd()); return (UnityEnd());
} }