ceedling 1.2.2 → 1.2.3

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.
Files changed (390) hide show
  1. checksums.yaml +4 -4
  2. data/GIT_COMMIT_SHA +1 -1
  3. data/README.md +1 -1
  4. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
  5. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
  6. data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
  7. data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
  8. data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
  9. data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
  10. data/docs/BreakingChanges.md +16 -0
  11. data/docs/Changelog.md +71 -0
  12. data/docs/KnownIssues.md +91 -4
  13. data/examples/wondrous_forest/README.md +29 -1
  14. data/examples/wondrous_forest/src/ForestUnits.h +23 -0
  15. data/examples/wondrous_forest/src/RainGauge.c +59 -0
  16. data/examples/wondrous_forest/src/RainGauge.h +39 -0
  17. data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
  18. data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
  19. data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
  20. data/lib/ceedling/c_extractor/README.md +15 -7
  21. data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
  22. data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
  23. data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
  24. data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
  25. data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
  26. data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
  27. data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
  28. data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
  29. data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
  30. data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
  31. data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
  32. data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
  33. data/lib/ceedling/c_identifier.rb +21 -0
  34. data/lib/ceedling/ceedling.h +8 -0
  35. data/lib/ceedling/config/configurator.rb +4 -3
  36. data/lib/ceedling/config/configurator_builder.rb +17 -0
  37. data/lib/ceedling/config/configurator_setup.rb +29 -5
  38. data/lib/ceedling/constants.rb +5 -1
  39. data/lib/ceedling/defaults.rb +31 -1
  40. data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
  41. data/lib/ceedling/dependencies/README.md +1 -1
  42. data/lib/ceedling/dependencies/dependency_cache_store.rb +30 -25
  43. data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
  44. data/lib/ceedling/dependencies/dependinator.rb +13 -1
  45. data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
  46. data/lib/ceedling/diagnostics/README.md +5 -0
  47. data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
  48. data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
  49. data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
  50. data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
  51. data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
  52. data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
  53. data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
  54. data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
  55. data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
  56. data/lib/ceedling/filesystem/PATH_HANDLING.md +83 -27
  57. data/lib/ceedling/filesystem/README.md +6 -1
  58. data/lib/ceedling/filesystem/build_roots.rb +105 -0
  59. data/lib/ceedling/filesystem/build_subpath.rb +110 -25
  60. data/lib/ceedling/filesystem/file_finder.rb +76 -110
  61. data/lib/ceedling/filesystem/file_finder_helper.rb +33 -11
  62. data/lib/ceedling/filesystem/file_path_utils.rb +113 -91
  63. data/lib/ceedling/filesystem/file_wrapper.rb +105 -28
  64. data/lib/ceedling/filesystem/path_matcher.rb +21 -0
  65. data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
  66. data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
  67. data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
  68. data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
  69. data/lib/ceedling/generators/generator.rb +27 -64
  70. data/lib/ceedling/generators/generator_helper.rb +0 -44
  71. data/lib/ceedling/generators/generator_mocks.rb +5 -0
  72. data/lib/ceedling/generators/generator_partials.rb +305 -243
  73. data/lib/ceedling/generators/generator_test_runner.rb +5 -8
  74. data/lib/ceedling/generators/partial_header_writer.rb +95 -0
  75. data/lib/ceedling/generators/partial_source_writer.rb +137 -0
  76. data/lib/ceedling/includes/header_search.rb +225 -0
  77. data/lib/ceedling/includes/include_factory.rb +9 -12
  78. data/lib/ceedling/includes/include_pathinator.rb +53 -31
  79. data/lib/ceedling/includes/includes.rb +149 -37
  80. data/lib/ceedling/objects.yml +89 -4
  81. data/lib/ceedling/partials/README.md +110 -16
  82. data/lib/ceedling/partials/carry_plan.rb +71 -0
  83. data/lib/ceedling/partials/definition_head.rb +74 -0
  84. data/lib/ceedling/partials/include_groups.rb +37 -0
  85. data/lib/ceedling/partials/interface_extras.rb +25 -0
  86. data/lib/ceedling/partials/partializer.rb +599 -120
  87. data/lib/ceedling/partials/partializer_config.rb +5 -0
  88. data/lib/ceedling/partials/partializer_helper.rb +851 -145
  89. data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
  90. data/lib/ceedling/partials/partializer_utils.rb +89 -109
  91. data/lib/ceedling/partials/partials.rb +153 -10
  92. data/lib/ceedling/partials/type_macros.rb +126 -0
  93. data/lib/ceedling/preprocess/README.md +43 -33
  94. data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
  95. data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
  96. data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +31 -75
  97. data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
  98. data/lib/ceedling/setupinator.rb +16 -3
  99. data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
  100. data/lib/ceedling/test_invoker/PIPELINE.md +57 -16
  101. data/lib/ceedling/test_invoker/README.md +1 -1
  102. data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
  103. data/lib/ceedling/test_invoker/mock_locator.rb +116 -9
  104. data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
  105. data/lib/ceedling/test_invoker/partials_manager.rb +265 -308
  106. data/lib/ceedling/test_invoker/standin_headerinator.rb +8 -15
  107. data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
  108. data/lib/ceedling/test_invoker/test_build_executor.rb +338 -198
  109. data/lib/ceedling/test_invoker/test_build_planner.rb +13 -19
  110. data/lib/ceedling/test_invoker/test_build_setup.rb +26 -6
  111. data/lib/ceedling/test_invoker/test_build_validations.rb +23 -20
  112. data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
  113. data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +1 -2
  114. data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
  115. data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
  116. data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +5 -3
  117. data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
  118. data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
  119. data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
  120. data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
  121. data/lib/ceedling/tools/shell_quoting.rb +45 -0
  122. data/lib/ceedling/tools/tool_quoting.rb +79 -0
  123. data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
  124. data/lib/version.rb +1 -1
  125. data/plugins/bullseye/bullseye.rake +1 -3
  126. data/plugins/bullseye/lib/bullseye.rb +15 -2
  127. data/plugins/command_hooks/lib/command_hooks.rb +1 -1
  128. data/plugins/fff/lib/fff.rb +42 -15
  129. data/plugins/fff/lib/fff_mock_generator.rb +12 -9
  130. data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +134 -0
  131. data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
  132. data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
  133. data/plugins/gcov/lib/console_reportinator.rb +25 -19
  134. data/plugins/gcov/lib/reportgenerator_reportinator.rb +2 -1
  135. data/site-local/404.html +2 -2
  136. data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
  137. data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
  138. data/site-local/configuration/environment-vars.html +2 -2
  139. data/site-local/configuration/global-collections.html +3 -3
  140. data/site-local/configuration/index.html +2 -2
  141. data/site-local/configuration/loading.html +2 -2
  142. data/site-local/configuration/mixins.html +2 -2
  143. data/site-local/configuration/parallel-builds.html +2 -2
  144. data/site-local/configuration/project-file.html +2 -2
  145. data/site-local/configuration/reference/cexception.html +2 -2
  146. data/site-local/configuration/reference/cmock.html +5 -2
  147. data/site-local/configuration/reference/defines.html +2 -2
  148. data/site-local/configuration/reference/environment.html +2 -2
  149. data/site-local/configuration/reference/extension.html +2 -2
  150. data/site-local/configuration/reference/files.html +56 -9
  151. data/site-local/configuration/reference/flags.html +2 -2
  152. data/site-local/configuration/reference/index.html +2 -2
  153. data/site-local/configuration/reference/libraries.html +2 -2
  154. data/site-local/configuration/reference/mixins.html +2 -2
  155. data/site-local/configuration/reference/partials.html +84 -2
  156. data/site-local/configuration/reference/paths.html +7 -2
  157. data/site-local/configuration/reference/plugins.html +2 -2
  158. data/site-local/configuration/reference/project.html +247 -5
  159. data/site-local/configuration/reference/release-build.html +2 -2
  160. data/site-local/configuration/reference/test-build.html +2 -2
  161. data/site-local/configuration/reference/test-runner.html +2 -2
  162. data/site-local/configuration/reference/tools.html +49 -4
  163. data/site-local/configuration/reference/unity.html +2 -2
  164. data/site-local/configuration/which-ceedling.html +2 -2
  165. data/site-local/development/index.html +2 -2
  166. data/site-local/development/plugins/configuration.html +2 -2
  167. data/site-local/development/plugins/index.html +2 -2
  168. data/site-local/development/plugins/plugin-subclass.html +5 -4
  169. data/site-local/development/plugins/rake-tasks.html +2 -2
  170. data/site-local/development/releases.html +2 -2
  171. data/site-local/development/workflow.html +2 -2
  172. data/site-local/getting-started/builds.html +2 -2
  173. data/site-local/getting-started/command-line.html +2 -2
  174. data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
  175. data/site-local/getting-started/example-projects/index.html +2 -2
  176. data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
  177. data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
  178. data/site-local/getting-started/index.html +2 -2
  179. data/site-local/getting-started/installation.html +2 -2
  180. data/site-local/getting-started/quick-start.html +2 -2
  181. data/site-local/help.html +2 -2
  182. data/site-local/index.html +2 -2
  183. data/site-local/overview/build-system.html +2 -2
  184. data/site-local/overview/index.html +2 -2
  185. data/site-local/overview/test-environments.html +2 -2
  186. data/site-local/overview/tools-and-frameworks.html +2 -2
  187. data/site-local/plugins/beep.html +2 -2
  188. data/site-local/plugins/bullseye/index.html +45 -38
  189. data/site-local/plugins/bullseye/licensing.html +2 -2
  190. data/site-local/plugins/command-hooks.html +4 -4
  191. data/site-local/plugins/compile-commands-json-db.html +2 -2
  192. data/site-local/plugins/cppcheck.html +2 -2
  193. data/site-local/plugins/dependencies.html +2 -2
  194. data/site-local/plugins/fff.html +16 -2
  195. data/site-local/plugins/gcov/examples.html +2 -2
  196. data/site-local/plugins/gcov/gcovr.html +8 -2
  197. data/site-local/plugins/gcov/index.html +2 -2
  198. data/site-local/plugins/gcov/overview.html +2 -2
  199. data/site-local/plugins/gcov/reportgenerator.html +18 -14
  200. data/site-local/plugins/gcov/reporting.html +2 -2
  201. data/site-local/plugins/gcov/setup.html +2 -2
  202. data/site-local/plugins/gcov/tool-versions.html +2 -2
  203. data/site-local/plugins/gcov/troubleshooting.html +2 -2
  204. data/site-local/plugins/index.html +2 -2
  205. data/site-local/plugins/module-generator.html +2 -2
  206. data/site-local/plugins/report-build-warnings-log.html +2 -2
  207. data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
  208. data/site-local/plugins/report-tests-ide-stdout.html +2 -2
  209. data/site-local/plugins/report-tests-log-factory.html +2 -2
  210. data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
  211. data/site-local/plugins/report-tests-raw-output-log.html +2 -2
  212. data/site-local/plugins/report-tests-teamcity-stdout.html +2 -2
  213. data/site-local/plugins/sanitize.html +2 -2
  214. data/site-local/plugins/valgrind.html +2 -2
  215. data/site-local/project/index.html +2 -2
  216. data/site-local/project/release-history.html +2 -2
  217. data/site-local/project/sbom.html +2 -2
  218. data/site-local/project/upgrade.html +2 -2
  219. data/site-local/reference/build-directives.html +2 -2
  220. data/site-local/reference/command-line.html +2 -2
  221. data/site-local/reference/environment-vars.html +2 -2
  222. data/site-local/reference/gcov-plugin.html +2 -2
  223. data/site-local/reference/global-collections.html +12 -12
  224. data/site-local/reference/index.html +2 -2
  225. data/site-local/reference/partials-macros.html +47 -2
  226. data/site-local/reference/project-configuration.html +2 -2
  227. data/site-local/sitemap.xml.gz +0 -0
  228. data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
  229. data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
  230. data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
  231. data/site-local/testing-guide/build-directives.html +2 -2
  232. data/site-local/testing-guide/conventions.html +67 -22
  233. data/site-local/testing-guide/frameworks.html +2 -2
  234. data/site-local/testing-guide/index.html +2 -2
  235. data/site-local/testing-guide/partials/configuration.html +31 -4
  236. data/site-local/testing-guide/partials/conventions.html +509 -8
  237. data/site-local/testing-guide/partials/directives.html +4 -3
  238. data/site-local/testing-guide/partials/example.html +2 -2
  239. data/site-local/testing-guide/partials/index.html +2 -2
  240. data/site-local/testing-guide/partials/overview.html +30 -12
  241. data/site-local/testing-guide/partials/variables.html +169 -4
  242. data/site-local/testing-guide/test-cases.html +2 -2
  243. data/site-local/testing-guide/test-sample.html +2 -2
  244. data/site-local/testing-guide/test-suite-anatomy.html +2 -2
  245. data/spec/integration/build_step_doctor_spec.rb +270 -0
  246. data/spec/integration/c_extractor_composition_spec.rb +254 -4
  247. data/spec/integration/includes_extraction_spec.rb +27 -14
  248. data/spec/integration/nested_test_artifacts_spec.rb +1 -1
  249. data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
  250. data/spec/integration/partials_carry_spec.rb +520 -0
  251. data/spec/integration/partials_declarations_spec.rb +655 -0
  252. data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
  253. data/spec/integration/partials_function_pointers_spec.rb +277 -0
  254. data/spec/integration/partials_header_composition_spec.rb +268 -35
  255. data/spec/integration/partials_macro_decorators_spec.rb +267 -0
  256. data/spec/integration/partials_module_resolution_spec.rb +26 -19
  257. data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
  258. data/spec/integration/path_length_reporting_spec.rb +64 -0
  259. data/spec/integration/path_scenarios_spec.rb +80 -3
  260. data/spec/integration/quote_include_isolator_spec.rb +56 -0
  261. data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
  262. data/spec/integration/test_includes_extractinator_spec.rb +70 -5
  263. data/spec/integration/test_naming_spec.rb +6 -3
  264. data/spec/integration/test_source_file_checks_spec.rb +5 -3
  265. data/spec/integration/tool_executor_spec.rb +1 -1
  266. data/spec/integration/tool_validator_spec.rb +2 -2
  267. data/spec/integration/win_long_paths_probe_spec.rb +46 -0
  268. data/spec/integration/win_path_limit_spec.rb +53 -0
  269. data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
  270. data/spec/support/integration/configurator_integration_helper.rb +8 -3
  271. data/spec/support/integration/partial_files_harness.rb +181 -0
  272. data/spec/support/integration/partials_generation_integration_helper.rb +237 -141
  273. data/spec/support/integration/path_scenario_harness.rb +4 -2
  274. data/spec/support/integration/spec_integration_helper.rb +8 -3
  275. data/spec/support/integration/test_includes_harness.rb +56 -35
  276. data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
  277. data/spec/system/bullseye_deployment_spec.rb +2 -0
  278. data/spec/system/delta_builds_spec.rb +26 -12
  279. data/spec/system/encoding_stress_spec.rb +4 -4
  280. data/spec/system/example_wondrous_forest_spec.rb +2 -2
  281. data/spec/system/gcov_deployment_spec.rb +2 -0
  282. data/spec/system/header_include_path_validation_spec.rb +4 -4
  283. data/spec/system/header_search_paths_spec.rb +1083 -0
  284. data/spec/system/mock_include_folders_spec.rb +121 -0
  285. data/spec/system/mockable_header_reassembly_spec.rb +184 -0
  286. data/spec/system/partials_carry_spec.rb +581 -0
  287. data/spec/system/partials_delta_builds_spec.rb +280 -0
  288. data/spec/system/partials_function_pointers_spec.rb +106 -0
  289. data/spec/system/partials_macro_decorators_spec.rb +127 -0
  290. data/spec/system/partials_module_disambiguation_spec.rb +125 -0
  291. data/spec/system/path_handling_probes_spec.rb +16 -12
  292. data/spec/system/pinned_thread_count_spec.rb +4 -4
  293. data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
  294. data/spec/system/short_build_paths_spec.rb +87 -0
  295. data/spec/system/sibling_header_collision_spec.rb +30 -6
  296. data/spec/system/support/bullseye_common_test_cases.rb +42 -0
  297. data/spec/system/support/common_test_cases.rb +2 -2
  298. data/spec/system/support/gcov_partials_test_cases.rb +48 -0
  299. data/spec/system/test_build_layout_spec.rb +209 -0
  300. data/spec/system/test_source_file_directive_spec.rb +35 -5
  301. data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
  302. data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
  303. data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
  304. data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
  305. data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
  306. data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
  307. data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
  308. data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
  309. data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
  310. data/spec/units/c_identifier_spec.rb +35 -0
  311. data/spec/units/config/configurator_builder_spec.rb +24 -0
  312. data/spec/units/config/configurator_setup_spec.rb +72 -4
  313. data/spec/units/config/configurator_spec.rb +27 -1
  314. data/spec/units/dependencies/dependency_cache_store_spec.rb +68 -3
  315. data/spec/units/dependencies/dependency_tracker_spec.rb +25 -0
  316. data/spec/units/dependencies/dependinator_spec.rb +17 -2
  317. data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
  318. data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
  319. data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
  320. data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
  321. data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
  322. data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
  323. data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
  324. data/spec/units/encodinator_spec.rb +3 -4
  325. data/spec/units/filesystem/build_roots_spec.rb +131 -0
  326. data/spec/units/filesystem/build_subpath_spec.rb +113 -0
  327. data/spec/units/filesystem/file_finder_helper_spec.rb +80 -0
  328. data/spec/units/filesystem/file_finder_spec.rb +242 -58
  329. data/spec/units/filesystem/file_path_utils_spec.rb +251 -118
  330. data/spec/units/filesystem/file_wrapper_spec.rb +191 -6
  331. data/spec/units/filesystem/path_matcher_spec.rb +36 -0
  332. data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
  333. data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
  334. data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
  335. data/spec/units/generators/generator_helper_spec.rb +0 -60
  336. data/spec/units/generators/generator_mocks_spec.rb +13 -0
  337. data/spec/units/generators/generator_partials_spec.rb +656 -55
  338. data/spec/units/generators/generator_spec.rb +26 -0
  339. data/spec/units/generators/generator_test_runner_spec.rb +9 -5
  340. data/spec/units/generators/partial_source_writer_spec.rb +129 -0
  341. data/spec/units/includes/header_search_spec.rb +406 -0
  342. data/spec/units/includes/include_factory_spec.rb +22 -5
  343. data/spec/units/includes/include_pathinator_spec.rb +77 -13
  344. data/spec/units/includes/include_spec.rb +14 -0
  345. data/spec/units/includes/includes_spec.rb +176 -19
  346. data/spec/units/loginator_spec.rb +31 -0
  347. data/spec/units/mock_locator_spec.rb +199 -5
  348. data/spec/units/partials/include_groups_spec.rb +42 -0
  349. data/spec/units/partials/partializer_config_spec.rb +25 -0
  350. data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
  351. data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
  352. data/spec/units/partials/partializer_helper_spec.rb +529 -277
  353. data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
  354. data/spec/units/partials/partializer_spec.rb +1578 -270
  355. data/spec/units/partials/partializer_utils_spec.rb +269 -232
  356. data/spec/units/partials/partials_rename_spec.rb +160 -0
  357. data/spec/units/partials_manager_spec.rb +554 -261
  358. data/spec/units/plugins/bullseye_spec.rb +34 -0
  359. data/spec/units/plugins/console_reportinator_spec.rb +58 -9
  360. data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +1 -1
  361. data/spec/units/plugins/reportgenerator_reportinator_spec.rb +51 -3
  362. data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
  363. data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
  364. data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
  365. data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
  366. data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
  367. data/spec/units/setupinator_spec.rb +51 -0
  368. data/spec/units/standin_headerinator_spec.rb +27 -11
  369. data/spec/units/test_build_executor_spec.rb +780 -166
  370. data/spec/units/test_build_planner_spec.rb +116 -28
  371. data/spec/units/test_build_setup_spec.rb +83 -18
  372. data/spec/units/test_context_extractor_spec.rb +11 -2
  373. data/spec/units/test_derived_search_paths_spec.rb +259 -0
  374. data/spec/units/test_includes_extractinator_spec.rb +56 -8
  375. data/spec/units/test_invoker/objects_wiring_spec.rb +20 -3
  376. data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
  377. data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
  378. data/spec/units/test_invoker_types_spec.rb +8 -7
  379. data/spec/units/test_pipeline_manager_spec.rb +54 -13
  380. data/spec/units/test_runner_generatinator_spec.rb +93 -1
  381. data/spec/units/test_search_paths_spec.rb +73 -5
  382. data/spec/units/{default_tools_quoting_spec.rb → tools/default_tools_quoting_spec.rb} +39 -5
  383. data/spec/units/tools/shell_quoting_spec.rb +76 -0
  384. data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
  385. data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +1 -1
  386. data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
  387. data/spec/units/windows_registry_query_tool_spec.rb +53 -0
  388. metadata +161 -16
  389. /data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +0 -0
  390. /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
