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
@@ -5,8 +5,10 @@
5
5
  # SPDX-License-Identifier: MIT
6
6
  # =========================================================================
7
7
 
8
+ require 'set'
8
9
  require 'ceedling/constants'
9
10
  require 'ceedling/exceptions'
11
+ require 'ceedling/filesystem/file_path_utils'
10
12
  require 'ceedling/test_invoker/test_invoker_types'
11
13
  require 'ceedling/test_invoker/test_pipeline_helpers'
12
14
 
@@ -29,28 +31,68 @@ class TestBuildExecutor
29
31
  :dependinator,
30
32
  :gcc_dependency_parser,
31
33
  :quote_include_isolator,
32
- :generator_helper,
34
+ :test_substitutions,
35
+ :build_step_doctor,
33
36
  :library_resolver,
34
- :mock_locator
37
+ :mock_locator,
38
+ :test_search_paths
35
39
  )
36
40
 
41
+ # The endings a header copy and its mock take while set aside, which no header search finds
42
+ HELD_COPY_SUFFIX = '.held'
43
+ HELD_MOCK_SUFFIX = '.held_mock'
44
+
45
+ # Before stage 4: sets aside each copy of a header in a test's mock root, and the mock beside
46
+ # it, under names no search finds. Under :treat_inlines :include, CMock and an FFF fake write a
47
+ # copy of a mock's header beside it. Stage 4 preprocesses the test through its mock root before
48
+ # any mock is planned, so a copy would stand in for its header there. CMock's mock includes the
49
+ # header by a text that may reach only the copy, so stage 4 places a stand-in in the mock's
50
+ # place, as on a first build. A copy is a header with its mock beside it, since no build
51
+ # removes a mock. No test's mock root lies below another's, so a root holds its own test's files.
52
+ def stage_hold_header_copies(state)
53
+ run_mock_roots( state ).each do |root|
54
+ each_copy( root ) do |copy|
55
+ mock = mock_beside( copy )
56
+ @file_wrapper.mv( copy, copy + HELD_COPY_SUFFIX )
57
+ @file_wrapper.mv( mock, mock + HELD_MOCK_SUFFIX )
58
+ end
59
+ end
60
+ end
61
+
62
+ # Before stage 9: puts back every mock set aside before stage 4, over the stand-in stage 4
63
+ # placed, and the copies a current mock writes, and removes every other copy. The mock root
64
+ # stays on the test's search path, with or without mocks, so a copy that outlives its mock
65
+ # shadows the header.
66
+ def stage_prune_header_copies(state)
67
+ keep = mock_files( state.mocks_list ) + header_copies( state.mocks_list )
68
+
69
+ run_mock_roots( state ).each do |root|
70
+ restore_held_copies( root, keep )
71
+ each_copy( root ) { |copy| @file_wrapper.rm_f( copy ) unless keep.include?( copy ) }
72
+ end
73
+ end
74
+
37
75
  # Stage 9: Preprocess header files to be mocked.
76
+ #
77
+ # A Partial mock is left out. CMock reads its generated interface header itself.
78
+ #
79
+ # Each header is read through its test's Partial directories and header paths, as the compiler
80
+ # finds real headers. The mock root holds CMock's copies of headers, which stage 10 brings up
81
+ # to date only after this stage. The headers a mocked header's full expansion entered are its
82
+ # dependencies.
38
83
  def stage_preprocess_mocks(state)
39
- directives_only = @configurator.test_build_preprocess_directives_only_available
40
- skipped = 0
41
-
42
- # Register every mock's preprocessed-header target and settle its staleness
43
- # up front (sequentially -- cheap, no subprocess work), since it gates both
44
- # of the parallel batches below.
45
- state.mocks_list.each do |mock|
84
+ directives_only = @configurator.test_build_preprocess_directives_only_available
85
+ extras = (@configurator.cmock_treat_inlines == :include)
86
+ mocks = state.mocks_list.reject { |mock| mock.details.partial }
87
+ preprocess_paths = test_mock_preprocess_paths( mocks )
88
+ skipped = 0
89
+
90
+ # Each remaining mock's target is registered and its staleness settled first. That
91
+ # staleness gates both parallel batches below, and settling it runs no subprocess.
92
+ mocks.each do |mock|
46
93
  details = mock.details
47
94
  testable = mock.testable
48
95
 
49
- # A Partial mock's own generated header is already free of inline function
50
- # bodies, so it never needs this extra pass regardless of what the project
51
- # configures for CMock's own mocks of real headers elsewhere.
52
- extras = !details.partial && (@configurator.cmock_treat_inlines == :include)
53
-
54
96
  target = @file_path_utils.form_preprocessed_file_filepath( details.source, testable.name )
55
97
 
56
98
  @dependinator.register(
@@ -59,13 +101,19 @@ class TestBuildExecutor
59
101
  meta: {
60
102
  flags: testable.preprocess_flags,
61
103
  defines: testable.preprocess_defines,
62
- search_paths: testable.search_paths,
104
+ search_paths: preprocess_paths[testable.name],
63
105
  extras: extras,
64
- tools: [@configurator.tools_test_bare_includes_preprocessor, @configurator.tools_test_file_directives_only_preprocessor],
106
+ tools: [
107
+ @configurator.tools_test_bare_includes_preprocessor,
108
+ @configurator.tools_test_file_directives_only_preprocessor,
109
+ @configurator.tools_test_file_full_preprocessor
110
+ ],
65
111
  preprocess_force_fallback: @configurator.test_build_preprocess_force_fallback
66
112
  }
67
113
  )
