ceedling 1.1.9 → 1.1.10

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.
@@ -2999,6 +2999,56 @@
2999
2999
  </span>
3000
3000
  </a>
3001
3001
 
3002
+ </li>
3003
+
3004
+ <li class="md-nav__item">
3005
+ <a href="#results-filtering" class="md-nav__link">
3006
+ <span class="md-ellipsis">
3007
+
3008
+ Results filtering
3009
+
3010
+ </span>
3011
+ </a>
3012
+
3013
+ <nav class="md-nav" aria-label="Results filtering">
3014
+ <ul class="md-nav__list">
3015
+
3016
+ <li class="md-nav__item">
3017
+ <a href="#coverage-generation-filtering" class="md-nav__link">
3018
+ <span class="md-ellipsis">
3019
+
3020
+ Coverage generation filtering
3021
+
3022
+ </span>
3023
+ </a>
3024
+
3025
+ </li>
3026
+
3027
+ <li class="md-nav__item">
3028
+ <a href="#report-filtering" class="md-nav__link">
3029
+ <span class="md-ellipsis">
3030
+
3031
+ Report filtering
3032
+
3033
+ </span>
3034
+ </a>
3035
+
3036
+ </li>
3037
+
3038
+ <li class="md-nav__item">
3039
+ <a href="#overriding-the-defaults" class="md-nav__link">
3040
+ <span class="md-ellipsis">
3041
+
3042
+ Overriding the defaults
3043
+
3044
+ </span>
3045
+ </a>
3046
+
3047
+ </li>
3048
+
3049
+ </ul>
3050
+ </nav>
3051
+
3002
3052
  </li>
3003
3053
 
3004
3054
  <li class="md-nav__item">
@@ -4170,6 +4220,56 @@
4170
4220
  </span>
4171
4221
  </a>
4172
4222
 
4223
+ </li>
4224
+
4225
+ <li class="md-nav__item">
4226
+ <a href="#results-filtering" class="md-nav__link">
4227
+ <span class="md-ellipsis">
4228
+
4229
+ Results filtering
4230
+
4231
+ </span>
4232
+ </a>
4233
+
4234
+ <nav class="md-nav" aria-label="Results filtering">
4235
+ <ul class="md-nav__list">
4236
+
4237
+ <li class="md-nav__item">
4238
+ <a href="#coverage-generation-filtering" class="md-nav__link">
4239
+ <span class="md-ellipsis">
4240
+
4241
+ Coverage generation filtering
4242
+
4243
+ </span>
4244
+ </a>
4245
+
4246
+ </li>
4247
+
4248
+ <li class="md-nav__item">
4249
+ <a href="#report-filtering" class="md-nav__link">
4250
+ <span class="md-ellipsis">
4251
+
4252
+ Report filtering
4253
+
4254
+ </span>
4255
+ </a>
4256
+
4257
+ </li>
4258
+
4259
+ <li class="md-nav__item">
4260
+ <a href="#overriding-the-defaults" class="md-nav__link">
4261
+ <span class="md-ellipsis">
4262
+
4263
+ Overriding the defaults
4264
+
4265
+ </span>
4266
+ </a>
4267
+
4268
+ </li>
4269
+
4270
+ </ul>
4271
+ </nav>
4272
+
4173
4273
  </li>
4174
4274
 
4175
4275
  <li class="md-nav__item">
@@ -4401,6 +4501,82 @@
4401
4501
  <a id="__codelineno-0-10" name="__codelineno-0-10" href="#__codelineno-0-10"></a><span class="w"> </span><span class="nt">:custom_args</span><span class="p">:</span>
4402
4502
  <a id="__codelineno-0-11" name="__codelineno-0-11" href="#__codelineno-0-11"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="s">&quot;-title:MyProject&quot;</span>
4403
4503
  </code></pre></div>