@@ -14,7 +14,7 @@
14
14
  #
15
15
  # Preprocessing is part of what it runs, and that matters more than it looks. Partials never
16
16
  # sees a module's original text. `Partializer#extract_module_contents` calls
17
- # `CExtractor#from_file` against what `Preprocessinator#preprocess_partial_*_preserve_macros`
17
+ # `CExtractor#from_file` against what `Preprocessinator#preprocess_partial_file`
18
18
  # reconstituted, so conditionals are already resolved, comments are gone, every line
19
19
  # belonging to an included header has been discarded, and the file has been rebuilt from the
20
20
  # survivors plus a reconciled include list. A harness fed original source would report
@@ -48,6 +48,7 @@ require 'ceedling/c_extractor/c_extractor_definitions'
48
48
  require 'ceedling/generators/generator_partials'
49
49
  require 'ceedling/partials/partializer'
50
50
  require 'ceedling/partials/partializer_helper'
51
+ require 'ceedling/partials/partializer_reconciler'
51
52
  require 'ceedling/partials/partializer_utils'
52
53
  require 'ceedling/partials/partializer_config'
53
54
  require 'ceedling/partials/partials'
@@ -55,8 +56,10 @@ require 'ceedling/preprocess/preprocessinator_reconstructor'
55
56
  require 'ceedling/preprocess/preprocessinator_comment_stripper'
