mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-14 23:27:51 +00:00
- added config option :when_no_prototypes which takes options :ignore, :warn, or :error, controlling how it will react to being asked to process headers with no prototypes (defaults to :warn)
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@134 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -17,6 +17,7 @@ class CMockConfig
|
||||
:unity_helper => false,
|
||||
:treat_as => {},
|
||||
:memcmp_if_unknown => true,
|
||||
:when_no_prototypes => :warn, #the options being :ignore, :warn, or :error
|
||||
:when_ptr_star =>:compare_data, #the options being :compare_ptr, :compare_data, :compare_array
|
||||
:when_ptr_brackets => :compare_array, #not really supported yet
|
||||
}
|
||||
|
||||
@@ -3,13 +3,14 @@ class CMockHeaderParser
|
||||
|
||||
attr_reader :src_lines, :prototypes, :attributes
|
||||
|
||||
def initialize(parser, source, cfg, name)
|
||||
def initialize(parser, source, config, name)
|
||||
@src_lines = []
|
||||
@prototypes = []
|
||||
@function_names = []
|
||||
@prototype_parse_matcher = /([\d\w\s\*\(\),\[\]]+??)\(([\d\w\s\*\(\),\.\[\]]*)\)$/m
|
||||
|
||||
@attributes = cfg.attributes
|
||||
@attributes = config.attributes
|
||||
@when_no_prototypes = config.when_no_prototypes
|
||||
@parser = parser
|
||||
@name = name
|
||||
|
||||
@@ -86,7 +87,14 @@ class CMockHeaderParser
|
||||
@src_lines.each do |line|
|
||||
@prototypes << line if (line =~ @prototype_parse_matcher)
|
||||
end
|
||||
raise "No function prototypes found in '#{@name}'" if @prototypes.empty?
|
||||
if @prototypes.empty?
|
||||
case @when_no_prototypes
|
||||
when :error
|
||||
raise "ERROR: No function prototypes found in '#{@name}'"
|
||||
when :warn
|
||||
puts "WARNING: No function prototypes found in '#{@name}'"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def parse_prototype(prototype)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
typedef unsigned short U16;
|
||||
typedef signed int int32_t;
|
||||
|
||||
typedef struct _POINT_T
|
||||
{
|
||||
@@ -48,3 +49,5 @@ void const_variants2(
|
||||
struct _DUMMY_T const * const param1,
|
||||
const unsigned long int const * const param2,
|
||||
const struct _DUMMY_T const * param3 );
|
||||
|
||||
int32_t example_c99_type(int32_t param1);
|
||||
|
||||
@@ -7,6 +7,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
create_mocks :config, :prototype_parser, :parsed
|
||||
@test_name = 'test_file.h'
|
||||
@config.expect.attributes.returns(['__ramfunc', 'funky_attrib'])
|
||||
@config.expect.when_no_prototypes.returns(:error)
|
||||
end
|
||||
|
||||
def teardown
|
||||
@@ -256,7 +257,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
begin
|
||||
@parser.parse
|
||||
rescue RuntimeError => e
|
||||
assert_equal("No function prototypes found in 'thinger.h'", e.message)
|
||||
assert_equal("ERROR: No function prototypes found in 'thinger.h'", e.message)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -281,7 +282,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
begin
|
||||
@parser.parse
|
||||
rescue RuntimeError => e
|
||||
assert_equal("No function prototypes found in 'hello_world.h'", e.message)
|
||||
assert_equal("ERROR: No function prototypes found in 'hello_world.h'", e.message)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user