ceedling 0.31.0 → 0.31.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/example_file_call.c +6 -0
- data/assets/example_file_call.h +6 -0
- data/assets/test_example_file_with_mock.c +13 -0
- data/bin/ceedling +2 -2
- data/ceedling.gemspec +1 -1
- data/lib/ceedling/configurator.rb +7 -2
- data/lib/ceedling/configurator_plugins.rb +21 -1
- data/lib/ceedling/defaults.rb +1 -0
- data/lib/ceedling/preprocessinator_extractor.rb +2 -0
- data/lib/ceedling/preprocessinator_includes_handler.rb +24 -24
- data/lib/ceedling/version.rb +11 -7
- data/plugins/gcov/config/defaults_gcov.rb +118 -0
- data/plugins/gcov/lib/gcovr_reportinator.rb +1 -1
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +1 -1
- data/plugins/junit_tests_report/lib/junit_tests_report.rb +6 -6
- data/plugins/module_generator/README.md +16 -2
- data/plugins/module_generator/lib/module_generator.rb +1 -0
- data/spec/gcov/gcov_deployment_spec.rb +1 -1
- data/spec/preprocessinator_includes_handler_spec.rb +38 -8
- data/spec/spec_system_helper.rb +19 -0
- data/spec/system/deployment_spec.rb +1 -0
- data/vendor/cmock/lib/cmock_file_writer.rb +2 -3
- data/vendor/cmock/lib/cmock_generator.rb +87 -70
- data/vendor/cmock/lib/cmock_header_parser.rb +29 -27
- data/vendor/cmock/src/cmock.h +1 -1
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +46 -41
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +46 -40
- data/vendor/cmock/vendor/c_exception/README.md +6 -4
- data/vendor/cmock/vendor/c_exception/docs/CException.md +2 -2
- data/vendor/cmock/vendor/c_exception/lib/CException.h +1 -1
- data/vendor/cmock/vendor/c_exception/lib/meson.build +2 -2
- data/vendor/cmock/vendor/c_exception/meson.build +36 -2
- data/vendor/cmock/vendor/unity/README.md +77 -71
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
- data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +149 -193
- data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
- data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
- data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
- data/vendor/cmock/vendor/unity/extras/fixture/readme.md +16 -19
- data/vendor/cmock/vendor/unity/extras/memory/readme.md +27 -34
- data/vendor/cmock/vendor/unity/src/unity.c +1 -1
- data/vendor/cmock/vendor/unity/src/unity.h +1 -1
- data/vendor/cmock/vendor/unity/src/unity_internals.h +21 -7
- data/vendor/unity/README.md +77 -71
- data/vendor/unity/auto/generate_test_runner.rb +1 -1
- data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +107 -126
- data/vendor/unity/docs/UnityAssertionsReference.md +149 -193
- data/vendor/unity/docs/UnityConfigurationGuide.md +236 -294
- data/vendor/unity/docs/UnityGettingStartedGuide.md +112 -121
- data/vendor/unity/docs/UnityHelperScriptsGuide.md +82 -115
- data/vendor/unity/extras/fixture/readme.md +16 -19
- data/vendor/unity/extras/memory/readme.md +27 -34
- data/vendor/unity/src/unity.c +1 -1
- data/vendor/unity/src/unity.h +1 -1
- data/vendor/unity/src/unity_internals.h +21 -7
- metadata +14 -5
- data/plugins/gcov/config/defaults.yml +0 -55
@@ -8,7 +8,6 @@ class CMockHeaderParser
|
|
8
8
|
attr_accessor :funcs, :c_attr_noconst, :c_attributes, :treat_as_void, :treat_externs, :treat_inlines, :inline_function_patterns
|
9
9
|
|
10
10
|
def initialize(cfg)
|
11
|
-
@funcs = []
|
12
11
|
@c_strippables = cfg.strippables
|
13
12
|
@c_attr_noconst = cfg.attributes.uniq - ['const']
|
14
13
|
@c_attributes = ['const'] + c_attr_noconst
|
@@ -31,32 +30,35 @@ class CMockHeaderParser
|
|
31
30
|
end
|
32
31
|
|
33
32
|
def parse(name, source)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
33
|
+
parse_project = {
|
34
|
+
:module_name => name.gsub(/\W/, ''),
|
35
|
+
:typedefs => [],
|
36
|
+
:functions => [],
|
37
|
+
:normalized_source => nil
|
38
|
+
}
|
39
|
+
|
38
40
|
function_names = []
|
39
41
|
|
40
|
-
all_funcs = parse_functions(import_source(source)).map { |item| [item] }
|
41
|
-
all_funcs += parse_cpp_functions(import_source(source, true))
|
42
|
+
all_funcs = parse_functions(import_source(source, parse_project)).map { |item| [item] }
|
43
|
+
all_funcs += parse_cpp_functions(import_source(source, parse_project, true))
|
42
44
|
all_funcs.map do |decl|
|
43
|
-
func = parse_declaration(*decl)
|
45
|
+
func = parse_declaration(parse_project, *decl)
|
44
46
|
unless function_names.include? func[:name]
|
45
|
-
|
47
|
+
parse_project[:functions] << func
|
46
48
|
function_names << func[:name]
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
52
|
+
parse_project[:normalized_source] = if @treat_inlines == :include
|
53
|
+
transform_inline_functions(source)
|
54
|
+
else
|
55
|
+
''
|
56
|
+
end
|
55
57
|
|
56
58
|
{ :includes => nil,
|
57
|
-
:functions =>
|
58
|
-
:typedefs =>
|
59
|
-
:normalized_source =>
|
59
|
+
:functions => parse_project[:functions],
|
60
|
+
:typedefs => parse_project[:typedefs],
|
61
|
+
:normalized_source => parse_project[:normalized_source] }
|
60
62
|
end
|
61
63
|
|
62
64
|
private if $ThisIsOnlyATest.nil? ################
|
@@ -211,7 +213,7 @@ class CMockHeaderParser
|
|
211
213
|
source
|
212
214
|
end
|
213
215
|
|
214
|
-
def import_source(source, cpp = false)
|
216
|
+
def import_source(source, parse_project, cpp = false)
|
215
217
|
# let's clean up the encoding in case they've done anything weird with the characters we might find
|
216
218
|
source = source.force_encoding('ISO-8859-1').encode('utf-8', :replace => nil)
|
217
219
|
|
@@ -264,9 +266,9 @@ class CMockHeaderParser
|
|
264
266
|
|
265
267
|
# scan for functions which return function pointers, because they are a pain
|
266
268
|
source.gsub!(/([\w\s\*]+)\(*\(\s*\*([\w\s\*]+)\s*\(([\w\s\*,]*)\)\)\s*\(([\w\s\*,]*)\)\)*/) do |_m|
|
267
|
-
functype = "cmock_#{
|
269
|
+
functype = "cmock_#{parse_project[:module_name]}_func_ptr#{parse_project[:typedefs].size + 1}"
|
268
270
|
unless cpp # only collect once
|
269
|
-
|
271
|
+
parse_project[:typedefs] << "typedef #{Regexp.last_match(1).strip}(*#{functype})(#{Regexp.last_match(4)});"
|
270
272
|
"#{functype} #{Regexp.last_match(2).strip}(#{Regexp.last_match(3)});"
|
271
273
|
end
|
272
274
|
end
|
@@ -469,7 +471,7 @@ class CMockHeaderParser
|
|
469
471
|
divination
|
470
472
|
end
|
471
473
|
|
472
|
-
def clean_args(arg_list)
|
474
|
+
def clean_args(arg_list, parse_project)
|
473
475
|
if @local_as_void.include?(arg_list.strip) || arg_list.empty?
|
474
476
|
'void'
|
475
477
|
else
|
@@ -483,7 +485,7 @@ class CMockHeaderParser
|
|
483
485
|
|
484
486
|
# scan argument list for function pointers and replace them with custom types
|
485
487
|
arg_list.gsub!(/([\w\s\*]+)\(+\s*\*[\*\s]*([\w\s]*)\s*\)+\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |_m|
|
486
|
-
functype = "cmock_#{
|
488
|
+
functype = "cmock_#{parse_project[:module_name]}_func_ptr#{parse_project[:typedefs].size + 1}"
|
487
489
|
funcret = Regexp.last_match(1).strip
|
488
490
|
funcname = Regexp.last_match(2).strip
|
489
491
|
funcargs = Regexp.last_match(3).strip
|
@@ -492,14 +494,14 @@ class CMockHeaderParser
|
|
492
494
|
funcname.gsub!('const', '').strip!
|
493
495
|
funconst = 'const '
|
494
496
|
end
|
495
|
-
|
497
|
+
parse_project[:typedefs] << "typedef #{funcret}(*#{functype})(#{funcargs});"
|
496
498
|
funcname = "cmock_arg#{c += 1}" if funcname.empty?
|
497
499
|
"#{functype} #{funconst}#{funcname}"
|
498
500
|
end
|
499
501
|
|
500
502
|
# scan argument list for function pointers with shorthand notation and replace them with custom types
|
501
503
|
arg_list.gsub!(/([\w\s\*]+)+\s+(\w+)\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |_m|
|
502
|
-
functype = "cmock_#{
|
504
|
+
functype = "cmock_#{parse_project[:module_name]}_func_ptr#{parse_project[:typedefs].size + 1}"
|
503
505
|
funcret = Regexp.last_match(1).strip
|
504
506
|
funcname = Regexp.last_match(2).strip
|
505
507
|
funcargs = Regexp.last_match(3).strip
|
@@ -508,7 +510,7 @@ class CMockHeaderParser
|
|
508
510
|
funcname.gsub!('const', '').strip!
|
509
511
|
funconst = 'const '
|
510
512
|
end
|
511
|
-
|
513
|
+
parse_project[:typedefs] << "typedef #{funcret}(*#{functype})(#{funcargs});"
|
512
514
|
funcname = "cmock_arg#{c += 1}" if funcname.empty?
|
513
515
|
"#{functype} #{funconst}#{funcname}"
|
514
516
|
end
|
@@ -525,7 +527,7 @@ class CMockHeaderParser
|
|
525
527
|
end
|
526
528
|
end
|
527
529
|
|
528
|
-
def parse_declaration(declaration, namespace = [], classname = nil)
|
530
|
+
def parse_declaration(parse_project, declaration, namespace = [], classname = nil)
|
529
531
|
decl = {}
|
530
532
|
decl[:namespace] = namespace
|
531
533
|
decl[:class] = classname
|
@@ -581,7 +583,7 @@ class CMockHeaderParser
|
|
581
583
|
else
|
582
584
|
decl[:var_arg] = nil
|
583
585
|
end
|
584
|
-
args = clean_args(args)
|
586
|
+
args = clean_args(args, parse_project)
|
585
587
|
decl[:args_string] = args
|
586
588
|
decl[:args] = parse_args(args)
|
587
589
|
decl[:args_call] = decl[:args].map { |a| a[:name] }.join(', ')
|
data/vendor/cmock/src/cmock.h
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
#define CMOCK_VERSION_MAJOR 2
|
13
13
|
#define CMOCK_VERSION_MINOR 5
|
14
|
-
#define CMOCK_VERSION_BUILD
|
14
|
+
#define CMOCK_VERSION_BUILD 4
|
15
15
|
#define CMOCK_VERSION ((CMOCK_VERSION_MAJOR << 16) | (CMOCK_VERSION_MINOR << 8) | CMOCK_VERSION_BUILD)
|
16
16
|
|
17
17
|
/* should be big enough to index full range of CMOCK_MEM_MAX */
|
@@ -78,20 +78,26 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
78
78
|
@config.expect :treat_inlines, :exclude
|
79
79
|
@config.expect :exclude_setjmp_h, false
|
80
80
|
@cmock_generator_strict = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
81
|
-
|
82
|
-
@
|
83
|
-
|
84
|
-
|
81
|
+
|
82
|
+
@test_project = {
|
83
|
+
:module_name => @module_name,
|
84
|
+
:module_ext => '.h',
|
85
|
+
:mock_name => "Mock#{@module_name}",
|
86
|
+
:clean_name => "Mock#{@module_name}",
|
87
|
+
:folder => nil,
|
88
|
+
:parsed_stuff => {},
|
89
|
+
:skeleton => false
|
90
|
+
}
|
85
91
|
end
|
86
92
|
|
87
93
|
after do
|
88
94
|
end
|
89
95
|
|
90
|
-
def
|
96
|
+
def helper_create_header_top_with_opt_includes_form_config_and_plugin(ext)
|
91
97
|
@config.expect :mock_prefix, "Mock"
|
92
98
|
@config.expect :mock_suffix, ""
|
93
99
|
@config.expect :weak, ""
|
94
|
-
|
100
|
+
|
95
101
|
orig_filename = "PoutPoutFish#{ext}"
|
96
102
|
define_name = "MOCKPOUTPOUTFISH_H"
|
97
103
|
output = []
|
@@ -122,41 +128,26 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
122
128
|
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
123
129
|
@plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
|
124
130
|
|
125
|
-
|
131
|
+
# Update the extention for this test
|
132
|
+
test_project = @test_project.clone
|
133
|
+
test_project[:module_ext] = ext
|
134
|
+
|
135
|
+
@cmock_generator.create_mock_header_header(output, "Mock#{orig_filename}", test_project)
|
126
136
|
|
127
137
|
assert_equal(expected, output)
|
128
138
|
end
|
129
139
|
|
130
140
|
it "create the top of a header file with optional include files from config and include file from plugin" do
|
131
141
|
['.h','.hh','.hpp'].each do |ext|
|
132
|
-
|
142
|
+
helper_create_header_top_with_opt_includes_form_config_and_plugin(ext)
|
133
143
|
end
|
134
144
|
end
|
135
145
|
|
136
146
|
it "handle dashes and spaces in the module name" do
|
137
|
-
#no strict handling
|
138
|
-
@config.expect :mock_prefix, "Mock"
|
139
|
-
@config.expect :mock_suffix, ""
|
140
|
-
@config.expect :weak, ""
|
141
|
-
@config.expect :enforce_strict_ordering, nil
|
142
|
-
@config.expect :framework, :unity
|
143
|
-
@config.expect :includes, ["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"]
|
144
|
-
@config.expect :includes_h_post_orig_header, nil
|
145
|
-
@config.expect :includes_c_pre_header, nil
|
146
|
-
@config.expect :includes_c_post_header, nil
|
147
|
-
@config.expect :subdir, nil
|
148
|
-
@config.expect :fail_on_unexpected_calls, true
|
149
|
-
@config.expect :treat_inlines, :exclude
|
150
|
-
@config.expect :exclude_setjmp_h, false
|
151
|
-
@cmock_generator2 = CMockGenerator.new(@config, @file_writer, @utils, @plugins)
|
152
|
-
@cmock_generator2.module_name = "Pout-Pout Fish"
|
153
|
-
@cmock_generator2.module_ext = '.h'
|
154
|
-
@cmock_generator2.mock_name = "MockPout-Pout Fish"
|
155
|
-
@cmock_generator2.clean_mock_name = "MockPout_Pout_Fish"
|
156
|
-
|
157
147
|
@config.expect :mock_prefix, "Mock"
|
158
148
|
@config.expect :mock_suffix, ""
|
159
149
|
@config.expect :weak, ""
|
150
|
+
|
160
151
|
orig_filename = "Pout-Pout Fish.h"
|
161
152
|
define_name = "MOCKPOUT_POUT_FISH_H"
|
162
153
|
output = []
|
@@ -187,7 +178,13 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
187
178
|
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
188
179
|
@plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
|
189
180
|
|
190
|
-
|
181
|
+
# Create a project with some added challenges
|
182
|
+
test_project = @test_project.clone
|
183
|
+
test_project[:module_name] = "Pout-Pout Fish"
|
184
|
+
test_project[:mock_name] = "MockPout-Pout Fish"
|
185
|
+
test_project[:clean_name] = "MockPout_Pout_Fish"
|
186
|
+
|
187
|
+
@cmock_generator.create_mock_header_header(output, "MockPout-Pout Fish.h", test_project)
|
191
188
|
|
192
189
|
assert_equal(expected, output)
|
193
190
|
end
|
@@ -225,7 +222,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
225
222
|
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
226
223
|
@plugins.expect :run, '', [:include_files]
|
227
224
|
|
228
|
-
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
225
|
+
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h", @test_project)
|
229
226
|
|
230
227
|
assert_equal(expected, output)
|
231
228
|
end
|
@@ -264,7 +261,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
264
261
|
@config.expect :orig_header_include_fmt, "#include \"%s\""
|
265
262
|
@plugins.expect :run, "#include \"PluginRequiredHeader.h\"\n", [:include_files]
|
266
263
|
|
267
|
-
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
264
|
+
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h", @test_project)
|
268
265
|
|
269
266
|
assert_equal(expected, output)
|
270
267
|
end
|
@@ -282,7 +279,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
282
279
|
"\n\n"
|
283
280
|
]
|
284
281
|
|
285
|
-
@
|
282
|
+
@test_project[:parsed_stuff][:typedefs] = typedefs
|
283
|
+
@cmock_generator.create_typedefs(output, @test_project)
|
286
284
|
|
287
285
|
assert_equal(expected, output.flatten)
|
288
286
|
end
|
@@ -296,7 +294,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
296
294
|
"void #{mock_name}_Verify(void);\n\n"
|
297
295
|
]
|
298
296
|
|
299
|
-
@cmock_generator.create_mock_header_service_call_declarations(output)
|
297
|
+
@cmock_generator.create_mock_header_service_call_declarations(output, @test_project)
|
300
298
|
|
301
299
|
assert_equal(expected, output)
|
302
300
|
end
|
@@ -340,7 +338,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
340
338
|
"\n"
|
341
339
|
]
|
342
340
|
|
343
|
-
@
|
341
|
+
@test_project[:parsed_stuff][:functions] = functions
|
342
|
+
@cmock_generator.create_source_header_section(output, "MockPoutPoutFish.c", @test_project)
|
344
343
|
|
345
344
|
assert_equal(expected, output)
|
346
345
|
end
|
@@ -354,7 +353,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
354
353
|
"} Mock;\n\n"
|
355
354
|
].join
|
356
355
|
|
357
|
-
@
|
356
|
+
@test_project[:parsed_stuff][:functions] = functions
|
357
|
+
@cmock_generator.create_instance_structure(output, @test_project)
|
358
358
|
|
359
359
|
assert_equal(expected, output.join)
|
360
360
|
end
|
@@ -384,7 +384,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
384
384
|
@plugins.expect :run, [" d1"], [:instance_structure, functions[0]]
|
385
385
|
@plugins.expect :run, [" e1"," e2"," e3"], [:instance_structure, functions[1]]
|
386
386
|
|
387
|
-
@
|
387
|
+
@test_project[:parsed_stuff][:functions] = functions
|
388
|
+
@cmock_generator.create_instance_structure(output, @test_project)
|
388
389
|
|
389
390
|
assert_equal(expected, output.join)
|
390
391
|
end
|
@@ -416,7 +417,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
416
417
|
output = []
|
417
418
|
expected = "void MockPoutPoutFish_Verify(void)\n{\n}\n\n"
|
418
419
|
|
419
|
-
@
|
420
|
+
@test_project[:parsed_stuff][:functions] = functions
|
421
|
+
@cmock_generator.create_mock_verify_function(output, @test_project)
|
420
422
|
|
421
423
|
assert_equal(expected, output.join)
|
422
424
|
end
|
@@ -441,7 +443,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
441
443
|
@plugins.expect :run, [" Uno_Second"," Dos_Second"], [:mock_verify, functions[1]]
|
442
444
|
|
443
445
|
@cmock_generator.ordered = true
|
444
|
-
@
|
446
|
+
@test_project[:parsed_stuff][:functions] = functions
|
447
|
+
@cmock_generator.create_mock_verify_function(output, @test_project)
|
445
448
|
|
446
449
|
assert_equal(expected, output.flatten)
|
447
450
|
end
|
@@ -453,7 +456,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
453
456
|
"}\n\n"
|
454
457
|
]
|
455
458
|
|
456
|
-
@cmock_generator.create_mock_init_function(output)
|
459
|
+
@cmock_generator.create_mock_init_function(output, @test_project)
|
457
460
|
|
458
461
|
assert_equal(expected.join, output.join)
|
459
462
|
end
|
@@ -467,7 +470,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
467
470
|
"}\n\n"
|
468
471
|
]
|
469
472
|
|
470
|
-
@
|
473
|
+
@test_project[:parsed_stuff][:functions] = functions
|
474
|
+
@cmock_generator.create_mock_destroy_function(output, @test_project)
|
471
475
|
|
472
476
|
assert_equal(expected.join, output.join)
|
473
477
|
end
|
@@ -488,7 +492,8 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
488
492
|
@plugins.expect :run, [], [:mock_destroy, functions[0]]
|
489
493
|
@plugins.expect :run, [" uno"], [:mock_destroy, functions[1]]
|
490
494
|
|
491
|
-
@
|
495
|
+
@test_project[:parsed_stuff][:functions] = functions
|
496
|
+
@cmock_generator_strict.create_mock_destroy_function(output, @test_project)
|
492
497
|
|
493
498
|
assert_equal(expected.join, output.join)
|
494
499
|
end
|
@@ -13,7 +13,6 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
13
13
|
|
14
14
|
before do
|
15
15
|
create_mocks :config
|
16
|
-
@test_name = 'test_file.h'
|
17
16
|
@config.expect :strippables, ["STRIPPABLE"]
|
18
17
|
@config.expect :attributes, ['__ramfunc', 'funky_attrib', 'SQLITE_API']
|
19
18
|
@config.expect :c_calling_conventions, ['__stdcall']
|
@@ -29,13 +28,20 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
29
28
|
@config.expect :array_size_name, 'size|len'
|
30
29
|
|
31
30
|
@parser = CMockHeaderParser.new(@config)
|
31
|
+
|
32
|
+
@test_project = {
|
33
|
+
:module_name => 'test_file.h',
|
34
|
+
:typedefs => [],
|
35
|
+
:functions => [],
|
36
|
+
:normalized_source => nil
|
37
|
+
}
|
32
38
|
end
|
33
39
|
|
34
40
|
after do
|
35
41
|
end
|
36
42
|
|
37
43
|
it "create and initialize variables to defaults appropriately" do
|
38
|
-
assert_equal(
|
44
|
+
assert_equal(nil, @parser.funcs)
|
39
45
|
assert_equal(['const', '__ramfunc', 'funky_attrib', 'SQLITE_API'], @parser.c_attributes)
|
40
46
|
assert_equal(['void','MY_FUNKY_VOID'], @parser.treat_as_void)
|
41
47
|
end
|
@@ -52,7 +58,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
52
58
|
"who"
|
53
59
|
]
|
54
60
|
|
55
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
61
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
56
62
|
end
|
57
63
|
|
58
64
|
it "remove block comments" do
|
@@ -85,7 +91,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
85
91
|
"shown_because_line_above_ended_comment_this_time"
|
86
92
|
]
|
87
93
|
|
88
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
94
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
89
95
|
end
|
90
96
|
|
91
97
|
it "remove strippables from the beginning or end of function declarations" do
|
@@ -105,7 +111,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
105
111
|
"void universal_handler()"
|
106
112
|
]
|
107
113
|
|
108
|
-
assert_equal(expected, @parser.import_source(source))
|
114
|
+
assert_equal(expected, @parser.import_source(source, @test_project))
|
109
115
|
end
|
110
116
|
|
111
117
|
it "remove gcc's function __attribute__'s" do
|
@@ -125,7 +131,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
125
131
|
"void universal_handler()"
|
126
132
|
]
|
127
133
|
|
128
|
-
assert_equal(expected, @parser.import_source(source))
|
134
|
+
assert_equal(expected, @parser.import_source(source, @test_project))
|
129
135
|
end
|
130
136
|
|
131
137
|
it "remove preprocessor directives" do
|
@@ -136,7 +142,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
136
142
|
|
137
143
|
expected = []
|
138
144
|
|
139
|
-
assert_equal(expected, @parser.import_source(source))
|
145
|
+
assert_equal(expected, @parser.import_source(source, @test_project))
|
140
146
|
end
|
141
147
|
|
142
148
|
|
@@ -151,7 +157,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
151
157
|
|
152
158
|
expected = ["foo"]
|
153
159
|
|
154
|
-
assert_equal(expected, @parser.import_source(source))
|
160
|
+
assert_equal(expected, @parser.import_source(source, @test_project))
|
155
161
|
end
|
156
162
|
|
157
163
|
|
@@ -165,7 +171,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
165
171
|
"hoo hah when"
|
166
172
|
]
|
167
173
|
|
168
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
174
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
169
175
|
end
|
170
176
|
|
171
177
|
|
@@ -178,7 +184,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
178
184
|
|
179
185
|
expected = ["but I'm here"]
|
180
186
|
|
181
|
-
assert_equal(expected, @parser.import_source(source))
|
187
|
+
assert_equal(expected, @parser.import_source(source, @test_project))
|
182
188
|
end
|
183
189
|
|
184
190
|
|
@@ -212,7 +218,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
212
218
|
"this should remain!"
|
213
219
|
]
|
214
220
|
|
215
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
221
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
216
222
|
end
|
217
223
|
|
218
224
|
|
@@ -230,7 +236,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
230
236
|
"} Thinger;\n" +
|
231
237
|
"or me!!\n"
|
232
238
|
|
233
|
-
assert_equal(["don't delete me!! or me!!"], @parser.import_source(source).map!{|s|s.strip})
|
239
|
+
assert_equal(["don't delete me!! or me!!"], @parser.import_source(source, @test_project).map!{|s|s.strip})
|
234
240
|
end
|
235
241
|
|
236
242
|
|
@@ -248,7 +254,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
248
254
|
"} Whatever;\n" +
|
249
255
|
"me too!!\n"
|
250
256
|
|
251
|
-
assert_equal(["I want to live!! me too!!"], @parser.import_source(source).map!{|s|s.strip})
|
257
|
+
assert_equal(["I want to live!! me too!!"], @parser.import_source(source, @test_project).map!{|s|s.strip})
|
252
258
|
end
|
253
259
|
|
254
260
|
|
@@ -271,7 +277,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
271
277
|
"I want to live!!\n"
|
272
278
|
|
273
279
|
assert_equal(["void foo(void)", "struct THINGER foo(void)", "I want to live!!"],
|
274
|
-
@parser.import_source(source).map!{|s|s.strip})
|
280
|
+
@parser.import_source(source, @test_project).map!{|s|s.strip})
|
275
281
|
end
|
276
282
|
|
277
283
|
it "remove externed and inline functions" do
|
@@ -290,7 +296,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
290
296
|
"uint32 funcinline(unsigned int)"
|
291
297
|
]
|
292
298
|
|
293
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
299
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
294
300
|
end
|
295
301
|
|
296
302
|
it "remove function definitions but keep function declarations" do
|
@@ -312,7 +318,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
312
318
|
"uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
|
313
319
|
]
|
314
320
|
|
315
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
321
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
316
322
|
end
|
317
323
|
|
318
324
|
it "remove function definitions with nested braces but keep function declarations" do
|
@@ -354,7 +360,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
354
360
|
"uint32 func_with_decl_c", #okay. it's not going to be interpretted as another function
|
355
361
|
]
|
356
362
|
|
357
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
363
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
358
364
|
end
|
359
365
|
|
360
366
|
it "remove a fully defined inline function" do
|
@@ -371,7 +377,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
371
377
|
@parser.parse("module", source)
|
372
378
|
end
|
373
379
|
|
374
|
-
assert_equal(
|
380
|
+
assert_equal(nil, @parser.funcs)
|
375
381
|
|
376
382
|
# verify exception message
|
377
383
|
begin
|
@@ -395,7 +401,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
395
401
|
@parser.parse("module", source)
|
396
402
|
end
|
397
403
|
|
398
|
-
assert_equal(
|
404
|
+
assert_equal(nil, @parser.funcs)
|
399
405
|
|
400
406
|
# verify exception message
|
401
407
|
begin
|
@@ -423,7 +429,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
423
429
|
@parser.parse("module", source)
|
424
430
|
end
|
425
431
|
|
426
|
-
assert_equal(
|
432
|
+
assert_equal(nil, @parser.funcs)
|
427
433
|
|
428
434
|
# verify exception message
|
429
435
|
begin
|
@@ -452,7 +458,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
452
458
|
]
|
453
459
|
|
454
460
|
@parser.treat_externs = :include
|
455
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
461
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
456
462
|
end
|
457
463
|
|
458
464
|
it "leave inline functions if inline to be included" do
|
@@ -478,7 +484,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
478
484
|
]
|
479
485
|
|
480
486
|
@parser.treat_inlines = :include
|
481
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
487
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
482
488
|
end
|
483
489
|
|
484
490
|
it "leave inline and extern functions if inline and extern to be included" do
|
@@ -507,7 +513,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
507
513
|
|
508
514
|
@parser.treat_externs = :include
|
509
515
|
@parser.treat_inlines = :include
|
510
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
516
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
511
517
|
end
|
512
518
|
|
513
519
|
it "Include inline functions that contain user defined inline function formats" do
|
@@ -538,7 +544,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
538
544
|
|
539
545
|
@parser.treat_inlines = :include
|
540
546
|
@parser.inline_function_patterns = ['static __inline__ __attribute__ \(\(always_inline\)\)', 'static __inline__', '\binline\b']
|
541
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
547
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
542
548
|
end
|
543
549
|
|
544
550
|
it "remove defines" do
|
@@ -554,7 +560,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
554
560
|
"void hello(void)",
|
555
561
|
]
|
556
562
|
|
557
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
563
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
558
564
|
end
|
559
565
|
|
560
566
|
|
@@ -567,7 +573,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
567
573
|
"const int TheMatrix(int Trinity, unsigned int * Neo)",
|
568
574
|
]
|
569
575
|
|
570
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
576
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
571
577
|
end
|
572
578
|
|
573
579
|
|
@@ -593,7 +599,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
593
599
|
:args=>[{:type=>"int", :name=>"a", :ptr? => false, :const? => false, :const_ptr? => false}],
|
594
600
|
:args_string=>"int a",
|
595
601
|
:args_call=>"a"}
|
596
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
602
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
597
603
|
end
|
598
604
|
|
599
605
|
it "handle odd case of typedef'd void as arg" do
|
@@ -616,7 +622,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
616
622
|
:args=>[],
|
617
623
|
:args_string=>"void",
|
618
624
|
:args_call=>"" }
|
619
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
625
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
620
626
|
end
|
621
627
|
|
622
628
|
it "handle odd case of typedef'd void as arg pointer" do
|
@@ -639,7 +645,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
639
645
|
:args=>[{:type=>"MY_FUNKY_VOID*", :name=>"bluh", :ptr? => true, :const? => false, :const_ptr? => false}],
|
640
646
|
:args_string=>"MY_FUNKY_VOID* bluh",
|
641
647
|
:args_call=>"bluh" }
|
642
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
648
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
643
649
|
end
|
644
650
|
|
645
651
|
|
@@ -652,7 +658,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
652
658
|
"void Foo(int a, float b, char c, char* e)"
|
653
659
|
]
|
654
660
|
|
655
|
-
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
661
|
+
assert_equal(expected, @parser.import_source(source, @test_project).map!{|s|s.strip})
|
656
662
|
end
|
657
663
|
|
658
664
|
|
@@ -664,7 +670,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
664
670
|
@parser.parse("module", source)
|
665
671
|
end
|
666
672
|
|
667
|
-
assert_equal(
|
673
|
+
assert_equal(nil, @parser.funcs)
|
668
674
|
|
669
675
|
# verify exception message
|
670
676
|
begin
|
@@ -693,7 +699,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
693
699
|
@parser.parse("module", source)
|
694
700
|
end
|
695
701
|
|
696
|
-
assert_equal(
|
702
|
+
assert_equal(nil, @parser.funcs)
|
697
703
|
|
698
704
|
# verify exception message
|
699
705
|
begin
|
@@ -743,7 +749,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
743
749
|
],
|
744
750
|
:args_string=>"int a, unsigned int b",
|
745
751
|
:args_call=>"a, b" }
|
746
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
752
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
747
753
|
end
|
748
754
|
|
749
755
|
it "extract and return function declarations with no retval" do
|
@@ -770,7 +776,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
770
776
|
],
|
771
777
|
:args_string=>"uint la, int de, bool da",
|
772
778
|
:args_call=>"la, de, da" }
|
773
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
779
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
774
780
|
end
|
775
781
|
|
776
782
|
it "extract and return function declarations with implied voids" do
|
@@ -794,7 +800,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
794
800
|
:args=>[ ],
|
795
801
|
:args_string=>"void",
|
796
802
|
:args_call=>"" }
|
797
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
803
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
798
804
|
end
|
799
805
|
|
800
806
|
it "extract modifiers properly" do
|
@@ -820,7 +826,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
820
826
|
],
|
821
827
|
:args_string=>"int Trinity, unsigned int* Neo",
|
822
828
|
:args_call=>"Trinity, Neo" }
|
823
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
829
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
824
830
|
end
|
825
831
|
|
826
832
|
it "extract c calling conventions properly" do
|
@@ -847,7 +853,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
847
853
|
],
|
848
854
|
:args_string=>"int Trinity, unsigned int* Neo",
|
849
855
|
:args_call=>"Trinity, Neo" }
|
850
|
-
assert_equal(expected, @parser.parse_declaration(source))
|
856
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source))
|
851
857
|
end
|
852
858
|
|
853
859
|
it "extract and return function declarations inside namespace and class" do
|
@@ -872,7 +878,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
872
878
|
],
|
873
879
|
:args_string=>"int a, unsigned int b",
|
874
880
|
:args_call=>"a, b" }
|
875
|
-
assert_equal(expected, @parser.parse_declaration(source, ["ns1", "ns2"], "Bar"))
|
881
|
+
assert_equal(expected, @parser.parse_declaration(@test_project, source, ["ns1", "ns2"], "Bar"))
|
876
882
|
end
|
877
883
|
|
878
884
|
it "fully parse multiple prototypes" do
|
@@ -2387,8 +2393,8 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
2387
2393
|
"} }"
|
2388
2394
|
]
|
2389
2395
|
|
2390
|
-
assert_equal(expected, @parser.import_source(source, cpp=true))
|
2391
|
-
refute_equal(expected, @parser.import_source(source))
|
2396
|
+
assert_equal(expected, @parser.import_source(source, @test_project, cpp=true))
|
2397
|
+
refute_equal(expected, @parser.import_source(source, @test_project))
|
2392
2398
|
end
|
2393
2399
|
|
2394
2400
|
# only so parse_functions does not raise an error
|