68
114
 
115
+ register_previous_expansion( target, mock )
116
+
69
117
  mock.preprocessed_target = target
70
118
  mock.stale = @dependinator.stale?( target )
71
119
 
@@ -83,7 +131,7 @@ class TestBuildExecutor
83
131
  log_skip_summary( task: "mock preprocessing", count: skipped, noun: "mocks" )
84
132
 
85
133
  # Generate directive-only preprocessor output if available
86
- @batchinator.exec(workload: :compile, things: state.mocks_list) do |mock|
134
+ @batchinator.exec(workload: :compile, things: mocks) do |mock|
87
135
  next unless mock.stale
88
136
 
89
137
  details = mock.details
@@ -95,29 +143,22 @@ class TestBuildExecutor
95
143
  filepath: filepath,
96
144
  test: name,
97
145
  flags: testable.preprocess_flags,
98
- include_paths: testable.search_paths,
146
+ include_paths: preprocess_paths[name],
99
147
  vendor_paths: vendor_search_paths(),
100
148
  defines: testable.preprocess_defines
101
149
  }
102
150
 
103
- _filepath = @preprocessinator.generate_directives_only_output( **arg_hash )
104
-
105
- if _filepath.nil?
106
- msg = "Failed to generate directive-only preprocessor output (fallback methods will be used) for #{filepath}"
107
- @loginator.log( msg, Verbosity::COMPLAIN )
108
- end
109
-
110
- mock.directives_only_filepath = _filepath
151
+ # Nil when the preprocessor fails. Preprocessinator logs the warning.
152
+ mock.directives_only_filepath = @preprocessinator.generate_directives_only_output( **arg_hash )
111
153
  end if directives_only
112
154
 
113
155
  # Preprocess and assemble header files to be mocked
114
- @batchinator.exec(workload: :compile, things: state.mocks_list) do |mock|
156
+ @batchinator.exec(workload: :compile, things: mocks) do |mock|
115
157
  next unless mock.stale
116
158
 
117
159
  details = mock.details
118
160
  testable = mock.testable
119
161
  directives_only_filepath = mock.directives_only_filepath
120
- extras = !details.partial && (@configurator.cmock_treat_inlines == :include)
121
162
 
122
163
  arg_hash = {
123
164
  test: testable.name,
@@ -125,14 +166,16 @@ class TestBuildExecutor
125
166
  directives_only_filepath: directives_only_filepath,
126
167
  fallback: directives_only_fallback?( directives_only, directives_only_filepath ),
127
168
  flags: testable.preprocess_flags,
128
- include_paths: testable.search_paths,
169
+ include_paths: preprocess_paths[testable.name],
129
170
  vendor_paths: vendor_search_paths(),
130
171
  defines: testable.preprocess_defines,
131
- extras: extras
172
+ extras: extras,
173
+ include_search: @mock_locator.header_search( testable )
132
174
  }
133
175
 
134
176
  @preprocessinator.preprocess_mockable_header_file( **arg_hash )
135
177
 
178
+ register_preprocessed_dependencies( mock.preprocessed_target, full_expansion( mock ) )
136
179
  @dependinator.mark_fresh( mock.preprocessed_target )
137
180
  end
138
181
  end
@@ -142,8 +185,12 @@ class TestBuildExecutor
142
185
  # get_cmock_config, not project_config_hash[:cmock]: project_config_hash is
143
186
  # flattened -- CMock's own settings live there as individual top-level keys
144
187
  # like :cmock_mock_prefix, not as a :cmock section -- so this is the only
145
- # place that still holds CMock's configuration as a single value to compare.
146
- cmock_meta = @configurator.get_cmock_config
188
+ # place that still holds CMock's configuration as a single value to compare. Verbosity
189
+ # changes only what CMock prints, and Generator sets it anew for each mock. The class
190
+ # that writes the mock is recorded too, since a plugin such as FFF can take CMock's place.
191
+ cmock_meta = @configurator.get_cmock_config.except( :verbosity )
192
+ generator = @generator.mock_generator_name
193
+ produced = mock_files( state.mocks_list )
147
194
  skipped = 0
148
195
 
149
196
  @batchinator.exec(workload: :compile, things: state.mocks_list) do |mock|
@@ -162,16 +209,24 @@ class TestBuildExecutor
162
209
  # `details.name` (a String), not `mock.name` (the Symbol key T2 carried
163
210
  # the same value in for hash lookups) -- needed here as a real filename.
164
211
  target = File.join( output_path, details.name + EXTENSION_CORE_SOURCE )
165
- mock_header = File.join( output_path, details.name + EXTENSION_CORE_HEADER )
212
+ mock_header = File.join( output_path, details.name + mock_header_extension( details ) )
166
213
 
167
214
  # CMock writes `mock_header` in the same call as `target`, so the mock vouches for
168
215
  # it as an output. Stage 4 places a stand-in at this exact path when no file is
169
216
  # there or an earlier stand-in is out of date (StandinHeaderinator), independent of
170
217
  # this mock's antecedents. The recorded hash catches a stand-in in the mock's place
171
218
  # and regenerates the mock.
