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
@@ -9,7 +9,9 @@ require 'spec_helper'
9
9
  require 'ceedling/test_invoker/partials_manager'
10
10
  require 'ceedling/test_invoker/test_invoker_types'
11
11
  require 'ceedling/partials/partials'
12
+ require 'ceedling/partials/partializer_config'
12
13
  require 'ceedling/includes/includes'
14
+ require 'ceedling/includes/header_search'
13
15
 
14
16
  describe PartialsManager do
15
17
  before(:each) do
@@ -17,30 +19,31 @@ describe PartialsManager do
17
19
  @loginator = double( "Loginator" )
18
20
  @reportinator = double( "Reportinator" )
19
21
  @batchinator = double( "Batchinator" )
20
- @preprocessinator = double( "Preprocessinator" )
21
22
  @partializer = double( "Partializer" )
22
23
  @generator = double( "Generator" )
23
24
  @dependinator = double( "Dependinator" )
24
25
  @file_path_utils = double( "FilePathUtils" )
26
+ @file_wrapper = double( "FileWrapper" )
27
+ @mock_locator = double( "MockLocator" )
28
+ @header_search = double( "HeaderSearch" )
29
+
30
+ allow(@mock_locator).to receive(:header_search).and_return( @header_search )
31
+ allow(@header_search).to receive(:header_candidates).and_return( [] )
32
+ allow(@header_search).to receive(:at).and_return( nil )
25
33
 
26
34
  allow(@reportinator).to receive(:generate_module_progress).and_return( '' )
27
35
  allow(@reportinator).to receive(:generate_skip_summary).and_return( nil )
28
36
  allow(@loginator).to receive(:log)
29
37
 
30
- @tools_test_bare_includes_preprocessor = { name: 'fake bare includes preprocessor' }
31
- @tools_test_file_directives_only_preprocessor = { name: 'fake directives-only preprocessor' }
32
- @tools_test_file_full_preprocessor = { name: 'fake full preprocessor' }
33
- @partials_config = { max_extraction_length: 5000 }
38
+ @partials_config = { max_extraction_length: 5000 }
34
39
 
35
- allow(@configurator).to receive(:tools_test_bare_includes_preprocessor).and_return( @tools_test_bare_includes_preprocessor )
36
- allow(@configurator).to receive(:tools_test_file_directives_only_preprocessor).and_return( @tools_test_file_directives_only_preprocessor )
37
- allow(@configurator).to receive(:tools_test_file_full_preprocessor).and_return( @tools_test_file_full_preprocessor )
38
40
  allow(@configurator).to receive(:test_build_preprocess_force_fallback).and_return( false )
39
41
  allow(@configurator).to receive(:get_partials_config).and_return( @partials_config )
40
42
 
41
43
  allow(@dependinator).to receive(:register)
42
44
  allow(@dependinator).to receive(:stale?).and_return( true )
43
45
  allow(@dependinator).to receive(:mark_fresh)
46
+ allow(@file_wrapper).to receive(:exist?).and_return( false )
44
47
 
45
48
  @manager = described_class.new(
46
49
  {
@@ -48,11 +51,12 @@ describe PartialsManager do
48
51
  :loginator => @loginator,
49
52
  :reportinator => @reportinator,
50
53
  :batchinator => @batchinator,
51
- :preprocessinator => @preprocessinator,
52
54
  :partializer => @partializer,
53
55
  :generator => @generator,
54
56
  :dependinator => @dependinator,
55
- :file_path_utils => @file_path_utils
57
+ :file_path_utils => @file_path_utils,
58
+ :file_wrapper => @file_wrapper,
59
+ :mock_locator => @mock_locator
56
60
  }
57
61
  )
58
62
  end
@@ -61,267 +65,37 @@ describe PartialsManager do
61
65
  # stubbed to synchronously yield every `things` entry to the given block,
62
66
  # matching its real per-item iteration contract without pulling in Parallel.
63
67
  def stub_batchinator_exec
64
- allow(@batchinator).to receive(:exec) do |workload:, things:, &block|
68
+ allow(@batchinator).to receive(:exec) do |things:, **, &block|
65
69
  things.each { |k, v| block.call(k, v) }
66
70
  end
67
71
  end
68
72
 