56
57
  require 'ceedling/preprocess/c_comment_scanner'
57
58
  require 'ceedling/preprocess/preprocessinator_file_assembler'
59
+ require 'ceedling/preprocess/preprocessinator_code_finder'
58
60
  require 'ceedling/parsing_parcels'
59
61
  require 'ceedling/filesystem/file_path_utils'
62
+ require 'ceedling/filesystem/test_build_layout'
60
63
  require 'ceedling/filesystem/file_wrapper'
61
64
  require 'ceedling/includes/includes'
62
65
 
@@ -69,10 +72,12 @@ module PartialsGeneration
69
72
  # GeneratorPartials#generate_types returning nil for that case. `pp_header` and `pp_source`
70
73
  # are the reconstituted files the extractor actually parsed, which is where to look when a
71
74
  # generated file is missing something the original module had.
75
+ # `carry` is the plan the implementation source was written from, or nil when nothing
76
+ # was selected to test.
72
77
  Result = Struct.new(
73
78
  :dir, :module_name, :mode,
74
- :types_h, :impl_h, :impl_c, :interface_h,
75
- :pp_header, :pp_source,
79
+ :types_h, :impl_h, :impl_c, :interface_h, :extras_h,
80
+ :pp_header, :pp_source, :carry,
76
81
  keyword_init: true
77
82
  ) do