4504
+ <h2 id="results-filtering">Results filtering</h2>
4505
+ <p>This plugin filters coverage results for <code>reportgenerator</code> coverage reporting
4506
+ in two separate stages, each with its own defaults.</p>
4507
+ <h3 id="coverage-generation-filtering">Coverage generation filtering</h3>
4508
+ <p>Before <code>reportgenerator</code> ever runs, this plugin runs <code>gcov</code> itself against each
4509
+ <code>.gcno</code> file produced by the coverage test build, skipping any that match an
4510
+ exclusion pattern — no <code>.gcov</code> data is ever produced for a skipped file, so
4511
+ nothing downstream can put it back into a report.</p>
4512
+ <p>By default this skips:</p>
4513
+ <ul>
4514
+ <li><strong>Test files</strong> — matched by <code>:test_file_prefix</code>.</li>
4515
+ <li><strong>Mocks</strong> — matched by <code>:mock_prefix</code>.</li>
4516
+ <li><strong>Test runners</strong> — any filename containing <code>_runner</code>.</li>
4517
+ <li><strong>Vendored Unity and CMock sources</strong> — <code>unity.gcno</code> and <code>cmock.gcno</code> by
4518
+ name.</li>
4519
+ </ul>
4520
+ <p>Given <code>:test_file_prefix</code> ⇒ <code>test_</code> and CMock's default <code>:mock_prefix</code> ⇒
4521
+ <code>Mock</code>, the equivalent filename-fragment patterns are:</p>
4522
+ <div class="highlight"><pre><span></span><code><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>test_[^\/\\]*
4523
+ <a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a>Mock[^\/\\]*
4524
+ <a id="__codelineno-1-3" name="__codelineno-1-3" href="#__codelineno-1-3"></a>[^\/\\]*_runner[^\/\\]*
4525
+ <a id="__codelineno-1-4" name="__codelineno-1-4" href="#__codelineno-1-4"></a>unity
4526
+ <a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a>cmock
4527
+ </code></pre></div>
4528
+ <p>These combine with whatever you add via <a href="#gcov_exclude"><code>:gcov_exclude</code></a>
4529
+ below. Your patterns extend this list, they don't replace it.</p>
4530
+ <h3 id="report-filtering">Report filtering</h3>
4531
+ <p>Separately, once <code>.gcov</code> files exist, ReportGenerator's own <code>-filefilters:</code>
4532
+ argument controls which of them actually appear in the generated report(s).
4533
+ By default this excludes:</p>
4534
+ <ol>
4535
+ <li>
4536
+ <p><strong>Test paths</strong> — every file anywhere under each of your configured
4537
+ <code>:paths</code> ↳ <code>:test</code> directories, not only files matching
4538
+ <code>:test_file_prefix</code>. A support subdirectory nested under a test path
4539
+ (e.g. <code>test/support/</code>) is excluded as a side effect of this — the whole
4540
+ tree goes, not just prefixed test files.</p>
4541
+ <p>Given a <code>:paths</code> ↳ <code>:test</code> entry of <code>test/</code>:
4542
+ <div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a>-./test/**/*
4543
+ </code></pre></div></p>
4544
+ </li>
4545
+ <li>
4546
+ <p><strong>The build root</strong> — every generated and vendored file: mocks, test
4547
+ runners, Partials output, Unity, CMock, CException.</p>
4548
+ <p>Given <code>:build_root</code> ⇒ <code>build/</code>:
4549
+ <div class="highlight"><pre><span></span><code><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a>-./build/**/*
4550
+ </code></pre></div></p>
4551
+ </li>
4552
+ <li>
4553
+ <p><strong>Partial-generated files</strong> — only when <code>:use_partials</code> is enabled, any
4554
+ file whose name starts with Ceedling's Partial filename prefix, wherever
4555
+ it's found (not only under the build root).</p>
4556
+ <div class="highlight"><pre><span></span><code><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a>-ceedling_partial_*
4557
+ </code></pre></div>
4558
+ </li>
4559
+ </ol>
4560
+ <p>These patterns are generated automatically and placed ahead of whatever you
4561
+ provide via <a href="#file_filters"><code>:file_filters</code></a> below.</p>
4562
+ <h3 id="overriding-the-defaults">Overriding the defaults</h3>
4563
+ <p>Neither filtering stage above can be overridden or narrowed by plugin
4564
+ configuration — only added to.</p>
4565
+ <p>For <a href="#coverage-generation-filtering">coverage generation filtering</a>,
4566
+ <a href="#gcov_exclude"><code>:gcov_exclude</code></a> only ever adds more exclusion patterns; there
4567
+ is no plugin option to disable one of the built-in exclusions, and no way to
4568
+ resurrect <code>.gcov</code> data for a file <code>gcov</code> was never run against in the first
4569
+ place.</p>
4570
+ <p>For <a href="#report-filtering">report filtering</a>, the natural instinct is to reach
4571
+ for <a href="#custom_args"><code>:custom_args</code></a> to pass a second, conflicting
4572
+ <code>-filefilters:</code> argument, but this is not an option because of ReportGenerator's
4573
+ rules and the order in which the filters are provided by the plugin.</p>
4574
+ <p>In short, there's no supported way to broaden what this plugin reports
4575
+ beyond its defaults. If you need to override coverage reporting filtering,
4576
+ use the <a href="gcovr.html">Gcovr option for this pluing</a> instead. Its
4577
+ <code>:config_file</code> option hands full control to a <code>gcovr</code> configuration file,
4578
+ bypassing Ceedling's generated exclusions entirely (see
4579
+ <a href="gcovr.html#results-filtering">Gcovr's Results filtering</a>).</p>
4404
4580
  <h2 id="plugin-configuration">Plugin configuration</h2>