69
- context "#stage_preprocess_partial_headers" do
70
- before(:each) do
71
- stub_batchinator_exec()
72
-
73
- allow(@configurator).to receive(:project_build_vendor_ceedling_path).and_return( 'build/vendor/ceedling' )
74
- allow(@file_path_utils).to receive(:form_preprocessed_file_filepath).and_return( 'build/preprocess/Foo.h' )
75
- allow(@file_path_utils).to receive(:form_preprocessed_file_full_expansion_filepath).and_return( 'build/preprocess/full_expansion/Foo.h' )
76
- allow(@file_path_utils).to receive(:form_preprocessed_includes_list_filepath).and_return( 'build/preprocess/includes/Foo.h.yml' )
77
- allow(@preprocessinator).to receive(:generate_directives_only_output).and_return( 'build/preprocess/raw/Foo.h' )
78
- allow(@preprocessinator).to receive(:preprocess_partial_header_file_preserve_macros).and_return( ['build/preprocess/raw/Foo.h', []] )
79
- allow(@preprocessinator).to receive(:preprocess_partial_header_expand_macros).and_return( 'build/preprocess/full_expansion/Foo.h' )
80
- allow(@preprocessinator).to receive(:load_includes_list).and_return( [] )
81
-
82
- @testable = TestInvokerTypes::Testable.new(
83
- :name => 'a_test',
84
- :preprocess_flags => ['-Wall'], :preprocess_defines => ['TEST'], :search_paths => ['src']
85
- )
86
- @config = Partials::ConfigFileInfo.new( filepath: 'src/Foo.h' )
87
- @details = TestInvokerTypes::PartialWork.new( :config => @config, :testable => @testable, :directives_only_filepath => nil )
88
- @state = TestInvokerTypes::PipelineState.new(
89
- :testables => { :a_test => @testable }, :partials_headers => [@details], :context => :test, :options => []
90
- )
91
- end
92
-
93
- it "registers the header's deterministic target with the header file as sole antecedent and preprocess flags/defines/search paths, preprocessing tools, and :partials config as meta" do
94
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( false )
95
-
96
- expect(@dependinator).to receive(:register).with(
97
- 'build/preprocess/Foo.h',
98
- files: ['src/Foo.h'],
99
- meta: {
100
- flags: ['-Wall'], defines: ['TEST'], search_paths: ['src'],
101
- tools: [@tools_test_file_directives_only_preprocessor, @tools_test_bare_includes_preprocessor, @tools_test_file_full_preprocessor],
102
- preprocess_force_fallback: false,
103
- partials: @partials_config
104
- }
105
- )
106
-
107
- @manager.stage_preprocess_partial_headers( @state )
108
- end
109
-
110
- it "runs all three preprocessing passes and marks the target fresh once, at the end, when the dependency tracker reports it stale" do
111
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
112
- allow(@dependinator).to receive(:stale?).and_return( true )
113
-
114
- expect(@preprocessinator).to receive(:generate_directives_only_output).ordered
115
- expect(@preprocessinator).to receive(:preprocess_partial_header_file_preserve_macros).ordered
116
- expect(@preprocessinator).to receive(:preprocess_partial_header_expand_macros).ordered
117
- expect(@dependinator).to receive(:mark_fresh).with('build/preprocess/Foo.h').ordered
118
-
119
- @manager.stage_preprocess_partial_headers( @state )
120
- end
121
-
122
- # A skipped run recalls both, so the preprocessed target vouches for them
123
- it "registers the includes list and full expansion as outputs before marking the target fresh" do
124
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( false )
125
- allow(@dependinator).to receive(:stale?).and_return( true )
126
- allow(@preprocessinator).to receive(:preprocess_partial_header_file_preserve_macros)
127
- allow(@preprocessinator).to receive(:preprocess_partial_header_expand_macros)
128
-
129
- expect(@dependinator).to receive(:register).with(
130
- 'build/preprocess/Foo.h', outputs: ['build/preprocess/includes/Foo.h.yml', 'build/preprocess/full_expansion/Foo.h']
131
- ).ordered
132
- expect(@dependinator).to receive(:mark_fresh).with('build/preprocess/Foo.h').ordered
133
-
134
- @manager.stage_preprocess_partial_headers( @state )
135
- end
136
-
137
- it "skips all three preprocessing passes and reconstructs config state from the deterministic paths and cached includes list when the dependency tracker reports it unchanged" do
138
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
139
- allow(@dependinator).to receive(:stale?).and_return( false )
140
- cached_includes = [ double("Include") ]
141
- allow(@preprocessinator).to receive(:load_includes_list).with( test: 'a_test', filepath: 'src/Foo.h' ).and_return( cached_includes )
142
-
143
- expect(@preprocessinator).to_not receive(:generate_directives_only_output)
144
- expect(@preprocessinator).to_not receive(:preprocess_partial_header_file_preserve_macros)
145
- expect(@preprocessinator).to_not receive(:preprocess_partial_header_expand_macros)
146
- expect(@dependinator).to_not receive(:mark_fresh)
147
-
148
- @manager.stage_preprocess_partial_headers( @state )
149
-
150
- expect( @config.directives_only_filepath ).to eq( 'build/preprocess/Foo.h' )
151
- expect( @config.includes ).to eq( cached_includes )
152
- expect( @config.full_expansion_filepath ).to eq( 'build/preprocess/full_expansion/Foo.h' )
153
- end
154
-
155
- it "does nothing for the directives-only pass when directives-only preprocessing is unavailable for this toolchain, but still runs preserve-macros and full-expansion" do
156
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( false )
157
- allow(@dependinator).to receive(:stale?).and_return( true )
158
-
159
- expect(@preprocessinator).to_not receive(:generate_directives_only_output)
160
- expect(@preprocessinator).to receive(:preprocess_partial_header_file_preserve_macros)
161
- expect(@preprocessinator).to receive(:preprocess_partial_header_expand_macros)
162
-
163
- @manager.stage_preprocess_partial_headers( @state )
164
- end
165
-
166
- it "logs a NORMAL progress line for a header that needs preprocessing, and no OBNOXIOUS skip line" do
167
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
168
- allow(@dependinator).to receive(:stale?).and_return( true )
169
- allow(@reportinator).to receive(:generate_module_progress)
170
- .with( operation: 'Preprocessing partial header for', module_name: 'a_test', filename: 'Foo.h' )
171
- .and_return( 'Preprocessing partial header for a_test::Foo.h...' )
172
-
173
- expect(@loginator).to receive(:log).with( 'Preprocessing partial header for a_test::Foo.h...' )
174
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::OBNOXIOUS )
175
-
176
- @manager.stage_preprocess_partial_headers( @state )
177
- end
178
-
179
- it "logs an OBNOXIOUS skip line for a header recalled from cache, and no NORMAL preprocessing line" do
180
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
181
- allow(@dependinator).to receive(:stale?).and_return( false )
182
- allow(@reportinator).to receive(:generate_module_progress)
183
- .with( operation: 'Skipping partial header preprocessing for', module_name: 'a_test', filename: 'Foo.h' )
184
- .and_return( 'Skipping partial header preprocessing for a_test::Foo.h...' )
185
-
186
- expect(@loginator).to receive(:log).with( 'Skipping partial header preprocessing for a_test::Foo.h...', Verbosity::OBNOXIOUS )
187
- expect(@reportinator).to_not receive(:generate_module_progress)
188
- .with( operation: 'Preprocessing partial header for', module_name: anything, filename: anything )
189
-
190
- @manager.stage_preprocess_partial_headers( @state )
191
- end
192
- end
193
-
194
- context "#stage_preprocess_partial_sources" do
195
- before(:each) do
196
- stub_batchinator_exec()
197
-
198
- allow(@configurator).to receive(:project_build_vendor_ceedling_path).and_return( 'build/vendor/ceedling' )
199
- allow(@file_path_utils).to receive(:form_preprocessed_file_filepath).and_return( 'build/preprocess/Foo.c' )
200
- allow(@file_path_utils).to receive(:form_preprocessed_file_full_expansion_filepath).and_return( 'build/preprocess/full_expansion/Foo.c' )
201
- allow(@file_path_utils).to receive(:form_preprocessed_includes_list_filepath).and_return( 'build/preprocess/includes/Foo.c.yml' )
202
- allow(@preprocessinator).to receive(:generate_directives_only_output).and_return( 'build/preprocess/raw/Foo.c' )
203
- allow(@preprocessinator).to receive(:preprocess_partial_source_file_preserve_macros).and_return( ['build/preprocess/raw/Foo.c', []] )
204
- allow(@preprocessinator).to receive(:preprocess_partial_source_expand_macros).and_return( 'build/preprocess/full_expansion/Foo.c' )
205
- allow(@preprocessinator).to receive(:load_includes_list).and_return( [] )
206
-
207
- @testable = TestInvokerTypes::Testable.new(
208
- :name => 'a_test',
209
- :preprocess_flags => ['-Wall'], :preprocess_defines => ['TEST'], :search_paths => ['src']
210
- )
211
- @config = Partials::ConfigFileInfo.new( filepath: 'src/Foo.c' )
212
- @details = TestInvokerTypes::PartialWork.new( :config => @config, :testable => @testable, :directives_only_filepath => nil )
213
- @state = TestInvokerTypes::PipelineState.new(
214
- :testables => { :a_test => @testable }, :partials_sources => [@details], :context => :test, :options => []
215
- )
216
- end
217
-
218
- it "registers the source's deterministic target with the source file as sole antecedent and preprocess flags/defines/search paths, preprocessing tools, and :partials config as meta" do
219
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( false )
220
-
221
- expect(@dependinator).to receive(:register).with(
222
- 'build/preprocess/Foo.c',
223
- files: ['src/Foo.c'],
224
- meta: {
225
- flags: ['-Wall'], defines: ['TEST'], search_paths: ['src'],
226
- tools: [@tools_test_file_directives_only_preprocessor, @tools_test_bare_includes_preprocessor, @tools_test_file_full_preprocessor],
227
- preprocess_force_fallback: false,
228
- partials: @partials_config
229
- }
230
- )
231
-
232
- @manager.stage_preprocess_partial_sources( @state )
233
- end
234
-
235
- it "runs all three preprocessing passes and marks the target fresh once, at the end, when the dependency tracker reports it stale" do
236
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
237
- allow(@dependinator).to receive(:stale?).and_return( true )
238
-
239
- expect(@preprocessinator).to receive(:generate_directives_only_output).ordered
240
- expect(@preprocessinator).to receive(:preprocess_partial_source_file_preserve_macros).ordered
241
- expect(@preprocessinator).to receive(:preprocess_partial_source_expand_macros).ordered
242
- expect(@dependinator).to receive(:mark_fresh).with('build/preprocess/Foo.c').ordered
243
-
244
- @manager.stage_preprocess_partial_sources( @state )
245
- end
246
-
247
- it "skips all three preprocessing passes and reconstructs config state from the deterministic paths and cached includes list when the dependency tracker reports it unchanged" do
248
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
249
- allow(@dependinator).to receive(:stale?).and_return( false )
250
- cached_includes = [ double("Include") ]
251
- allow(@preprocessinator).to receive(:load_includes_list).with( test: 'a_test', filepath: 'src/Foo.c' ).and_return( cached_includes )
252
-
253
- expect(@preprocessinator).to_not receive(:generate_directives_only_output)
254
- expect(@preprocessinator).to_not receive(:preprocess_partial_source_file_preserve_macros)
255
- expect(@preprocessinator).to_not receive(:preprocess_partial_source_expand_macros)
256
- expect(@dependinator).to_not receive(:mark_fresh)
257
-
258
- @manager.stage_preprocess_partial_sources( @state )
259
-
260
- expect( @config.directives_only_filepath ).to eq( 'build/preprocess/Foo.c' )
261
- expect( @config.includes ).to eq( cached_includes )
262
- expect( @config.full_expansion_filepath ).to eq( 'build/preprocess/full_expansion/Foo.c' )
263
- end
264
-
265
- it "does nothing for the directives-only pass when directives-only preprocessing is unavailable for this toolchain, but still runs preserve-macros and full-expansion" do
266
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( false )
267
- allow(@dependinator).to receive(:stale?).and_return( true )
268
-
269
- expect(@preprocessinator).to_not receive(:generate_directives_only_output)
270
- expect(@preprocessinator).to receive(:preprocess_partial_source_file_preserve_macros)
271
- expect(@preprocessinator).to receive(:preprocess_partial_source_expand_macros)
272
-
273
- @manager.stage_preprocess_partial_sources( @state )
274
- end
275
-
276
- it "logs a NORMAL progress line for a source that needs preprocessing, and no OBNOXIOUS skip line" do
277
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
278
- allow(@dependinator).to receive(:stale?).and_return( true )
279
- allow(@reportinator).to receive(:generate_module_progress)
280
- .with( operation: 'Preprocessing partial source for', module_name: 'a_test', filename: 'Foo.c' )
281
- .and_return( 'Preprocessing partial source for a_test::Foo.c...' )
282
-
283
- expect(@loginator).to receive(:log).with( 'Preprocessing partial source for a_test::Foo.c...' )
284
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::OBNOXIOUS )
285
-
286
- @manager.stage_preprocess_partial_sources( @state )
287
- end
288
-
289
- it "logs an OBNOXIOUS skip line for a source recalled from cache, and no NORMAL preprocessing line" do
290
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
291
- allow(@dependinator).to receive(:stale?).and_return( false )
292
- allow(@reportinator).to receive(:generate_module_progress)
293
- .with( operation: 'Skipping partial source preprocessing for', module_name: 'a_test', filename: 'Foo.c' )
294
- .and_return( 'Skipping partial source preprocessing for a_test::Foo.c...' )
295
-
296
- expect(@loginator).to receive(:log).with( 'Skipping partial source preprocessing for a_test::Foo.c...', Verbosity::OBNOXIOUS )
297
- expect(@reportinator).to_not receive(:generate_module_progress)
298
- .with( operation: 'Preprocessing partial source for', module_name: anything, filename: anything )
299
-
300
- @manager.stage_preprocess_partial_sources( @state )
301
- end
302
- end
303
-
304
73
  context "#stage_generate_partials" do