78
83
  # Generated file contents by role, so the accessors below read one way for any of them.
@@ -84,6 +89,7 @@ module PartialsGeneration
84
89
  when :impl_h then impl_h
85
90
  when :impl_c then impl_c
86
91
  when :interface_h then interface_h
92
+ when :extras_h then extras_h
87
93
  else raise ArgumentError, "unknown generated file '#{file}'"
88
94
  end
89
95
  end
@@ -192,9 +198,9 @@ module PartialsGeneration
192
198
  end
193
199
  end
194
200
 
195
- # Raised when the accurate preprocessing pass fails outright. Production falls back to a
196
- # text scan here; a case that cannot preprocess is a broken case, so the harness refuses
197
- # rather than silently measuring a different path than the one asked for.
201
+ # Raised when a preprocessor run fails outright. Production falls back for that file. A
202
+ # case that cannot preprocess is a broken case, so the harness refuses rather than silently
203
+ # measuring a different path than the one asked for.
198
204
  class PreprocessFailure < StandardError; end
199
205
 
200
206
  end
@@ -206,6 +212,7 @@ module PartialsGenerationHelpers
206
212
  #
207
213
  # `header_includes` and `source_includes` are include spellings; `<name>` marks a system
208
214
  # header and anything else a user header, matching what reconciliation hands the assembler.
215
+ # `source: nil` makes a header-only module, which has no source to write or preprocess.
209
216
  # `extra` writes additional headers into the working directory, where the preprocessor and
210
217
  # the later compile resolve them. `partials` defaults to empty: this module is partialized,
211
218
  # which the remap methods handle from `name:` alone. The hash names *other* partialized
@@ -222,79 +229,81 @@ module PartialsGenerationHelpers
222
229
  mode: :accurate,
223
230
  tests_expose: PartializerConfig::DEDUCT,
224
231
  mocks_expose: PartializerConfig::DEDUCT,
232
+ tests_subtract: [],
233
+ mocks_add: [],
234
+ mocks_subtract: [],
235
+ suppress_redundant_decls: true,
236
+ extern_variables: :weak,
225
237
  dir: nil
226
238
  )
227
239
  # A caller supplies `dir` to generate two modules into one working directory, which is
228
240
  # what a link across two partialized modules needs.
229
241
  dir ||= Dir.mktmpdir( 'partials-generation-' )
230
242
 
231
- File.write( File.join( dir, "#{module_name}.h" ), header )
232
- File.write( File.join( dir, "#{module_name}.c" ), source )
233
- extra.each { |name, text| File.write( File.join( dir, name ), text ) }
243
+ # Byte for byte, so a module's line endings are the same on every platform
244
+ File.binwrite( File.join( dir, "#{module_name}.h" ), header )
245
+ File.binwrite( File.join( dir, "#{module_name}.c" ), source ) unless source.nil?
246
+ extra.each { |name, text| File.binwrite( File.join( dir, name ), text ) }
234
247
 