172
- @dependinator.register( target, files: [details.input], meta: { cmock: cmock_meta }, outputs: [mock_header] )
173
-
174
- unless @dependinator.stale?( target )
219
+ #
220
+ # CMock names the mock by its folder, which an #include can change while the mock's
221
+ # place stays. A mock with no folder records nil, since a record holding no folder
222
+ # can't tell it from one named by a folder the record never held. A respelling of the
223
+ # real header's #include (MockLocator#header_respelling) follows the test's search
224
+ # paths, which CMock's configuration doesn't hold. Both are recorded too.
225
+ meta = { cmock: cmock_meta, generator: generator, folder: placement.folder }
226
+ meta[:header_include] = details.header_include if details.header_include
227
+ @dependinator.register( target, files: [details.input], meta: meta, outputs: [mock_header] )
228
+
229
+ unless @dependinator.stale?( target ) or missing_header_copy?( details, output_path, produced )
175
230
  msg = @reportinator.generate_module_progress(
176
231
  operation: 'Skipping mock generation for',
177
232
  module_name: testable.name,
@@ -185,8 +240,9 @@ class TestBuildExecutor
185
240
  # A Partial mock's own generated header is already free of inline function
186
241
  # bodies -- CMock's own inline handling has nothing to do on it and is
187
242
  # skipped for this one mock, independent of whatever the project configures
188
- # for CMock's own mocks of real headers elsewhere in the same test suite.
189
- overrides = details.partial ? { treat_inlines: :exclude } : {}
243
+ # for CMock's own mocks of real headers elsewhere in the same test suite. The helpers a
244
+ # mock-only Partial keeps sit in its extras header, whose #include CMock skips.
245
+ overrides = details.partial ? { treat_inlines: :exclude } : header_include_overrides( details.header_include )
190
246
 
191
247
  arg_hash = {
192
248
  context: state.context,
@@ -199,6 +255,7 @@ class TestBuildExecutor
199
255
  overrides: overrides
200
256
  }
201
257
 
258
+ discard_header_copy( details, output_path, produced ) unless details.partial
202
259
  @generator.generate_mock( **arg_hash )
203
260
 
204
261
  @dependinator.mark_fresh( target )
@@ -230,7 +287,7 @@ class TestBuildExecutor
230
287
  # `compile_pass.call( test_file_pairs )` fully drains (Parallel.map blocks until
231
288
  # every thread in that call is done) before `compile_pass.call( other_pairs )`
232
289
  # even starts. That's what makes apply_sibling_isolation's unguarded writes to
233
- # testable.search_paths/isolated_headers_path safe: the only thread that ever
290
+ # testable.search_paths/header_isolation safe: the only thread that ever
234
291
  # writes them is the one compiling that test's own file, in the first batch, and
235
292
  # every thread reading them afterward starts only once that write has already
236
293
  # happened. Merging or reordering these two calls -- e.g. to parallelize them
@@ -264,21 +321,27 @@ class TestBuildExecutor
264
321
  end
265
322
  end
266
323
 
267
- compile_pass.call( test_file_pairs )
268
- compile_pass.call( other_pairs )
269
-
270
- # Any isolated sibling-header copy staged for a testable during either batch
271
- # above was scoped to this one build and never registered as a tracked
272
- # dependency in its own right (see isolate_sibling_headers) -- nothing past
273
- # this point still needs it to exist.
274
- state.testables.each_value do |testable|
275
- next if testable.isolated_headers_path.nil?
276
- @quote_include_isolator.release( testable.isolated_headers_path )
324
+ begin
325
+ compile_pass.call( test_file_pairs )
326
+ compile_pass.call( other_pairs )
327
+ ensure
328
+ release_header_isolations( state )
277
329
  end
278
330
 
279
331
  log_skip_summary( task: "compilation", count: skipped, noun: "objects" )
280
332
  end
281
333
 
334
+ # Any isolated sibling-header copy staged for a testable during either compile batch
335
+ # was scoped to this one build and is never a tracked dependency in its own right (see
336
+ # isolate_sibling_headers). Nothing past the compile stage still needs it, whether the
337
+ # stage finished or failed.
338
+ def release_header_isolations(state)
339
+ state.testables.each_value do |testable|
340
+ next if testable.header_isolation.nil?
341
+ @quote_include_isolator.release( testable.header_isolation.dir )
342
+ end
343
+ end
344
+
282
345
  # Stage 16: Link test executables.
283
346
  def stage_build_executables(state)
284
347
  lib_args = convert_libraries_to_arguments()
@@ -312,7 +375,8 @@ class TestBuildExecutor
312
375
  flags: link_flags,
313
376
  lib_args: lib_args,
314
377
  lib_paths: lib_paths,
315
- tool: tool
378
+ tool: tool,
379
+ testable: testable
316
380
  }
317
381
 
318
382
  generate_executable( **arg_hash )
@@ -490,8 +554,11 @@ class TestBuildExecutor
490
554
  }
491
555
  end
492
556
 
493
- def generate_executable(context:, build_path:, executable:, objects:, flags:, lib_args:, lib_paths:, tool:)
494
- begin
557
+ # A failed link goes to the build step doctor before it is raised
558
+ def generate_executable(context:, build_path:, executable:, objects:, flags:, lib_args:, lib_paths:, tool:, testable:)
559
+ inputs = { tool: tool, objects: objects, executable: executable, flags: flags, lib_args: lib_args, lib_paths: lib_paths, testable: testable }
560
+
561
+ @build_step_doctor.attend( step: :link, inputs: inputs ) do
495
562
  @generator.generate_executable_file(
496
563
  tool,
497
564
  context,
@@ -502,37 +569,6 @@ class TestBuildExecutor
502
569
  lib_args,
503
570
  lib_paths
504
571
  )