305
74
  before(:each) do
306
75
  stub_batchinator_exec()
307
76
 
308
- allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( false )
309
-
310
77
  @module_contents = double( "CModule",
311
78
  function_definitions: [],
312
79
  function_declarations: [],
313
80
  type_definitions: [],
314
81
  aggregate_definitions: []
315
82
  )
83
+ # Whether the module has types follows from its lists, which an example may stub
84
+ allow(@module_contents).to receive(:types?) { !(@module_contents.type_definitions.empty? and @module_contents.aggregate_definitions.empty?) }
316
85
  allow(@partializer).to receive(:extract_module_contents).and_return( @module_contents )
317
86
  allow(@partializer).to receive(:validate_config)
318
87
  allow(@partializer).to receive(:sanitize)
319
88
  allow(@partializer).to receive(:validate_extracted_functions)
320
- allow(@partializer).to receive(:remap_implementation_header_includes).and_return( [] )
89
+ allow(@partializer).to receive(:remap_implementation_header_includes).and_return( Partials::IncludeGroups.new )
321
90
  allow(@partializer).to receive(:remap_implementation_source_includes).and_return( [] )
322
- allow(@partializer).to receive(:remap_interface_header_includes).and_return( [] )
323
- allow(@partializer).to receive(:remap_types_header_includes).and_return( [] )
91
+ allow(@partializer).to receive(:remap_interface_header_includes).and_return( Partials::IncludeGroups.new )
92
+ allow(@partializer).to receive(:remap_types_header_includes).and_return( Partials::IncludeGroups.new )
324
93
  allow(@partializer).to receive(:extract_module_include_guard).and_return( 'FOO_H' )