235
- pp_header = reconstitute_partial_file(
236
- dir: dir, filename: "#{module_name}.h", kind: :header,
237
- includes: header_includes, defines: defines, mode: mode
238
- )
239
- pp_source = reconstitute_partial_file(
240
- dir: dir, filename: "#{module_name}.c", kind: :source,
241
- includes: source_includes, defines: defines, mode: mode
248
+ # Each file is preprocessed as stages 6 and 7 preprocess it, into the record they fill in
249
+ header_file = preprocess_partial_file(
250
+ dir: dir, filename: "#{module_name}.h", kind: :header, includes: header_includes, defines: defines, mode: mode
242
251
  )
252
+ # A header-only module's source keeps the empty record PartialsManager leaves it
253
+ source_file =
254
+ if source.nil?
255
+ Partials::ConfigFileInfo.new
256
+ else
257
+ preprocess_partial_file(
258
+ dir: dir, filename: "#{module_name}.c", kind: :source, includes: source_includes, defines: defines, mode: mode
259
+ )
260
+ end
243
261
 
244
- c_module = extract_c( pp_header ) + extract_c( pp_source )
262
+ # DEDUCT with no subtractions is what TEST_PARTIAL_ALL_MODULE resolves to -- every function
263
+ # exposed. The two sides are separate because a module is routinely tested at one visibility
264
+ # and mocked at another, which splits its own content across two generated files. Visibility
265
+ # filtering has its own thorough unit coverage, so a case states the exposure it wants rather
266
+ # than re-proving the filter.
267
+ config = PartializerConfig::Config.new(
268
+ module: module_name,
269
+ tests: PartializerConfig::PartialFunctions.new( type: tests_expose, subtractions: tests_subtract ),
270
+ mocks: PartializerConfig::PartialFunctions.new( type: mocks_expose, additions: mocks_add, subtractions: mocks_subtract ),
271
+ header: header_file,
272
+ source: source_file
273
+ )
245
274
 
246
275
  generator = build_partials_generator
247
276
  partializer = build_partializer
248
277
 
249
- # Function-scoped statics are promoted to module scope before generation, the way
250
- # Partializer#extract_module_contents does it. Promotion is what puts a name that was
251
- # private to one function into link-time resolution, so a linkage case cannot see its
252
- # own subject without this step. Line-number association is deliberately skipped: it
253
- # only sets `#line` attribution, which no assertion here depends on.
254
- promoted = partials_helper.extract_function_scope_static_vars(
255
- c_module.function_definitions,
256
- name: 'PartialsGenerationTest', module_name: module_name, file_type: 'source'
257
- )
258
- c_module.variable_declarations.concat( promoted )
259
- c_module.element_sequence.concat( promoted ) unless promoted.empty?
278
+ # Extraction runs as PartialsManager runs it. Each file is extracted, reconciled with its
279
+ # expansion, located in its raw copy or in fallback its source, and has its function-scope
280
+ # statics promoted. The two merge, and declarations an included header defines inline are
281
+ # marked.
282
+ c_module = partializer.extract_module_contents( 'PartialsGenerationTest', config )
283
+
284
+ # Partials refuses a module whose shape fallback preprocessing cannot resolve, rather than
285
+ # generating from a guess and leaving a compiler to report something arcane later. The
286
+ # refusal comes right after extraction, before generation, as in PartialsManager.
287
+ partializer.validate_config( c_module: c_module, config: config, name: 'PartialsGenerationTest' )
260
288
 
261
289
  # Generated-file boilerplate carried in from the reconstituted files is stripped before
262
290
  # generation, exactly as PartialsManager#stage_generate_partials does. Skipping this
263
291
  # leaves synthetic include guards in the extracted macros and misreports what a real
264
- # build would emit.
265
- partializer.sanitize( c_module )
292
+ # build would emit. The real header's own guard goes too, since every generated file states it.
293
+ partializer.sanitize( c_module, include_guard: partializer.extract_module_include_guard( config.header.filepath ) )
266
294
 
267
- # Header list first, then source list -- the order partials_manager uses when it
268
- # concatenates the two before remapping.
269
- raw_includes = partial_include_objects( source_includes + header_includes )
270
-
271
- # DEDUCT with no subtractions is what TEST_PARTIAL_ALL_MODULE resolves to -- every function
272
- # exposed. The two sides are separate because a module is routinely tested at one visibility
273
- # and mocked at another, which splits its own content across two generated files. Visibility
274
- # filtering has its own thorough unit coverage, so a case states the exposure it wants rather
275
- # than re-proving the filter.
276
- config = PartializerConfig::Config.new(
277
- module: module_name,
278
- tests: PartializerConfig::PartialFunctions.new( type: tests_expose ),
279
- mocks: PartializerConfig::PartialFunctions.new( type: mocks_expose ),
280
- header: Partials::ConfigFileInfo.new( filepath: File.join( dir, "#{module_name}.h" ) ),
281
- source: Partials::ConfigFileInfo.new( filepath: File.join( dir, "#{module_name}.c" ) )
282
- )
295
+ # The header remaps take the source's and the header's lists apart, as partials_manager
296
+ # hands them. The implementation source's remap takes them joined, source first.
297
+ source_objects = source_file.includes
298
+ header_objects = header_file.includes
299
+ raw_includes = source_objects + header_objects
300
+ apart = { source_includes: source_objects, header_includes: header_objects }
283
301
 
284
302
  # Production hands the remaps the whole test file's partials hash, which includes the module
285
303
  # being generated. That entry is what tells the source remap to carry this module's own
286
304
  # interface header, so omitting it hides a real behavior.
287
305
  all_partials = partials.merge( module_name => config )
288
306
 
289
- # Partials refuses a module whose shape fallback preprocessing cannot resolve, rather than
290
- # generating from a guess and leaving a compiler to report something arcane later. Routed
291
- # through validate_config so the refusal happens exactly where production puts it: before
292
- # generation, not after.
293
- partializer.validate_config(
294
- c_module: c_module, config: config, name: 'PartialsGenerationTest',
295
- fallback: mode == :fallback
296
- )
297
-
298
307
  implementation = partializer.extract_implementation_functions(
299
308
  test: 'PartialsGenerationTest', partial: module_name,
300
309
  definitions: c_module.function_definitions, config: config
@@ -309,17 +318,18 @@ module PartialsGenerationHelpers
309
318
  # The types header carries its own dependencies and its own guard-spoof, so both are
310
319
  # computed here the way partials_manager does and handed to the generator.
311
320
  types_includes = partializer.remap_types_header_includes(
312
- name: module_name, includes: raw_includes, partials: all_partials
321
+ name: module_name, **apart, partials: all_partials
313
322
  )
314
323
  include_guard = partializer.extract_module_include_guard( config.header.filepath )
315
324
 
316
325
  types_h_name = generator.generate_types(
317
326
  name: module_name, c_module: c_module, output_path: dir,
318
- includes: types_includes, include_guard: include_guard
327
+ includes: types_includes.leading, following_includes: types_includes.following,
328
+ include_guard: include_guard
319
329
  )
320
330
 
321
331
  header_list = partializer.remap_implementation_header_includes(
322
- name: module_name, includes: raw_includes, partials: all_partials,
332
+ name: module_name, **apart, partials: all_partials,
323
333
  types_header: types_h_name
324
334
  )
325
335
 
@@ -328,32 +338,54 @@ module PartialsGenerationHelpers
328
338
  )
329
339
 
330
340
  interface_list = partializer.remap_interface_header_includes(
331
- name: module_name, includes: raw_includes, partials: all_partials,
341
+ name: module_name, **apart, partials: all_partials,
332
342
  types_header: types_h_name
333
343
  )
334
344
 
345
+ # What the implementation carries beyond the selection, planned as PartialsManager plans it
346
+ carry = nil
347
+ unless implementation.nil?
348
+ carry = partializer.plan_carry(
349
+ test: 'PartialsGenerationTest', c_module: c_module, impl: implementation, interface: interface,
350
+ header_guarded: !include_guard.nil?, config: config
351
+ )
352
+ end
353
+
335
354
  generator.generate_implementation(
336
- test: 'PartialsGenerationTest',
337
355
  name: module_name,
338
356
  function_definitions: implementation || [],
339
357
  source_includes: source_list,
340
- header_includes: header_list,
358
+ header_includes: header_list.leading,
359
+ header_following_includes: header_list.following,
341
360
  c_module: c_module,
342
361
  output_path: dir,
343
- include_guard: include_guard
362
+ include_guard: include_guard,
363
+ carry: carry || Partials::CarryPlan.new,
364
+ suppress_redundant_decls: suppress_redundant_decls,
365
+ extern_variables: extern_variables
344
366
  )
345
367
 
368
+ # A mock-only Partial's interface keeps the rest of its real header in an extras header,
369
+ # planned as PartialsManager plans it
370
+ extras = nil
371
+ if implementation.nil? and !interface.nil?
372
+ extras = partializer.plan_interface_extras(
373
+ test: 'PartialsGenerationTest', c_module: c_module, interface: interface, header_guarded: !include_guard.nil?, config: config
374
+ )
375
+ end
376
+
346
377
  # The mockable interface header is what CMock mocks in place of the real module header,
347
378
  # and it carries the same types header the implementation header does. Both land in one
348
379
  # translation unit when a module is tested and mocked in the same test file.
349
380
  generator.generate_interface(
350
- test: 'PartialsGenerationTest',
351
381
  name: module_name,
352
382
  function_declarations: interface || [],
353
- includes: interface_list,
383
+ includes: interface_list.leading,
384
+ following_includes: interface_list.following,
354
385
  c_module: c_module,
355
386
  output_path: dir,
356
- include_guard: include_guard
387
+ include_guard: include_guard,
388
+ extras: extras
357
389
  )
358
390
 
359
391
  PartialsGeneration::Result.new(
@@ -364,30 +396,79 @@ module PartialsGenerationHelpers
364
396
  impl_h: read_generated( dir, "ceedling_partial_#{module_name}_impl.h" ),
365
397
  impl_c: read_generated( dir, "ceedling_partial_#{module_name}_impl.c" ),
366
398
  interface_h: read_generated( dir, "ceedling_partial_#{module_name}_interface.h" ),
367
- pp_header: pp_header,
368
- pp_source: pp_source
399
+ extras_h: read_generated( dir, "ceedling_partial_#{module_name}_extras.h" ),
400
+ pp_header: File.read( header_file.assembled_filepath, encoding: 'UTF-8' ),
401
+ pp_source: source_file.assembled_filepath && File.read( source_file.assembled_filepath, encoding: 'UTF-8' ),
402
+ carry: carry
369
403
  )
370
404
  end
371
405
 
372
- # Reproduces what Preprocessinator#preprocess_partial_{header,source}_file_preserve_macros
373
- # leaves on disk for the extractor to read, in the same steps and with the same
374
- # collaborators.
375
- #
376
- # The accurate path runs real GCC, which resolves every conditional and follows every
377
- # include while leaving macro directives as written. The fallback path never runs a
378
- # compiler: it scans the file's own text, tracking conditionals approximately, which is
379
- # why it resolves less and why Partials needs to refuse some shapes outright under it.
380
- def reconstitute_partial_file(dir:, filename:, kind:, includes:, defines: [], mode: :accurate)
406
+ # Preprocesses one module file as stages 6 and 7 do, and gives the record they fill in. The
407
+ # accurate path keeps a raw directives-only copy, which locates functions and marks inline
408
+ # bodies. Both paths keep a full expansion and its own lines as plain code, which
409
+ # reconciliation parses.
410
+ def preprocess_partial_file(dir:, filename:, kind:, includes:, defines:, mode:)
381
411
  path = File.join( dir, filename )
382
412
 
383
- contents, extras =
413
+ raw =
384
414
  case mode
385
- when :accurate then reconstitute_accurate( dir: dir, path: path, defines: defines )
386
- when :fallback then reconstitute_fallback( path: path, defines: defines )
415
+ when :accurate then directives_only( dir: dir, path: path, defines: defines )
416
+ when :fallback then nil
387
417
  else raise ArgumentError, "unknown preprocessing mode '#{mode}'"
388
418
  end
389
419
 
390
- assembled = File.join( dir, "preprocessed_#{filename}" )
420
+ raw_expansion, expansion = expand( dir: dir, path: path, defines: defines )
421
+
422
+ return Partials::ConfigFileInfo.new(
423
+ filepath: path, raw_directives_only_filepath: raw, raw_expansion_filepath: raw_expansion, expansion_filepath: expansion,
424
+ assembled_filepath: reconstitute_partial_file( dir: dir, filename: filename, kind: kind, includes: includes, raw: raw, defines: defines ),
425
+ fallback: raw.nil?, includes: partial_include_objects( includes )
426
+ )
427
+ end
428
+
429
+ # GCC's -fdirectives-only output with its comments stripped, as Preprocessinator#generate_directives_only_output
430
+ # leaves it. Defines reach every pass, as they do in production. Without them a case pairing
431
+ # `defines:` with accurate mode would silently measure the undefined configuration instead.
432
+ def directives_only(dir:, path:, defines:)
433
+ raw = "#{path}.directives_only"
434
+ run_partials_preprocessor( dir: dir, path: path, output: raw, defines: defines, flags: '-fdirectives-only' )
435
+ partials_comment_stripper.strip_file( raw )
436
+
437
+ return raw
438
+ end
439
+
440
+ # The full expansion and its own lines, as Preprocessinator#generate_partial_expansion writes them
441
+ def expand(dir:, path:, defines:)
442
+ raw = "#{path}.full_expansion"
443
+ code = "#{path}.expanded_code"
444
+ run_partials_preprocessor( dir: dir, path: path, output: raw, defines: defines )
445
+
446
+ contents = partials_file_assembler.collect_own_lines( source_filepath: path, preprocessed_filepath: raw )
447
+ partials_file_assembler.assemble_preprocessed_code_file( preprocessed_filepath: code, contents: contents, extras: [], includes: [] )
448
+
449
+ return raw, code
450
+ end
451
+
452
+ def run_partials_preprocessor(dir:, path:, output:, defines:, flags: '')
453
+ defines = defines.map { |name| "-D#{name}" }.join( ' ' )
454
+ command = "#{partials_compiler} -E #{flags} #{defines} -I#{dir} -x c #{path} -o #{output}".squeeze( ' ' )
455
+
456
+ _out, stderr, status = Open3.capture3( command )
457
+ raise PartialsGeneration::PreprocessFailure, "#{command}\n#{stderr}" unless status.success?
458
+ end
459
+
460
+ # Reproduces the assembled copy Preprocessinator#preprocess_partial_file leaves for the
461
+ # extractor, in the same steps and with the same collaborators, and gives its path.
462
+ #
463
+ # The accurate path reads GCC's directives-only output, which resolves every conditional and
464
+ # follows every include while leaving macro directives as written. The fallback path never
465
+ # runs a compiler: it scans the file's own text, tracking conditionals approximately, which
466
+ # is why it resolves less and why Partials needs to refuse some shapes outright under it.
467
+ def reconstitute_partial_file(dir:, filename:, kind:, includes:, raw:, defines:)
468
+ path = File.join( dir, filename )
469
+ contents, extras = raw ? reconstitute_accurate( path: path, raw: raw ) : reconstitute_fallback( path: path, defines: defines )
470
+
471
+ assembled = File.join( dir, "preprocessed_#{filename}" )
391
472
  include_list = partial_include_objects( includes )
392
473
 
393
474
  if kind == :header
@@ -397,53 +478,37 @@ module PartialsGenerationHelpers
397
478
  )