505
- rescue ShellException => ex
506
- if ex.shell_result[:output].match?(/symbol/i)
507
- notice = "If the linker reports missing symbols, the following may be to blame:\n" +
508
- " 1. This test lacks #include statements corresponding to needed source files (see note below).\n" +
509
- " 2. Project file paths omit source files corresponding to #include statements in this test.\n" +
510
- " 3. Complex macros, #ifdefs, etc. have obscured correct #include statements in this test.\n" +
511
- " 4. Your project is attempting to mix C++ and C file extensions (not supported).\n"
512
- if @configurator.project_use_mocks
513
- notice += " 5. This test does not #include needed mocks (that triggers their generation).\n"
514
- end
515
-
516
- notice += "\n"
517
- notice += "NOTE: A test file directs the build of a test executable with #include statements:\n" +
518
- " * By convention, Ceedling assumes header filenames correspond to source filenames.\n" +
519
- " * Which code files to compile and link are determined by #include statements.\n"
520
- if @configurator.project_use_mocks
521
- notice += " * An #include statement convention directs the generation of mocks from header files.\n"
522
- end
523
-
524
- notice += "\n"
525
- notice += "OPTIONS:\n" +
526
- " 1. Doublecheck this test's #include statements.\n" +
527
- " 2. Simplify complex macros or fully specify symbols for this test in :project ↳ :defines.\n" +
528
- " 3. If no header file corresponds to the needed source file, use the TEST_SOURCE_FILE()\n" +
529
- " build directive macro in this test to inject a source file into the build.\n\n" +
530
- "See the docs on conventions, paths, preprocessing, compilation symbols, and build directive macros.\n\n"
531
-
532
- @loginator.log( notice, Verbosity::COMPLAIN, LogLabels::NOTICE )
533
- end
534
-
535
- raise ex
536
572
  end
537
573
  end
538
574
 
@@ -567,16 +603,143 @@ class TestBuildExecutor
567
603
  return ((@configurator.project_config_hash[:libraries_test] || []) + ((defined? LIBRARIES_SYSTEM) ? LIBRARIES_SYSTEM : [])).flatten
568
604
  end
569
605
 
