diff --git a/docs/CMock_Summary.md b/docs/CMock_Summary.md index 19fac14..06c2aa6 100644 --- a/docs/CMock_Summary.md +++ b/docs/CMock_Summary.md @@ -284,6 +284,9 @@ Defined in the yaml file, they look more like this: The prefix to append to your mock files. Defaults to “Mock”, so a file “USART.h” will get a mock called “MockUSART.c” +* `:mock_suffix`: + The suffix to append to your mock files. Defaults to “”. + * `:subdir`: Relative subdir for your mocks. Set this to e.g. "sys" in order to create mock for `sys/types.h` in `:mock_path`/sys/ diff --git a/lib/cmock_config.rb b/lib/cmock_config.rb index 9e2637b..7b15858 100644 --- a/lib/cmock_config.rb +++ b/lib/cmock_config.rb @@ -11,6 +11,7 @@ class CMockConfig :framework => :unity, :mock_path => 'mocks', :mock_prefix => 'Mock', + :mock_suffix => '', :subdir => nil, :plugins => [], :strippables => ['(?:__attribute__\s*\(+.*?\)+)'], diff --git a/lib/cmock_generator.rb b/lib/cmock_generator.rb index 495398e..d4a3220 100644 --- a/lib/cmock_generator.rb +++ b/lib/cmock_generator.rb @@ -14,6 +14,7 @@ class CMockGenerator @plugins = plugins @config = config @prefix = @config.mock_prefix + @suffix = @config.mock_suffix @ordered = @config.enforce_strict_ordering @framework = @config.framework.to_s @@ -39,7 +40,7 @@ class CMockGenerator def create_mock(module_name, parsed_stuff) @module_name = module_name - @mock_name = @prefix + @module_name + @mock_name = @prefix + @module_name + @suffix @clean_mock_name = TypeSanitizer.sanitize_c_identifier(@mock_name) create_mock_subdir() create_mock_header_file(parsed_stuff) @@ -83,7 +84,7 @@ class CMockGenerator def create_mock_header_header(file, filename) define_name = @clean_mock_name.upcase - orig_filename = (@subdir ? @subdir + "/" : "") + filename[@config.mock_prefix.size..-1] + orig_filename = (@subdir ? @subdir + "/" : "") + @module_name + ".h" file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n" file << "#ifndef _#{define_name}_H\n" file << "#define _#{define_name}_H\n\n"