94
+ allow(@partializer).to receive(:plan_carry).and_return( Partials::CarryPlan.new )
95
+ allow(@partializer).to receive(:plan_interface_extras).and_return( Partials::InterfaceExtras.new )
96
+ allow(@partializer).to receive(:explain_tested_mock)
97
+ allow(@configurator).to receive(:partials_suppress_redundant_decls).and_return( true )
98
+ allow(@configurator).to receive(:partials_extern_variables).and_return( :weak )
325
99
  allow(@generator).to receive(:generate_partial_types)
326
100
  allow(@generator).to receive(:generate_partial_implementation)
327
101
  allow(@generator).to receive(:generate_partial_interface)
@@ -330,12 +104,13 @@ describe PartialsManager do
330
104
  allow(@file_path_utils).to receive(:form_partial_implementation_source_filename).and_return( 'ceedling_partial_Foo_impl.c' )
331
105
  allow(@file_path_utils).to receive(:form_partial_implementation_header_filename).and_return( 'ceedling_partial_Foo_impl.h' )
332
106
  allow(@file_path_utils).to receive(:form_partial_interface_header_filename).and_return( 'ceedling_partial_Foo_interface.h' )
107
+ allow(@file_path_utils).to receive(:form_partial_extras_header_filename).and_return( 'ceedling_partial_Foo_extras.h' )
333
108
 
334
109
  allow(@dependinator).to receive(:register)
335
110
  allow(@dependinator).to receive(:stale?).and_return( true )
336
111
  allow(@dependinator).to receive(:mark_fresh)
337
112
 