606
+ # Each test's mock preprocess paths by its name, composed once for all its mocks
607
+ def test_mock_preprocess_paths(mocks)
608
+ paths = {}
609
+ mocks.each { |mock| paths[mock.testable.name] ||= @test_search_paths.mock_preprocess_paths( mock.testable ) }
610
+ return paths
611
+ end
612
+
613
+ # Where stage 9 writes a mocked header's full expansion. Its line markers name each file it entered.
614
+ def full_expansion(mock)
615
+ return @file_path_utils.form_preprocessed_file_full_expansion_filepath( mock.details.source, mock.testable.name )
616
+ end
617
+
618
+ # Registers the headers the previous run's expansion entered, so an edit to one makes the target stale
619
+ def register_previous_expansion(target, mock)
620
+ expansion = full_expansion( mock )
621
+ register_preprocessed_dependencies( target, expansion ) if @file_wrapper.exist?( expansion )
622
+ end
623
+
624
+ # Where CMock under :treat_inlines :include, or an FFF fake, writes a copy of the header it
625
+ # reads: beside the mock, named as that header. Nil where a mock's own file is at that path
626
+ # (`produced`), as when a real header is named like another mock, or the input itself is.
627
+ def header_copy(details, output_path, produced)
628
+ copy = File.join( output_path, File.basename( details.input ) )
629
+ return (produced.include?( copy ) or copy == details.input) ? nil : copy
630
+ end
631
+
632
+ # Whether a mock under :treat_inlines :include is missing its copy. The mock would then include
633
+ # the header itself, inline function bodies and all.
634
+ def missing_header_copy?(details, output_path, produced)
635
+ return false if details.partial or @configurator.cmock_treat_inlines != :include
636
+
637
+ copy = header_copy( details, output_path, produced )
638
+ return (!copy.nil? and !@file_wrapper.exist?( copy ))
639
+ end
640
+
641
+ # A generation without :include writes no copy, and an earlier one would stay for the mock's
642
+ # #include to reach. One under :include writes a current copy in the same call that needs it.
643
+ def discard_header_copy(details, output_path, produced)
644
+ copy = header_copy( details, output_path, produced )
645
+ @file_wrapper.rm_f( copy ) if copy and @file_wrapper.exist?( copy )
646
+ end
647
+
648
+ # Every mock's source and header, where stage 10 writes them
649
+ def mock_files(mocks)
650
+ return mocks.each_with_object( Set.new ) do |mock, files|
651
+ directory = mock_directory( mock )
652
+ [EXTENSION_CORE_SOURCE, mock_header_extension( mock.details )].each { |ext| files << File.join( directory, mock.details.name + ext ) }
653
+ end
654
+ end
655
+
656
+ # The extension of a mock's header, the one its #include names, as CMock names the mock by
657
+ # its header's own extension
658
+ def mock_header_extension(details)
659
+ ext = File.extname( details.include_path.to_s )
660
+ return ext.empty? ? EXTENSION_CORE_HEADER : ext
661
+ end
662
+
663
+ # Where each non-Partial mock's copy of its header goes under :treat_inlines :include
664
+ def header_copies(mocks)
665
+ return mocks.each_with_object( Set.new ) do |mock, copies|
666
+ copies << File.join( mock_directory( mock ), File.basename( mock.details.input ) ) unless mock.details.partial
667
+ end
668
+ end
669
+
670
+ def mock_directory(mock)
671
+ details = mock.details
672
+ return @mock_locator.placement( mocks_root: mock.testable.paths[:mocks], subdir: details.path, include_path: details.include_path ).directory
673
+ end
674
+
675
+ # Yields each copy below `root`, a header with its mock beside it
676
+ def each_copy(root)
677
+ headers = root_headers( root )
678
+ listed = headers.to_set
679
+ headers.each do |path|
680
+ yield( path ) if listed.include?( mock_beside( path ) )
681
+ end
682
+ end
683
+
684
+ # Puts each mock set aside below `root` back, and each copy where `keep` names it, removing
685
+ # the other copies
686
+ def restore_held_copies(root, keep)
687
+ each_held( root, HELD_MOCK_SUFFIX ) { |held, mock| @file_wrapper.mv( held, mock ) }
688
+ each_held( root, HELD_COPY_SUFFIX ) do |held, copy|
689
+ keep.include?( copy ) ? @file_wrapper.mv( held, copy ) : @file_wrapper.rm_f( held )
690
+ end
691
+ end
692
+
693
+ # Yields each file set aside below `root` with `suffix`, and its own path
694
+ def each_held(root, suffix)
695
+ @file_wrapper.directory_listing( FilePathUtils.glob( root, '**', "*#{suffix}" ) ).each do |path|
696
+ yield( path, path.delete_suffix( suffix ) )
697
+ end
698
+ end
699
+
700
+ # The header of the mock CMock writes beside a copy of the header at `path`, with the header's
701
+ # own extension. A header named as its own mock, with no prefix or suffix, has none.
702
+ def mock_beside(path)
703
+ ext = File.extname( path )
704
+ mock = File.join( File.dirname( path ), @configurator.cmock_mock_prefix + File.basename( path, ext ) + @configurator.cmock_mock_suffix + ext )
705
+ return mock == path ? nil : mock
706
+ end
707
+
708
+ # The mock root of each test this run builds
709
+ def run_mock_roots(state)
710
+ return state.testables.each_value.filter_map { |testable| testable.paths[:mocks] }.uniq
711
+ end
712
+
713
+ # Every header below a mock root
714
+ def root_headers(root)
715
+ return @configurator.extension_header.flat_map do |ext|
716
+ @file_wrapper.directory_listing( FilePathUtils.glob( root, '**', "*#{ext}" ) )
717
+ end
718
+ end
719
+
720
+ # The settings that have a mock include its real header by `header_include` in place of
721
+ # CMock's own text. `:orig_header_include` is Ceedling's, which CMock ignores and an FFF
722
+ # fake reads. CMock keeps its own text under an :orig_header_include_fmt that takes no
723
+ # respelling. It keeps it under :treat_inlines :include too, where its text reaches the copy
724
+ # of the header it writes beside the mock. A fake writes no format.
725
+ def header_include_overrides(header_include)
726
+ return {} if header_include.nil?
727
+
728
+ overrides = { orig_header_include: header_include }
729
+ return overrides if @configurator.cmock_treat_inlines == :include or !@mock_locator.respellable_format?
730
+
731
+ return overrides.merge( orig_header_include_fmt: @mock_locator.header_include_line( header_include ) )
732
+ end
733
+
570
734
  # Compile a single C or assembly source file into an object file. Returns
571
735
  # whether a real compile actually happened, so the caller can report how
572
736
  # many objects across the whole build needed nothing done.
573
737
  #
574
738
  # A test file's own C compile (only) gets one extra check: isolate_sibling_headers
575
739
  # inspects its freshly-written .d file for a real header sharing a directory with
576
- # one this test mocks or Partializes, and retries with corrected search paths if
577
- # it finds one. A failure that's still standing afterward -- nothing to isolate,
578
- # or an isolated retry that failed too -- gets one last look from generator_helper
579
- # before it's raised, in case it's explainable as this same class of collision.
740
+ # one this test mocks under inline handling, and retries with corrected search paths if
741
+ # it finds one. A failure still standing afterward, with nothing to isolate or a
742
+ # retry that failed too, goes to the build step doctor before it is raised.
580
743
  #
581
744
  # Any other source sharing a directory with a header mocked under inline shadowing
582
745
  # compiles from an isolated copy instead (compile_isolated_source).
@@ -592,7 +755,7 @@ class TestBuildExecutor
592
755
  context: context, operation: OPERATION_COMPILE_SYM, tool: @configurator.tools_test_compiler,
593
756
  flags: flags, defines: defines, module_name: test, source: source, object: object
594
757
  )
595
- stale = register_and_check_object_staleness( object: object, source: source, dependencies: dependencies, flags: flags, defines: defines, search_paths: search_paths, tool: tool )
758
+ stale = register_and_check_object_staleness( object: object, source: source, dependencies: dependencies, flags: flags, defines: defines, search_paths: search_paths, tool: tool, isolation: testable.header_isolation )
596
759
 
