require 'ceedling/plugin' require 'fff_mock_generator' class FakeFunctionFramework < Plugin # Set up Ceedling to use this plugin. def setup # Get the location of this plugin. @plugin_root = File.expand_path(File.join(File.dirname(__FILE__), '..')) puts "Using fake function framework (fff)..." # Switch out the cmock_builder with our own. @ceedling[:cmock_builder].cmock = FffMockGeneratorForCMock.new(@ceedling[:setupinator].config_hash[:cmock]) # Add the path to fff.h to the include paths. COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR << "#{@plugin_root}/vendor/fff" COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR << "#{@plugin_root}/src" end def post_runner_generate(arg_hash) # After the test runner file has been created, append the FFF globals # definition to the end of the test runner. These globals will be shared by # all mocks linked into the test. File.open(arg_hash[:runner_file], 'a') do |f| f.puts f.puts "//=======Defintions of FFF variables=====" f.puts %{#include "fff.h"} f.puts "DEFINE_FFF_GLOBALS;" end end end # class FakeFunctionFramework class FffMockGeneratorForCMock def initialize(options=nil) @cm_config = CMockConfig.new(options) @cm_parser = CMockHeaderParser.new(@cm_config) @silent = (@cm_config.verbosity < 2) # These are the additional files to include in the mock files. @includes_h_pre_orig_header = (@cm_config.includes || @cm_config.includes_h_pre_orig_header || []).map{|h| h =~ /