338
- @config = Partials::Config.new(
113
+ @config = PartializerConfig::Config.new(
339
114
  module: 'Foo',
340
115
  header: Partials::ConfigFileInfo.new( filepath: 'src/Foo.h', includes: [] ),
341
116
  source: Partials::ConfigFileInfo.new( filepath: 'src/Foo.c', includes: [] )
@@ -368,11 +143,11 @@ describe PartialsManager do
368
143
  it "keeps a test's Partial modules in configuration order, however the batch finishes" do
369
144
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
370
145
  allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
371
- allow(@batchinator).to receive(:exec) do |workload:, things:, &block|
146
+ allow(@batchinator).to receive(:exec) do |things:, **, &block|
372
147
  things.reverse_each { |thing| block.call( thing ) }
373
148
  end
374
149
  @testable.partials.configs = %w[Alpha Beta Gamma].to_h do |name|
375
- [name, Partials::Config.new( module: name, header: @config.header, source: @config.source )]
150
+ [name, PartializerConfig::Config.new( module: name, header: @config.header, source: @config.source )]
376
151
  end
377
152
 
378
153
  @manager.stage_generate_partials( @state )
@@ -381,6 +156,140 @@ describe PartialsManager do
381
156
  expect( @testable.partials.mocks ).to eq( %w[Alpha Beta Gamma] )
382
157
  end
383
158
 
159
+ it "plans what the implementation carries from both selections, the Partial and the guard" do
160
+ impl = [double("FunctionDefinition")]
161
+ iface = [double("FunctionDeclaration")]
162
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( impl )
163
+ allow(@partializer).to receive(:extract_interface_functions).and_return( iface )
164
+
165
+ expect(@partializer).to receive(:plan_carry).with(
166
+ test: 'a_test', c_module: @module_contents, impl: impl, interface: iface, header_guarded: true, config: @config
167
+ ).and_return( Partials::CarryPlan.new )
168
+
169
+ @manager.stage_generate_partials( @state )
170
+ end
171
+
172
+ # Without a guard to stand in for, the real header may arrive through another include
173
+ it "plans for an unguarded module header when the header has no guard" do
174
+ allow(@partializer).to receive(:extract_module_include_guard).and_return( nil )
175
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
176
+ allow(@partializer).to receive(:extract_interface_functions).and_return( nil )
177
+
178
+ expect(@partializer).to receive(:plan_carry).with( hash_including( header_guarded: false ) ).and_return( Partials::CarryPlan.new )
179
+
180
+ @manager.stage_generate_partials( @state )
181
+ end
182
+
183
+ it "hands the plan and both Partials settings to implementation generation" do
184
+ plan = Partials::CarryPlan.new
185
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
186
+ allow(@partializer).to receive(:extract_interface_functions).and_return( nil )
187
+ allow(@partializer).to receive(:plan_carry).and_return( plan )
188
+ allow(@configurator).to receive(:partials_suppress_redundant_decls).and_return( false )
189
+ allow(@configurator).to receive(:partials_extern_variables).and_return( :test )
190
+
191
+ expect(@generator).to receive(:generate_partial_implementation).with(
192
+ hash_including( carry: plan, suppress_redundant_decls: false, extern_variables: :test )
193
+ )
194
+
195
+ @manager.stage_generate_partials( @state )
196
+ end
197
+
198
+ # Only a regenerating implementation reads the plan, so its notices appear with that build
199
+ it "plans nothing when only the interface regenerates" do
200
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
201
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
202
+ allow(@dependinator).to receive(:stale?) { |target| target.end_with?( 'ceedling_partial_Foo_interface.h' ) }
203
+
204
+ expect(@partializer).not_to receive(:plan_carry)
205
+ expect(@generator).to receive(:generate_partial_interface)
206
+
207
+ @manager.stage_generate_partials( @state )
208
+ end
209
+
210
+ it "plans nothing when no implementation is extracted" do
211
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
212
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
213
+
214
+ expect(@partializer).not_to receive(:plan_carry)
215
+
216
+ @manager.stage_generate_partials( @state )
217
+ end
218
+
219
+ # A mock-only Partial's interface stands in for the real header, so it keeps the rest of it
220
+ it "plans what a mock-only Partial's interface keeps from the module, its selection and the guard" do
221
+ interface = [double("FunctionDeclaration")]
222
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
223
+ allow(@partializer).to receive(:extract_interface_functions).and_return( interface )
224
+
225
+ expect(@partializer).to receive(:plan_interface_extras).with(
226
+ test: 'a_test', c_module: @module_contents, interface: interface, header_guarded: true, config: @config
227
+ ).and_return( Partials::InterfaceExtras.new )
228
+
229
+ @manager.stage_generate_partials( @state )
230
+ end
231
+
232
+ # The module's implementation carries what its own code uses
233
+ it "plans no extras for a module the test also tests" do
234
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
235
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
236
+
237
+ expect(@partializer).not_to receive(:plan_interface_extras)
238
+ expect(@generator).to receive(:generate_partial_interface).with( hash_including( extras: nil ) )
239
+
240
+ @manager.stage_generate_partials( @state )
241
+ end
242
+
243
+ it "explains what other Partials go without when the test both tests and mocks a module" do
244
+ interface = [double("FunctionDeclaration")]
245
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
246
+ allow(@partializer).to receive(:extract_interface_functions).and_return( interface )
247
+
248
+ expect(@partializer).to receive(:explain_tested_mock).with(
249
+ test: 'a_test', c_module: @module_contents, interface: interface, header_guarded: true, config: @config,
250
+ partials: @testable.partials.configs
251
+ )
252
+
253
+ @manager.stage_generate_partials( @state )
254
+ end
255
+
256
+ it "explains nothing for a mock-only Partial" do
257
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
258
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
259
+
260
+ expect(@partializer).not_to receive(:explain_tested_mock)
261
+
262
+ @manager.stage_generate_partials( @state )
263
+ end
264
+
265
+ it "hands the extras to interface generation, which vouches for the extras header" do
266
+ extras = Partials::InterfaceExtras.new( items: [double("CFunctionDefinition")] )
267
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
268
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
269
+ allow(@partializer).to receive(:plan_interface_extras).and_return( extras )
270
+
271
+ expect(@generator).to receive(:generate_partial_interface).with( hash_including( extras: extras ) )
272
+
273
+ @manager.stage_generate_partials( @state )
274
+
275
+ expect(@dependinator).to have_received(:register).with(
276
+ 'build/test/partials/a_test/ceedling_partial_Foo_interface.h',
277
+ hash_including( outputs: ['build/test/partials/a_test/ceedling_partial_Foo_extras.h'] )
278
+ )
279
+ end
280
+
281
+ # An extras header an earlier build left would sit beside an interface that no longer includes it
282
+ it "removes an extras header an earlier build left once the interface keeps nothing" do
283
+ extras = 'build/test/partials/a_test/ceedling_partial_Foo_extras.h'
284
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
285
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
286
+ allow(@file_wrapper).to receive(:exist?).with( extras ).and_return( true )
287
+
288
+ expect(@file_wrapper).to receive(:rm_f).with( extras )
289
+
290
+ @manager.stage_generate_partials( @state )
291
+ end
292
+
384
293
  it "does not add to tests when no implementation is extracted" do
385
294
  allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
386
295
  allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
@@ -402,6 +311,9 @@ describe PartialsManager do
402
311
  end
403
312
 
404
313
  it "skips writing types, implementation, and interface when the dependency tracker reports all three unchanged, but still updates tests/mocks bookkeeping" do
314
+ @config.tests = PartializerConfig::PartialFunctions.new( type: Partials::PUBLIC )
315
+ @config.mocks = PartializerConfig::PartialFunctions.new( type: Partials::PRIVATE )
316
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
405
317
  allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
406
318
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
407
319
  allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
@@ -432,6 +344,48 @@ describe PartialsManager do
432
344
  )
433
345
  end
434
346
 
347
+ # Both include the types header, so each vouches for it
348
+ it "registers the types header as an output of both the implementation and the interface" do
349
+ allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
350
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
351
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
352
+
353
+ @manager.stage_generate_partials( @state )
354
+
355
+ types = 'build/test/partials/a_test/ceedling_partial_Foo_types.h'
356
+ expect(@dependinator).to have_received(:register).with(
357
+ 'build/test/partials/a_test/ceedling_partial_Foo_impl.c',
358
+ hash_including( outputs: ['build/test/partials/a_test/ceedling_partial_Foo_impl.h', types] )
359
+ )
360
+ expect(@dependinator).to have_received(:register).with(
361
+ 'build/test/partials/a_test/ceedling_partial_Foo_interface.h', hash_including( outputs: [types] )
362
+ )
363
+ end
364
+
365
+ # Whether a types header exists follows from the module files the record already holds, so
366
+ # the record can be known before extraction while generation still includes the header
367
+ it "records include lists without the types header and still generates with it" do
368
+ types_include = UserInclude.new( 'ceedling_partial_Foo_types.h' )
369
+ allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
370
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
371
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
372
+ [:remap_implementation_header_includes, :remap_interface_header_includes].each do |remap|
373
+ allow(@partializer).to receive(remap) do |types_header: nil, **|
374
+ Partials::IncludeGroups.new( leading: [types_header && types_include, UserInclude.new( 'dep.h' )].compact )
375
+ end
376
+ end
377
+
378
+ metas = []
379
+ allow(@dependinator).to receive(:register) { |_target, meta: {}, **| metas << meta }
380
+ expect(@generator).to receive(:generate_partial_implementation).with( hash_including( header_includes: [types_include, UserInclude.new( 'dep.h' )] ) )
381
+ expect(@generator).to receive(:generate_partial_interface).with( hash_including( includes: [types_include, UserInclude.new( 'dep.h' )] ) )
382
+
383
+ @manager.stage_generate_partials( @state )
384
+
385
+ recorded = { leading: ['#include "dep.h"'], following: [] }
386
+ expect( metas.map { |meta| meta.values_at( :impl_header_includes, :interface_includes ) }.uniq ).to eq( [[recorded, recorded]] )
387
+ end
388
+
435
389
  it "registers the whole :partials config as meta, and an empty tools list since this stage runs no shell tool" do
436
390
  allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
437
391
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
@@ -453,11 +407,210 @@ describe PartialsManager do
453
407
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
454
408
  allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
455
409
  allow(@partializer).to receive(:remap_types_header_includes)
456
- .and_return( [UserInclude.new('foundation.h')] )
410
+ .and_return( Partials::IncludeGroups.new( leading: [UserInclude.new('foundation.h')], following: [UserInclude.new('log.h')] ) )
457
411
 
458
412
  expect(@dependinator).to receive(:register).at_least(:once) do |_target, meta: {}, **|
459
413
  expect( meta[:include_guard] ).to eq( 'FOO_H' )
460
- expect( meta[:types_includes] ).to eq( ['#include "foundation.h"'] )
414
+ expect( meta[:types_includes] ).to eq( { leading: ['#include "foundation.h"'], following: ['#include "log.h"'] } )
415
+ end
416
+
417
+ @manager.stage_generate_partials( @state )
418
+ end
419
+
420
+ # What a test selects decides what is generated, so switching TEST_PARTIAL_PUBLIC_MODULE to
421
+ # TEST_PARTIAL_ALL_MODULE, or adding a function, has to regenerate the Partial.
422
+ it "registers the module's selection, both sides, as meta" do
423
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
424
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
425
+ @config.tests = PartializerConfig::PartialFunctions.new( type: Partials::PUBLIC, additions: ['bar'] )
426
+ @config.mocks = PartializerConfig::PartialFunctions.new( type: Partials::PRIVATE, subtractions: ['baz'] )
427
+
428
+ expect(@dependinator).to receive(:register).at_least(:once) do |_target, meta: {}, **|
429
+ expect( meta[:selection] ).to eq(
430
+ tests: { type: Partials::PUBLIC, additions: ['bar'], subtractions: [] },
431
+ mocks: { type: Partials::PRIVATE, additions: [], subtractions: ['baz'] }
432
+ )
433
+ end
434
+
435
+ @manager.stage_generate_partials( @state )
436
+ end
437
+
438
+ it "registers different meta for selections that differ only in mode or additions" do
439
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
440
+ allow(@partializer).to receive(:extract_interface_functions).and_return( nil )
441
+
442
+ metas = []
443
+ allow(@dependinator).to receive(:register) { |_target, meta: {}, **| metas << meta }
444
+
445
+ [
446
+ PartializerConfig::PartialFunctions.new( type: Partials::PUBLIC ),
447
+ PartializerConfig::PartialFunctions.new( type: Partials::DEDUCT ),
448
+ PartializerConfig::PartialFunctions.new( type: Partials::PUBLIC, additions: ['helper'] )
449
+ ].each do |tests|
450
+ @config.tests = tests
451
+ @manager.stage_generate_partials( @state )
452
+ end
453
+
454
+ expect( metas.uniq.length ).to eq( 3 )
455
+ end
456
+
457
+ # Each generated file's includes depend on the test's other Partial modules and how each is
458
+ # selected, so a change to any of those lists has to regenerate.
459
+ it "registers every generated file's include list as meta" do
460
+ allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
461
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
462
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
463
+ allow(@partializer).to receive(:remap_types_header_includes).and_return( Partials::IncludeGroups.new( leading: [UserInclude.new('types_dep.h')] ) )
464
+ allow(@partializer).to receive(:remap_implementation_header_includes).and_return( Partials::IncludeGroups.new( following: [UserInclude.new('impl_h_dep.h')] ) )
465
+ allow(@partializer).to receive(:remap_implementation_source_includes).and_return( [UserInclude.new('impl_c_dep.h')] )
466
+ allow(@partializer).to receive(:remap_interface_header_includes).and_return( Partials::IncludeGroups.new( leading: [UserInclude.new('interface_dep.h')] ) )
467
+
468
+ expect(@dependinator).to receive(:register).at_least(:once) do |_target, meta: {}, **|
469
+ expect( meta[:types_includes] ).to eq( { leading: ['#include "types_dep.h"'], following: [] } )
470
+ expect( meta[:impl_header_includes] ).to eq( { leading: [], following: ['#include "impl_h_dep.h"'] } )
471
+ expect( meta[:impl_source_includes] ).to eq( ['#include "impl_c_dep.h"'] )
472
+ expect( meta[:interface_includes] ).to eq( { leading: ['#include "interface_dep.h"'], following: [] } )
473
+ end
474
+
475
+ @manager.stage_generate_partials( @state )
476
+ end
477
+
478
+ # Remapping logs each list it computes for a named test, so generation's lists are the only ones named
479
+ it "computes generation's include lists once, logged under the test's name, and hands them to generation" do
480
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
481
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
482
+
483
+ impl_h = Partials::IncludeGroups.new( leading: [UserInclude.new('impl_h_dep.h')], following: [UserInclude.new('impl_h_later.h')] )
484
+ impl_c = [UserInclude.new('impl_c_dep.h')]
485
+ interface = Partials::IncludeGroups.new( leading: [UserInclude.new('interface_dep.h')], following: [UserInclude.new('interface_later.h')] )
486
+ expect(@partializer).to receive(:remap_implementation_header_includes).with( hash_including( test: 'a_test' ) ).once.and_return( impl_h )
487
+ expect(@partializer).to receive(:remap_implementation_source_includes).with( hash_including( test: 'a_test' ) ).once.and_return( impl_c )
488
+ expect(@partializer).to receive(:remap_interface_header_includes).with( hash_including( test: 'a_test' ) ).once.and_return( interface )
489
+ expect(@partializer).to receive(:remap_types_header_includes).with( hash_including( test: 'a_test' ) ).once.and_return( Partials::IncludeGroups.new )
490
+
491
+ expect(@generator).to receive(:generate_partial_implementation).with(
492
+ hash_including( header_includes: impl_h.leading, header_following_includes: impl_h.following, source_includes: impl_c )
493
+ )
494
+ expect(@generator).to receive(:generate_partial_interface).with(
495
+ hash_including( includes: interface.leading, following_includes: interface.following )
496
+ )
497
+
498
+ @manager.stage_generate_partials( @state )
499
+ end
500
+
501
+ # A generated header's includes split where the source includes the module's header, so the
502
+ # header remaps need the two lists apart. The implementation source keeps one list.
503
+ it "hands the header remaps the source's and the header's includes apart" do
504
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
505
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
506
+ @config.source.includes = [UserInclude.new( 'Foo.h' ), UserInclude.new( 'log.h' )]
507
+ @config.header.includes = [UserInclude.new( 'base.h' )]
508
+ apart = hash_including( source_includes: @config.source.includes, header_includes: @config.header.includes )
509
+
510
+ %i[remap_types_header_includes remap_implementation_header_includes remap_interface_header_includes].each do |remap|
511
+ expect(@partializer).to receive(remap).with( apart ).twice.and_return( Partials::IncludeGroups.new )
512
+ end
513
+ expect(@partializer).to receive(:remap_implementation_source_includes)
514
+ .with( hash_including( includes: @config.source.includes + @config.header.includes ) ).twice.and_return( [] )
515
+
516
+ @manager.stage_generate_partials( @state )
517
+ end
518
+
519
+ # A real search over `tree`, a list of header paths, as IncludePathinator lists a directory
520
+ def header_search_over(paths, tree)
521
+ return HeaderSearch.new( paths, ->(dir) { tree.select { |header| File.dirname( header ) == dir }.sort } )
522
+ end
523
+
524
+ # The source includes both remaps of the module's includes receive
525
+ def expect_source_includes(includes)
526
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
527
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
528
+
529
+ expect(@partializer).to receive(:remap_types_header_includes)
530
+ .with( hash_including( source_includes: includes ) ).twice.and_return( Partials::IncludeGroups.new )
531
+ expect(@partializer).to receive(:remap_implementation_source_includes)
532
+ .with( hash_including( includes: includes ) ).twice.and_return( [] )
533
+ end
534
+
535
+ # A generated file writes each #include by the text the test's search paths reach its header by
536
+ it "hands the remaps each include spelled as the test's search paths reach its header" do
537
+ @config.source.includes = [UserInclude.new( 'src/drivers/foo.h' )]
538
+ allow(@mock_locator).to receive(:header_search).and_return( header_search_over( ['src'], ['src/drivers/foo.h'] ) )
539
+
540
+ expect_source_includes( [UserInclude.new( 'src/drivers/foo.h', include_path: 'drivers/foo.h' )] )
541
+
542
+ @manager.stage_generate_partials( @state )
543
+ end
544
+
545
+ # A preprocessor's #include holds the path the compiler found its header by
546
+ it "spells a preprocessed #include by the header the compiler found" do
547
+ @config.source.includes = [UserInclude.new( 'include/config.h' )]
548
+ allow(@mock_locator).to receive(:header_search)
549
+ .and_return( header_search_over( ['include', 'third_party/mylib'], ['include/config.h', 'third_party/mylib/include/config.h'] ) )
550
+
551
+ expect_source_includes( [UserInclude.new( 'include/config.h', include_path: 'config.h' )] )
552
+
553
+ @manager.stage_generate_partials( @state )
554
+ end
555
+
556
+ # Fallback's text scan holds an #include as written, which the compiler looks for beside the
557
+ # file holding it before any search path
558
+ it "spells a fallback #include by the header beside the file holding it" do
559
+ @config.source = Partials::ConfigFileInfo.new( filepath: 'src/drivers/uart/config.c', fallback: true, includes: [UserInclude.new( 'config.h' )] )
560
+ allow(@mock_locator).to receive(:header_search)
561
+ .and_return( header_search_over( ['src', 'src/drivers/uart'], ['src/config.h', 'src/drivers/uart/config.h'] ) )
562
+
563
+ expect(@partializer).to receive(:remap_types_header_includes) do |source_includes:, **|
564
+ expect( source_includes.map( &:filepath ) ).to eq( ['src/drivers/uart/config.h'] )
565
+ Partials::IncludeGroups.new
566
+ end.twice
567
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
568
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
569
+
570
+ @manager.stage_generate_partials( @state )
571
+ end
572
+
573
+ it "searches once per test, however many Partials it holds" do
574
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
575
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
576
+ @testable.partials.configs = { 'Foo' => @config, 'Bar' => @config.dup.tap { |c| c.module = 'Bar' } }
577
+
578
+ expect(@mock_locator).to receive(:header_search).with( @testable ).once.and_return( @header_search )
579
+
580
+ @manager.stage_generate_partials( @state )
581
+ end
582
+
583
+ it "computes the record's include lists without a test name, so nothing logs them" do
584
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
585
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
586
+
587
+ %i[remap_types_header_includes remap_implementation_header_includes remap_implementation_source_includes remap_interface_header_includes].each do |remap|
588
+ result = (remap == :remap_implementation_source_includes) ? [] : Partials::IncludeGroups.new
589
+ expect(@partializer).to receive(remap).with( hash_including( test: nil ) ).once.and_return( result )
590
+ end
591
+
592
+ @manager.stage_generate_partials( @state )
593
+ end
594
+
595
+ # Generation reads the preprocessed copies, not the originals. A change that rewrites the
596
+ # copies without touching the originals -- forced fallback toggled, a different
597
+ # preprocessor -- has to regenerate.
598
+ it "registers the preprocessed copies generation reads as antecedent files" do
599
+ allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
600
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
601
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
602
+ @config.header.assembled_filepath = 'build/pp/src/Foo.h'
603
+ @config.header.expansion_filepath = 'build/pp/expanded_code/src/Foo.h'
604
+ @config.source.assembled_filepath = 'build/pp/src/Foo.c'
605
+ @config.source.expansion_filepath = 'build/pp/expanded_code/src/Foo.c'
606
+ @config.header.raw_directives_only_filepath = 'build/pp/directives_only/raw/src/Foo.h'
607
+
608
+ expect(@dependinator).to receive(:register).exactly(3).times do |_target, files: [], **|
609
+ expect( files ).to contain_exactly(
610
+ 'src/Foo.h', 'src/Foo.c',
611
+ 'build/pp/src/Foo.h', 'build/pp/expanded_code/src/Foo.h',
612
+ 'build/pp/src/Foo.c', 'build/pp/expanded_code/src/Foo.c', 'build/pp/directives_only/raw/src/Foo.h'
613
+ )
461
614
  end
462
615
 
463
616
  @manager.stage_generate_partials( @state )
@@ -468,11 +621,11 @@ describe PartialsManager do
468
621
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
469
622
  allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
470
623
 
471
- carried = [UserInclude.new('foundation.h')]
624
+ carried = Partials::IncludeGroups.new( leading: [UserInclude.new('foundation.h')], following: [UserInclude.new('log.h')] )
472
625
  allow(@partializer).to receive(:remap_types_header_includes).and_return( carried )
473
626
 
474
627
  expect(@generator).to receive(:generate_partial_types).with(
475
- hash_including( includes: carried, include_guard: 'FOO_H' )
628
+ hash_including( includes: carried.leading, following_includes: carried.following, include_guard: 'FOO_H' )
476
629
  )
477
630
 
478
631
  @manager.stage_generate_partials( @state )
@@ -494,6 +647,16 @@ describe PartialsManager do
494
647
  @manager.stage_generate_partials( @state )
495
648
  end
496
649
 
650
+ # Every generated file states the guard, so extraction's copy of it is removed
651
+ it "hands the guard to sanitizing the extracted module" do
652
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [] )
653
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [] )
654
+
655
+ expect(@partializer).to receive(:sanitize).with( @module_contents, include_guard: 'FOO_H' )
656
+
657
+ @manager.stage_generate_partials( @state )
658
+ end
659
+
497
660
  it "reads the guard from the module's own header" do
