vendor/cmock/lib/cmock_generator.rb in ceedling-0.28.1 vs vendor/cmock/lib/cmock_generator.rb in ceedling-0.28.2
- old
+ new
@@ -16,10 +16,11 @@
@prefix = @config.mock_prefix
@suffix = @config.mock_suffix
@weak = @config.weak
@ordered = @config.enforce_strict_ordering
@framework = @config.framework.to_s
+ @fail_on_unexpected_calls = @config.fail_on_unexpected_calls
@subdir = @config.subdir
@includes_h_pre_orig_header = (@config.includes || @config.includes_h_pre_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
@includes_h_post_orig_header = (@config.includes_h_post_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
@@ -100,10 +101,11 @@
plugin_includes = @plugins.run(:include_files)
file << plugin_includes if (!plugin_includes.empty?)
file << "\n"
file << "/* Ignore the following warnings, since we are copying code */\n"
file << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n"
+ file << "#pragma GCC diagnostic push\n"
file << "#if !defined(__clang__)\n"
file << "#pragma GCC diagnostic ignored \"-Wpragmas\"\n"
file << "#endif\n"
file << "#pragma GCC diagnostic ignored \"-Wunknown-pragmas\"\n"
file << "#pragma GCC diagnostic ignored \"-Wduplicate-decl-specifier\"\n"
@@ -122,11 +124,16 @@
file << "void #{@clean_mock_name}_Destroy(void);\n"
file << "void #{@clean_mock_name}_Verify(void);\n\n"
end
def create_mock_header_footer(header)
- header << "\n#endif\n"
+ header << "\n"
+ header << "#if defined(__GNUC__) && !defined(__ICC) && !defined(__TMS470__)\n"
+ header << "#pragma GCC diagnostic pop\n"
+ header << "#endif\n"
+ header << "\n"
+ header << "#endif\n"
end
def create_source_header_section(file, filename, functions)
header_file = (@subdir ? @subdir + '/' : '') + filename.gsub(".c",".h")
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
@@ -194,9 +201,14 @@
def create_mock_destroy_function(file, functions)
file << "void #{@clean_mock_name}_Destroy(void)\n{\n"
file << " CMock_Guts_MemFreeAll();\n"
file << " memset(&Mock, 0, sizeof(Mock));\n"
file << functions.collect {|function| @plugins.run(:mock_destroy, function)}.join
+
+ unless (@fail_on_unexpected_calls)
+ file << functions.collect {|function| @plugins.run(:mock_ignore, function)}.join
+ end
+
if (@ordered)
file << " GlobalExpectCount = 0;\n"
file << " GlobalVerifyOrder = 0;\n"
end
file << "}\n\n"