398
479
  else
399
480
  partials_file_assembler.assemble_preprocessed_code_file(
400
- filename: filename, preprocessed_filepath: assembled,
401
- contents: contents, extras: extras, includes: include_list
481
+ preprocessed_filepath: assembled, contents: contents, extras: extras, includes: include_list
402
482
  )
403
483
  end
404
484
 
405
- File.read( assembled, encoding: 'UTF-8' )
485
+ return assembled
406
486
  end
407
487
 
408
- # Only lines belonging to this file survive the reconstructor; a type arriving from an
409
- # included header is discarded here, which is why an extracted type can reference
410
- # something no generated file declares.
411
- def reconstitute_accurate(dir:, path:, defines: [])
412
- raw = "#{path}.directives_only"
413
-
414
- # Defines reach both passes, as they do in production. Without this a case pairing
415
- # `defines:` with accurate mode would silently measure the undefined configuration instead.
416
- flags = defines.map { |name| "-D#{name}" }.join( ' ' )
417
-
418
- command = "#{partials_compiler} -E -fdirectives-only #{flags} -I#{dir} -x c #{path} -o #{raw}".squeeze( ' ' )
419
- _out, stderr, status = Open3.capture3( command )
420
- raise PartialsGeneration::PreprocessFailure, "#{command}\n#{stderr}" unless status.success?
421
-
422
- partials_comment_stripper.strip_file( raw )
423
-
424
- contents = File.open( raw, 'rb' ) do |file|
425
- partials_reconstructor.extract_file_as_array_from_expansion( file, path )
426
- end
427
-
428
- [contents, []]
488
+ # Only lines belonging to this file survive. A type arriving from an included header is
489
+ # discarded here, which is why an extracted type can reference something no generated file
490
+ # declares. On Windows, GCC's directives-only output of a CRLF source ends each line in
491
+ # "\r\r\n", and the production reader's text mode keeps one line break, not two.
492
+ def reconstitute_accurate(path:, raw:)
493
+ return partials_file_assembler.collect_own_lines( source_filepath: path, preprocessed_filepath: raw, rejoin: false ), []
429
494
  end