597
760
  unless stale
598
761
  # A skipped compile still needs this test's search paths corrected the same
@@ -650,41 +813,21 @@ class TestBuildExecutor
650
813
  # the shell-out exits (a raw miss here silently drops this compile's discovered
651
814
  # header dependencies -- self-correcting into one extra recompile next run, but
652
815
  # worth riding out directly).
653
- @dependinator.register_gcc_deps_file( dependencies ) if @file_wrapper.exist_with_retry?( dependencies )
816
+ if @file_wrapper.exist_with_retry?( dependencies )
817
+ restore_isolated_dependencies( testable, dependencies )
818
+ @dependinator.register_gcc_deps_file( dependencies )
819
+ end
654
820
 
655
821
  # Only the test file's own compile is ever checked here directly -- every other
656
822
  # object in the same test's build already sees whatever search paths that check
657
823
  # settled on (see stage_build_objects's own two-pass split).
658
824
  if source == testable.filepath && @file_wrapper.exist_with_retry?( dependencies )
659
825
  isolation = apply_sibling_isolation( testable: testable, dependencies_filepath: dependencies )
660
-
661
- if isolation
662
- # A throwaway retry: its own .d file is never registered, so the attempt
663
- # registered just above -- real headers, real paths -- remains the lasting
664
- # record of this object's antecedents. The isolated copy is always freshly,
665
- # fully derived from those same tracked files, so it can never itself go
666
- # stale independently and needs no tracking of its own.
667
- retry_arg_hash = arg_hash.merge(
668
- search_paths: tailor_search_paths( search_paths: isolation[:search_paths], filepath: source ),
669
- dependencies: dependencies + '.isolated_retry'
670
- )
671
-
672
- begin
673
- @generator.generate_object_file_c( **retry_arg_hash )
674
- compile_failure = nil
675
- rescue ShellException => ex
676
- compile_failure = ex
677
- end
678
- end
826
+ compile_failure = compile_isolated_retry( arg_hash: arg_hash, isolation: isolation ) if isolation
679
827
  end
680
828
 
681
829
  if compile_failure
682
- notice = @generator_helper.explain_possible_mock_partial_collision(
683
- output: compile_failure.shell_result[:output],
684
- mocked_headers: mocked_and_partialized_headers( testable )
685
- )
686
- @loginator.log( notice, Verbosity::ERRORS, LogLabels::NOTICE ) if notice
687
-
830
+ diagnose_compile_failure( compile_failure, arg_hash: arg_hash, testable: testable )
688
831
  raise compile_failure
689
832
  end
690
833
 
@@ -694,7 +837,7 @@ class TestBuildExecutor
694
837
  context: context, operation: OPERATION_ASSEMBLE_SYM, tool: @configurator.tools_test_assembler,
695
838
  flags: flags, defines: defines, module_name: test, source: source, object: object
696
839
  )
697
- stale = register_and_check_object_staleness( object: object, source: source, dependencies: dependencies, flags: flags, defines: defines, search_paths: search_paths, tool: tool )
840
+ stale = register_and_check_object_staleness( object: object, source: source, dependencies: dependencies, flags: flags, defines: defines, search_paths: search_paths, tool: tool, isolation: testable.header_isolation )
698
841
 
699
842
  return log_compile_skip( test: test, source: source ) unless stale
700
843
 
@@ -754,6 +897,31 @@ class TestBuildExecutor
754
897
  return nil
755
898
  end
756
899
 
900
+ # A throwaway retry with the isolation's search paths. Its .d file is never
901
+ # registered, so the first attempt's, with real headers and real paths, stays the
902
+ # lasting record of this object's antecedents. The isolated copy is always freshly
903
+ # derived from those same tracked files, so it never goes stale on its own. Returns
904
+ # the retry's failure, or nil when it compiles.
905
+ def compile_isolated_retry(arg_hash:, isolation:)
906
+ retry_arg_hash = arg_hash.merge(
907
+ search_paths: tailor_search_paths( search_paths: isolation[:search_paths], filepath: arg_hash[:source] ),
908
+ dependencies: arg_hash[:dependencies] + '.isolated_retry'
909
+ )
910
+
911
+ @generator.generate_object_file_c( **retry_arg_hash )
912
+ return nil
913
+ rescue ShellException => ex
914
+ return ex
915
+ end
916
+
917
+ # The doctor sees the first attempt's .d file, whose paths are the real headers,
918
+ # whichever attempt produced the failure
919
+ def diagnose_compile_failure(failure, arg_hash:, testable:)
920
+ inputs = arg_hash.slice( :tool, :source, :object, :search_paths, :flags, :defines, :dependencies )
921
+
922
+ @build_step_doctor.diagnose( step: :compile, output: failure.shell_result[:output], inputs: inputs.merge( testable: testable ) )
923
+ end
924
+
757
925
  # Compiles a source from a copy staged alone, returning any compile failure.
758
926
  #
759
927
  # With no real header beside the copy, its quoted #include of `header` reaches CMock's
@@ -838,7 +1006,7 @@ class TestBuildExecutor
838
1006
  # skipped one share, so search_paths reads the same way regardless of which one
839
1007
  # happened this run. Returns whatever isolate_sibling_headers itself returned.
840
1008
  # BARRIER INVARIANT (see also stage_build_objects's own note): the writes below to