4405
4581
  <h3 id="history_directory"><code>:history_directory</code></h3>
4406
4582
  <p>Optional directory for storing persistent coverage information. Can be used
@@ -4426,10 +4602,15 @@ filters. Wildcards are allowed, but not regular expressions.</p>
4426
4602
  <h3 id="file_filters"><code>:file_filters</code></h3>
4427
4603
  <p>Optional list of files that should be included or excluded in the report
4428
4604
  (separated by semicolon). Exclusion filters take precedence over inclusion
4429
- filters. Wildcards are allowed, but not regular expressions. Ceedling places
4430
- your own patterns first, ahead of the exclusions it generates automatically
4431
- for test paths, the build root, and (when Partials are in use) Partial
4432
- source files, so your patterns take precedence.</p>
4605
+ filters regardless of order. Wildcards are allowed, but not regular
4606
+ expressions.</p>
4607
+ <p>This plugin places your own patterns first, ahead of the exclusions it
4608
+ generates automatically for test paths, the build root, and (when Partials
4609
+ are in use) Partial-generated files (see
4610
+ <a href="#report-filtering">Report filtering</a> above for exactly what those defaults
4611
+ cover). Because exclusions always win, your patterns can add further
4612
+ exclusions or includes but cannot override or remove one of those defaults;
4613
+ see <a href="#overriding-the-defaults">Overriding the defaults</a> above.</p>
4433
4614
  <p><strong>Example:</strong> <code>"-./vendor/*;-./build/*;-./test/*;-./lib/*;+./src/*"</code></p>
4434
4615
  <hr />
4435
4616
  <h3 id="verbosity"><code>:verbosity</code></h3>
@@ -4445,11 +4626,17 @@ source files, so your patterns take precedence.</p>
4445
4626
  (<code>.gcno</code>) files that match these filters from coverage processing — these
4446
4627
  files are never run through <code>gcov</code> at all. A trailing <code>.gcov</code> or <code>.gcno</code>
4447
4628
  suffix on a pattern is stripped automatically, so either form works.</p>
4448
- <div class="highlight"><pre><span></span><code><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a><span class="nt">:gcov</span><span class="p">:</span>
4449
- <a id="__codelineno-1-2" name="__codelineno-1-2" href="#__codelineno-1-2"></a><span class="w"> </span><span class="nt">:report_generator</span><span class="p">:</span>
4450
- <a id="__codelineno-1-3" name="__codelineno-1-3" href="#__codelineno-1-3"></a><span class="w"> </span><span class="nt">:gcov_exclude</span><span class="p">:</span>
4451
- <a id="__codelineno-1-4" name="__codelineno-1-4" href="#__codelineno-1-4"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">&lt;regex&gt;</span>
4452
- <a id="__codelineno-1-5" name="__codelineno-1-5" href="#__codelineno-1-5"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
4629
+ <p>Ceedling combines your patterns with exclusions it generates automatically
4630
+ for test files, mocks, test runners, and vendored Unity/CMock sources (see
4631
+ <a href="#coverage-generation-filtering">Coverage generation filtering</a> above for
4632
+ exactly what these cover). Your patterns can only add further exclusions;
4633
+ there's no way to override or remove one of the defaults — see
4634
+ <a href="#overriding-the-defaults">Overriding the defaults</a> above.</p>
4635
+ <div class="highlight"><pre><span></span><code><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a><span class="nt">:gcov</span><span class="p">:</span>
4636
+ <a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a><span class="w"> </span><span class="nt">:report_generator</span><span class="p">:</span>
4637
+ <a id="__codelineno-5-3" name="__codelineno-5-3" href="#__codelineno-5-3"></a><span class="w"> </span><span class="nt">:gcov_exclude</span><span class="p">:</span>
4638
+ <a id="__codelineno-5-4" name="__codelineno-5-4" href="#__codelineno-5-4"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">&lt;regex&gt;</span>
4639
+ <a id="__codelineno-5-5" name="__codelineno-5-5" href="#__codelineno-5-5"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
4453
4640
  </code></pre></div>