430
495
 
431
496
  # Fallback strips every directive line out of the content, so the macros and pragmas the
432
497
  # extractor still needs are recovered separately and reinserted as assembler extras. That
433
498
  # second pass is what keeps a type's array-size macro visible when no compiler ran.
434
- def reconstitute_fallback(path:, defines: [])
435
- contents = partials_file_assembler.collect_file_contents_fallback(
436
- source_filepath: path, defines: defines
437
- )
438
- extras = partials_file_assembler.collect_macros_and_pragmas_fallback(
439
- source_filepath: path, defines: defines
440
- )
499
+ def reconstitute_fallback(path:, defines:)
500
+ contents = partials_file_assembler.collect_file_contents_fallback( source_filepath: path, defines: defines )
501
+ extras = partials_file_assembler.collect_macros_and_pragmas_fallback( source_filepath: path, defines: defines )
441
502
 
442
- [contents, extras]
503
+ return contents, extras
443
504
  end
444
505
 
445
506
  # ---- compilation -------------------------------------------------------------
446
507
 
508
+ # GCC before 14 only warns about a call to an undeclared function, as Clang does not. A
509
+ # missing prototype has to fail on every compiler for a case about carrying one to mean anything.
510
+ STRICT_DECLARATIONS = '-Werror=implicit-function-declaration' unless const_defined?( :STRICT_DECLARATIONS )
511
+
447
512
  # Compiles a translation unit that includes the generated implementation header, the way a
448
513
  # generated test runner would. Syntax-only: this probes declarations and ordering, not code
449
514
  # generation.
@@ -468,6 +533,15 @@ module PartialsGenerationHelpers
468
533
  syntax_only( result, probe )
469
534
  end
470
535
 
536
+ # Compiles a translation unit that includes the generated interface header, the way the mock
537
+ # CMock generates from it includes it
538
+ def compile_interface(result)
539
+ probe = File.join( result.dir, "probe_#{result.module_name}_interface.c" )
540
+ File.write( probe, "#include \"ceedling_partial_#{result.module_name}_interface.h\"\nint main(void) { return 0; }\n" )
541
+
542
+ syntax_only( result, probe )
543
+ end
544
+
471
545
  # Compiles the types header entirely on its own, which is the question of whether that
472
546
  # header is self-contained. Nothing else is included first.
473
547
  def compile_types_header_alone(result)
@@ -478,7 +552,7 @@ module PartialsGenerationHelpers
478
552
  end
479
553
 
480
554
  def syntax_only(result, probe)
481
- command = "#{partials_compiler} -fsyntax-only -I#{result.dir} #{probe}"
555
+ command = "#{partials_compiler} #{STRICT_DECLARATIONS} -fsyntax-only -I#{result.dir} #{probe}"
482
556
  _out, stderr, status = Open3.capture3( command )
483
557
 
484
558
  PartialsGeneration::Compilation.new( ok: status.success?, stderr: stderr, command: command )
@@ -493,12 +567,13 @@ module PartialsGenerationHelpers
493
567
  # of`, so stripping `static` from a file-scope variable -- which turns a module-private
494
568
  # name into one that participates in link-time resolution -- is testable only here.
495
569
 
496
- # Compiles one result's generated implementation source to a real object file.
497
- def compile_objects(result)
570
+ # Compiles one result's generated implementation source to a real object file. `flags`
571
+ # reach the compiler as given, so a case can hold the source to a warning set.
572
+ def compile_objects(result, flags: '')
498
573
  object = File.join( result.dir, "ceedling_partial_#{result.module_name}_impl.o" )
499
574
  source = File.join( result.dir, "ceedling_partial_#{result.module_name}_impl.c" )
500
575
 
501
- command = "#{partials_compiler} -c -I#{result.dir} #{source} -o #{object}"
576
+ command = "#{partials_compiler} #{STRICT_DECLARATIONS} #{flags} -c -I#{result.dir} #{source} -o #{object}".squeeze( ' ' )
502
577
  _out, stderr, status = Open3.capture3( command )
503
578
 
504
579
  PartialsGeneration::Compilation.new( ok: status.success?, stderr: stderr, command: command )
@@ -507,7 +582,10 @@ module PartialsGenerationHelpers
507
582
  # Links one or more results' generated implementations against a stand-in test translation
508
583
  # unit. The stand-in takes the address of each named symbol so the linker has to resolve
509
584
  # it; a symbol that merely compiles is not proof the definition survived.
510
- def link_partials(results, references: [])
585
+ #
586
+ # `stubs` is C the stand-in test file defines, the way a real test defines a stub for a
587
+ # function it subtracted. `flags` reach the compiler as given.
588
+ def link_partials(results, references: [], stubs: '', flags: '')
511
589
  results = Array( results )
512
590
  dir = results.first.dir
513
591
 
@@ -521,20 +599,20 @@ module PartialsGenerationHelpers
521
599
  end
522
600
 
523
601
  probe = File.join( dir, "probe_link_#{results.map( &:module_name ).join( '_' )}.c" )
524
- File.write( probe, "#{headers.join( "\n" )}\nint main(void) {\n#{body}\n}\n" )
602
+ File.write( probe, "#{headers.join( "\n" )}\n#{stubs}\nint main(void) {\n#{body}\n}\n" )
525
603
 
526
604
  sources = results.map { |r| File.join( r.dir, "ceedling_partial_#{r.module_name}_impl.c" ) }
527
605
  includes = results.map( &:dir ).uniq.map { |d| "-I#{d}" }.join( ' ' )
528
606
  output = File.join( dir, "probe_link_#{results.map( &:module_name ).join( '_' )}" )
529
607
 
530
- command = "#{partials_compiler} #{includes} #{probe} #{sources.join( ' ' )} -o #{output}"
608
+ command = "#{partials_compiler} #{STRICT_DECLARATIONS} #{flags} #{includes} #{probe} #{sources.join( ' ' )} -o #{output}".squeeze( ' ' )
531
609
  _out, stderr, status = Open3.capture3( command )
532
610
 
533
611
  PartialsGeneration::Compilation.new( ok: status.success?, stderr: stderr, command: command )
534
612
  end
535
613
 