841
- # testable.search_paths/isolated_headers_path are completely unguarded -- no mutex --
1009
+ # testable.search_paths/header_isolation are completely unguarded -- no mutex --
842
1010
  # which is only safe because this method is only ever called while compiling a
843
1011
  # test's own file, and stage_build_objects's two-pass split guarantees every other
844
1012
  # object belonging to that same test compiles in a later, separate batch that starts
@@ -850,8 +1018,8 @@ class TestBuildExecutor
850
1018
  isolation = isolate_sibling_headers( testable: testable, dependencies_filepath: dependencies_filepath )
851
1019
  return nil if isolation.nil?
852
1020
 
853
- testable.search_paths = isolation[:search_paths]
854
- testable.isolated_headers_path = isolation[:isolation_dir]
1021
+ testable.search_paths = isolation[:search_paths]
1022
+ testable.header_isolation = isolation[:isolation]
855
1023
 
856
1024
  isolation
857
1025
  end
@@ -864,33 +1032,36 @@ class TestBuildExecutor
864
1032
  # it, mocked/Partialized or not, which is enough to know where that risk exists
865
1033
  # even though it says nothing about whether any given occurrence actually won.
866
1034
  #
867
- # For each header this test mocks or Partializes, any other file sharing its real
868
- # directory in that dependency list, that itself actually #includes the real
869
- # header by name, is staged, alone, into an isolated directory -- with nothing
870
- # else there for its own #include of the real header to find, that #include is
871
- # forced through the search paths that list the mock/Partial first. Actually
872
- # #including the real header is the deciding signal, not mere co-residency: most
873
- # real projects keep every header in one shared directory as a matter of
874
- # ordinary convention, so "shares a directory" alone would flag nearly every
1035
+ # Isolation can only redirect a quoted #include to a file of the same name earlier on the
1036
+ # search path. CMock writes one for each header it mocks under `:treat_inlines: :include`,
1037
+ # and nothing else does, so only those headers are considered (see
1038
+ # TestSubstitutions#shadowed_headers).
1039
+ #
1040
+ # For each such header, any other file sharing its real directory in that dependency
1041
+ # list, that itself actually #includes the real header by name, is staged, alone, into
1042
+ # an isolated directory -- with nothing else there for its own #include of the real
1043
+ # header to find, that #include is forced through the search paths that list CMock's
1044
+ # copy first. Actually #including the real header is the deciding signal, not mere
1045
+ # co-residency: most real projects keep every header in one shared directory as a
1046
+ # matter of ordinary convention, so "shares a directory" alone would flag nearly every
875
1047
  # file in the project. Only one level deep: a directory elsewhere in the same
876
- # dependency list that shares no header with any of this test's own mocks or
877
- # Partials, but itself holds more than one candidate, is shaped the same way
878
- # and reported, but nothing designates which of its occupants should win, so
879
- # nothing there is acted on.
1048
+ # dependency list that shares no header with any of those mocks is shaped the same way,
1049
+ # but nothing designates which of its occupants should win, so nothing there is acted
1050
+ # on. Should the compilation fail with a collision there, the build step doctor's
1051
+ # shared-directory diagnosis explains it.
880
1052
  #
881
- # Returns nil when nothing needs isolating; otherwise a hash of the search
882
- # paths to compile with (isolation directory listed first) and that directory's
883
- # own path, for the caller to track and eventually clean up.
1053
+ # Returns nil when nothing needs isolating; otherwise a hash of the search paths to
1054
+ # compile with (isolation directory listed first) and the isolation itself, for the
1055
+ # caller to track and eventually clean up.
884
1056
  def isolate_sibling_headers(testable:, dependencies_filepath:)
885
- mocked_headers = mocked_and_partialized_headers( testable )
1057
+ mocked_headers = @test_substitutions.shadowed_headers( testable )
886
1058
  return nil if mocked_headers.empty?
887
1059
 
888
1060
  parsed = @gcc_dependency_parser.parse( @file_wrapper.read( dependencies_filepath ) )
889
1061
  dependencies = parsed.values.flatten.uniq
890
1062
  by_directory = dependencies.group_by { |dep| File.dirname( dep ) }
891
1063
 
892
- isolated = []
893
- mocked_dirs = mocked_headers.values.map { |real_path| File.dirname( real_path ) }.uniq
1064
+ isolated = []
894
1065
 
895
1066
  mocked_headers.each_value do |real_path|
896
1067
  next unless dependencies.include?( real_path )
@@ -913,69 +1084,13 @@ class TestBuildExecutor
913
1084
  end
914
1085
  end
915
1086
 
916
- # Any other directory in this same reachable set holding more than one file is
917
- # shaped the same way a mocked header's own directory is -- but with no
918
- # designated substitute among its occupants, there's nothing to safely isolate.
919
- # Ceedling's own generated/vendor directories are exempt: a mocks output
920
- # directory or a vendor framework's own source directory routinely holds
921
- # several co-resident files as a matter of course, never a same-directory
922
- # quote-include shortcut risk the way a real project header directory is.
923
- generated_dirs = generated_content_dirs( testable )
924
-
925
- by_directory.each do |dir, files|
926
- next if mocked_dirs.include?( dir )
927
- next if generated_dirs.any? { |gd| dir.start_with?( gd ) }
928
-
929
- files.uniq.combination( 2 ).each do |a, b|
930
- msg = "'#{a}' sits alongside '#{b}' at a nesting depth beyond what automated sibling-header " \
931
- "isolation provides. If this test's build fails with a redeclaration or conflicting types " \
932
- "error, the include ordering and path structure leading to '#{a}' or '#{b}' is worth investigating."
933
- @loginator.log( msg, Verbosity::COMPLAIN, LogLabels::NOTICE )
934
- end
935
- end
936
-
937
1087
  return nil if isolated.empty?