498
661
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [] )
499
662
  allow(@partializer).to receive(:extract_interface_functions).and_return( [] )
@@ -504,12 +667,12 @@ describe PartialsManager do
504
667
  end
505
668
 
506
669
  # Fallback resolves strictly less than the accurate pass, and validate_config refuses the
507
- # shapes it cannot handle. The stage has to tell it which path ran.
508
- it "tells config validation whether preprocessing fell back" do
670
+ # shapes it cannot handle. The Partial's own files record which path ran.
671
+ it "hands config validation the Partial whose files record how they were preprocessed" do
509
672
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [] )
510
673
  allow(@partializer).to receive(:extract_interface_functions).and_return( [] )
511
674
 
512
- expect(@partializer).to receive(:validate_config).with( hash_including( fallback: true ) )
675
+ expect(@partializer).to receive(:validate_config).with( c_module: @module_contents, config: @config, name: 'a_test' )
513
676
 
514
677
  @manager.stage_generate_partials( @state )
515
678
  end
@@ -539,7 +702,137 @@ describe PartialsManager do
539
702
  @manager.stage_generate_partials( @state )
540
703
  end
541
704
 
705
+ # Generated files that are all fresh already hold what extraction would produce
706
+ context "when the implementation and interface are both fresh" do
707
+ before(:each) do
708
+ @config.tests = PartializerConfig::PartialFunctions.new( type: Partials::PUBLIC )
709
+ @config.mocks = PartializerConfig::PartialFunctions.new( type: Partials::PRIVATE )
710
+ allow(@dependinator).to receive(:stale?).and_return( false )
711
+ end
712
+
713
+ it "extracts nothing, yet adds the module to tests and mocks" do
714
+ expect(@partializer).not_to receive(:extract_module_contents)
715
+ expect(@partializer).not_to receive(:validate_config)
716
+ expect(@generator).not_to receive(:generate_partial_implementation)
717
+
718
+ @manager.stage_generate_partials( @state )
719
+
720
+ expect( @testable.partials.tests ).to eq( ['Foo'] )
721
+ expect( @testable.partials.mocks ).to eq( ['Foo'] )
722
+ end
723
+
724
+ it "adds the module only to the list its selection names" do
725
+ @config.mocks = PartializerConfig::PartialFunctions.new
726
+
727
+ @manager.stage_generate_partials( @state )
728
+
729
+ expect( @testable.partials.tests ).to eq( ['Foo'] )
730
+ expect( @testable.partials.mocks ).to eq( [] )
731
+ end
732
+
733
+ # A module mocked from its header alone has only an interface to vouch for it
734
+ it "skips a mock-only Partial on its interface alone" do
735
+ @config.tests = PartializerConfig::PartialFunctions.new
736
+
737
+ expect(@partializer).not_to receive(:extract_module_contents)
738
+ expect(@reportinator).not_to receive(:generate_module_progress).with( hash_including( operation: "Skipping Partial implementation generation for" ) )
739
+
740
+ @manager.stage_generate_partials( @state )
741
+
742
+ expect( @testable.partials.tests ).to eq( [] )
743
+ expect( @testable.partials.mocks ).to eq( ['Foo'] )
744
+ end
745
+
746
+ # A full run prunes the record of any target it never registers
747
+ it "registers a types header still on disk, so its record survives" do
748
+ types = 'build/test/partials/a_test/ceedling_partial_Foo_types.h'
749
+ allow(@file_wrapper).to receive(:exist?).with( types ).and_return( true )
750
+
751
+ @manager.stage_generate_partials( @state )
752
+
753
+ expect(@dependinator).to have_received(:register).with( types, hash_including( :files, :meta ) )
754
+ end
755
+
756
+ # The implementation and interface vouch for the types header they include
757
+ it "leaves the types header's own record out of the decision" do
758
+ types = 'build/test/partials/a_test/ceedling_partial_Foo_types.h'
759
+ allow(@file_wrapper).to receive(:exist?).with( types ).and_return( true )
760
+ allow(@dependinator).to receive(:stale?) { |target| target == types }
761
+
762
+ expect(@partializer).not_to receive(:extract_module_contents)
763
+
764
+ @manager.stage_generate_partials( @state )
765
+ end
766
+
767
+ it "logs a skip line and counts a skip for each file it would have generated" do
768
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
769
+ %w[types implementation interface].each do |kind|
770
+ expect(@reportinator).to receive(:generate_module_progress)
771
+ .with( hash_including( operation: "Skipping Partial #{kind} generation for" ) ).and_return( '' )
772
+ end
773
+ [
774
+ ['Partial types generation', 'types headers'],
775
+ ['Partial implementation generation', 'implementations'],
776
+ ['Partial interface generation', 'interfaces']
777
+ ].each do |task, noun|
778
+ expect(@reportinator).to receive(:generate_skip_summary).with( hash_including( task: task, count: 1, noun: noun ) )
779
+ end
780
+
781
+ @manager.stage_generate_partials( @state )
782
+ end
783
+
784
+ it "extracts and generates when the interface alone is stale" do
785
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
786
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
787
+ allow(@dependinator).to receive(:stale?) { |target| target.end_with?( '_interface.h' ) }
788
+
789
+ expect(@partializer).to receive(:extract_module_contents).and_return( @module_contents )
790
+ expect(@generator).to receive(:generate_partial_interface)
791
+
792
+ @manager.stage_generate_partials( @state )
793
+ end
794
+ end
795
+
796
+ # A types header an earlier build left would pass for current whenever the Partial is next fresh
797
+ it "removes a types header an earlier build left once the module has no types" do
798
+ types = 'build/test/partials/a_test/ceedling_partial_Foo_types.h'
799
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
800
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
801
+ allow(@file_wrapper).to receive(:exist?).with( types ).and_return( true )
802
+
803
+ expect(@file_wrapper).to receive(:rm_f).with( types )
804
+ expect(@dependinator).to receive(:invalidate).with( types )
805
+
806
+ @manager.stage_generate_partials( @state )
807
+ end
808
+
809
+ it "keeps the types header of a module that still has types" do
810
+ allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )
811
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
812
+ allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
813
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
814
+ allow(@file_wrapper).to receive(:rm_f)
815
+
816
+ @manager.stage_generate_partials( @state )
817
+
818
+ expect(@file_wrapper).not_to have_received(:rm_f).with( 'build/test/partials/a_test/ceedling_partial_Foo_types.h' )
819
+ end
820
+
821
+ # Nothing else can vouch for what the module's files would generate
822
+ it "extracts a Partial whose selection names neither an implementation nor an interface" do
823
+ allow(@partializer).to receive(:extract_implementation_functions).and_return( nil )
824
+ allow(@partializer).to receive(:extract_interface_functions).and_return( nil )
825
+ allow(@dependinator).to receive(:stale?).and_return( false )
826
+
827
+ expect(@partializer).to receive(:extract_module_contents).and_return( @module_contents )
828
+
829
+ @manager.stage_generate_partials( @state )
830
+ end
831
+
542
832
  it "logs summary lines stating how many of each Partial artifact were recalled from cache" do
833
+ @config.tests = PartializerConfig::PartialFunctions.new( type: Partials::PUBLIC )
834
+ @config.mocks = PartializerConfig::PartialFunctions.new( type: Partials::PRIVATE )
835
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
543
836
  allow(@partializer).to receive(:extract_implementation_functions).and_return( [double("FunctionDefinition")] )
544
837
  allow(@partializer).to receive(:extract_interface_functions).and_return( [double("FunctionDeclaration")] )
545
838
  allow(@module_contents).to receive(:type_definitions).and_return( [double("TypeDef")] )