536
- def link_partial(result, references: [])
537
- link_partials( [result], references: references )
614
+ def link_partial(result, references: [], stubs: '', flags: '')
615
+ link_partials( [result], references: references, stubs: stubs, flags: flags )
538
616
  end
539
617
 
540
618
  # A `partials:` entry for some *other* partialized module in the same test file. The remap
@@ -570,6 +648,12 @@ module PartialsGenerationHelpers
570
648
  ENV.fetch( 'PARTIALS_GENERATION_CC', 'gcc' )
571
649
  end
572
650
 
651
+ # Clang answers to `gcc` on macOS, and some warnings only GCC reports
652
+ def partials_compiler_gcc?
653
+ @partials_compiler_gcc = !`#{partials_compiler} --version 2>&1`.match?( /clang/i ) if @partials_compiler_gcc.nil?
654
+ return @partials_compiler_gcc
655
+ end
656
+
573
657
  # ---- construction -------------------------------------------------------------
574
658
 
575
659
  # `<name>` is a system header, everything else a user header -- the distinction
@@ -585,6 +669,12 @@ module PartialsGenerationHelpers
585
669
  end
586
670
 
587
671
  def extract_c(content)
672
+ partials_c_extractor.from_string( content: content )
673
+ end
674
+
675
+ # A real extractor that reads files with a real file wrapper, as Partializer reads the
676
+ # assembled copies and reconciliation reads the expanded code
677
+ def partials_c_extractor
588
678
  code_text = CExtractorCodeText.new
589
679
  declarations = CExtractorDeclarations.new({ c_extractor_code_text: code_text })
590
680
  functions = CExtractorFunctions.new({ c_extractor_code_text: code_text })
@@ -604,11 +694,11 @@ module PartialsGenerationHelpers
604
694
  # length, as c_extractor_composition_spec.rb does.
605
695
  configurator: RSpec::Mocks::Double.new( 'Configurator' ),
606
696
  loginator: RSpec::Mocks::Double.new( 'Loginator' ).as_null_object,
607
- file_wrapper: RSpec::Mocks::Double.new( 'FileWrapper' ).as_null_object
697
+ file_wrapper: partials_file_wrapper
608
698
  }
609
699
  )
610
700
  extractor.setup()
611
- extractor.from_string( content: content )
701
+ extractor
612
702
  end
613
703
 
614
704
  def build_partials_generator
@@ -626,36 +716,36 @@ module PartialsGenerationHelpers
626
716
  def build_partializer
627
717
  Partializer.new(
628
718
  {
629
- configurator: RSpec::Mocks::Double.new( 'Configurator' ).as_null_object,
630
- partializer_helper: partials_helper,
631
- file_finder: RSpec::Mocks::Double.new( 'FileFinder' ).as_null_object,
632
- c_extractor: RSpec::Mocks::Double.new( 'CExtractor' ).as_null_object,
633
- file_path_utils: partials_file_path_utils,
719
+ configurator: RSpec::Mocks::Double.new( 'Configurator' ).as_null_object,
720
+ partializer_helper: partials_helper,
721
+ partializer_reconciler: PartializerReconciler.new( c_extractor: partials_c_extractor, loginator: partials_null_loginator ),
722
+ file_finder: RSpec::Mocks::Double.new( 'FileFinder' ).as_null_object,
723
+ c_extractor: partials_c_extractor,
724
+ file_path_utils: partials_file_path_utils,
634
725
  preprocessinator_reconstructor: partials_reconstructor,
635
- file_wrapper: partials_file_wrapper,
636
- reportinator: RSpec::Mocks::Double.new( 'Reportinator' ).as_null_object,
637
- loginator: partials_null_loginator
726
+ file_wrapper: partials_file_wrapper,
727
+ reportinator: RSpec::Mocks::Double.new( 'Reportinator' ).as_null_object,
728
+ loginator: partials_null_loginator
638
729
  }
639
730
  )
640
731
  end
641
732
 
642
- # One instance per case, memoized so the promotion pass and the extraction passes share
643
- # state. The code finder stays doubled: it serves only line-number association, which this
644
- # harness skips. Wiring mirrors partializer_helper_spec.rb's own end-to-end context.
733
+ # One instance per case, memoized so extraction and the later passes share state. Every
734
+ # collaborator is real, so selected bodies and carried items alike carry the #line a build
735
+ # gives them.
645
736
  def partials_helper
646
737
  @partials_helper ||= PartializerHelper.new(
647
738
  {
739
+ # A real finder, so a carried prototype's #line names its true line and reaches the compiler
648
740
  partializer_utils: PartializerUtils.new(
649
741
  {
650
- preprocessinator_code_finder: RSpec::Mocks::Double.new( 'CodeFinder' ).as_null_object,
742
+ preprocessinator_code_finder: PreprocessinatorCodeFinder.new( { file_wrapper: partials_file_wrapper } ),
651
743
  loginator: partials_null_loginator
652
744
  }
653
745
  ),
654
- c_extractor: RSpec::Mocks::Double.new( 'CExtractor' ).as_null_object,
655
746
  c_extractor_declarations: CExtractorDeclarations.new(
656
747
  { c_extractor_code_text: CExtractorCodeText.new }
657
748
  ).tap( &:setup ),
658
- file_path_utils: partials_file_path_utils,
659
749
  parsing_parcels: ParsingParcels.new,
660
750
  loginator: partials_null_loginator
661
751
  }
@@ -674,7 +764,7 @@ module PartialsGenerationHelpers
674
764
  )
675
765
  end
676
766
 
677
- # Of the eight collaborators, the assemble and fallback-collect methods used here consult
767
+ # Of the nine collaborators, the assemble and fallback-collect methods used here consult
678
768
  # only the reconstructor, the file wrapper, and parsing parcels; the rest serve collection
679
769
  # methods the harness drives itself.
680
770
  def partials_file_assembler
@@ -687,7 +777,8 @@ module PartialsGenerationHelpers
687
777
  file_wrapper: partials_file_wrapper,
688
778
  parsing_parcels: ParsingParcels.new,
689
779
  loginator: partials_null_loginator,
690
- reportinator: RSpec::Mocks::Double.new( 'Reportinator' ).as_null_object
780
+ reportinator: RSpec::Mocks::Double.new( 'Reportinator' ).as_null_object,
781
+ build_step_doctor: RSpec::Mocks::Double.new( 'BuildStepDoctor' ).as_null_object
691
782
  }
692
783
  )
693
784
  end
@@ -696,10 +787,15 @@ module PartialsGenerationHelpers
696
787
  FileWrapper.new( loginator: partials_null_loginator, verbosinator: partials_null_verbosinator )
697
788
  end
698
789
 
790
+ # Partializer names generated files with it. Each record carries its preprocessed paths, so
791
+ # no build tree is needed.
699
792
  def partials_file_path_utils
793
+ configurator = RSpec::Mocks::Double.new( 'Configurator', project_test_preprocess_files_path: '/no/preprocessed/files' ).as_null_object
794
+
700
795
  FilePathUtils.new(
701
- configurator: RSpec::Mocks::Double.new( 'Configurator' ).as_null_object,
702
- file_wrapper: partials_file_wrapper
796
+ configurator: configurator,
797
+ file_wrapper: partials_file_wrapper,
798
+ test_build_layout: TestBuildLayout.new( configurator: configurator, file_wrapper: partials_file_wrapper )
703
799
  )
704
800
  end
705
801