938
1088
 
939
- isolation = @quote_include_isolator.isolate( parent: testable.paths[:build], files: isolated.uniq )
940
-
941
- { search_paths: [isolation.dir] + testable.search_paths, isolation_dir: isolation.dir }
942
- end
943
-
944
- # `{ basename => real path }` for every real header this test substitutes -- CMock
945
- # mocks of a real header, and Partials -- cross-referenced elsewhere against
946
- # whatever a test's own compile actually reached. A mock Partial's own `source` is
947
- # its own generated interface header, not a real project header, and is excluded.
948
- def mocked_and_partialized_headers(testable)
949
- headers = {}
950
-
951
- (testable.mocks || {}).each_value do |details|
952
- next if details.partial
953
- headers[File.basename( details.source )] = details.source if details.source
954
- end
955
-
956
- testable.partials.configs.each_value do |config|
957
- filepath = config.header.filepath
958
- headers[File.basename( filepath )] = filepath if filepath
959
- end
1089
+ # Each copy names its original through #line, so diagnostics, __FILE__, debug info and
1090
+ # coverage data report the original
1091
+ isolation = @quote_include_isolator.isolate( parent: testable.paths[:build], files: isolated.uniq, preserve_location: true )
960
1092
 
961
- headers
962
- end
963
-
964
- # Directory roots holding only Ceedling's own generated or vendored content for this
965
- # test -- never real project headers, so co-residency there is routine, not a
966
- # same-directory quote-include risk. A test's own Partials output directory
967
- # routinely holds several generated headers side by side (a types header, an
968
- # interface header, and more, one set per Partialized module), exactly the same
969
- # shape as the mocks output directory.
970
- def generated_content_dirs(testable)
971
- [
972
- testable.paths[:mocks],
973
- testable.paths[:partials],
974
- PROJECT_BUILD_VENDOR_UNITY_PATH,
975
- PROJECT_BUILD_VENDOR_CMOCK_PATH,
976
- PROJECT_BUILD_VENDOR_CEXCEPTION_PATH,
977
- @configurator.project_build_vendor_ceedling_path
978
- ].compact
1093
+ { search_paths: [isolation.dir] + testable.search_paths, isolation: isolation }
979
1094
  end
980
1095
 
981
1096
  # Registers `object`'s antecedents (its source file, plus whatever headers
@@ -985,12 +1100,37 @@ class TestBuildExecutor
985
1100
  # if headers changed, that's exactly what makes this stale. Nothing has just
986
1101
  # written that file, so one look suffices: a clean build has none, and a missed
987
1102
  # one leaves the object stale, forcing a recompile.
988
- def register_and_check_object_staleness(object:, source:, dependencies:, flags:, defines:, search_paths:, tool:)
989
- @dependinator.register( object, files: [source], meta: dependency_meta( flags: flags, defines: defines, search_paths: search_paths, tools: [tool] ) )
1103
+ #
1104
+ # A header isolation's directory takes a new name every build, so an object compiled
1105
+ # with it weighs the isolated originals in its place (see isolation_meta).
1106
+ def register_and_check_object_staleness(object:, source:, dependencies:, flags:, defines:, search_paths:, tool:, isolation: nil)
1107
+ meta = dependency_meta( flags: flags, defines: defines, tools: [tool], **isolation_meta( search_paths, isolation ) )
1108
+
1109
+ @dependinator.register( object, files: [source], meta: meta )
990
1110
  @dependinator.register_gcc_deps_file( dependencies ) if @file_wrapper.exist?( dependencies )
991
1111
  @dependinator.stale?( object )
992
1112
  end
993
1113
 
1114
+ # The search paths and isolated originals an object's staleness weighs.
1115
+ #
1116
+ # The isolated originals stand in for the isolation directory, so a change to which
1117
+ # files are isolated still rebuilds the object while the directory's own name never
1118
+ # counts. The originals' contents are tracked through the object's restored .d file.
1119
+ def isolation_meta(search_paths, isolation)
1120
+ return { search_paths: search_paths } unless isolation && search_paths.include?( isolation.dir )
1121
+
1122
+ return { search_paths: search_paths - [isolation.dir], isolated: isolation.copies.keys.sort }
1123
+ end
1124
+
1125
+ # Rewrites a compile's .d file to name each isolated original in place of its copy.
1126
+ # The copies are removed once the compile stage ends, so a .d file naming one would
1127
+ # read as a vanished dependency on the next build.
1128
+ def restore_isolated_dependencies(testable, dependencies)
1129
+ return if testable.header_isolation.nil?
1130
+
1131
+ @quote_include_isolator.restore_dependencies( testable.header_isolation, dependencies )
1132
+ end
1133
+
994
1134
  # Each framework/support source needs its own vendor path (and, for CMock and a
995
1135
  # support file, other frameworks' vendor paths too, when those frameworks are also in
996
1136
  # play) spliced in ahead of a test's ordinary search paths -- the vendor sources