4454
4641
  <p><strong>Default:</strong> <code>[]</code></p>
4455
4642
  <hr />
@@ -4467,11 +4654,11 @@ covered by the options above. See the
4467
4654
  <p>Note: This can be accomplished with Ceedling's tool configuration options
4468
4655
  outside of plugin configuration but is supported here to collect
4469
4656
  configuration options in one place.</p>
4470
- <div class="highlight"><pre><span></span><code><a id="__codelineno-2-1" name="__codelineno-2-1" href="#__codelineno-2-1"></a><span class="nt">:gcov</span><span class="p">:</span>
4471
- <a id="__codelineno-2-2" name="__codelineno-2-2" href="#__codelineno-2-2"></a><span class="w"> </span><span class="nt">:report_generator</span><span class="p">:</span>
4472
- <a id="__codelineno-2-3" name="__codelineno-2-3" href="#__codelineno-2-3"></a><span class="w"> </span><span class="nt">:custom_args</span><span class="p">:</span>
4473
- <a id="__codelineno-2-4" name="__codelineno-2-4" href="#__codelineno-2-4"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">&lt;argument&gt;</span>
4474
- <a id="__codelineno-2-5" name="__codelineno-2-5" href="#__codelineno-2-5"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
4657
+ <div class="highlight"><pre><span></span><code><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><span class="nt">:gcov</span><span class="p">:</span>
4658
+ <a id="__codelineno-6-2" name="__codelineno-6-2" href="#__codelineno-6-2"></a><span class="w"> </span><span class="nt">:report_generator</span><span class="p">:</span>
4659
+ <a id="__codelineno-6-3" name="__codelineno-6-3" href="#__codelineno-6-3"></a><span class="w"> </span><span class="nt">:custom_args</span><span class="p">:</span>
4660
+ <a id="__codelineno-6-4" name="__codelineno-6-4" href="#__codelineno-6-4"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">&lt;argument&gt;</span>
4661
+ <a id="__codelineno-6-5" name="__codelineno-6-5" href="#__codelineno-6-5"></a><span class="w"> </span><span class="p p-Indicator">-</span><span class="w"> </span><span class="l l-Scalar l-Scalar-Plain">...</span>
4475
4662
  </code></pre></div>
4476
4663
  <p><strong>Default:</strong> <code>[]</code></p>
4477
4664
  <p><br/><br/></p>
Binary file
@@ -0,0 +1,166 @@
1
+ # =========================================================================
2
+ # Ceedling - Test-Centered Build System for C
3
+ # ThrowTheSwitch.org
4
+ # Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
5
+ # SPDX-License-Identifier: MIT
6
+ # =========================================================================
7
+
8
+ require 'spec_system_helper'
9
+
10
+ ##
11
+ ## Shared Partials Types Header (issue #1319)
12
+ ## ==========================================
13
+ ##
14
+ ## Partials lifts a module's type definitions into one shared header so a module tested and
15
+ ## mocked in the same test file still gets exactly one C definition of each type. That header
16
+ ## lands in the generated include lists at the position the module's own header occupied, which
17
+ ## is earlier than the module's own source placed its dependencies.
18
+ ##
19
+ ## Until this fix the shared header emitted no #include directives at all, so it compiled only
20
+ ## where something earlier in the translation unit happened to have declared the names its
21
+ ## extracted types reference. A module whose header declares a type in terms of one another
22
+ ## header supplies failed with `unknown type name`, and the same gap applied to a macro an
23
+ ## extracted type names.
24
+ ##
25
+ ## The header now carries those dependencies itself, and states the real module header's include
26
+ ## guard deliberately so a transitive reach at that header finds it already satisfied.
27
+ ##
28
+
29
+ ceedling_system_tests do
30
+
31
+ before :all do
32
+ @c = SystemContext.new
33
+ @c.deploy_gem
34
+ end
35
+
36
+ after :all do
37
+ @c.done!
38
+ end
39
+
40
+ before { @proj_name = unique_proj_name("partials_types") }
41
+
42
+ describe "Deployed as a gem" do
43
+ before do
44
+ @c.with_context do
45
+ @c.ceedling_appcmd_exec("new #{@proj_name}")
46
+ end
47
+ end
48
+
49
+ # =========================================================================
50
+ describe "a Partial's extracted types depending on another header" do
51
+ # =========================================================================
52
+
53
+ before do
54
+ @c.with_context do
55
+ Dir.chdir @proj_name do
56
+ File.write('src/units.h', <<~C)
57
+ #ifndef UNITS_H
58
+ #define UNITS_H
59
+
60
+ typedef signed short Celsius;
61
+
62
+ #endif // UNITS_H
63
+ C
64
+ File.write('src/sensor.h', <<~C)
65
+ #ifndef SENSOR_H
66
+ #define SENSOR_H
67
+
68
+ #include "units.h"
69
+
70
+ typedef struct
71
+ {
72
+ Celsius limit;
73
+ } SensorConfig;
74
+
75
+ int sensor_over_limit(Celsius reading);
76
+
77
+ #endif // SENSOR_H
78
+ C
79
+ File.write('src/sensor.c', <<~C)
80
+ #include "sensor.h"
81
+
82
+ static SensorConfig config = { .limit = 30 };
83
+
84
+ static Celsius sensor_limit(void)
85
+ {
86
+ return config.limit;
87
+ }
88
+
89
+ int sensor_over_limit(Celsius reading)
90
+ {
91
+ return reading > sensor_limit();
92
+ }
93
+ C
94
+ File.write('test/test_sensor.c', <<~C)
95
+ #ifdef TEST
96
+
97
+ #include "unity.h"
98
+ #include "ceedling.h"
99
+
100
+ #include TEST_PARTIAL_ALL_MODULE(sensor)
101
+
102
+ void setUp(void) {}
103
+ void tearDown(void) {}
104
+
105
+ void test_sensor_reads_its_own_file_scope_config(void)
106
+ {
107
+ TEST_ASSERT_EQUAL_INT(30, sensor_limit());
108
+ }
109
+
110
+ void test_sensor_over_limit_uses_the_exposed_limit(void)
111
+ {
112
+ config.limit = 10;
113
+ TEST_ASSERT_TRUE(sensor_over_limit(11));
114
+ TEST_ASSERT_FALSE(sensor_over_limit(9));
115
+ }
116
+
117
+ #endif // TEST
118
+ C
119
+
120
+ @c.merge_project_yml_for_test( :project => { :use_partials => true } )
121
+ end
122
+ end
123
+ end
124
+
125
+ # Exercises the whole chain at once: the carried dependency makes the shared types header
126
+ # compile, the stripped `static` on a file-scope variable makes it reachable from the test,
127
+ # and the stripped `static` on a function makes it callable.
128
+ it "builds and passes, reaching the module's exposed statics" do
129
+ @c.with_context do
130
+ Dir.chdir @proj_name do
131
+ output = @c.ceedling_build_exec("test:all")
132
+
133
+ expect(@c.last_exit_status).to eq(0), "build failed:\n#{output}"
134
+ expect(output).to match(/TESTED:\s+2/)
135
+ expect(output).to match(/PASSED:\s+2/)
136
+ expect(output).to match(/FAILED:\s+0/)
137
+ end
138
+ end
139
+ end
140
+
141
+ # The dependency the shared header carries, and the guard it spoofs, are both emitted into
142
+ # the generated file. Reading it directly states what the build result alone cannot show.
143
+ it "carries the dependency and spoofs the real header's guard" do
144
+ @c.with_context do
145
+ Dir.chdir @proj_name do
146
+ @c.ceedling_build_exec("test:all")
147
+
148
+ generated = Dir.glob('build/test/partials/**/*sensor_types.h').first
149
+ expect(generated).not_to be_nil, 'no shared types header was generated'
150
+
151
+ contents = File.read(generated)
152
+ expect(contents).to match(/#include\s+"units\.h"/)
153
+ expect(contents).to match(/^#define SENSOR_H$/)
154
+
155
+ # The spoof has to precede the carried include: that include can reach the real
156
+ # module header in turn, and the guard must already be satisfied when it does.
157
+ expect(contents.index('#define SENSOR_H')).to be < contents.index('#include "units.h"')
158
+ end
159
+ end
160
+ end
161
+
162
+ end
163
+
164
+ end
165
+
166
+ end