ceedling 1.2.1 → 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 (545) hide show
  1. checksums.yaml +4 -4
  2. data/GIT_COMMIT_SHA +1 -1
  3. data/README.md +11 -9
  4. data/Rakefile +2 -1
  5. data/assets/features/ceedling +1 -1
  6. data/assets/fixtures/test_source_file_duplicate_basenames/test_calc_typo.c +14 -0
  7. data/assets/fixtures/tests_with_duplicate_test_names/test_foo.c +21 -0
  8. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
  9. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
  10. data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
  11. data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
  12. data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
  13. data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
  14. data/bin/actionator.rb +6 -12
  15. data/bin/app_cfg.rb +14 -1
  16. data/bin/ceedling +13 -3
  17. data/bin/cli.rb +25 -6
  18. data/bin/cli_handler.rb +113 -73
  19. data/bin/cli_helper.rb +51 -78
  20. data/bin/installation_selector.rb +81 -0
  21. data/bin/launchinator.rb +69 -0
  22. data/bin/mixin_resolvinator.rb +26 -36
  23. data/bin/objects.yml +13 -0
  24. data/bin/path_validator.rb +25 -29
  25. data/bin/versionator.rb +47 -48
  26. data/ceedling.gemspec +19 -15
  27. data/docs/BreakingChanges.md +86 -1
  28. data/docs/Changelog.md +145 -3
  29. data/docs/KnownIssues.md +179 -6
  30. data/docs/ReleaseNotes.md +13 -0
  31. data/examples/wondrous_forest/README.md +29 -1
  32. data/examples/wondrous_forest/src/ForestUnits.h +23 -0
  33. data/examples/wondrous_forest/src/RainGauge.c +59 -0
  34. data/examples/wondrous_forest/src/RainGauge.h +39 -0
  35. data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
  36. data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
  37. data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
  38. data/lib/ceedling/build_log_writer.rb +33 -0
  39. data/lib/ceedling/c_extractor/README.md +15 -7
  40. data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
  41. data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
  42. data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
  43. data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
  44. data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
  45. data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
  46. data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
  47. data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
  48. data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
  49. data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
  50. data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
  51. data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
  52. data/lib/ceedling/c_identifier.rb +21 -0
  53. data/lib/ceedling/ceedling.h +8 -0
  54. data/lib/ceedling/config/build_root_policy.rb +70 -0
  55. data/lib/ceedling/config/configurator.rb +18 -19
  56. data/lib/ceedling/config/configurator_builder.rb +75 -28
  57. data/lib/ceedling/config/configurator_paths_validator.rb +179 -0
  58. data/lib/ceedling/config/configurator_plugins.rb +1 -1
  59. data/lib/ceedling/config/configurator_setup.rb +44 -33
  60. data/lib/ceedling/config/configurator_validator.rb +1 -110
  61. data/lib/ceedling/constants.rb +5 -1
  62. data/lib/ceedling/defaults.rb +35 -5
  63. data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
  64. data/lib/ceedling/dependencies/README.md +18 -16
  65. data/lib/ceedling/dependencies/dependency_cache_store.rb +43 -21
  66. data/lib/ceedling/dependencies/dependency_hasher.rb +35 -1
  67. data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
  68. data/lib/ceedling/dependencies/dependinator.rb +13 -1
  69. data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
  70. data/lib/ceedling/diagnostics/README.md +5 -0
  71. data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
  72. data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
  73. data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
  74. data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
  75. data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
  76. data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
  77. data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
  78. data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
  79. data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
  80. data/lib/ceedling/filename_extension.rb +7 -1
  81. data/lib/ceedling/filesystem/FILE_TREE.md +253 -0
  82. data/lib/ceedling/filesystem/PATH_HANDLING.md +360 -0
  83. data/lib/ceedling/filesystem/README.md +46 -0
  84. data/lib/ceedling/filesystem/build_roots.rb +105 -0
  85. data/lib/ceedling/filesystem/build_subpath.rb +187 -0
  86. data/lib/ceedling/filesystem/destination_collision.rb +25 -0
  87. data/lib/ceedling/{file_finder.rb → filesystem/file_finder.rb} +177 -156
  88. data/lib/ceedling/filesystem/file_finder_helper.rb +154 -0
  89. data/lib/ceedling/filesystem/file_path_collection_utils.rb +183 -0
  90. data/lib/ceedling/{file_path_utils.rb → filesystem/file_path_utils.rb} +200 -167
  91. data/lib/ceedling/{file_system_wrapper.rb → filesystem/file_system_wrapper.rb} +6 -5
  92. data/lib/ceedling/filesystem/file_tree.rb +241 -0
  93. data/lib/ceedling/{file_wrapper.rb → filesystem/file_wrapper.rb} +149 -65
  94. data/lib/ceedling/filesystem/path_exclusions.rb +30 -0
  95. data/lib/ceedling/{path_matcher.rb → filesystem/path_matcher.rb} +48 -23
  96. data/lib/ceedling/{path_mirror.rb → filesystem/path_mirror.rb} +19 -18
  97. data/lib/ceedling/filesystem/path_spellings.rb +55 -0
  98. data/lib/ceedling/filesystem/project_paths.rb +184 -0
  99. data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
  100. data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
  101. data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
  102. data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
  103. data/lib/ceedling/filesystem/working_dir.rb +40 -0
  104. data/lib/ceedling/generators/generator.rb +32 -70
  105. data/lib/ceedling/generators/generator_helper.rb +0 -44
  106. data/lib/ceedling/generators/generator_mocks.rb +5 -0
  107. data/lib/ceedling/generators/generator_partials.rb +306 -244
  108. data/lib/ceedling/generators/generator_test_results_backtrace.rb +7 -7
  109. data/lib/ceedling/generators/generator_test_runner.rb +5 -8
  110. data/lib/ceedling/generators/partial_header_writer.rb +95 -0
  111. data/lib/ceedling/generators/partial_source_writer.rb +137 -0
  112. data/lib/ceedling/handoff.rb +121 -0
  113. data/lib/ceedling/includes/header_search.rb +225 -0
  114. data/lib/ceedling/includes/include_factory.rb +9 -12
  115. data/lib/ceedling/includes/include_pathinator.rb +112 -33
  116. data/lib/ceedling/includes/includes.rb +150 -38
  117. data/lib/ceedling/installation.rb +92 -0
  118. data/lib/ceedling/library_resolver.rb +99 -0
  119. data/lib/ceedling/objects.yml +112 -6
  120. data/lib/ceedling/partials/README.md +110 -16
  121. data/lib/ceedling/partials/carry_plan.rb +71 -0
  122. data/lib/ceedling/partials/definition_head.rb +74 -0
  123. data/lib/ceedling/partials/include_groups.rb +37 -0
  124. data/lib/ceedling/partials/interface_extras.rb +25 -0
  125. data/lib/ceedling/partials/partializer.rb +603 -124
  126. data/lib/ceedling/partials/partializer_config.rb +8 -1
  127. data/lib/ceedling/partials/partializer_helper.rb +851 -145
  128. data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
  129. data/lib/ceedling/partials/partializer_utils.rb +89 -109
  130. data/lib/ceedling/partials/partials.rb +153 -10
  131. data/lib/ceedling/partials/type_macros.rb +126 -0
  132. data/lib/ceedling/plugins/report_log_writer_plugin.rb +3 -5
  133. data/lib/ceedling/preprocess/README.md +43 -33
  134. data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
  135. data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
  136. data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +32 -76
  137. data/lib/ceedling/preprocess/preprocessinator_includes_handler.rb +1 -1
  138. data/lib/ceedling/preprocess/preprocessinator_line_marker_includes_extractor.rb +1 -1
  139. data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
  140. data/lib/ceedling/rake_app/rakefile_component_resolver.rb +10 -17
  141. data/lib/ceedling/rakefile.rb +15 -1
  142. data/lib/ceedling/rakefiles/base/tasks_base.rake +1 -1
  143. data/lib/ceedling/rakefiles/release/rules_release.rake +4 -7
  144. data/lib/ceedling/release_invoker/release_build_executor.rb +33 -44
  145. data/lib/ceedling/release_invoker/release_build_planner.rb +14 -6
  146. data/lib/ceedling/reportinator.rb +3 -4
  147. data/lib/ceedling/setupinator.rb +104 -87
  148. data/lib/ceedling/test_context_extractor.rb +5 -1
  149. data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
  150. data/lib/ceedling/test_invoker/PIPELINE.md +62 -19
  151. data/lib/ceedling/test_invoker/README.md +1 -1
  152. data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
  153. data/lib/ceedling/test_invoker/mock_locator.rb +175 -10
  154. data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
  155. data/lib/ceedling/test_invoker/partials_manager.rb +271 -302
  156. data/lib/ceedling/test_invoker/standin_headerinator.rb +19 -17
  157. data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
  158. data/lib/ceedling/test_invoker/test_build_executor.rb +358 -234
  159. data/lib/ceedling/test_invoker/test_build_planner.rb +46 -33
  160. data/lib/ceedling/test_invoker/test_build_setup.rb +43 -18
  161. data/lib/ceedling/test_invoker/test_build_validations.rb +35 -47
  162. data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
  163. data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +2 -3
  164. data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
  165. data/lib/ceedling/test_invoker/test_invoker.rb +6 -1
  166. data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
  167. data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +6 -4
  168. data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
  169. data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
  170. data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
  171. data/lib/ceedling/test_invoker/test_source_file_directive_resolver.rb +40 -20
  172. data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
  173. data/lib/ceedling/tools/shell_quoting.rb +45 -0
  174. data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +9 -3
  175. data/lib/ceedling/tools/tool_quoting.rb +79 -0
  176. data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
  177. data/lib/ceedling/yaml_wrapper.rb +3 -2
  178. data/lib/version.rb +1 -1
  179. data/plugins/bullseye/bullseye.rake +1 -3
  180. data/plugins/bullseye/config/defaults_bullseye.rb +1 -1
  181. data/plugins/bullseye/lib/bullseye.rb +24 -9
  182. data/plugins/command_hooks/lib/command_hooks.rb +1 -1
  183. data/plugins/cppcheck/config/defaults_cppcheck.rb +1 -1
  184. data/plugins/dependencies/config/defaults.yml +6 -6
  185. data/plugins/dependencies/dependencies.rake +4 -1
  186. data/plugins/dependencies/lib/dependencies.rb +18 -8
  187. data/plugins/dependencies/lib/dependency_spec.rb +17 -5
  188. data/plugins/fff/lib/fff.rb +79 -46
  189. data/plugins/fff/lib/fff_mock_generator.rb +12 -9
  190. data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +262 -0
  191. data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
  192. data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
  193. data/plugins/gcov/config/defaults_gcov.rb +1 -1
  194. data/plugins/gcov/lib/console_reportinator.rb +28 -36
  195. data/plugins/gcov/lib/gcov.rb +9 -2
  196. data/plugins/gcov/lib/gcovr_reportinator.rb +8 -40
  197. data/plugins/gcov/lib/gcovr_thresholds.rb +74 -0
  198. data/plugins/gcov/lib/reportgenerator_reportinator.rb +3 -2
  199. data/plugins/module_generator/lib/module_generator.rb +3 -3
  200. data/plugins/report_tests_teamcity_stdout/lib/report_tests_teamcity_stdout.rb +53 -80
  201. data/plugins/sanitize/lib/sanitize_records.rb +3 -6
  202. data/plugins/valgrind/lib/valgrind.rb +14 -7
  203. data/site-local/404.html +2 -2
  204. data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
  205. data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
  206. data/site-local/configuration/environment-vars.html +2 -2
  207. data/site-local/configuration/global-collections.html +3 -3
  208. data/site-local/configuration/index.html +2 -2
  209. data/site-local/configuration/loading.html +2 -2
  210. data/site-local/configuration/mixins.html +2 -2
  211. data/site-local/configuration/parallel-builds.html +2 -2
  212. data/site-local/configuration/project-file.html +2 -2
  213. data/site-local/configuration/reference/cexception.html +2 -2
  214. data/site-local/configuration/reference/cmock.html +7 -3
  215. data/site-local/configuration/reference/defines.html +2 -2
  216. data/site-local/configuration/reference/environment.html +2 -2
  217. data/site-local/configuration/reference/extension.html +2 -2
  218. data/site-local/configuration/reference/files.html +65 -12
  219. data/site-local/configuration/reference/flags.html +2 -2
  220. data/site-local/configuration/reference/index.html +2 -2
  221. data/site-local/configuration/reference/libraries.html +23 -5
  222. data/site-local/configuration/reference/mixins.html +2 -2
  223. data/site-local/configuration/reference/partials.html +84 -2
  224. data/site-local/configuration/reference/paths.html +36 -8
  225. data/site-local/configuration/reference/plugins.html +2 -2
  226. data/site-local/configuration/reference/project.html +264 -12
  227. data/site-local/configuration/reference/release-build.html +4 -2
  228. data/site-local/configuration/reference/test-build.html +2 -2
  229. data/site-local/configuration/reference/test-runner.html +2 -2
  230. data/site-local/configuration/reference/tools.html +58 -4
  231. data/site-local/configuration/reference/unity.html +2 -2
  232. data/site-local/configuration/which-ceedling.html +379 -19
  233. data/site-local/development/index.html +2 -2
  234. data/site-local/development/plugins/configuration.html +2 -2
  235. data/site-local/development/plugins/index.html +2 -2
  236. data/site-local/development/plugins/plugin-subclass.html +5 -4
  237. data/site-local/development/plugins/rake-tasks.html +2 -2
  238. data/site-local/development/releases.html +7 -3
  239. data/site-local/development/workflow.html +50 -45
  240. data/site-local/getting-started/builds.html +4 -2
  241. data/site-local/getting-started/command-line.html +58 -6
  242. data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
  243. data/site-local/getting-started/example-projects/index.html +2 -2
  244. data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
  245. data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
  246. data/site-local/getting-started/index.html +2 -2
  247. data/site-local/getting-started/installation.html +2 -2
  248. data/site-local/getting-started/quick-start.html +2 -2
  249. data/site-local/help.html +2 -2
  250. data/site-local/index.html +2 -2
  251. data/site-local/overview/build-system.html +2 -2
  252. data/site-local/overview/index.html +2 -2
  253. data/site-local/overview/test-environments.html +2 -2
  254. data/site-local/overview/tools-and-frameworks.html +2 -2
  255. data/site-local/plugins/beep.html +2 -2
  256. data/site-local/plugins/bullseye/index.html +45 -38
  257. data/site-local/plugins/bullseye/licensing.html +2 -2
  258. data/site-local/plugins/command-hooks.html +4 -4
  259. data/site-local/plugins/compile-commands-json-db.html +2 -2
  260. data/site-local/plugins/cppcheck.html +2 -2
  261. data/site-local/plugins/dependencies.html +8 -5
  262. data/site-local/plugins/fff.html +58 -13
  263. data/site-local/plugins/gcov/examples.html +2 -2
  264. data/site-local/plugins/gcov/gcovr.html +23 -14
  265. data/site-local/plugins/gcov/index.html +2 -2
  266. data/site-local/plugins/gcov/overview.html +2 -2
  267. data/site-local/plugins/gcov/reportgenerator.html +18 -14
  268. data/site-local/plugins/gcov/reporting.html +2 -2
  269. data/site-local/plugins/gcov/setup.html +4 -3
  270. data/site-local/plugins/gcov/tool-versions.html +2 -2
  271. data/site-local/plugins/gcov/troubleshooting.html +2 -2
  272. data/site-local/plugins/index.html +2 -2
  273. data/site-local/plugins/module-generator.html +2 -2
  274. data/site-local/plugins/report-build-warnings-log.html +2 -2
  275. data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
  276. data/site-local/plugins/report-tests-ide-stdout.html +2 -2
  277. data/site-local/plugins/report-tests-log-factory.html +2 -2
  278. data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
  279. data/site-local/plugins/report-tests-raw-output-log.html +5 -3
  280. data/site-local/plugins/report-tests-teamcity-stdout.html +8 -5
  281. data/site-local/plugins/sanitize.html +9 -8
  282. data/site-local/plugins/valgrind.html +10 -9
  283. data/site-local/project/index.html +2 -2
  284. data/site-local/project/release-history.html +2 -2
  285. data/site-local/project/sbom.html +2 -2
  286. data/site-local/project/upgrade.html +5 -2
  287. data/site-local/reference/build-directives.html +2 -2
  288. data/site-local/reference/command-line.html +11 -4
  289. data/site-local/reference/environment-vars.html +2 -2
  290. data/site-local/reference/gcov-plugin.html +2 -2
  291. data/site-local/reference/global-collections.html +12 -12
  292. data/site-local/reference/index.html +2 -2
  293. data/site-local/reference/partials-macros.html +47 -2
  294. data/site-local/reference/project-configuration.html +2 -2
  295. data/site-local/sitemap.xml.gz +0 -0
  296. data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
  297. data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
  298. data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
  299. data/site-local/snapshot/plugins/bullseye/config/defaults_bullseye.rb +1 -1
  300. data/site-local/snapshot/plugins/gcov/config/defaults_gcov.rb +1 -1
  301. data/site-local/testing-guide/build-directives.html +2 -2
  302. data/site-local/testing-guide/conventions.html +113 -15
  303. data/site-local/testing-guide/frameworks.html +2 -2
  304. data/site-local/testing-guide/index.html +2 -2
  305. data/site-local/testing-guide/partials/configuration.html +31 -4
  306. data/site-local/testing-guide/partials/conventions.html +509 -8
  307. data/site-local/testing-guide/partials/directives.html +4 -3
  308. data/site-local/testing-guide/partials/example.html +2 -2
  309. data/site-local/testing-guide/partials/index.html +2 -2
  310. data/site-local/testing-guide/partials/overview.html +30 -12
  311. data/site-local/testing-guide/partials/variables.html +169 -4
  312. data/site-local/testing-guide/test-cases.html +2 -2
  313. data/site-local/testing-guide/test-sample.html +2 -2
  314. data/site-local/testing-guide/test-suite-anatomy.html +2 -2
  315. data/spec/integration/actionator_file_operations_spec.rb +91 -1
  316. data/spec/integration/build_step_doctor_spec.rb +270 -0
  317. data/spec/integration/c_extractor_composition_spec.rb +254 -4
  318. data/spec/integration/compile_commands_json_db_spec.rb +1 -1
  319. data/spec/integration/configurator_validation_spec.rb +1 -1
  320. data/spec/integration/dependencies/dependency_tracker_cache_hardening_spec.rb +26 -0
  321. data/spec/integration/dependencies/dependency_tracker_core_spec.rb +22 -0
  322. data/spec/integration/includes_extraction_spec.rb +27 -14
  323. data/spec/integration/launcher_handoff_spec.rb +297 -0
  324. data/spec/integration/mixin_loading_spec.rb +1 -1
  325. data/spec/integration/module_generator_spec.rb +3 -3
  326. data/spec/integration/nested_test_artifacts_spec.rb +99 -0
  327. data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
  328. data/spec/integration/partials_carry_spec.rb +520 -0
  329. data/spec/integration/partials_declarations_spec.rb +655 -0
  330. data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
  331. data/spec/integration/partials_function_pointers_spec.rb +277 -0
  332. data/spec/integration/partials_header_composition_spec.rb +268 -35
  333. data/spec/integration/partials_macro_decorators_spec.rb +267 -0
  334. data/spec/integration/partials_module_resolution_spec.rb +33 -23
  335. data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
  336. data/spec/integration/path_intake_scenarios_spec.rb +101 -0
  337. data/spec/integration/path_length_reporting_spec.rb +64 -0
  338. data/spec/integration/path_scenarios_spec.rb +399 -0
  339. data/spec/integration/quote_include_isolator_spec.rb +57 -1
  340. data/spec/integration/report_build_warnings_log_spec.rb +1 -1
  341. data/spec/integration/report_tests_log_factory_spec.rb +1 -1
  342. data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
  343. data/spec/integration/test_executable_manifest_spec.rb +1 -1
  344. data/spec/integration/test_includes_extractinator_spec.rb +69 -3
  345. data/spec/integration/test_naming_spec.rb +201 -0
  346. data/spec/integration/test_source_file_checks_spec.rb +168 -0
  347. data/spec/integration/tool_executor_spec.rb +1 -1
  348. data/spec/integration/tool_validator_spec.rb +3 -3
  349. data/spec/integration/upgrade_docs_spec.rb +84 -0
  350. data/spec/integration/vendor_copy_transient_io_retry_spec.rb +74 -5
  351. data/spec/integration/win_long_paths_probe_spec.rb +46 -0
  352. data/spec/integration/win_path_limit_spec.rb +53 -0
  353. data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
  354. data/spec/support/file_tree_helper.rb +88 -0
  355. data/spec/support/integration/configurator_integration_helper.rb +14 -9
  356. data/spec/support/integration/dependency_tracker_integration_helper.rb +1 -1
  357. data/spec/support/integration/partial_files_harness.rb +181 -0
  358. data/spec/support/integration/partials_generation_integration_helper.rb +239 -143
  359. data/spec/support/integration/path_scenario_harness.rb +175 -0
  360. data/spec/support/integration/spec_integration_helper.rb +9 -4
  361. data/spec/support/integration/test_includes_harness.rb +69 -37
  362. data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
  363. data/spec/support/spec_helper.rb +2 -0
  364. data/spec/support/system/spec_system_helper.rb +7 -6
  365. data/spec/support/system/system_context.rb +21 -3
  366. data/spec/support/working_dir_tracking.rb +49 -0
  367. data/spec/system/build_output_mirroring_spec.rb +2 -2
  368. data/spec/system/bullseye_deployment_spec.rb +2 -0
  369. data/spec/system/conditional_mock_includes_spec.rb +1 -1
  370. data/spec/system/delta_builds_spec.rb +163 -23
  371. data/spec/system/encoding_stress_spec.rb +4 -4
  372. data/spec/system/example_wondrous_forest_spec.rb +2 -2
  373. data/spec/system/gcov_deployment_spec.rb +3 -0
  374. data/spec/system/header_include_path_validation_spec.rb +4 -4
  375. data/spec/system/header_search_paths_spec.rb +1083 -0
  376. data/spec/system/launcher_handoff_spec.rb +82 -0
  377. data/spec/system/mock_include_folders_spec.rb +212 -0
  378. data/spec/system/mockable_header_reassembly_spec.rb +184 -0
  379. data/spec/system/parent_directory_reference_spec.rb +5 -3
  380. data/spec/system/partials_carry_spec.rb +581 -0
  381. data/spec/system/partials_delta_builds_spec.rb +280 -0
  382. data/spec/system/partials_function_pointers_spec.rb +106 -0
  383. data/spec/system/partials_macro_decorators_spec.rb +127 -0
  384. data/spec/system/partials_module_disambiguation_spec.rb +125 -0
  385. data/spec/system/path_handling_probes_spec.rb +196 -0
  386. data/spec/system/pinned_thread_count_spec.rb +4 -4
  387. data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
  388. data/spec/system/preprocessing_parameterized_tests_spec.rb +1 -1
  389. data/spec/system/rake_release_task_path_disambiguation_spec.rb +6 -6
  390. data/spec/system/rake_test_task_path_disambiguation_spec.rb +85 -0
  391. data/spec/system/short_build_paths_spec.rb +87 -0
  392. data/spec/system/sibling_header_collision_spec.rb +30 -6
  393. data/spec/system/special_path_characters_spec.rb +86 -0
  394. data/spec/system/support/bullseye_common_test_cases.rb +42 -0
  395. data/spec/system/support/common_test_cases.rb +23 -21
  396. data/spec/system/support/gcov_common_test_cases.rb +37 -9
  397. data/spec/system/support/gcov_partials_test_cases.rb +48 -0
  398. data/spec/system/support/sanitize_common_test_cases.rb +2 -2
  399. data/spec/system/support/valgrind_common_test_cases.rb +12 -12
  400. data/spec/system/test_build_layout_spec.rb +209 -0
  401. data/spec/system/test_pipeline_stop_points_spec.rb +4 -4
  402. data/spec/system/test_runner_system_include_spec.rb +1 -1
  403. data/spec/system/test_source_file_directive_spec.rb +64 -5
  404. data/spec/units/bin/actionator_spec.rb +14 -17
  405. data/spec/units/bin/app_cfg_spec.rb +37 -0
  406. data/spec/units/bin/cli_handler_spec.rb +282 -6
  407. data/spec/units/bin/cli_helper_spec.rb +116 -45
  408. data/spec/units/bin/installation_selector_spec.rb +114 -0
  409. data/spec/units/bin/launchinator_spec.rb +171 -0
  410. data/spec/units/bin/path_validator_spec.rb +10 -0
  411. data/spec/units/bin/versionator_spec.rb +38 -6
  412. data/spec/units/build_log_writer_spec.rb +57 -0
  413. data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
  414. data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
  415. data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
  416. data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
  417. data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
  418. data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
  419. data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
  420. data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
  421. data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
  422. data/spec/units/c_identifier_spec.rb +35 -0
  423. data/spec/units/config/build_root_policy_spec.rb +61 -0
  424. data/spec/units/config/configurator_builder_spec.rb +61 -6
  425. data/spec/units/config/configurator_paths_validator_spec.rb +292 -0
  426. data/spec/units/config/configurator_setup_spec.rb +80 -68
  427. data/spec/units/config/configurator_spec.rb +54 -6
  428. data/spec/units/config/configurator_validator_spec.rb +1 -172
  429. data/spec/units/dependencies/dependency_cache_store_spec.rb +98 -2
  430. data/spec/units/dependencies/dependency_debug_tree_spec.rb +1 -1
  431. data/spec/units/dependencies/dependency_hasher_spec.rb +42 -1
  432. data/spec/units/dependencies/dependency_path_normalizer_spec.rb +1 -1
  433. data/spec/units/dependencies/dependency_tracker_spec.rb +28 -1
  434. data/spec/units/dependencies/dependinator_spec.rb +17 -2
  435. data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
  436. data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
  437. data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
  438. data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
  439. data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
  440. data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
  441. data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
  442. data/spec/units/encodinator_spec.rb +3 -4
  443. data/spec/units/filename_extension_spec.rb +11 -0
  444. data/spec/units/filesystem/build_roots_spec.rb +131 -0
  445. data/spec/units/filesystem/build_subpath_spec.rb +235 -0
  446. data/spec/units/filesystem/destination_collision_spec.rb +30 -0
  447. data/spec/units/{file_finder_helper_spec.rb → filesystem/file_finder_helper_spec.rb} +126 -1
  448. data/spec/units/filesystem/file_finder_spec.rb +845 -0
  449. data/spec/units/{file_path_collection_utils_spec.rb → filesystem/file_path_collection_utils_spec.rb} +181 -1
  450. data/spec/units/{file_path_utils_spec.rb → filesystem/file_path_utils_spec.rb} +435 -185
  451. data/spec/units/filesystem/file_system_wrapper_spec.rb +33 -0
  452. data/spec/units/filesystem/file_tree_spec.rb +511 -0
  453. data/spec/units/filesystem/file_tree_windows_spec.rb +78 -0
  454. data/spec/units/{file_wrapper_spec.rb → filesystem/file_wrapper_spec.rb} +286 -18
  455. data/spec/units/{path_matcher_spec.rb → filesystem/path_matcher_spec.rb} +48 -1
  456. data/spec/units/{path_mirror_spec.rb → filesystem/path_mirror_spec.rb} +32 -4
  457. data/spec/units/filesystem/project_paths_spec.rb +147 -0
  458. data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
  459. data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
  460. data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
  461. data/spec/units/filesystem/working_dir_spec.rb +71 -0
  462. data/spec/units/generators/generator_helper_spec.rb +0 -60
  463. data/spec/units/generators/generator_mocks_spec.rb +13 -0
  464. data/spec/units/generators/generator_partials_spec.rb +656 -55
  465. data/spec/units/generators/generator_spec.rb +38 -6
  466. data/spec/units/generators/generator_test_results_backtrace_spec.rb +50 -46
  467. data/spec/units/generators/generator_test_results_spec.rb +1 -1
  468. data/spec/units/generators/generator_test_runner_spec.rb +9 -5
  469. data/spec/units/generators/partial_source_writer_spec.rb +129 -0
  470. data/spec/units/handoff_spec.rb +205 -0
  471. data/spec/units/includes/header_search_spec.rb +406 -0
  472. data/spec/units/includes/include_factory_spec.rb +23 -6
  473. data/spec/units/includes/include_pathinator_spec.rb +118 -8
  474. data/spec/units/includes/include_spec.rb +14 -0
  475. data/spec/units/includes/includes_spec.rb +176 -19
  476. data/spec/units/installation_spec.rb +228 -0
  477. data/spec/units/library_resolver_spec.rb +157 -0
  478. data/spec/units/loginator_spec.rb +31 -0
  479. data/spec/units/mock_locator_spec.rb +275 -6
  480. data/spec/units/partials/include_groups_spec.rb +42 -0
  481. data/spec/units/partials/partializer_config_spec.rb +32 -0
  482. data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
  483. data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
  484. data/spec/units/partials/partializer_helper_spec.rb +529 -277
  485. data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
  486. data/spec/units/partials/partializer_spec.rb +1579 -270
  487. data/spec/units/partials/partializer_utils_spec.rb +269 -232
  488. data/spec/units/partials/partials_rename_spec.rb +160 -0
  489. data/spec/units/partials_manager_spec.rb +561 -251
  490. data/spec/units/plugins/bullseye_spec.rb +49 -2
  491. data/spec/units/plugins/console_reportinator_spec.rb +73 -26
  492. data/spec/units/plugins/dependencies_spec.rb +33 -7
  493. data/spec/units/plugins/dependency_spec_spec.rb +17 -0
  494. data/spec/units/plugins/gcov_spec.rb +28 -3
  495. data/spec/units/plugins/gcovr_reportinator_spec.rb +19 -47
  496. data/spec/units/plugins/gcovr_thresholds_spec.rb +95 -0
  497. data/spec/units/plugins/module_generator_spec.rb +5 -5
  498. data/spec/units/plugins/report_build_warnings_log_spec.rb +3 -3
  499. data/spec/units/plugins/report_log_writer_plugin_spec.rb +10 -1
  500. data/spec/units/plugins/report_tests_raw_output_log_spec.rb +13 -2
  501. data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +77 -3
  502. data/spec/units/plugins/reportgenerator_reportinator_spec.rb +52 -4
  503. data/spec/units/plugins/sanitize_records_spec.rb +3 -1
  504. data/spec/units/plugins/sanitize_spec.rb +1 -1
  505. data/spec/units/plugins/valgrind_spec.rb +23 -8
  506. data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
  507. data/spec/units/preprocess/preprocessinator_comment_stripper_spec.rb +1 -1
  508. data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
  509. data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
  510. data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
  511. data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
  512. data/spec/units/rake_app/rakefile_component_resolver_spec.rb +21 -0
  513. data/spec/units/release_build_executor_spec.rb +53 -14
  514. data/spec/units/release_build_planner_spec.rb +15 -3
  515. data/spec/units/reportinator_spec.rb +5 -5
  516. data/spec/units/setupinator_spec.rb +51 -0
  517. data/spec/units/standin_headerinator_spec.rb +55 -9
  518. data/spec/units/test_build_executor_spec.rb +842 -166
  519. data/spec/units/test_build_planner_spec.rb +205 -15
  520. data/spec/units/test_build_setup_spec.rb +179 -30
  521. data/spec/units/test_context_extractor_spec.rb +36 -2
  522. data/spec/units/test_derived_search_paths_spec.rb +259 -0
  523. data/spec/units/test_file_preprocessinator_spec.rb +17 -1
  524. data/spec/units/test_includes_extractinator_spec.rb +61 -9
  525. data/spec/units/test_invoker/objects_wiring_spec.rb +24 -4
  526. data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
  527. data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
  528. data/spec/units/test_invoker_spec.rb +14 -1
  529. data/spec/units/test_invoker_types_spec.rb +8 -7
  530. data/spec/units/test_pipeline_manager_spec.rb +54 -13
  531. data/spec/units/test_runner_generatinator_spec.rb +93 -1
  532. data/spec/units/test_search_paths_spec.rb +73 -5
  533. data/spec/units/test_source_file_directive_resolver_spec.rb +38 -7
  534. data/spec/units/tools/default_tools_quoting_spec.rb +117 -0
  535. data/spec/units/tools/shell_quoting_spec.rb +76 -0
  536. data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
  537. data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +27 -1
  538. data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
  539. data/spec/units/windows_registry_query_tool_spec.rb +53 -0
  540. data/spec/units/yaml_wrapper_spec.rb +11 -0
  541. metadata +265 -36
  542. data/lib/ceedling/file_finder_helper.rb +0 -127
  543. data/lib/ceedling/file_path_collection_utils.rb +0 -164
  544. data/spec/units/file_finder_spec.rb +0 -495
  545. /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
@@ -10,8 +10,10 @@ require 'spec_helper'
10
10
  require 'ceedling/includes/includes'
11
11
  require 'ceedling/partials/partializer'
12
12
  require 'ceedling/partials/partials'
13
+ require 'ceedling/partials/partializer_config'
13
14
  require 'ceedling/reportinator'
14
15
  require 'ceedling/c_extractor/c_extractor_types'
16
+ require 'ceedling/c_extractor/c_extractor_defined_type'
15
17
  require 'ostruct'
16
18
 
17
19
  describe Partializer do
@@ -26,23 +28,26 @@ describe Partializer do
26
28
  # Guard extraction reads the module's own header text through these two.
27
29
  @preprocessinator_reconstructor = double("PreprocessinatorReconstructor")
28
30
  @file_wrapper = double("FileWrapper")
31
+ @partializer_reconciler = double("PartializerReconciler")
29
32
 
30
33
  @configurator = double( "Configurator" )
31
34
  allow(@configurator).to receive(:paths_test).and_return( ['test'] )
32
35
  allow(@configurator).to receive(:paths_support).and_return( [] )
33
36
  allow(@configurator).to receive(:paths_include).and_return( ['include'] )
37
+ allow(@configurator).to receive(:collection_mirror_roots_headers).and_return( ['test', 'include'] )
34
38
 
35
39
  @partializer = described_class.new(
36
40
  {
37
- :configurator => @configurator,
38
- :partializer_helper => @partializer_helper,
39
- :file_finder => @file_finder,
40
- :c_extractor => @c_extractor,
41
- :file_path_utils => @file_path_utils,
41
+ :configurator => @configurator,
42
+ :partializer_helper => @partializer_helper,
43
+ :partializer_reconciler => @partializer_reconciler,
44
+ :file_finder => @file_finder,
45
+ :c_extractor => @c_extractor,
46
+ :file_path_utils => @file_path_utils,
42
47
  :preprocessinator_reconstructor => @preprocessinator_reconstructor,
43
- :file_wrapper => @file_wrapper,
44
- :reportinator => @reportinator,
45
- :loginator => @loginator
48
+ :file_wrapper => @file_wrapper,
49
+ :reportinator => @reportinator,
50
+ :loginator => @loginator
46
51
  }
47
52
  )
48
53
 
@@ -57,10 +62,11 @@ describe Partializer do
57
62
  # A stand-in for another partialized module's config. Only the two visibility types matter to
58
63
  # include remapping: a non-nil mocks type means that module has a generated interface header
59
64
  # to redirect to.
60
- def make_partial_config(mocks_type: nil, tests_type: nil)
65
+ def make_partial_config(mocks_type: nil, tests_type: nil, header: nil)
61
66
  OpenStruct.new(
62
67
  mocks: OpenStruct.new(type: mocks_type),
63
- tests: OpenStruct.new(type: tests_type)
68
+ tests: OpenStruct.new(type: tests_type),
69
+ header: OpenStruct.new(filepath: header)
64
70
  )
65
71
  end
66
72
 
@@ -275,7 +281,7 @@ describe Partializer do
275
281
  context "#validate_config" do
276
282
  it "delegates to three validation helpers in order" do
277
283
  c_module = double("CModule")
278
- config = double("Config")
284
+ config = double("Config", fallback?: false)
279
285
  name = "test_foo"
280
286
 
281
287
  expect(@partializer_helper).to receive(:validate_function_names_exist)
@@ -285,11 +291,11 @@ describe Partializer do
285
291
  expect(@partializer_helper).to receive(:validate_additions_subtractions_visibility)
286
292
  .with(c_module, config, name).ordered
287
293
 
288
- @partializer.validate_config(c_module: c_module, config: config, name: name, fallback: false)
294
+ @partializer.validate_config(c_module: c_module, config: config, name: name)
289
295
  end
290
296
 
291
297
  # The fourth check only applies where preprocessing resolved less than it could, so the
292
- # accurate path must not pay for it.
298
+ # accurate path must not pay for it. The Partial's own files say which path ran.
293
299
  it "does not check fallback sufficiency when preprocessing was accurate" do
294
300
  allow(@partializer_helper).to receive(:validate_function_names_exist)
295
301
  allow(@partializer_helper).to receive(:validate_no_additions_subtractions_overlap)
@@ -298,7 +304,7 @@ describe Partializer do
298
304
  expect(@partializer_helper).not_to receive(:validate_fallback_sufficiency)
299
305
 
300
306
  @partializer.validate_config(
301
- c_module: double("CModule"), config: double("Config"), name: 'test_foo', fallback: false
307
+ c_module: double("CModule"), config: double("Config", fallback?: false), name: 'test_foo'
302
308
  )
303
309
  end
304
310
 
@@ -307,10 +313,10 @@ describe Partializer do
307
313
  allow(@partializer_helper).to receive(:validate_no_additions_subtractions_overlap)
308
314
  allow(@partializer_helper).to receive(:validate_additions_subtractions_visibility)
309
315
 
310
- config = Partials::Config.new(
316
+ config = PartializerConfig::Config.new(
311
317
  module: 'Foo',
312
- header: Partials::ConfigFileInfo.new( filepath: 'src/Foo.h' ),
313
- source: Partials::ConfigFileInfo.new( filepath: 'src/Foo.c' )
318
+ header: Partials::ConfigFileInfo.new( filepath: 'src/Foo.h', assembled_filepath: 'build/Foo.h', fallback: true ),
319
+ source: Partials::ConfigFileInfo.new( filepath: 'src/Foo.c', assembled_filepath: 'build/Foo.c', fallback: true )
314
320
  )
315
321
 
316
322
  allow(@file_wrapper).to receive(:read).with('src/Foo.h').and_return('header text')
@@ -323,7 +329,7 @@ describe Partializer do
323
329
  )
324
330
 
325
331
  @partializer.validate_config(
326
- c_module: double("CModule"), config: config, name: 'test_foo', fallback: true
332
+ c_module: double("CModule"), config: config, name: 'test_foo'
327
333
  )
328
334
  end
329
335
 
@@ -334,9 +340,9 @@ describe Partializer do
334
340
  allow(@partializer_helper).to receive(:validate_no_additions_subtractions_overlap)
335
341
  allow(@partializer_helper).to receive(:validate_additions_subtractions_visibility)
336
342
 
337
- config = Partials::Config.new(
343
+ config = PartializerConfig::Config.new(
338
344
  module: 'Foo',
339
- header: Partials::ConfigFileInfo.new( filepath: 'src/Foo.h' ),
345
+ header: Partials::ConfigFileInfo.new( filepath: 'src/Foo.h', assembled_filepath: 'build/Foo.h', fallback: true ),
340
346
  source: Partials::ConfigFileInfo.new( filepath: nil )
341
347
  )
342
348
 
@@ -347,9 +353,32 @@ describe Partializer do
347
353
  )
348
354
 
349
355
  @partializer.validate_config(
350
- c_module: double("CModule"), config: config, name: 'test_foo', fallback: true
356
+ c_module: double("CModule"), config: config, name: 'test_foo'
351
357
  )
352
358
  end
359
+
360
+ # Fallback's limits belong to the file that fell back, so an accurately preprocessed one is
361
+ # never refused for a computed #include fallback can't resolve
362
+ it "checks only the module files preprocessed in fallback" do
363
+ allow(@partializer_helper).to receive(:validate_function_names_exist)
364
+ allow(@partializer_helper).to receive(:validate_no_additions_subtractions_overlap)
365
+ allow(@partializer_helper).to receive(:validate_additions_subtractions_visibility)
366
+
367
+ config = PartializerConfig::Config.new(
368
+ module: 'Foo',
369
+ header: Partials::ConfigFileInfo.new( filepath: 'src/Foo.h', assembled_filepath: 'build/Foo.h', fallback: true ),
370
+ source: Partials::ConfigFileInfo.new( filepath: 'src/Foo.c', assembled_filepath: 'build/Foo.c', fallback: false )
371
+ )
372
+
373
+ allow(@file_wrapper).to receive(:read).with('src/Foo.h').and_return('header text')
374
+ expect(@file_wrapper).not_to receive(:read).with('src/Foo.c')
375
+
376
+ expect(@partializer_helper).to receive(:validate_fallback_sufficiency).with(
377
+ name: 'test_foo', module_name: 'Foo', files: { 'src/Foo.h' => 'header text' }
378
+ )
379
+
380
+ @partializer.validate_config( c_module: double("CModule"), config: config, name: 'test_foo' )
381
+ end
353
382
  end
354
383
 
355
384
  ###
@@ -360,9 +389,9 @@ describe Partializer do
360
389
  # Read from the original header, not the reconstituted copy: that copy carries a synthetic
361
390
  # guard which #sanitize then strips, and fallback preprocessing excludes a guard from the
362
391
  # macros it recovers. Neither is a dependable source for the name to spoof.
363
- it "reads a bounded prefix of the module's own header and returns the guard found" do
392
+ it "reads the module's own header and returns the guard found" do
364
393
  expect(@file_wrapper).to receive(:read)
365
- .with('src/Foo.h', Partializer::GUARD_SCAN_BYTES)
394
+ .with('src/Foo.h')
366
395
  .and_return("#ifndef FOO_H\n#define FOO_H\n")
367
396
  allow(@preprocessinator_reconstructor).to receive(:extract_include_guard)
368
397
  .with("#ifndef FOO_H\n#define FOO_H\n")
@@ -470,6 +499,30 @@ describe Partializer do
470
499
  expect(mod.macro_definitions).to eq(lookalikes)
471
500
  end
472
501
 
502
+ # The real header's own guard survives preprocessing too, and every generated file states it
503
+ # deliberately. A carried copy would only repeat it.
504
+ it "removes the real header's own guard when given it" do
505
+ guard = make_macro('#define MY_MODULE_H')
506
+ kept = make_macro('#define MY_DEFINE 1')
507
+ mod = make_module(macros: [guard, kept])
508
+
509
+ @partializer.sanitize(mod, include_guard: 'MY_MODULE_H')
510
+
511
+ expect(mod.macro_definitions).to eq([kept])
512
+ expect(mod.element_sequence).to eq([kept])
513
+ end
514
+
515
+ # A macro whose name merely begins with the guard's, and a guard-named macro carrying a
516
+ # value, are neither of them the guard statement
517
+ it "keeps a macro whose name only resembles the real header's guard" do
518
+ lookalikes = [make_macro('#define MY_MODULE_H_LIMIT 8'), make_macro('#define MY_MODULE_H 2')]
519
+ mod = make_module(macros: lookalikes)
520
+
521
+ @partializer.sanitize(mod, include_guard: 'MY_MODULE_H')
522
+
523
+ expect(mod.macro_definitions).to eq(lookalikes)
524
+ end
525
+
473
526
  it "does not remove non-macro elements from element_sequence" do
474
527
  generated = make_macro('#ifndef GEN0123ABCD_C_H_CEEDLING')
475
528
  other_elem = double('CFunction', text: 'void foo(void){}')
@@ -496,6 +549,373 @@ describe Partializer do
496
549
  ### validate_extracted_functions()
497
550
  ###
498
551
 
552
+ context "#plan_carry" do
553
+ before(:each) do
554
+ allow(@file_wrapper).to receive(:read).with( 'src/engine.h' ).and_return( "int engine_get(void);\n" )
555
+ end
556
+
557
+ it "returns the helper's plan for the module and both selections" do
558
+ c_module = CExtractorTypes::CModule.new
559
+ impl = [Partials.manufacture_function_definition( name: 'get', signature: 'int get(void)', code_block: '' )]
560
+ plan = Partials::CarryPlan.new
561
+
562
+ expect(@partializer_helper).to receive(:plan_carry).with(
563
+ c_module: c_module, impl: impl, interface: nil, fallback: false, header_guarded: true
564
+ ).and_return( plan )
565
+
566
+ result = @partializer.plan_carry(
567
+ test: 'test_foo', c_module: c_module, impl: impl, interface: nil, header_guarded: true, config: carry_config( 'Foo' )
568
+ )
569
+
570
+ expect( result ).to equal( plan )
571
+ end
572
+
573
+ # Fallback can keep two copies of one function from a file it read without resolving it
574
+ it "plans for fallback when any file the module is extracted from fell back" do
575
+ config = carry_config( 'Foo' )
576
+ config.source.fallback = true
577
+
578
+ expect(@partializer_helper).to receive(:plan_carry).with( hash_including( fallback: true ) ).and_return( Partials::CarryPlan.new )
579
+
580
+ @partializer.plan_carry( test: 'test_foo', c_module: CExtractorTypes::CModule.new, impl: [], interface: nil, header_guarded: true, config: config )
581
+ end
582
+
583
+ def plan_for(prototypes: [], helpers: [], skipped: [])
584
+ plan = Partials::CarryPlan.new
585
+ prototypes.each { |sig, reason| plan.add_prototype( CExtractorTypes::CFunctionDeclaration.new( name: sig[/(\w+)\(/, 1], signature: sig ), reason ) }
586
+ helpers.each do |name, reason|
587
+ plan.add_helper( Partials.manufacture_function_definition( name: name, signature: "int #{name}(int v)", code_block: '' ), reason )
588
+ end
589
+ skipped.each { |name, kind| plan.skip( name, kind ) }
590
+ plan
591
+ end
592
+
593
+ def carry_with(plan, pragma_once: false)
594
+ allow(@partializer_helper).to receive(:plan_carry).and_return( plan )
595
+ allow(@preprocessinator_reconstructor).to receive(:pragma_once?).and_return( pragma_once )
596
+ @partializer.plan_carry(
597
+ test: 'test_engine', c_module: CExtractorTypes::CModule.new, impl: [], interface: nil, header_guarded: true,
598
+ config: carry_config( 'engine' )
599
+ )
600
+ end
601
+
602
+ # A Partial whose files were preprocessed accurately, as stages 6 and 7 record them
603
+ def carry_config(name, raw: {})
604
+ PartializerConfig::Config.new(
605
+ module: name,
606
+ header: Partials::ConfigFileInfo.new( filepath: "src/#{name}.h", assembled_filepath: "build/#{name}.h", raw_directives_only_filepath: raw[:header] ),
607
+ source: Partials::ConfigFileInfo.new( filepath: "src/#{name}.c", assembled_filepath: "build/#{name}.c", raw_directives_only_filepath: raw[:source] )
608
+ )
609
+ end
610
+
611
+ # A match in the original file can't belong to a header that file includes
612
+ it "locates each carried prototype in the text of the file it came from" do
613
+ header_proto = CExtractorTypes::CFunctionDeclaration.new( name: 'tick', signature: 'int tick(void);', origin: :header )
614
+ source_proto = CExtractorTypes::CFunctionDeclaration.new( name: 'twice', signature: 'extern inline int twice(void);', origin: :source )
615
+ plan = Partials::CarryPlan.new
616
+ plan.add_prototype( header_proto, 'external: no body in module' )
617
+ plan.add_prototype( source_proto, 'external: no body in module' )
618
+ allow(@partializer_helper).to receive(:plan_carry).and_return( plan )
619
+ allow(@file_wrapper).to receive(:read).with('src/engine.h').and_return('header text')
620
+ allow(@file_wrapper).to receive(:read).with('src/engine.c').and_return('source text')
621
+
622
+ expect(@partializer_helper).to receive(:associate_declaration_line_numbers).with(
623
+ decls: [header_proto], filepath: 'src/engine.h', text: 'header text'
624
+ )
625
+ expect(@partializer_helper).to receive(:associate_declaration_line_numbers).with(
626
+ decls: [source_proto], filepath: 'src/engine.c', text: 'source text'
627
+ )
628
+
629
+ carry_with( plan )
630
+ end
631
+
632
+ # A prototype with no known file, or from a file the module lacks, is written without a #line
633
+ it "searches no file for a prototype whose file is unknown" do
634
+ unknown = CExtractorTypes::CFunctionDeclaration.new( name: 'tick', signature: 'int tick(void);', origin: nil )
635
+ source = CExtractorTypes::CFunctionDeclaration.new( name: 'twice', signature: 'int twice(void);', origin: :source )
636
+ plan = Partials::CarryPlan.new
637
+ plan.add_prototype( unknown, 'external: no body in module' )
638
+ plan.add_prototype( source, 'external: no body in module' )
639
+ allow(@partializer_helper).to receive(:plan_carry).and_return( plan )
640
+
641
+ expect(@file_wrapper).not_to receive(:read)
642
+ expect(@partializer_helper).not_to receive(:associate_declaration_line_numbers)
643
+
644
+ config = carry_config( 'engine' )
645
+ config.source = Partials::ConfigFileInfo.new
646
+ @partializer.plan_carry(
647
+ test: 'test_engine', c_module: CExtractorTypes::CModule.new, impl: [], interface: nil, header_guarded: true, config: config
648
+ )
649
+ end
650
+
651
+ it "reads no file when nothing is carried" do
652
+ expect(@file_wrapper).not_to receive(:read)
653
+
654
+ carry_with( Partials::CarryPlan.new )
655
+ end
656
+
657
+ it "lists everything carried, with reasons, at debug verbosity" do
658
+ plan = plan_for(
659
+ prototypes: [['int board_tick(void);', 'external: no body in module'], ['int engine_poll(void);', 'left out: body not selected']],
660
+ helpers: [['clamp', 'helper: referenced by `engine_get`']]
661
+ )
662
+
663
+ expect(@loginator).to receive(:log_list).with(
664
+ ['`int board_tick(void);` (external: no body in module)',
665
+ '`int engine_poll(void);` (left out: body not selected)',
666
+ '`clamp()` (helper: referenced by `engine_get`)'],
667
+ 'Carried into Partial test_engine::engine implementation:',
668
+ Verbosity::DEBUG
669
+ )
670
+
671
+ carry_with( plan )
672
+ end
673
+
674
+ it "lists nothing when nothing is carried" do
675
+ expect(@loginator).not_to receive(:log_list)
676
+
677
+ carry_with( Partials::CarryPlan.new )
678
+ end
679
+
680
+ it "gives notice of a helper fallback left with more than one definition" do
681
+ plan = plan_for( skipped: [['clamp', :helper_conflict]] )
682
+
683
+ expect(@loginator).to receive(:log).with(
684
+ "Partial test_engine::engine \u23e9\ufe0f Not carrying helper `clamp()`: fallback preprocessing found more than one definition. Add `+clamp` if a selected function needs it",
685
+ Verbosity::COMPLAIN,
686
+ LogLabels::NOTICE
687
+ )
688
+
689
+ carry_with( plan )
690
+ end
691
+
692
+ it "gives one notice naming every helper an unguarded module header kept out" do
693
+ plan = plan_for( skipped: [
694
+ ['clamp', :unguarded_helper],
695
+ ['counter', :unguarded_helper]
696
+ ] )
697
+
698
+ allow(@loginator).to receive(:log)
699
+
700
+ carry_with( plan )
701
+
702
+ expect(@loginator).to have_received(:log).with(
703
+ "Partial test_engine::engine \u23e9\ufe0f Not carrying helpers `clamp()`, `counter()` from src/engine.h.\n" \
704
+ "Selected functions call these helpers, but src/engine.h has no include guard. Without a guard\n" \
705
+ "a Partial cannot stand in for the header everywhere it is included, and a carried copy could\n" \
706
+ "collide with the real one.\n" \
707
+ "\n" \
708
+ "OPTIONS:\n" \
709
+ " 1. Give src/engine.h an include guard so the Partial can stand in for it.\n" \
710
+ " 2. Select the helpers with `+name` (for example `+clamp`). This works only when no other\n" \
711
+ " header this module includes pulls in src/engine.h.\n" \
712
+ "\n" \
713
+ "See the docs on Partials conventions.\n",
714
+ Verbosity::COMPLAIN,
715
+ LogLabels::NOTICE
716
+ )
717
+ expect(@loginator).to have_received(:log).once
718
+ end
719
+
720
+ # Ceedling stands a Partial in for a header only by defining its include guard
721
+ it "explains that a #pragma once module header keeps its helpers out, as the toolchain guidance does" do
722
+ plan = plan_for( skipped: [['clamp', :unguarded_helper], ['counter', :unguarded_helper]] )
723
+
724
+ allow(@loginator).to receive(:log)
725
+
726
+ carry_with( plan, pragma_once: true )
727
+
728
+ expect(@loginator).to have_received(:log).with( <<~NOTICE, Verbosity::COMPLAIN, LogLabels::NOTICE )
729
+ Partial test_engine::engine ⏩️ Not carrying helpers `clamp()`, `counter()` from src/engine.h.
730
+
731
+ HOW THIS HAPPENS:
732
+ • Selected functions call these helpers.
733
+ • src/engine.h uses `#pragma once`, which is not an include guard.
734
+ • A Partial stands in for a header everywhere it's included by defining the header's include guard. Ceedling relies on include guards for this.
735
+ • Without one, a carried copy could collide with the real one.
736
+
737
+ OPTIONS:
738
+ 1. Replace `#pragma once` in src/engine.h with an include guard so the Partial can stand in for it.
739
+ 2. Select the helpers with `+name` (for example `+clamp`). This works only when no other header this module includes pulls in src/engine.h.
740
+
741
+ See the docs on Partials conventions.
742
+ NOTICE
743
+ end
744
+
745
+ it "words the unguarded-header notice for a single helper" do
746
+ plan = plan_for( skipped: [['clamp', :unguarded_helper]] )
747
+
748
+ expect(@loginator).to receive(:log).with(
749
+ a_string_including( 'Not carrying helper `clamp()` from src/engine.h.', 'call this helper', 'Select the helper with' ),
750
+ Verbosity::COMPLAIN,
751
+ LogLabels::NOTICE
752
+ )
753
+
754
+ carry_with( plan )
755
+ end
756
+
757
+ # Additions can't name a function the module only declares, so no `+name` hint follows
758
+ it "gives notice of a prototype fallback left with conflicting declarations" do
759
+ plan = plan_for( skipped: [['board_tick', :prototype_conflict]] )
760
+
761
+ expect(@loginator).to receive(:log).with(
762
+ "Partial test_engine::engine \u23e9\ufe0f Not carrying `board_tick()`: fallback preprocessing found conflicting declarations",
763
+ Verbosity::COMPLAIN,
764
+ LogLabels::NOTICE
765
+ )
766
+
767
+ carry_with( plan )
768
+ end
769
+
770
+ context "marking extern variables of incomplete types" do
771
+ def extern_var(name, type)
772
+ CExtractorTypes::CVariableDeclaration.new( name: name, type: type, decorators: ['extern'], text: "#{type} #{name};" )
773
+ end
774
+
775
+ # A typedef as the extractor records it, with the tag and the name it reads
776
+ def typedef(text)
777
+ CExtractorTypes::CStatement.new( text: text, kind: :typedef, **CExtractorDefinedType.names( text ) )
778
+ end
779
+
780
+ # Each file's raw directives-only copy, recorded only where `copies` gives its text, keyed by
781
+ # :header or :source. Files and copies are read as bytes, since the search needs nothing more.
782
+ def stub_texts(header:, source:, copies: {})
783
+ allow(@file_wrapper).to receive(:read_binary).with('src/engine.h').and_return( header )
784
+ allow(@file_wrapper).to receive(:read_binary).with('src/engine.c').and_return( source )
785
+ @copies = copies.to_h { |file, _| [file, "raw/src/engine.#{file == :header ? 'h' : 'c'}"] }
786
+ copies.each { |file, copy| allow(@file_wrapper).to receive(:read_binary).with( @copies[file] ).and_return( copy ) }
787
+ end
788
+
789
+ # A file preprocessed in fallback records no raw copy, whatever is on disk
790
+ def incomplete_for(c_module, fallback: false)
791
+ allow(@partializer_helper).to receive(:plan_carry).and_return( Partials::CarryPlan.new )
792
+ config = carry_config( 'engine', raw: fallback ? {} : @copies.to_h )
793
+ [config.header, config.source].each { |file| file.fallback = fallback }
794
+ @partializer.plan_carry(
795
+ test: 'test_engine', c_module: c_module, impl: [], interface: nil, header_guarded: true, config: config
796
+ ).incomplete
797
+ end
798
+
799
+ it "marks a struct variable whose struct the module only declares" do
800
+ stub_texts( header: "struct handle_s;\nextern struct handle_s handle;\n", source: "#include \"engine.h\"\n" )
801
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'handle', 'struct handle_s' )] )
802
+
803
+ expect( incomplete_for( c_module ) ).to eq( Set['handle'] )
804
+ end
805
+
806
+ # Such a keyword changes how the variable is stored or accessed, not which type it holds
807
+ it "marks a thread-local or atomic struct variable whose struct the module only declares" do
808
+ stub_texts( header: "struct handle_s;\ntypedef struct handle_s handle_t;\n", source: '' )
809
+ c_module = CExtractorTypes::CModule.new(
810
+ variable_declarations: [
811
+ extern_var( 'local', '_Thread_local struct handle_s' ),
812
+ extern_var( 'shared', '_Atomic struct handle_s' ),
813
+ extern_var( 'named', '__thread _Atomic handle_t' )
814
+ ],
815
+ type_definitions: [typedef( 'typedef struct handle_s handle_t;' )]
816
+ )
817
+
818
+ expect( incomplete_for( c_module ) ).to eq( Set['local', 'shared', 'named'] )
819
+ end
820
+
821
+ # A pointer is complete whatever it points to, so a function pointer can always be defined
822
+ it "leaves alone a function pointer returning a struct the module only declares" do
823
+ stub_texts( header: "struct handle_s;\nextern struct handle_s (*make_handle)(void);\n", source: '' )
824
+ maker = CExtractorTypes::CVariableDeclaration.new(
825
+ name: 'make_handle', type: 'struct handle_s', declarator: '(*make_handle)(void)',
826
+ decorators: ['extern'], text: 'struct handle_s (*make_handle)(void);'
827
+ )
828
+
829
+ expect( incomplete_for( CExtractorTypes::CModule.new( variable_declarations: [maker] ) ) ).to be_empty
830
+ end
831
+
832
+ it "follows a typedef to the struct it names" do
833
+ stub_texts( header: "typedef struct handle_s handle_t;\nextern handle_t handle;\n", source: '' )
834
+ c_module = CExtractorTypes::CModule.new(
835
+ variable_declarations: [extern_var( 'handle', 'handle_t' )],
836
+ type_definitions: [typedef( 'typedef struct handle_s handle_t;' )]
837
+ )
838
+
839
+ expect( incomplete_for( c_module ) ).to eq( Set['handle'] )
840
+ end
841
+
842
+ it "follows a typedef to the union it names" do
843
+ stub_texts( header: "typedef union word_u word_t;\nextern word_t word;\n", source: '' )
844
+ c_module = CExtractorTypes::CModule.new(
845
+ variable_declarations: [extern_var( 'word', 'word_t' )],
846
+ type_definitions: [typedef( 'typedef union word_u word_t;' )]
847
+ )
848
+
849
+ expect( incomplete_for( c_module ) ).to eq( Set['word'] )
850
+ end
851
+
852
+ it "leaves alone a variable whose struct the module defines" do
853
+ stub_texts( header: "extern struct point_s origin;\n", source: "struct point_s { int x; };\n" )
854
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'origin', 'struct point_s' )] )
855
+
856
+ expect( incomplete_for( c_module ) ).to be_empty
857
+ end
858
+
859
+ # A directives-only copy holds the text of every header its file includes
860
+ it "leaves alone a variable whose struct an included header defines" do
861
+ stub_texts(
862
+ header: "#include \"point.h\"\nextern struct point_s origin;\n", source: '',
863
+ copies: { header: "struct point_s {\n int x;\n};\nextern struct point_s origin;\n" }
864
+ )
865
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'origin', 'struct point_s' )] )
866
+
867
+ expect( incomplete_for( c_module ) ).to be_empty
868
+ end
869
+
870
+ # An earlier raw copy on disk says nothing about a file preprocessed in fallback
871
+ it "reads no raw copy under fallback preprocessing" do
872
+ stub_texts(
873
+ header: "#include \"point.h\"\nextern struct point_s origin;\n", source: '',
874
+ copies: { header: "struct point_s {\n int x;\n};\n" }
875
+ )
876
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'origin', 'struct point_s' )] )
877
+
878
+ expect(@file_wrapper).not_to receive(:read_binary).with('raw/src/engine.h')
879
+ expect( incomplete_for( c_module, fallback: true ) ).to eq( Set['origin'] )
880
+ end
881
+
882
+ it "still searches the module's own files under fallback preprocessing" do
883
+ stub_texts( header: "extern struct point_s origin;\n", source: "struct point_s { int x; };\n" )
884
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'origin', 'struct point_s' )] )
885
+
886
+ expect( incomplete_for( c_module, fallback: true ) ).to be_empty
887
+ end
888
+
889
+ # A file read as bytes may hold CRLF line endings and bytes no encoding accepts
890
+ it "finds the completing definition in text read as bytes" do
891
+ stub_texts( header: "extern struct point_s origin;\n".b, source: "/* \xFF */\r\nstruct point_s\r\n{ int x; };\r\n".b )
892
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'origin', 'struct point_s' )] )
893
+
894
+ expect( incomplete_for( c_module ) ).to be_empty
895
+ end
896
+
897
+ # A tag that merely ends in the variable's tag completes a different type
898
+ it "does not take a longer tag's definition for the variable's own" do
899
+ stub_texts( header: "extern struct point_s origin;\n", source: "struct my_point_s { int x; };\n" )
900
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [extern_var( 'origin', 'struct point_s' )] )
901
+
902
+ expect( incomplete_for( c_module ) ).to eq( Set['origin'] )
903
+ end
904
+
905
+ it "reads no file when no extern variable names a struct or union" do
906
+ expect(@file_wrapper).not_to receive(:read)
907
+ expect(@file_wrapper).not_to receive(:read_binary)
908
+ c_module = CExtractorTypes::CModule.new( variable_declarations: [
909
+ extern_var( 'count', 'int' ),
910
+ extern_var( 'next', 'struct node_s*' ),
911
+ CExtractorTypes::CVariableDeclaration.new( name: 'own', type: 'struct node_s', text: 'struct node_s own;' )
912
+ ] )
913
+
914
+ expect( incomplete_for( c_module ) ).to be_empty
915
+ end
916
+ end
917
+ end
918
+
499
919
  context "#validate_extracted_functions" do
500
920
  def make_impl(name)
501
921
  Partials.manufacture_function_definition(
@@ -579,6 +999,245 @@ describe Partializer do
579
999
  end
580
1000
  end
581
1001
 
1002
+ ###
1003
+ ### plan_interface_extras()
1004
+ ###
1005
+
1006
+ context "#plan_interface_extras" do
1007
+ before(:each) do
1008
+ @config = OpenStruct.new( module: 'sensor', fallback?: false, header: OpenStruct.new( filepath: 'src/sensor.h' ) )
1009
+ allow(@file_wrapper).to receive(:read).with( 'src/sensor.h' ).and_return( "int sensor_read(void);\n" )
1010
+ allow(@preprocessinator_reconstructor).to receive(:pragma_once?).with( "int sensor_read(void);\n" ).and_return( false )
1011
+ end
1012
+
1013
+ def plan_with(extras)
1014
+ allow(@partializer_helper).to receive(:plan_interface_extras)
1015
+ .with( c_module: :module, interface: :interface, fallback: false, header_guarded: true ).and_return( extras )
1016
+
1017
+ return @partializer.plan_interface_extras(
1018
+ test: 'test_sensor', c_module: :module, interface: :interface, header_guarded: true, config: @config
1019
+ )
1020
+ end
1021
+
1022
+ it "lists what the mock keeps at DEBUG" do
1023
+ extras = Partials::InterfaceExtras.new( items: [
1024
+ CExtractorTypes::CFunctionDefinition.new( name: 'twice' ),
1025
+ CExtractorTypes::CVariableDeclaration.new( name: 'table', decorators: ['static'] ),
1026
+ CExtractorTypes::CVariableDeclaration.new( name: 'count', decorators: ['extern'] ),
1027
+ CExtractorTypes::CFunctionDeclaration.new( name: 'init' )
1028
+ ] )
1029
+
1030
+ expect(@loginator).to receive(:log_list).with(
1031
+ ['`twice()` (helper)', '`table` (static variable)', '`count` (extern declaration)', '`init()` (prototype)'],
1032
+ 'Kept in the mock of Partial test_sensor::sensor:', Verbosity::DEBUG
1033
+ )
1034
+
1035
+ expect( plan_with( extras ) ).to equal( extras )
1036
+ end
1037
+
1038
+ it "explains what an unguarded header's mock leaves behind" do
1039
+ extras = Partials::InterfaceExtras.new( withheld: [
1040
+ CExtractorTypes::CFunctionDefinition.new( name: 'twice' ),
1041
+ CExtractorTypes::CVariableDeclaration.new( name: 'table', decorators: ['static'] )
1042
+ ] )
1043
+
1044
+ expect(@loginator).to receive(:log).with( <<~NOTICE, Verbosity::COMPLAIN, LogLabels::NOTICE )
1045
+ Partial test_sensor::sensor ⏩️ Its mock leaves helper `twice()` and variable `table` from src/sensor.h behind.
1046
+ src/sensor.h has no include guard. Without a guard the mock can't stand in for the header everywhere
1047
+ it's included, and a copy could collide with the real one. Code that uses these compiles only where
1048
+ another #include brings in the real header.
1049
+
1050
+ Give src/sensor.h an include guard so the mock keeps them.
1051
+
1052
+ See the docs on Partials conventions.
1053
+ NOTICE
1054
+
1055
+ plan_with( extras )
1056
+ end
1057
+
1058
+ # Ceedling stands a mock in for a header only by defining its include guard
1059
+ it "explains that a #pragma once header's mock leaves items behind, since #pragma once is not an include guard" do
1060
+ allow(@preprocessinator_reconstructor).to receive(:pragma_once?).with( "int sensor_read(void);\n" ).and_return( true )
1061
+ extras = Partials::InterfaceExtras.new( withheld: [
1062
+ CExtractorTypes::CFunctionDefinition.new( name: 'twice' ),
1063
+ CExtractorTypes::CVariableDeclaration.new( name: 'table', decorators: ['static'] )
1064
+ ] )
1065
+
1066
+ expect(@loginator).to receive(:log).with( <<~NOTICE, Verbosity::COMPLAIN, LogLabels::NOTICE )
1067
+ Partial test_sensor::sensor ⏩️ Its mock leaves helper `twice()` and variable `table` from src/sensor.h behind.
1068
+
1069
+ HOW THIS HAPPENS:
1070
+ • src/sensor.h uses `#pragma once`, which is not an include guard.
1071
+ • A mock stands in for a header everywhere it's included by defining the header's include guard. Ceedling relies on include guards for this.
1072
+ • Without one, a kept copy could collide with the real one, so the mock leaves them out.
1073
+ • Code that uses these compiles only where another #include brings in the real header.
1074
+
1075
+ Replace `#pragma once` in src/sensor.h with an include guard so the mock keeps them.
1076
+
1077
+ See the docs on Partials conventions.
1078
+ NOTICE
1079
+
1080
+ plan_with( extras )
1081
+ end
1082
+
1083
+ it "names one item it leaves behind in the singular" do
1084
+ extras = Partials::InterfaceExtras.new( withheld: [CExtractorTypes::CFunctionDefinition.new( name: 'twice' )] )
1085
+
1086
+ expect(@loginator).to receive(:log) do |notice, *|
1087
+ expect( notice ).to include( 'Its mock leaves helper `twice()` from src/sensor.h behind.' )
1088
+ expect( notice ).to include( 'Code that uses it compiles' )
1089
+ expect( notice ).to include( 'so the mock keeps it.' )
1090
+ end
1091
+
1092
+ plan_with( extras )
1093
+ end
1094
+
1095
+ it "names several helpers and variables in the plural" do
1096
+ extras = Partials::InterfaceExtras.new( withheld: [
1097
+ CExtractorTypes::CFunctionDefinition.new( name: 'twice' ), CExtractorTypes::CFunctionDefinition.new( name: 'half' ),
1098
+ CExtractorTypes::CVariableDeclaration.new( name: 'a' ), CExtractorTypes::CVariableDeclaration.new( name: 'b' )
1099
+ ] )
1100
+
1101
+ expect(@loginator).to receive(:log) do |notice, *|
1102
+ expect( notice ).to include( 'Its mock leaves helpers `twice()`, `half()` and variables `a`, `b` from src/sensor.h behind.' )
1103
+ end
1104
+
1105
+ plan_with( extras )
1106
+ end
1107
+
1108
+ it "says nothing when the mock withholds nothing" do
1109
+ expect(@loginator).not_to receive(:log)
1110
+
1111
+ plan_with( Partials::InterfaceExtras.new )
1112
+ end
1113
+ end
1114
+
1115
+ ###
1116
+ ### explain_tested_mock()
1117
+ ###
1118
+
1119
+ context "#explain_tested_mock" do
1120
+ before(:each) do
1121
+ @config = OpenStruct.new( module: 'port', fallback?: false, header: OpenStruct.new( filepath: 'src/port.h', includes: [] ),
1122
+ source: OpenStruct.new( includes: [UserInclude.new( 'port.h' )] ) )
1123
+ @engine = OpenStruct.new( module: 'engine', header: OpenStruct.new( includes: [] ),
1124
+ source: OpenStruct.new( includes: [UserInclude.new( 'engine.h' ), UserInclude.new( 'port.h' )],
1125
+ assembled_filepath: 'pp/engine.c' ) )
1126
+ allow(@file_wrapper).to receive(:read).with('pp/engine.c').and_return( 'int engine_get(void) { return port_twice(port_read()) + port_k; }' )
1127
+ @extras = Partials::InterfaceExtras.new( items: [
1128
+ CExtractorTypes::CFunctionDefinition.new( name: 'port_twice' ),
1129
+ CExtractorTypes::CVariableDeclaration.new( name: 'port_k', decorators: ['static'] )
1130
+ ] )
1131
+ allow(@partializer_helper).to receive(:plan_interface_extras)
1132
+ .with( c_module: :module, interface: :interface, fallback: false, header_guarded: true ).and_return( @extras )
1133
+ allow(@partializer_helper).to receive(:names_in) { |text| Set.new( text.scan( /[A-Za-z_]\w*/ ) ) }
1134
+ end
1135
+
1136
+ def explain(partials)
1137
+ @partializer.explain_tested_mock(
1138
+ test: 'test_engine', c_module: :module, interface: :interface, header_guarded: true, config: @config, partials: partials
1139
+ )
1140
+ end
1141
+
1142
+ # A module tested and mocked in one test keeps its header's content in its own implementation
1143
+ it "explains what other Partials including a tested and mocked module's header go without" do
1144
+ expect(@loginator).to receive(:log).with( <<~NOTICE, Verbosity::COMPLAIN, LogLabels::NOTICE )
1145
+ Partial test_engine::port ⏩️ Other Partials in this test include src/port.h's mock, which leaves helper `port_twice()` and variable `port_k` out.
1146
+
1147
+ HOW THIS HAPPENS:
1148
+ • A module both tested and mocked in one test keeps its header's helpers and static variables in its own implementation.
1149
+ • Every other Partial that includes src/port.h gets the mock's interface in its place, which declares only the mocked functions.
1150
+ • Code in those Partials that uses them fails to compile or link.
1151
+
1152
+ OPTIONS:
1153
+ 1. Test port in a test file of its own, and only mock it in this one.
1154
+ 2. Move what the other Partials use into a header that src/port.h includes, which the mock keeps.
1155
+
1156
+ See the docs on Partials conventions.
1157
+ NOTICE
1158
+
1159
+ explain( { 'engine' => @engine, 'port' => @config } )
1160
+ end
1161
+
1162
+ it "lists helpers, variables and prototypes as one list" do
1163
+ @extras.items << CExtractorTypes::CFunctionDeclaration.new( name: 'port_scaled' )
1164
+ allow(@file_wrapper).to receive(:read).with('pp/engine.c').and_return( 'int g(void) { return port_twice(port_k) + port_scaled(); }' )
1165
+
1166
+ expect(@loginator).to receive(:log) do |notice, *|
1167
+ expect( notice ).to include( 'which leaves helper `port_twice()`, variable `port_k` and prototype `port_scaled()` out.' )
1168
+ end
1169
+
1170
+ explain( { 'engine' => @engine, 'port' => @config } )
1171
+ end
1172
+
1173
+ # Only what another Partial's code uses can fail there
1174
+ it "names only what the other Partials use, in the singular for one" do
1175
+ allow(@file_wrapper).to receive(:read).with('pp/engine.c').and_return( 'int engine_get(void) { return port_twice(port_read()); }' )
1176
+
1177
+ expect(@loginator).to receive(:log) do |notice, *|
1178
+ expect( notice ).to include( 'which leaves helper `port_twice()` out.' )
1179
+ expect( notice ).to include( 'Code in those Partials that uses it fails to compile or link.' )
1180
+ end
1181
+
1182
+ explain( { 'engine' => @engine, 'port' => @config } )
1183
+ end
1184
+
1185
+ it "says nothing when the other Partials use none of it" do
1186
+ allow(@file_wrapper).to receive(:read).with('pp/engine.c').and_return( 'int engine_get(void) { return port_read(); }' )
1187
+ expect(@loginator).not_to receive(:log)
1188
+
1189
+ explain( { 'engine' => @engine, 'port' => @config } )
1190
+ end
1191
+
1192
+ it "reads a Partial that includes the header from its own header" do
1193
+ @engine.source.includes = [UserInclude.new( 'engine.h' )]
1194
+ @engine.header = OpenStruct.new( includes: [UserInclude.new( 'port.h' )], assembled_filepath: 'pp/engine.h' )
1195
+ allow(@file_wrapper).to receive(:read).with('pp/engine.c').and_return( '' )
1196
+ allow(@file_wrapper).to receive(:read).with('pp/engine.h').and_return( 'static inline int e(void) { return port_k; }' )
1197
+
1198
+ expect(@loginator).to receive(:log) do |notice, *|
1199
+ expect( notice ).to include( 'which leaves variable `port_k` out.' )
1200
+ end
1201
+
1202
+ explain( { 'engine' => @engine, 'port' => @config } )
1203
+ end
1204
+
1205
+ # A use through a macro shows only in the expansion
1206
+ it "reads another Partial's expansion where it has one" do
1207
+ @engine.source.expansion_filepath = 'pp/engine.expanded.c'
1208
+ allow(@file_wrapper).to receive(:read).with('pp/engine.c').and_return( 'int engine_get(void) { return PORT_TWICE(1); }' )
1209
+ allow(@file_wrapper).to receive(:read).with('pp/engine.expanded.c').and_return( 'int engine_get(void) { return port_twice(1); }' )
1210
+
1211
+ expect(@loginator).to receive(:log) do |notice, *|
1212
+ expect( notice ).to include( 'which leaves helper `port_twice()` out.' )
1213
+ end
1214
+
1215
+ explain( { 'engine' => @engine, 'port' => @config } )
1216
+ end
1217
+
1218
+ it "never counts the module itself among the Partials including its header" do
1219
+ @config.source.assembled_filepath = 'pp/port.c'
1220
+ allow(@file_wrapper).to receive(:read).with('pp/port.c').and_return( 'int port_scaled(void) { return port_twice(port_k); }' )
1221
+ expect(@loginator).not_to receive(:log)
1222
+
1223
+ explain( { 'port' => @config } )
1224
+ end
1225
+
1226
+ it "says nothing when no other Partial includes the module's header" do
1227
+ @engine.source.includes = [UserInclude.new( 'engine.h' )]
1228
+ expect(@loginator).not_to receive(:log)
1229
+
1230
+ explain( { 'engine' => @engine, 'port' => @config } )
1231
+ end
1232
+
1233
+ it "says nothing when the mock would leave nothing out" do
1234
+ allow(@partializer_helper).to receive(:plan_interface_extras).and_return( Partials::InterfaceExtras.new )
1235
+ expect(@loginator).not_to receive(:log)
1236
+
1237
+ explain( { 'engine' => @engine, 'port' => @config } )
1238
+ end
1239
+ end
1240
+
582
1241
  ###
583
1242
  ### remap_implementation_header_includes()
584
1243
  ###
@@ -589,9 +1248,9 @@ describe Partializer do
589
1248
  partials = {}
590
1249
  result = @partializer.remap_implementation_header_includes(
591
1250
  name: 'module',
592
- includes: includes,
1251
+ source_includes: includes,
593
1252
  partials: partials
594
- )
1253
+ ).to_a
595
1254
 
596
1255
  expect(result).to eq([])
597
1256
  end
@@ -601,9 +1260,9 @@ describe Partializer do
601
1260
  partials = {}
602
1261
  result = @partializer.remap_implementation_header_includes(
603
1262
  name: 'module',
604
- includes: includes,
1263
+ source_includes: includes,
605
1264
  partials: partials
606
- )
1265
+ ).to_a
607
1266
 
608
1267
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
609
1268
  expect(result).not_to include(UserInclude.new('module.h'))
@@ -618,9 +1277,9 @@ describe Partializer do
618
1277
 
619
1278
  result = @partializer.remap_implementation_header_includes(
620
1279
  name: 'drivers/uart/config',
621
- includes: includes,
1280
+ source_includes: includes,
622
1281
  partials: {}
623
- )
1282
+ ).to_a
624
1283
 
625
1284
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
626
1285
  end
@@ -630,10 +1289,10 @@ describe Partializer do
630
1289
 
631
1290
  result = @partializer.remap_implementation_header_includes(
632
1291
  name: 'drivers/uart/config',
633
- includes: includes,
1292
+ source_includes: includes,
634
1293
  partials: {},
635
1294
  types_header: 'drivers/uart/ceedling_partial_config_types.h'
636
- )
1295
+ ).to_a
637
1296
 
638
1297
  expect(result.map(&:filepath)).to eq(
639
1298
  ['header1.h', 'drivers/uart/ceedling_partial_config_types.h', 'header2.h']
@@ -645,9 +1304,9 @@ describe Partializer do
645
1304
 
646
1305
  result = @partializer.remap_implementation_header_includes(
647
1306
  name: 'drivers/uart/config',
648
- includes: includes,
1307
+ source_includes: includes,
649
1308
  partials: { 'drivers/spi/other' => nil }
650
- )
1309
+ ).to_a
651
1310
 
652
1311
  expect(result).to match_array([UserInclude.new('header1.h')])
653
1312
  end
@@ -655,13 +1314,13 @@ describe Partializer do
655
1314
  it "removes partialized module headers from includes" do
656
1315
  includes = [UserInclude.new('header1.h'), UserInclude.new('partial_module.h'), UserInclude.new('header2.h')]
657
1316
  partials = {
658
- 'partial_module' => { types: [:test_public] }
1317
+ 'partial_module' => make_partial_config(tests_type: :public)
659
1318
  }
660
1319
  result = @partializer.remap_implementation_header_includes(
661
1320
  name: 'module',
662
- includes: includes,
1321
+ source_includes: includes,
663
1322
  partials: partials
664
- )
1323
+ ).to_a
665
1324
 
666
1325
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
667
1326
  expect(result).not_to include(UserInclude.new('partial_module.h'))
@@ -680,9 +1339,9 @@ describe Partializer do
680
1339
  }
681
1340
  result = @partializer.remap_implementation_header_includes(
682
1341
  name: 'module',
683
- includes: includes,
1342
+ source_includes: includes,
684
1343
  partials: partials
685
- )
1344
+ ).to_a
686
1345
 
687
1346
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
688
1347
  expect(result).not_to include(UserInclude.new('partial1.h'))
@@ -701,9 +1360,9 @@ describe Partializer do
701
1360
  }
702
1361
  result = @partializer.remap_implementation_header_includes(
703
1362
  name: 'module',
704
- includes: includes,
1363
+ source_includes: includes,
705
1364
  partials: partials
706
- )
1365
+ ).to_a
707
1366
 
708
1367
  expect(result).to match_array(
709
1368
  [
@@ -726,9 +1385,9 @@ describe Partializer do
726
1385
  }
727
1386
  result = @partializer.remap_implementation_header_includes(
728
1387
  name: 'module',
729
- includes: includes,
1388
+ source_includes: includes,
730
1389
  partials: partials
731
- )
1390
+ ).to_a
732
1391
 
733
1392
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
734
1393
  end
@@ -743,9 +1402,9 @@ describe Partializer do
743
1402
  partials = {}
744
1403
  result = @partializer.remap_implementation_header_includes(
745
1404
  name: 'module',
746
- includes: includes,
1405
+ source_includes: includes,
747
1406
  partials: partials
748
- )
1407
+ ).to_a
749
1408
 
750
1409
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
751
1410
  expect(result).not_to include(UserInclude.new('module.h'))
@@ -766,9 +1425,9 @@ describe Partializer do
766
1425
  }
767
1426
  result = @partializer.remap_implementation_header_includes(
768
1427
  name: 'module',
769
- includes: includes,
1428
+ source_includes: includes,
770
1429
  partials: partials
771
- )
1430
+ ).to_a
772
1431
 
773
1432
  expect(result).to match_array([UserInclude.new('header1.h')])
774
1433
  end
@@ -778,9 +1437,9 @@ describe Partializer do
778
1437
  partials = {}
779
1438
  result = @partializer.remap_implementation_header_includes(
780
1439
  name: 'module',
781
- includes: includes,
1440
+ source_includes: includes,
782
1441
  partials: partials
783
- )
1442
+ ).to_a
784
1443
 
785
1444
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
786
1445
  end
@@ -801,9 +1460,9 @@ describe Partializer do
801
1460
  }
802
1461
  result = @partializer.remap_implementation_header_includes(
803
1462
  name: 'module',
804
- includes: includes,
1463
+ source_includes: includes,
805
1464
  partials: partials
806
- )
1465
+ ).to_a
807
1466
 
808
1467
  expect(result).to match_array(
809
1468
  [
@@ -822,10 +1481,10 @@ describe Partializer do
822
1481
  partials = {}
823
1482
  result = @partializer.remap_implementation_header_includes(
824
1483
  name: 'module',
825
- includes: includes,
1484
+ source_includes: includes,
826
1485
  partials: partials,
827
1486
  types_header: 'ceedling_partial_module_types.h'
828
- )
1487
+ ).to_a
829
1488
 
830
1489
  expect(result).to include(UserInclude.new('ceedling_partial_module_types.h'))
831
1490
  end
@@ -835,9 +1494,9 @@ describe Partializer do
835
1494
  partials = {}
836
1495
  result = @partializer.remap_implementation_header_includes(
837
1496
  name: 'module',
838
- includes: includes,
1497
+ source_includes: includes,
839
1498
  partials: partials
840
- )
1499
+ ).to_a
841
1500
 
842
1501
  expect(result).to match_array([UserInclude.new('header1.h')])
843
1502
  end
@@ -855,10 +1514,10 @@ describe Partializer do
855
1514
  ]
856
1515
  result = @partializer.remap_implementation_header_includes(
857
1516
  name: 'module',
858
- includes: includes,
1517
+ source_includes: includes,
859
1518
  partials: {},
860
1519
  types_header: 'ceedling_partial_module_types.h'
861
- )
1520
+ ).to_a
862
1521
 
863
1522
  expect(result).to eq([
864
1523
  UserInclude.new('header1.h'),
@@ -867,19 +1526,27 @@ describe Partializer do
867
1526
  ])
868
1527
  end
869
1528
 
870
- it "appends the shared types header when the module's own header wasn't in the includes list to begin with" do
871
- includes = [UserInclude.new('header1.h')]
872
- result = @partializer.remap_implementation_header_includes(
1529
+ # A source that never includes its own header leaves the header's place after its last
1530
+ # include. The types header stands there, ahead of the declarations that use its types.
1531
+ it "puts the types header after the source's includes when the source never includes the module's header" do
1532
+ groups = @partializer.remap_implementation_header_includes(
873
1533
  name: 'module',
874
- includes: includes,
875
- partials: {},
876
- types_header: 'ceedling_partial_module_types.h'
1534
+ source_includes: [UserInclude.new( 'a.h' ), UserInclude.new( 'b.h' )],
1535
+ header_includes: [UserInclude.new( 'c.h' )], partials: {}, types_header: 'module_types.h'
877
1536
  )
878
1537
 
879
- expect(result).to eq([
880
- UserInclude.new('header1.h'),
881
- UserInclude.new('ceedling_partial_module_types.h')
882
- ])
1538
+ expect( groups.leading.map( &:filename ) ).to eq( ['a.h', 'b.h', 'module_types.h', 'c.h'] )
1539
+ expect( groups.following ).to eq( [] )
1540
+ end
1541
+
1542
+ it "puts a header-only module's types header ahead of its declarations" do
1543
+ groups = @partializer.remap_implementation_header_includes(
1544
+ name: 'module', source_includes: [], header_includes: [UserInclude.new( 'base.h' )], partials: {},
1545
+ types_header: 'module_types.h'
1546
+ )
1547
+
1548
+ expect( groups.leading.map( &:filename ) ).to eq( ['module_types.h', 'base.h'] )
1549
+ expect( groups.following ).to eq( [] )
883
1550
  end
884
1551
  end
885
1552
 
@@ -888,12 +1555,69 @@ describe Partializer do
888
1555
  ###
889
1556
 
890
1557
  context "#remap_interface_header_includes" do
1558
+ # The types header carries the header's own content, so it stands where the header was
1559
+ it "puts the types header where the module's header was, ahead of the following group" do
1560
+ groups = @partializer.remap_interface_header_includes(
1561
+ name: 'module',
1562
+ source_includes: [UserInclude.new( 'config.h' ), UserInclude.new( 'module.h' ), UserInclude.new( 'log.h' )],
1563
+ header_includes: [UserInclude.new( 'base.h' )], partials: {}, types_header: 'module_types.h'
1564
+ )
1565
+
1566
+ expect( groups.leading.map( &:filename ) ).to eq( ['config.h', 'module_types.h', 'base.h'] )
1567
+ expect( groups.following.map( &:filename ) ).to eq( ['log.h'] )
1568
+ end
1569
+
1570
+ # The split comes at the module's own header, not at an unrelated header sharing its basename
1571
+ it "splits the groups at a directory-named module's own header" do
1572
+ groups = @partializer.remap_interface_header_includes(
1573
+ name: 'drivers/uart/config',
1574
+ source_includes: [UserInclude.new( 'src/config.h' ), UserInclude.new( 'a.h' ), UserInclude.new( 'include/drivers/uart/config.h' ), UserInclude.new( 'b.h' )],
1575
+ header_includes: [UserInclude.new( 'h.h' )], types_header: 'module_types.h',
1576
+ partials: { 'drivers/uart/config' => make_partial_config(mocks_type: :public, header: 'include/drivers/uart/config.h') }
1577
+ )
1578
+
1579
+ expect( groups.leading.map( &:filepath ) ).to eq( ['src/config.h', 'a.h', 'module_types.h', 'h.h'] )
1580
+ expect( groups.following.map( &:filepath ) ).to eq( ['b.h'] )
1581
+ end
1582
+
1583
+ # A tested Partial's header is dropped from another module's interface, and only its header
1584
+ it "keeps an unpartialized header sharing a tested Partial's basename" do
1585
+ groups = @partializer.remap_interface_header_includes(
1586
+ name: 'motor', source_includes: [UserInclude.new( 'src/motor.h' )],
1587
+ header_includes: [UserInclude.new( 'src/config.h' ), UserInclude.new( 'include/drivers/uart/config.h' )],
1588
+ partials: { 'drivers/uart/config' => make_partial_config(tests_type: :public, header: 'include/drivers/uart/config.h') }
1589
+ )
1590
+
1591
+ expect( groups.leading.map( &:filepath ) ).to eq( ['src/config.h'] )
1592
+ end
1593
+
1594
+ it "puts a header-only module's types header ahead of its declarations" do
1595
+ groups = @partializer.remap_interface_header_includes(
1596
+ name: 'module', source_includes: [], header_includes: [UserInclude.new( 'base.h' )], partials: {},
1597
+ types_header: 'module_types.h'
1598
+ )
1599
+
1600
+ expect( groups.leading.map( &:filename ) ).to eq( ['module_types.h', 'base.h'] )
1601
+ expect( groups.following ).to eq( [] )
1602
+ end
1603
+
1604
+ it "puts the types header after the source's includes when the source never includes the module's header" do
1605
+ groups = @partializer.remap_interface_header_includes(
1606
+ name: 'module',
1607
+ source_includes: [UserInclude.new( 'a.h' ), UserInclude.new( 'b.h' )],
1608
+ header_includes: [UserInclude.new( 'c.h' )], partials: {}, types_header: 'module_types.h'
1609
+ )
1610
+
1611
+ expect( groups.leading.map( &:filename ) ).to eq( ['a.h', 'b.h', 'module_types.h', 'c.h'] )
1612
+ expect( groups.following ).to eq( [] )
1613
+ end
1614
+
891
1615
  it "returns empty array when input is empty and no partials" do
892
1616
  result = @partializer.remap_interface_header_includes(
893
1617
  name: 'module',
894
- includes: [],
1618
+ source_includes: [],
895
1619
  partials: {}
896
- )
1620
+ ).to_a
897
1621
  expect(result).to eq([])
898
1622
  end
899
1623
 
@@ -901,9 +1625,9 @@ describe Partializer do
901
1625
  includes = [UserInclude.new('header1.h'), UserInclude.new('module.h'), UserInclude.new('header2.h')]
902
1626
  result = @partializer.remap_interface_header_includes(
903
1627
  name: 'module',
904
- includes: includes,
1628
+ source_includes: includes,
905
1629
  partials: {}
906
- )
1630
+ ).to_a
907
1631
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
908
1632
  expect(result).not_to include(UserInclude.new('module.h'))
909
1633
  end
@@ -913,9 +1637,9 @@ describe Partializer do
913
1637
  partials = { 'partial_module' => nil }
914
1638
  result = @partializer.remap_interface_header_includes(
915
1639
  name: 'module',
916
- includes: includes,
1640
+ source_includes: includes,
917
1641
  partials: partials
918
- )
1642
+ ).to_a
919
1643
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
920
1644
  expect(result).not_to include(UserInclude.new('partial_module.h'))
921
1645
  end
@@ -930,9 +1654,9 @@ describe Partializer do
930
1654
  partials = { 'partial1' => nil, 'partial2' => nil }
931
1655
  result = @partializer.remap_interface_header_includes(
932
1656
  name: 'module',
933
- includes: includes,
1657
+ source_includes: includes,
934
1658
  partials: partials
935
- )
1659
+ ).to_a
936
1660
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
937
1661
  expect(result).not_to include(UserInclude.new('partial1.h'))
938
1662
  expect(result).not_to include(UserInclude.new('partial2.h'))
@@ -948,9 +1672,9 @@ describe Partializer do
948
1672
  partials = { 'partial_module' => nil }
949
1673
  result = @partializer.remap_interface_header_includes(
950
1674
  name: 'module',
951
- includes: includes,
1675
+ source_includes: includes,
952
1676
  partials: partials
953
- )
1677
+ ).to_a
954
1678
  expect(result).to match_array([
955
1679
  UserInclude.new('header1.h'),
956
1680
  UserInclude.new('header2.h'),
@@ -968,9 +1692,9 @@ describe Partializer do
968
1692
  partials = { 'partial_module' => nil }
969
1693
  result = @partializer.remap_interface_header_includes(
970
1694
  name: 'module',
971
- includes: includes,
1695
+ source_includes: includes,
972
1696
  partials: partials
973
- )
1697
+ ).to_a
974
1698
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
975
1699
  end
976
1700
 
@@ -983,9 +1707,9 @@ describe Partializer do
983
1707
  ]
984
1708
  result = @partializer.remap_interface_header_includes(
985
1709
  name: 'module',
986
- includes: includes,
1710
+ source_includes: includes,
987
1711
  partials: {}
988
- )
1712
+ ).to_a
989
1713
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
990
1714
  expect(result).not_to include(UserInclude.new('module.h'))
991
1715
  expect(result).not_to include(UserInclude.new('MODULE.H'))
@@ -1001,9 +1725,9 @@ describe Partializer do
1001
1725
  partials = { 'partial1' => nil, 'partial2' => nil, 'partial3' => nil }
1002
1726
  result = @partializer.remap_interface_header_includes(
1003
1727
  name: 'module',
1004
- includes: includes,
1728
+ source_includes: includes,
1005
1729
  partials: partials
1006
- )
1730
+ ).to_a
1007
1731
  expect(result).to match_array([UserInclude.new('header1.h')])
1008
1732
  end
1009
1733
 
@@ -1011,9 +1735,9 @@ describe Partializer do
1011
1735
  includes = [UserInclude.new('header1.h'), UserInclude.new('header2.h'), UserInclude.new('module.h')]
1012
1736
  result = @partializer.remap_interface_header_includes(
1013
1737
  name: 'module',
1014
- includes: includes,
1738
+ source_includes: includes,
1015
1739
  partials: {}
1016
- )
1740
+ ).to_a
1017
1741
  expect(result).to match_array([UserInclude.new('header1.h'), UserInclude.new('header2.h')])
1018
1742
  end
1019
1743
 
@@ -1030,9 +1754,9 @@ describe Partializer do
1030
1754
  partials = { 'partial1' => nil, 'partial2' => nil }
1031
1755
  result = @partializer.remap_interface_header_includes(
1032
1756
  name: 'module',
1033
- includes: includes,
1757
+ source_includes: includes,
1034
1758
  partials: partials
1035
- )
1759
+ ).to_a
1036
1760
  expect(result).to match_array([
1037
1761
  UserInclude.new('header1.h'),
1038
1762
  UserInclude.new('header2.h'),
@@ -1048,75 +1772,347 @@ describe Partializer do
1048
1772
  partials = {}
1049
1773
  result = @partializer.remap_interface_header_includes(
1050
1774
  name: 'module',
1051
- includes: includes,
1775
+ source_includes: includes,
1052
1776
  partials: partials,
1053
1777
  types_header: 'ceedling_partial_module_types.h'
1778
+ ).to_a
1779
+
1780
+ expect(result).to include(UserInclude.new('ceedling_partial_module_types.h'))
1781
+ end
1782
+
1783
+ it "does not append a types header when the module has none" do
1784
+ includes = [UserInclude.new('header1.h')]
1785
+ partials = {}
1786
+ result = @partializer.remap_interface_header_includes(
1787
+ name: 'module',
1788
+ source_includes: includes,
1789
+ partials: partials
1790
+ ).to_a
1791
+
1792
+ expect(result).to match_array([UserInclude.new('header1.h')])
1793
+ end
1794
+
1795
+ # See the matching example in #remap_implementation_header_includes for the full
1796
+ # rationale; the mockable interface header needs the identical ordering guarantee.
1797
+ it "splices the shared types header in at the module's own original list position, not at the end" do
1798
+ includes = [
1799
+ UserInclude.new('header1.h'),
1800
+ UserInclude.new('module.h'),
1801
+ UserInclude.new('header2.h')
1802
+ ]
1803
+ result = @partializer.remap_interface_header_includes(
1804
+ name: 'module',
1805
+ source_includes: includes,
1806
+ partials: {},
1807
+ types_header: 'ceedling_partial_module_types.h'
1808
+ ).to_a
1809
+
1810
+ expect(result).to eq([
1811
+ UserInclude.new('header1.h'),
1812
+ UserInclude.new('ceedling_partial_module_types.h'),
1813
+ UserInclude.new('header2.h')
1814
+ ])
1815
+ end
1816
+ end
1817
+
1818
+ ###
1819
+ ### remap_implementation_source_includes()
1820
+ ###
1821
+
1822
+ context "#remap_implementation_source_includes" do
1823
+ # Fallback holds an #include as written beside the header it resolved to elsewhere, and
1824
+ # the two are one header
1825
+ it "drops an unresolved #include beside the resolved header of the same name" do
1826
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1827
+ .with('module').and_return('ceedling_partial_module_impl.h')
1828
+
1829
+ result = @partializer.remap_implementation_source_includes(
1830
+ name: 'module',
1831
+ includes: [UserInclude.new('module.h'), UserInclude.new('config.h'), UserInclude.new('include/drivers/config.h')],
1832
+ partials: { 'module' => make_partial_config(tests_type: :public) }
1054
1833
  )
1055
1834
 
1056
- expect(result).to include(UserInclude.new('ceedling_partial_module_types.h'))
1835
+ expect( result.map( &:filepath ) ).to eq( ['ceedling_partial_module_impl.h', 'include/drivers/config.h'] )
1836
+ end
1837
+
1838
+ # A module tested and mocked in one test file splits its own content across two generated
1839
+ # headers: the implementation carries the public bodies and the interface declares the
1840
+ # private functions those bodies call. The generated source needs both, so this module's own
1841
+ # interface header belongs in its own include list. wondrous_forest's ForestMonitor is
1842
+ # exactly this shape, and dropping the entry leaves its private transition function
1843
+ # undeclared at compile time.
1844
+ it "carries this module's own interface header when it is also mocked" do
1845
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1846
+ .with('module').and_return('ceedling_partial_module_impl.h')
1847
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1848
+ .with('module').and_return('ceedling_partial_module_interface.h')
1849
+
1850
+ result = @partializer.remap_implementation_source_includes(
1851
+ name: 'module',
1852
+ includes: [UserInclude.new('module.h')],
1853
+ partials: { 'module' => make_partial_config(tests_type: :public, mocks_type: :private) }
1854
+ )
1855
+
1856
+ expect( result.map( &:filename ) ).to eq(
1857
+ ['ceedling_partial_module_impl.h', 'ceedling_partial_module_interface.h']
1858
+ )
1859
+ end
1860
+
1861
+ # The implementation header already stands where this module's header was, so the
1862
+ # interface header follows it rather than everything else.
1863
+ it "puts this module's own interface header right after its implementation header" do
1864
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1865
+ .with('module').and_return('ceedling_partial_module_impl.h')
1866
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1867
+ .with('module').and_return('ceedling_partial_module_interface.h')
1868
+
1869
+ result = @partializer.remap_implementation_source_includes(
1870
+ name: 'module',
1871
+ includes: [UserInclude.new('module.h'), UserInclude.new('last.h')],
1872
+ partials: { 'module' => make_partial_config(tests_type: :public, mocks_type: :private) }
1873
+ )
1874
+
1875
+ expect( result.map( &:filename ) ).to eq(
1876
+ ['ceedling_partial_module_impl.h', 'ceedling_partial_module_interface.h', 'last.h']
1877
+ )
1878
+ end
1879
+
1880
+ it "puts a mocked dependency's interface header where its real header was" do
1881
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1882
+ .with('module').and_return('ceedling_partial_module_impl.h')
1883
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1884
+ .with('other').and_return('ceedling_partial_other_interface.h')
1885
+
1886
+ result = @partializer.remap_implementation_source_includes(
1887
+ name: 'module',
1888
+ includes: [UserInclude.new('first.h'), UserInclude.new('other.h'), UserInclude.new('module.h'), UserInclude.new('last.h')],
1889
+ partials: { 'other' => make_partial_config(mocks_type: :public) }
1890
+ )
1891
+
1892
+ expect( result.map( &:filename ) ).to eq(
1893
+ ['first.h', 'ceedling_partial_other_interface.h', 'ceedling_partial_module_impl.h', 'last.h']
1894
+ )
1895
+ end
1896
+
1897
+ # A source that never includes its own header is read as including it last, so the
1898
+ # interface header still follows the implementation header
1899
+ it "carries this module's own interface header when its source never includes its header" do
1900
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1901
+ .with('module').and_return('ceedling_partial_module_impl.h')
1902
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1903
+ .with('module').and_return('ceedling_partial_module_interface.h')
1904
+
1905
+ result = @partializer.remap_implementation_source_includes(
1906
+ name: 'module',
1907
+ includes: [UserInclude.new('first.h')],
1908
+ partials: { 'module' => make_partial_config(tests_type: :public, mocks_type: :private) }
1909
+ )
1910
+
1911
+ expect( result.map( &:filename ) ).to eq(
1912
+ ['first.h', 'ceedling_partial_module_impl.h', 'ceedling_partial_module_interface.h']
1913
+ )
1914
+ end
1915
+
1916
+ # A module named by directory is keyed by that directory, but its header is included by name
1917
+ it "puts the interface header of a mocked dependency named by directory where its real header was" do
1918
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1919
+ .with('module').and_return('ceedling_partial_module_impl.h')
1920
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1921
+ .with('hw/port').and_return('hw/ceedling_partial_port_interface.h')
1922
+
1923
+ result = @partializer.remap_implementation_source_includes(
1924
+ name: 'module',
1925
+ includes: [UserInclude.new('module.h'), UserInclude.new('port.h')],
1926
+ partials: { 'hw/port' => make_partial_config(mocks_type: :private, header: 'src/hw/port.h') }
1927
+ )
1928
+
1929
+ expect( result.map( &:filepath ) ).to eq( ['ceedling_partial_module_impl.h', 'hw/ceedling_partial_port_interface.h'] )
1930
+ end
1931
+
1932
+ # Two modules sharing a basename are told apart by where each header lives
1933
+ context "with a mocked module sharing this module's basename" do
1934
+ before do
1935
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1936
+ .with('drivers/uart/config').and_return('drivers/uart/ceedling_partial_config_impl.h')
1937
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1938
+ .with('drivers/spi/config').and_return('drivers/spi/ceedling_partial_config_interface.h')
1939
+ @partials = {
1940
+ 'drivers/uart/config' => make_partial_config(tests_type: :public, header: 'src/drivers/uart/config.h'),
1941
+ 'drivers/spi/config' => make_partial_config(mocks_type: :private, header: 'src/drivers/spi/config.h')
1942
+ }
1943
+ end
1944
+
1945
+ it "puts the mocked module's interface header where its real header was" do
1946
+ result = @partializer.remap_implementation_source_includes(
1947
+ name: 'drivers/uart/config', partials: @partials,
1948
+ includes: [UserInclude.new('src/drivers/uart/config.h'), UserInclude.new('src/drivers/spi/config.h')]
1949
+ )
1950
+
1951
+ expect( result.map( &:filepath ) ).to eq(
1952
+ ['drivers/uart/ceedling_partial_config_impl.h', 'drivers/spi/ceedling_partial_config_interface.h']
1953
+ )
1954
+ end
1955
+
1956
+ it "replaces the mocked module's header in place when it comes first" do
1957
+ result = @partializer.remap_implementation_source_includes(
1958
+ name: 'drivers/uart/config', partials: @partials,
1959
+ includes: [UserInclude.new('src/drivers/spi/config.h'), UserInclude.new('src/drivers/uart/config.h'), UserInclude.new('last.h')]
1960
+ )
1961
+
1962
+ expect( result.map( &:filepath ) ).to eq(
1963
+ ['drivers/spi/ceedling_partial_config_interface.h', 'drivers/uart/ceedling_partial_config_impl.h', 'last.h']
1964
+ )
1965
+ end
1966
+
1967
+ # A case-insensitive filesystem reaches the module's header by any case of its path
1968
+ it "takes a case variant of this module's own header path for its header" do
1969
+ result = @partializer.remap_implementation_source_includes(
1970
+ name: 'drivers/uart/config', partials: @partials, includes: [UserInclude.new('src/drivers/uart/Config.h')]
1971
+ )
1972
+
1973
+ expect( result.map( &:filepath ) ).to eq( ['drivers/uart/ceedling_partial_config_impl.h'] )
1974
+ end
1975
+
1976
+ it "never takes this module's own header for the mocked module's" do
1977
+ result = @partializer.remap_implementation_source_includes(
1978
+ name: 'drivers/uart/config', partials: @partials, includes: [UserInclude.new('src/drivers/uart/config.h')]
1979
+ )
1980
+
1981
+ expect( result.map( &:filepath ) ).to eq( ['drivers/uart/ceedling_partial_config_impl.h'] )
1982
+ end
1057
1983
  end
1058
1984
 
1059
- it "does not append a types header when the module has none" do
1060
- includes = [UserInclude.new('header1.h')]
1061
- partials = {}
1062
- result = @partializer.remap_interface_header_includes(
1063
- name: 'module',
1064
- includes: includes,
1065
- partials: partials
1066
- )
1985
+ # A module named by directory claims only its own header, even with no other Partial
1986
+ # sharing its basename
1987
+ context "with an unpartialized header sharing a Partial's basename" do
1988
+ before do
1989
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1990
+ .with('motor').and_return('ceedling_partial_motor_impl.h')
1991
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1992
+ .with('drivers/uart/config').and_return('drivers/uart/ceedling_partial_config_interface.h')
1993
+ end
1067
1994
 
1068
- expect(result).to match_array([UserInclude.new('header1.h')])
1995
+ it "keeps that header where a mocked Partial would take it" do
1996
+ result = @partializer.remap_implementation_source_includes(
1997
+ name: 'motor', includes: [UserInclude.new('src/motor.h'), UserInclude.new('src/config.h')],
1998
+ partials: { 'drivers/uart/config' => make_partial_config(mocks_type: :public, header: 'include/drivers/uart/config.h') }
1999
+ )
2000
+
2001
+ expect( result.map( &:filepath ) ).to eq( ['ceedling_partial_motor_impl.h', 'src/config.h'] )
2002
+ end
2003
+
2004
+ it "places a mocked Partial's interface header at its own header, not at that header" do
2005
+ result = @partializer.remap_implementation_source_includes(
2006
+ name: 'motor',
2007
+ includes: [UserInclude.new('src/config.h'), UserInclude.new('include/drivers/uart/config.h'), UserInclude.new('src/motor.h')],
2008
+ partials: { 'drivers/uart/config' => make_partial_config(mocks_type: :public, header: 'include/drivers/uart/config.h') }
2009
+ )
2010
+
2011
+ expect( result.map( &:filepath ) ).to eq(
2012
+ ['src/config.h', 'drivers/uart/ceedling_partial_config_interface.h', 'ceedling_partial_motor_impl.h']
2013
+ )
2014
+ end
2015
+
2016
+ it "keeps that header where a tested Partial's header would be dropped" do
2017
+ groups = @partializer.remap_types_header_includes(
2018
+ name: 'motor', source_includes: [UserInclude.new('src/motor.h')], header_includes: [UserInclude.new('src/config.h')],
2019
+ partials: { 'drivers/uart/config' => make_partial_config(tests_type: :public, header: 'include/drivers/uart/config.h') }
2020
+ )
2021
+
2022
+ expect( groups.leading.map( &:filepath ) ).to eq( ['src/config.h'] )
2023
+ end
1069
2024
  end
1070
2025
 
1071
- # See the matching example in #remap_implementation_header_includes for the full
1072
- # rationale; the mockable interface header needs the identical ordering guarantee.
1073
- it "splices the shared types header in at the module's own original list position, not at the end" do
1074
- includes = [
1075
- UserInclude.new('header1.h'),
1076
- UserInclude.new('module.h'),
1077
- UserInclude.new('header2.h')
1078
- ]
1079
- result = @partializer.remap_interface_header_includes(
1080
- name: 'module',
1081
- includes: includes,
1082
- partials: {},
1083
- types_header: 'ceedling_partial_module_types.h'
2026
+ # Fallback anchors a `..` #include to its file's own directory. One that names no file there
2027
+ # was found elsewhere through a search path, so its path says nothing and its filename decides.
2028
+ it "takes an anchored #include naming no file for a directory-named module's own header" do
2029
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
2030
+ .with('hw/port').and_return('hw/ceedling_partial_port_impl.h')
2031
+ allow(@file_wrapper).to receive(:exist?).with('src/port.h').and_return( false )
2032
+
2033
+ result = @partializer.remap_implementation_source_includes(
2034
+ name: 'hw/port', includes: [UserInclude.new( 'src/port.h', directory_relative: true )],
2035
+ partials: { 'hw/port' => make_partial_config(tests_type: :public, header: 'include/hw/port.h') }
1084
2036
  )
1085
2037
 
1086
- expect(result).to eq([
1087
- UserInclude.new('header1.h'),
1088
- UserInclude.new('ceedling_partial_module_types.h'),
1089
- UserInclude.new('header2.h')
1090
- ])
2038
+ expect( result.map( &:filepath ) ).to eq( ['hw/ceedling_partial_port_impl.h'] )
1091
2039
  end
1092
- end
1093
-
1094
- ###
1095
- ### remap_implementation_source_includes()
1096
- ###
1097
2040
 
1098
- context "#remap_implementation_source_includes" do
1099
- # A module tested and mocked in one test file splits its own content across two generated
1100
- # headers: the implementation carries the public bodies and the interface declares the
1101
- # private functions those bodies call. The generated source needs both, so this module's own
1102
- # interface header belongs in its own include list. wondrous_forest's ForestMonitor is
1103
- # exactly this shape, and dropping the entry leaves its private transition function
1104
- # undeclared at compile time.
1105
- it "carries this module's own interface header when it is also mocked" do
2041
+ it "matches an anchored #include naming a file by its path" do
1106
2042
  allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
1107
- .with('module').and_return('ceedling_partial_module_impl.h')
1108
- allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
1109
- .with('module').and_return('ceedling_partial_module_interface.h')
2043
+ .with('hw/port').and_return('hw/ceedling_partial_port_impl.h')
2044
+ allow(@file_wrapper).to receive(:exist?).with('src/port.h').and_return( true )
1110
2045
 
1111
2046
  result = @partializer.remap_implementation_source_includes(
1112
- name: 'module',
1113
- includes: [UserInclude.new('module.h')],
1114
- partials: { 'module' => make_partial_config(tests_type: :public, mocks_type: :private) }
2047
+ name: 'hw/port', includes: [UserInclude.new( 'src/port.h', directory_relative: true )],
2048
+ partials: { 'hw/port' => make_partial_config(tests_type: :public, header: 'include/hw/port.h') }
1115
2049
  )
1116
2050
 
1117
- expect( result.map( &:filename ) ).to eq(
1118
- ['ceedling_partial_module_impl.h', 'ceedling_partial_module_interface.h']
1119
- )
2051
+ expect( result.map( &:filepath ) ).to eq( ['src/port.h', 'hw/ceedling_partial_port_impl.h'] )
2052
+ end
2053
+
2054
+ # A module named without a directory is named by its basename, however an #include spells
2055
+ # the path to its header
2056
+ context "with this module's own header spelled another way" do
2057
+ before do
2058
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
2059
+ .with('module').and_return('ceedling_partial_module_impl.h')
2060
+ allow(@file_path_utils).to receive(:form_partial_implementation_header_filename)
2061
+ .with('shared/module').and_return('shared/ceedling_partial_module_impl.h')
2062
+ end
2063
+
2064
+ it "takes an absolute #include of a header outside the project for its own header" do
2065
+ header = '../shared/module.h'
2066
+ result = @partializer.remap_implementation_source_includes(
2067
+ name: 'module', includes: [UserInclude.new( ProjectPaths.absolute( header ) )],
2068
+ partials: { 'module' => make_partial_config(tests_type: :public, header: header) }
2069
+ )
2070
+
2071
+ expect( result.map( &:filepath ) ).to eq( ['ceedling_partial_module_impl.h'] )
2072
+ end
2073
+
2074
+ # A module named by directory is matched by path, so both sides are compared absolutely
2075
+ it "takes an absolute #include of a directory-named module's header outside the project for its own" do
2076
+ header = '../shared/module.h'
2077
+ result = @partializer.remap_implementation_source_includes(
2078
+ name: 'shared/module', includes: [UserInclude.new( ProjectPaths.absolute( header ) )],
2079
+ partials: { 'shared/module' => make_partial_config(tests_type: :public, header: header) }
2080
+ )
2081
+
2082
+ expect( result.map( &:filepath ) ).to eq( ['shared/ceedling_partial_module_impl.h'] )
2083
+ end
2084
+
2085
+ it "takes a relative #include of a directory-named module's header the project names absolutely" do
2086
+ header = ProjectPaths.absolute( '../shared/module.h' )
2087
+ result = @partializer.remap_implementation_source_includes(
2088
+ name: 'shared/module', includes: [UserInclude.new( '../shared/module.h' )],
2089
+ partials: { 'shared/module' => make_partial_config(tests_type: :public, header: header) }
2090
+ )
2091
+
2092
+ expect( result.map( &:filepath ) ).to eq( ['shared/ceedling_partial_module_impl.h'] )
2093
+ end
2094
+
2095
+ # A case-insensitive filesystem reaches the header by either case of its absolute path
2096
+ it "takes a case variant of a directory-named module's absolute header path for its own" do
2097
+ header = '../shared/module.h'
2098
+ result = @partializer.remap_implementation_source_includes(
2099
+ name: 'shared/module', includes: [UserInclude.new( ProjectPaths.absolute( header ).sub( 'shared', 'SHARED' ) )],
2100
+ partials: { 'shared/module' => make_partial_config(tests_type: :public, header: header) }
2101
+ )
2102
+
2103
+ expect( result.map( &:filepath ) ).to eq( ['shared/ceedling_partial_module_impl.h'] )
2104
+ end
2105
+
2106
+ # Fallback preprocessing anchors a `..` #include to the file's own directory, which need
2107
+ # not be where the compiler finds the header
2108
+ it "takes a fallback-anchored #include for its own header" do
2109
+ result = @partializer.remap_implementation_source_includes(
2110
+ name: 'module', includes: [UserInclude.new( 'src/module.h', directory_relative: true )],
2111
+ partials: { 'module' => make_partial_config(tests_type: :public, header: 'include/module.h') }
2112
+ )
2113
+
2114
+ expect( result.map( &:filepath ) ).to eq( ['ceedling_partial_module_impl.h'] )
2115
+ end
1120
2116
  end
1121
2117
 
1122
2118
  it "carries no interface header for a module that is tested but not mocked" do
@@ -1538,14 +2534,110 @@ describe Partializer do
1538
2534
  ###
1539
2535
 
1540
2536
  context "#remap_types_header_includes" do
2537
+ # The source meets its later includes only after the module header, so they follow
2538
+ # whatever the header supplies
2539
+ context "grouping includes where the source includes the module's header" do
2540
+ def types_groups(source, header = [], partials: {})
2541
+ @partializer.remap_types_header_includes(
2542
+ name: 'module', source_includes: source.map { |name| UserInclude.new( name ) },
2543
+ header_includes: header.map { |name| UserInclude.new( name ) }, partials: partials
2544
+ )
2545
+ end
2546
+
2547
+ def filenames(groups)
2548
+ [groups.leading.map( &:filename ), groups.following.map( &:filename )]
2549
+ end
2550
+
2551
+ it "puts the header's includes after the source's earlier ones, and the rest after them" do
2552
+ groups = types_groups( ['config.h', 'module.h', 'log.h'], ['base.h'] )
2553
+
2554
+ expect( filenames( groups ) ).to eq( [['config.h', 'base.h'], ['log.h']] )
2555
+ end
2556
+
2557
+ it "keeps an include named in both groups in its earlier place" do
2558
+ groups = types_groups( ['module.h', 'base.h'], ['base.h'] )
2559
+
2560
+ expect( filenames( groups ) ).to eq( [['base.h'], []] )
2561
+ end
2562
+
2563
+ # The place a missing own header holds is no header, so it can't name another module
2564
+ it "names no mocked module through the place a missing own header holds" do
2565
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
2566
+ .with('calibration').and_return('ceedling_partial_calibration_interface.h')
2567
+
2568
+ groups = @partializer.remap_types_header_includes(
2569
+ name: 'sensors/Calibration', source_includes: [], header_includes: [UserInclude.new( 'base.h' )],
2570
+ partials: {
2571
+ 'sensors/Calibration' => make_partial_config(mocks_type: :private, header: 'src/sensors/Calibration.h'),
2572
+ 'calibration' => make_partial_config(mocks_type: :private, header: 'src/calibration.h')
2573
+ }
2574
+ )
2575
+
2576
+ expect( filenames( groups ) ).to eq( [['base.h'], []] )
2577
+ end
2578
+
2579
+ # A bare name claims its basename, but not a header that a same-named module named by
2580
+ # directory claims by its path
2581
+ it "leaves a same-named module named by directory its own header" do
2582
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
2583
+ .with('drivers/zspi/config').and_return('drivers/zspi/ceedling_partial_config_interface.h')
2584
+
2585
+ groups = @partializer.remap_types_header_includes(
2586
+ name: 'config', source_includes: [], header_includes: [UserInclude.new( 'include/drivers/zspi/config.h' )],
2587
+ partials: {
2588
+ 'config' => make_partial_config(tests_type: :public, header: 'include/drivers/uart/config.h'),
2589
+ 'drivers/zspi/config' => make_partial_config(mocks_type: :private, header: 'include/drivers/zspi/config.h')
2590
+ }
2591
+ )
2592
+
2593
+ expect( groups.leading.map( &:filepath ) ).to eq( ['drivers/zspi/ceedling_partial_config_interface.h'] )
2594
+ expect( groups.following ).to eq( [] )
2595
+ end
2596
+
2597
+ it "leaves nothing to follow when the source never includes the module's header" do
2598
+ groups = types_groups( ['a.h', 'b.h'], ['c.h'] )
2599
+
2600
+ expect( filenames( groups ) ).to eq( [['a.h', 'b.h', 'c.h'], []] )
2601
+ end
2602
+
2603
+ it "keeps a system include ahead of everything" do
2604
+ groups = @partializer.remap_types_header_includes(
2605
+ name: 'module', source_includes: [UserInclude.new( 'module.h' ), SystemInclude.new( 'stdint.h' )],
2606
+ header_includes: [], partials: {}
2607
+ )
2608
+
2609
+ expect( filenames( groups ) ).to eq( [['stdint.h'], []] )
2610
+ end
2611
+
2612
+ it "redirects a mocked dependency within the following group" do
2613
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
2614
+ .with('other').and_return('ceedling_partial_other_interface.h')
2615
+
2616
+ groups = types_groups( ['module.h', 'other.h'], partials: { 'other' => make_partial_config(mocks_type: :public) } )
2617
+
2618
+ expect( filenames( groups ) ).to eq( [[], ['ceedling_partial_other_interface.h']] )
2619
+ end
2620
+
2621
+ it "logs every include and no boundary" do
2622
+ expect(@loginator).to receive(:log_list).with(
2623
+ [UserInclude.new( 'config.h' ), UserInclude.new( 'log.h' )], anything, Verbosity::OBNOXIOUS
2624
+ )
2625
+
2626
+ @partializer.remap_types_header_includes(
2627
+ name: 'module', source_includes: [UserInclude.new( 'config.h' ), UserInclude.new( 'module.h' ), UserInclude.new( 'log.h' )],
2628
+ partials: {}, test: 'a_test'
2629
+ )
2630
+ end
2631
+ end
2632
+
1541
2633
  # Nothing replaces this module's own header here. The types header cannot include itself, so
1542
2634
  # its own entry is simply dropped.
1543
2635
  it "drops the module's own header without substituting anything" do
1544
2636
  result = @partializer.remap_types_header_includes(
1545
2637
  name: 'module',
1546
- includes: [UserInclude.new('module.h'), UserInclude.new('foundation.h')],
2638
+ source_includes: [UserInclude.new('module.h'), UserInclude.new('foundation.h')],
1547
2639
  partials: {}
1548
- )
2640
+ ).to_a
1549
2641
 
1550
2642
  expect( result ).to eq([UserInclude.new('foundation.h')])
1551
2643
  end
@@ -1553,9 +2645,9 @@ describe Partializer do
1553
2645
  it "keeps every other include in its original relative order" do
1554
2646
  result = @partializer.remap_types_header_includes(
1555
2647
  name: 'module',
1556
- includes: [UserInclude.new('first.h'), UserInclude.new('module.h'), UserInclude.new('last.h')],
2648
+ source_includes: [UserInclude.new('first.h'), UserInclude.new('module.h'), UserInclude.new('last.h')],
1557
2649
  partials: {}
1558
- )
2650
+ ).to_a
1559
2651
 
1560
2652
  expect( result.map( &:filename ) ).to eq(['first.h', 'last.h'])
1561
2653
  end
@@ -1570,19 +2662,35 @@ describe Partializer do
1570
2662
 
1571
2663
  result = @partializer.remap_types_header_includes(
1572
2664
  name: 'module',
1573
- includes: [UserInclude.new('module.h'), UserInclude.new('other.h')],
2665
+ source_includes: [UserInclude.new('module.h'), UserInclude.new('other.h')],
1574
2666
  partials: { 'other' => make_partial_config(mocks_type: :public) }
1575
- )
2667
+ ).to_a
1576
2668
 
1577
2669
  expect( result.map( &:filename ) ).to eq(['ceedling_partial_other_interface.h'])
1578
2670
  end
1579
2671
 
2672
+ # Whatever the real header declared, the includes after it could rely on. Its interface
2673
+ # header declares the same names, so it belongs at the same place.
2674
+ it "puts a mocked dependency's interface header where its real header was" do
2675
+ allow(@file_path_utils).to receive(:form_partial_interface_header_filename)
2676
+ .with('other')
2677
+ .and_return('ceedling_partial_other_interface.h')
2678
+
2679
+ result = @partializer.remap_types_header_includes(
2680
+ name: 'module',
2681
+ source_includes: [UserInclude.new('first.h'), UserInclude.new('other.h'), UserInclude.new('last.h'), UserInclude.new('module.h')],
2682
+ partials: { 'other' => make_partial_config(mocks_type: :public) }
2683
+ ).to_a
2684
+
2685
+ expect( result.map( &:filename ) ).to eq(['first.h', 'ceedling_partial_other_interface.h', 'last.h'])
2686
+ end
2687
+
1580
2688
  it "drops a partialized dependency that is not mocked" do
1581
2689
  result = @partializer.remap_types_header_includes(
1582
2690
  name: 'module',
1583
- includes: [UserInclude.new('module.h'), UserInclude.new('other.h')],
2691
+ source_includes: [UserInclude.new('module.h'), UserInclude.new('other.h')],
1584
2692
  partials: { 'other' => make_partial_config(tests_type: :public) }
1585
- )
2693
+ ).to_a
1586
2694
 
1587
2695
  expect( result ).to be_empty
1588
2696
  end
@@ -1592,9 +2700,9 @@ describe Partializer do
1592
2700
  it "leaves a header whose name only extends a partialized module's name" do
1593
2701
  result = @partializer.remap_types_header_includes(
1594
2702
  name: 'module',
1595
- includes: [UserInclude.new('module.h'), UserInclude.new('other_extra.h'), UserInclude.new('other.h')],
2703
+ source_includes: [UserInclude.new('module.h'), UserInclude.new('other_extra.h'), UserInclude.new('other.h')],
1596
2704
  partials: { 'other' => make_partial_config(tests_type: :public) }
1597
- )
2705
+ ).to_a
1598
2706
 
1599
2707
  expect( result.map( &:filename ) ).to eq(['other_extra.h'])
1600
2708
  end
@@ -1608,9 +2716,9 @@ describe Partializer do
1608
2716
 
1609
2717
  result = @partializer.remap_types_header_includes(
1610
2718
  name: 'module',
1611
- includes: [UserInclude.new('module.h'), UserInclude.new('foundation.h')],
2719
+ source_includes: [UserInclude.new('module.h'), UserInclude.new('foundation.h')],
1612
2720
  partials: { 'module' => make_partial_config(tests_type: :public, mocks_type: :private) }
1613
- )
2721
+ ).to_a
1614
2722
 
1615
2723
  expect( result.map( &:filename ) ).to eq(['foundation.h'])
1616
2724
  end
@@ -1624,10 +2732,10 @@ describe Partializer do
1624
2732
 
1625
2733
  @partializer.remap_types_header_includes(
1626
2734
  name: 'module',
1627
- includes: [UserInclude.new('foundation.h')],
2735
+ source_includes: [UserInclude.new('foundation.h')],
1628
2736
  partials: {},
1629
2737
  test: 'a_test'
1630
- )
2738
+ ).to_a
1631
2739
  end
1632
2740
  end
1633
2741
 
@@ -1642,21 +2750,43 @@ describe Partializer do
1642
2750
  # associate_function_line_numbers is called for every file processed; stub by default
1643
2751
  allow(@partializer_helper).to receive(:associate_function_line_numbers)
1644
2752
  # static var extraction/promotion called for every file processed; stub by default
1645
- allow(@partializer_helper).to receive(:extract_function_scope_static_vars).and_return([])
2753
+ allow(@partializer_helper).to receive(:promote_function_scope_statics)
2754
+ allow(@partializer_helper).to receive(:validate_function_names_readable)
2755
+ end
2756
+
2757
+ # Every later step finds a definition by its name
2758
+ it "stops on a definition it can't name before anything reads the name" do
2759
+ unnamed = CExtractorTypes::CFunctionDefinition.new(name: nil, signature: 'int __count__(void)')
2760
+ source_contents = CExtractorTypes::CModule.new(function_definitions: [unnamed])
2761
+
2762
+ config = PartializerConfig::Config.new(
2763
+ module: 'module1',
2764
+ header: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil),
2765
+ source: Partials::ConfigFileInfo.new(filepath: '/src/module1.c', assembled_filepath: '/build/preproc/module1.i')
2766
+ )
2767
+
2768
+ allow(@c_extractor).to receive(:from_file).and_return(source_contents)
2769
+ expect(@partializer_helper).to receive(:validate_function_names_readable)
2770
+ .with(source_contents, @name, 'module1').and_raise(CeedlingException, 'unreadable')
2771
+ expect(@partializer_helper).not_to receive(:associate_function_line_numbers)
2772
+ expect(@partializer_helper).not_to receive(:promote_function_scope_statics)
2773
+
2774
+ expect { @partializer.extract_module_contents(@name, config) }
2775
+ .to raise_error(CeedlingException, 'unreadable')
1646
2776
  end
1647
2777
 
1648
- it "returns empty CModule when both directives_only_filepaths are nil" do
1649
- config = Partials::Config.new(
2778
+ it "returns empty CModule when both assembled_filepaths are nil" do
2779
+ config = PartializerConfig::Config.new(
1650
2780
  module: 'module1',
1651
- header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', directives_only_filepath: nil),
1652
- source: Partials::ConfigFileInfo.new(filepath: '/path/to/source.c', directives_only_filepath: nil)
2781
+ header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', assembled_filepath: nil),
2782
+ source: Partials::ConfigFileInfo.new(filepath: '/path/to/source.c', assembled_filepath: nil)
1653
2783
  )
1654
2784
 
1655
2785
  expect(@c_extractor).not_to receive(:from_file)
1656
2786
  expect(@partializer_helper).not_to receive(:associate_function_line_numbers)
1657
- expect(@partializer_helper).not_to receive(:extract_function_scope_static_vars)
2787
+ expect(@partializer_helper).not_to receive(:promote_function_scope_statics)
1658
2788
 
1659
- result = @partializer.extract_module_contents(@name, config, fallback: false)
2789
+ result = @partializer.extract_module_contents(@name, config)
1660
2790
 
1661
2791
  expect(result.function_definitions).to eq([])
1662
2792
  expect(result.variable_declarations).to eq([])
@@ -1664,23 +2794,23 @@ describe Partializer do
1664
2794
 
1665
2795
  it "extracts contents from header preprocessed file only" do
1666
2796
  header_funcs = [
1667
- double('func1', name: 'func1', signature: 'void func1(void)'),
1668
- double('func2', name: 'func2', signature: 'int func2(int x)')
2797
+ CExtractorTypes::CFunctionDefinition.new(name: 'func1', signature: 'void func1(void)'),
2798
+ CExtractorTypes::CFunctionDefinition.new(name: 'func2', signature: 'int func2(int x)')
1669
2799
  ]
1670
2800
  header_contents = CExtractorTypes::CModule.new(function_definitions: header_funcs, variable_declarations: [])
1671
2801
 
1672
- config = Partials::Config.new(
2802
+ config = PartializerConfig::Config.new(
1673
2803
  module: 'module1',
1674
- header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', directives_only_filepath: '/build/preproc/header.i'),
1675
- source: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil)
2804
+ header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', assembled_filepath: '/build/preproc/header.i'),
2805
+ source: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil)
1676
2806
  )
1677
2807
 
1678
2808
  expect(@c_extractor).to receive(:from_file).with('/build/preproc/header.i').and_return(header_contents)
1679
2809
  expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1680
- name: @name, funcs: header_funcs, filepath: '/path/to/header.h', fallback: false
2810
+ funcs: header_funcs, filepath: '/path/to/header.h', raw_filepath: nil
1681
2811
  )
1682
2812
 
1683
- result = @partializer.extract_module_contents(@name, config, fallback: false)
2813
+ result = @partializer.extract_module_contents(@name, config)
1684
2814
 
1685
2815
  expect(result.function_definitions).to eq(header_funcs)
1686
2816
  expect(result.variable_declarations).to eq([])
@@ -1688,23 +2818,23 @@ describe Partializer do
1688
2818
 
1689
2819
  it "extracts contents from source preprocessed file only" do
1690
2820
  source_funcs = [
1691
- double('func1', name: 'func1', signature: 'static void func1(void)'),
1692
- double('func2', name: 'func2', signature: 'static int func2(int x)')
2821
+ CExtractorTypes::CFunctionDefinition.new(name: 'func1', signature: 'static void func1(void)'),
2822
+ CExtractorTypes::CFunctionDefinition.new(name: 'func2', signature: 'static int func2(int x)')
1693
2823
  ]
1694
2824
  source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [])
1695
2825
 
1696
- config = Partials::Config.new(
2826
+ config = PartializerConfig::Config.new(
1697
2827
  module: 'module1',
1698
- header: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil),
1699
- source: Partials::ConfigFileInfo.new(filepath: '/path/to/source.c', directives_only_filepath: '/build/preproc/source.i')
2828
+ header: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil),
2829
+ source: Partials::ConfigFileInfo.new(filepath: '/path/to/source.c', assembled_filepath: '/build/preproc/source.i')
1700
2830
  )
1701
2831
 
1702
2832
  expect(@c_extractor).to receive(:from_file).with('/build/preproc/source.i').and_return(source_contents)
1703
2833
  expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1704
- name: @name, funcs: source_funcs, filepath: '/path/to/source.c', fallback: false
2834
+ funcs: source_funcs, filepath: '/path/to/source.c', raw_filepath: nil
1705
2835
  )
1706
2836
 
1707
- result = @partializer.extract_module_contents(@name, config, fallback: false)
2837
+ result = @partializer.extract_module_contents(@name, config)
1708
2838
 
1709
2839
  expect(result.function_definitions).to eq(source_funcs)
1710
2840
  expect(result.variable_declarations).to eq([])
@@ -1712,194 +2842,316 @@ describe Partializer do
1712
2842
 
1713
2843
  it "extracts and merges contents from both source and header preprocessed files" do
1714
2844
  source_funcs = [
1715
- double('func1', name: 'func1', signature: 'static void func1(void)'),
1716
- double('func2', name: 'func2', signature: 'static int func2(int x)')
2845
+ CExtractorTypes::CFunctionDefinition.new(name: 'func1', signature: 'static void func1(void)'),
2846
+ CExtractorTypes::CFunctionDefinition.new(name: 'func2', signature: 'static int func2(int x)')
1717
2847
  ]
1718
2848
  header_funcs = [
1719
- double('func3', name: 'func3', signature: 'void func3(void)'),
1720
- double('func4', name: 'func4', signature: 'int func4(int x)')
2849
+ CExtractorTypes::CFunctionDefinition.new(name: 'func3', signature: 'void func3(void)'),
2850
+ CExtractorTypes::CFunctionDefinition.new(name: 'func4', signature: 'int func4(int x)')
1721
2851
  ]
1722
- source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [double('var1')])
1723
- header_contents = CExtractorTypes::CModule.new(function_definitions: header_funcs, variable_declarations: [double('var2')])
2852
+ source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [CExtractorTypes::CVariableDeclaration.new(name: 'var1')])
2853
+ header_contents = CExtractorTypes::CModule.new(function_definitions: header_funcs, variable_declarations: [CExtractorTypes::CVariableDeclaration.new(name: 'var2')])
1724
2854
 
1725
- config = Partials::Config.new(
2855
+ config = PartializerConfig::Config.new(
1726
2856
  module: 'module1',
1727
- header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', directives_only_filepath: '/build/preproc/header.i'),
1728
- source: Partials::ConfigFileInfo.new(filepath: '/path/to/source.c', directives_only_filepath: '/build/preproc/source.i')
2857
+ header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', assembled_filepath: '/build/preproc/header.i'),
2858
+ source: Partials::ConfigFileInfo.new(filepath: '/path/to/source.c', assembled_filepath: '/build/preproc/source.i')
1729
2859
  )
1730
2860
 
1731
2861
  allow(@c_extractor).to receive(:from_file).with('/build/preproc/source.i').and_return(source_contents)
1732
2862
  allow(@c_extractor).to receive(:from_file).with('/build/preproc/header.i').and_return(header_contents)
1733
2863
  expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1734
- name: @name, funcs: source_funcs, filepath: '/path/to/source.c', fallback: false
2864
+ funcs: source_funcs, filepath: '/path/to/source.c', raw_filepath: nil
1735
2865
  )
1736
2866
  expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1737
- name: @name, funcs: header_funcs, filepath: '/path/to/header.h', fallback: false
2867
+ funcs: header_funcs, filepath: '/path/to/header.h', raw_filepath: nil
1738
2868
  )
1739
2869
 
1740
- result = @partializer.extract_module_contents(@name, config, fallback: false)
2870
+ result = @partializer.extract_module_contents(@name, config)
1741
2871
 
1742
2872
  expect(result.function_definitions).to eq(header_funcs + source_funcs)
1743
2873
  expect(result.variable_declarations).to eq(header_contents.variable_declarations + source_contents.variable_declarations)
1744
2874
  end
1745
2875
 
1746
- it "calls associate_function_line_numbers with the preprocessed expansion filepath, not the preprocessed filepath" do
1747
- source_funcs = [double('func1', name: 'func1')]
1748
- source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [])
1749
-
1750
- config = Partials::Config.new(
1751
- module: 'module1',
1752
- header: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil),
1753
- source: Partials::ConfigFileInfo.new(filepath: '/src/module1.c', directives_only_filepath: '/build/preproc/module1.i')
1754
- )
1755
-
1756
- allow(@c_extractor).to receive(:from_file).and_return(source_contents)
1757
-
1758
- # associate_function_line_numbers must receive the original filepath, not the preprocessed one
1759
- expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1760
- name: @name, funcs: source_funcs, filepath: '/src/module1.c', fallback: false
1761
- )
1762
-
1763
- @partializer.extract_module_contents(@name, config, fallback: false)
1764
- end
1765
-
1766
- it "passes extraction name through to associate_function_line_numbers" do
1767
- source_funcs = [double('func1', name: 'func1')]
2876
+ # The original filepath names each function, and the raw copy locates it
2877
+ it "locates each file's functions in the raw copy its record names, under the original filepath" do
2878
+ source_funcs = [CExtractorTypes::CFunctionDefinition.new(name: 'func1')]
1768
2879
  source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [])
1769
2880
 
1770
- config = Partials::Config.new(
2881
+ config = PartializerConfig::Config.new(
1771
2882
  module: 'module1',
1772
- header: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil),
1773
- source: Partials::ConfigFileInfo.new(filepath: '/src/module1.c', directives_only_filepath: '/build/preproc/module1.i')
2883
+ header: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil),
2884
+ source: Partials::ConfigFileInfo.new(
2885
+ filepath: '/src/module1.c', assembled_filepath: '/build/preproc/module1.i', raw_directives_only_filepath: '/build/raw/module1.c'
2886
+ )
1774
2887
  )
1775
2888
 
1776
2889
  allow(@c_extractor).to receive(:from_file).and_return(source_contents)
1777
2890
 
1778
2891
  expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1779
- name: 'SpecificTestName', funcs: source_funcs, filepath: '/src/module1.c', fallback: false
2892
+ funcs: source_funcs, filepath: '/src/module1.c', raw_filepath: '/build/raw/module1.c'
1780
2893
  )
1781
2894
 
1782
- @partializer.extract_module_contents('SpecificTestName', config, fallback: false)
2895
+ @partializer.extract_module_contents(@name, config)
1783
2896
  end
1784
2897
 
1785
2898
  it "returns empty CModule when a preprocessed file has no contents" do
1786
2899
  empty_contents = CExtractorTypes::CModule.new(function_definitions: [], variable_declarations: [])
1787
2900
 
1788
- config = Partials::Config.new(
2901
+ config = PartializerConfig::Config.new(
1789
2902
  module: 'module1',
1790
- header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', directives_only_filepath: '/build/preproc/header.i'),
1791
- source: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil)
2903
+ header: Partials::ConfigFileInfo.new(filepath: '/path/to/header.h', assembled_filepath: '/build/preproc/header.i'),
2904
+ source: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil)
1792
2905
  )
1793
2906
 
1794
2907
  expect(@c_extractor).to receive(:from_file).and_return(empty_contents)
1795
2908
  expect(@partializer_helper).to receive(:associate_function_line_numbers).with(
1796
- name: @name, funcs: [], filepath: '/path/to/header.h', fallback: false
2909
+ funcs: [], filepath: '/path/to/header.h', raw_filepath: nil
1797
2910
  )
1798
2911
 
1799
- result = @partializer.extract_module_contents(@name, config, fallback: false)
2912
+ result = @partializer.extract_module_contents(@name, config)
1800
2913
 
1801
2914
  expect(result.function_definitions).to eq([])
1802
2915
  expect(result.variable_declarations).to eq([])
1803
2916
  end
1804
2917
 
1805
- it "appends promoted function-scope static variables to element_sequence" do
1806
- promoted_var1 = CExtractorTypes::CVariableDeclaration.new(text: 'static int counter = 0;', type: 'int', name: 'counter')
1807
- promoted_var2 = CExtractorTypes::CVariableDeclaration.new(text: 'static bool flag = false;', type: 'bool', name: 'flag')
1808
-
2918
+ # Promotion adds to the file's own module, ahead of each function, before the module merges
2919
+ it "promotes function-scope statics in each file's module" do
1809
2920
  source_contents = CExtractorTypes::CModule.new(function_definitions: [], variable_declarations: [])
1810
2921
 
1811
- config = Partials::Config.new(
2922
+ config = PartializerConfig::Config.new(
1812
2923
  module: 'module1',
1813
- header: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil),
1814
- source: Partials::ConfigFileInfo.new(filepath: '/src/module1.c', directives_only_filepath: '/build/preproc/module1.i')
2924
+ header: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil),
2925
+ source: Partials::ConfigFileInfo.new(filepath: '/src/module1.c', assembled_filepath: '/build/preproc/module1.i')
1815
2926
  )
1816
2927
 
1817
2928
  allow(@c_extractor).to receive(:from_file).and_return(source_contents)
1818
- allow(@partializer_helper).to receive(:extract_function_scope_static_vars).and_return([promoted_var1, promoted_var2])
2929
+ expect(@partializer_helper).to receive(:promote_function_scope_statics)
2930
+ .with(source_contents, name: @name, module_name: 'module1', file_type: 'source')
1819
2931
 
1820
- result = @partializer.extract_module_contents(@name, config, fallback: false)
1821
-
1822
- expect(result.element_sequence).to eq([promoted_var1, promoted_var2])
1823
- expect(result.element_sequence[0]).to equal(promoted_var1)
1824
- expect(result.element_sequence[1]).to equal(promoted_var2)
2932
+ @partializer.extract_module_contents(@name, config)
1825
2933
  end
1826
2934
 
1827
- it "calls update_signatures_from_full_expansion when full_expansion_filepath is set on source" do
1828
- source_funcs = [double('func1', name: 'func1')]
2935
+ it "reconciles the source's module with its expanded code when the record names one" do
2936
+ source_funcs = [CExtractorTypes::CFunctionDefinition.new(name: 'func1')]
1829
2937
  source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [])
1830
2938
 
1831
- config = Partials::Config.new(
2939
+ config = PartializerConfig::Config.new(
1832
2940
  module: 'module1',
1833
- header: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil),
2941
+ header: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil),
1834
2942
  source: Partials::ConfigFileInfo.new(
1835
- filepath: '/src/module1.c',
1836
- directives_only_filepath: '/build/preproc/module1.i',
1837
- full_expansion_filepath: '/build/preproc/full_expansion/module1.c'
2943
+ filepath: '/src/module1.c',
2944
+ assembled_filepath: '/build/preproc/module1.i',
2945
+ expansion_filepath: '/build/preproc/full_expansion/module1.c'
1838
2946
  )
1839
2947
  )
1840
2948
 
1841
2949
  allow(@c_extractor).to receive(:from_file).with('/build/preproc/module1.i').and_return(source_contents)
1842
2950
  allow(@partializer_helper).to receive(:associate_function_line_numbers)
1843
2951
 
1844
- expect(@partializer_helper).to receive(:update_signatures_from_full_expansion).with(
1845
- funcs: source_funcs,
1846
- full_expansion_filepath: '/build/preproc/full_expansion/module1.c',
1847
- name: @name,
1848
- module_name: 'module1',
1849
- file_type: 'source'
2952
+ expect(@partializer_reconciler).to receive(:reconcile).with(
2953
+ c_module: source_contents, expansion_filepath: '/build/preproc/full_expansion/module1.c', name: @name, module_name: 'module1', file_type: 'source'
1850
2954
  )
1851
2955
 
1852
- @partializer.extract_module_contents(@name, config, fallback: false)
2956
+ @partializer.extract_module_contents(@name, config)
1853
2957
  end
1854
2958
 
1855
- it "calls update_signatures_from_full_expansion when full_expansion_filepath is set on header" do
1856
- header_funcs = [double('func1', name: 'func1')]
2959
+ it "reconciles the header's module with its expanded code when the record names one" do
2960
+ header_funcs = [CExtractorTypes::CFunctionDefinition.new(name: 'func1')]
1857
2961
  header_contents = CExtractorTypes::CModule.new(function_definitions: header_funcs, variable_declarations: [])
1858
2962
 
1859
- config = Partials::Config.new(
2963
+ config = PartializerConfig::Config.new(
1860
2964
  module: 'module1',
1861
2965
  header: Partials::ConfigFileInfo.new(
1862
- filepath: '/path/to/header.h',
1863
- directives_only_filepath: '/build/preproc/header.h',
1864
- full_expansion_filepath: '/build/preproc/full_expansion/header.h'
2966
+ filepath: '/path/to/header.h',
2967
+ assembled_filepath: '/build/preproc/header.h',
2968
+ expansion_filepath: '/build/preproc/full_expansion/header.h'
1865
2969
  ),
1866
- source: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil)
2970
+ source: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil)
1867
2971
  )
1868
2972
 
1869
2973
  allow(@c_extractor).to receive(:from_file).with('/build/preproc/header.h').and_return(header_contents)
1870
2974
  allow(@partializer_helper).to receive(:associate_function_line_numbers)
1871
2975
 
1872
- expect(@partializer_helper).to receive(:update_signatures_from_full_expansion).with(
1873
- funcs: header_funcs,
1874
- full_expansion_filepath: '/build/preproc/full_expansion/header.h',
1875
- name: @name,
1876
- module_name: 'module1',
1877
- file_type: 'header'
2976
+ expect(@partializer_reconciler).to receive(:reconcile).with(
2977
+ c_module: header_contents, expansion_filepath: '/build/preproc/full_expansion/header.h', name: @name, module_name: 'module1', file_type: 'header'
1878
2978
  )
1879
2979
 
1880
- @partializer.extract_module_contents(@name, config, fallback: false)
2980
+ @partializer.extract_module_contents(@name, config)
1881
2981
  end
1882
2982
 
1883
- it "does not call update_signatures_from_full_expansion when full_expansion_filepath is nil" do
1884
- source_funcs = [double('func1', name: 'func1')]
2983
+ it "reconciles nothing when the record names no expanded code" do
2984
+ source_funcs = [CExtractorTypes::CFunctionDefinition.new(name: 'func1')]
1885
2985
  source_contents = CExtractorTypes::CModule.new(function_definitions: source_funcs, variable_declarations: [])
1886
2986
 
1887
- config = Partials::Config.new(
2987
+ config = PartializerConfig::Config.new(
1888
2988
  module: 'module1',
1889
- header: Partials::ConfigFileInfo.new(filepath: nil, directives_only_filepath: nil),
2989
+ header: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil),
1890
2990
  source: Partials::ConfigFileInfo.new(
1891
- filepath: '/src/module1.c',
1892
- directives_only_filepath: '/build/preproc/module1.i',
1893
- full_expansion_filepath: nil
2991
+ filepath: '/src/module1.c',
2992
+ assembled_filepath: '/build/preproc/module1.i',
2993
+ expansion_filepath: nil
1894
2994
  )
1895
2995
  )
1896
2996
 
1897
2997
  allow(@c_extractor).to receive(:from_file).with('/build/preproc/module1.i').and_return(source_contents)
1898
2998
  allow(@partializer_helper).to receive(:associate_function_line_numbers)
1899
2999
 
1900
- expect(@partializer_helper).not_to receive(:update_signatures_from_full_expansion)
3000
+ expect(@partializer_reconciler).not_to receive(:reconcile)
3001
+
3002
+ @partializer.extract_module_contents(@name, config)
3003
+ end
3004
+
3005
+ # Locating declarations costs a search of the file's text each, so only carried ones are located
3006
+ it "leaves declarations unlocated during extraction" do
3007
+ config = PartializerConfig::Config.new(
3008
+ module: 'module1',
3009
+ header: Partials::ConfigFileInfo.new(filepath: '/src/module1.h', assembled_filepath: '/build/preproc/module1.h'),
3010
+ source: Partials::ConfigFileInfo.new(filepath: nil, assembled_filepath: nil)
3011
+ )
3012
+ decls = [CExtractorTypes::CFunctionDeclaration.new(name: 'tick', signature: 'int tick(void);')]
3013
+ allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: decls))
3014
+
3015
+ expect(@partializer_helper).not_to receive(:associate_declaration_line_numbers)
3016
+ expect(@file_wrapper).not_to receive(:read)
3017
+
3018
+ @partializer.extract_module_contents(@name, config)
3019
+ end
3020
+
3021
+ context "marking functions an included header defines inline" do
3022
+ # Each file's record names the raw copy its preprocessing kept
3023
+ def file(filepath, raw: nil)
3024
+ Partials::ConfigFileInfo.new(
3025
+ filepath: filepath, assembled_filepath: filepath && "/build/preproc/#{File.basename( filepath )}", raw_directives_only_filepath: raw
3026
+ )
3027
+ end
3028
+
3029
+ let(:config) do
3030
+ PartializerConfig::Config.new( module: 'engine', header: file( nil ), source: file( 'src/engine.c', raw: 'raw/src/engine.c' ) )
3031
+ end
3032
+ let(:twice) { CExtractorTypes::CFunctionDeclaration.new( name: 'engine_get_twice', signature: 'int engine_get_twice(void);' ) }
3033
+ let(:both_files) do
3034
+ PartializerConfig::Config.new(
3035
+ module: 'engine', header: file( 'src/engine.h', raw: 'raw/src/engine.h' ), source: file( 'src/engine.c', raw: 'raw/src/engine.c' )
3036
+ )
3037
+ end
3038
+
3039
+ # The raw copy holds every header the file includes, so the inline body is found there.
3040
+ # The scan needs only bytes, so the copy is never transcoded.
3041
+ it "marks a source declaration against the source's raw copy, read as bytes" do
3042
+ allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: [twice]))
3043
+ allow(@file_wrapper).to receive(:read_binary).with('raw/src/engine.c').and_return('raw bytes')
3044
+
3045
+ expect(@partializer_helper).to receive(:mark_inline_elsewhere).with( decls: [twice], text: 'raw bytes' )
3046
+ expect(@file_wrapper).not_to receive(:read)
3047
+
3048
+ @partializer.extract_module_contents(@name, config)
3049
+ end
3050
+
3051
+ # A module mocked from its header alone has no source, and every declaration is the header's
3052
+ it "marks a header-only Partial's declarations against the header's raw copy" do
3053
+ header_only = PartializerConfig::Config.new( module: 'engine', header: file( 'src/engine.h', raw: 'raw/src/engine.h' ), source: file( nil ) )
3054
+ allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: [twice]))
3055
+ allow(@file_wrapper).to receive(:read_binary).with('raw/src/engine.h').and_return('header bytes')
3056
+
3057
+ expect(@partializer_helper).to receive(:mark_inline_elsewhere).with( decls: [twice], text: 'header bytes' )
3058
+
3059
+ @partializer.extract_module_contents(@name, header_only)
3060
+ end
3061
+
3062
+ # Each file's raw copy holds the headers that file includes, so each is searched for its own
3063
+ it "marks each file's declarations against that file's own raw copy" do
3064
+ tick = CExtractorTypes::CFunctionDeclaration.new( name: 'board_tick', signature: 'int board_tick(void);' )
3065
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/engine.h').and_return(
3066
+ CExtractorTypes::CModule.new(function_declarations: [tick])
3067
+ )
3068
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/engine.c').and_return(
3069
+ CExtractorTypes::CModule.new(function_declarations: [twice])
3070
+ )
3071
+ allow(@file_wrapper).to receive(:read_binary).with('raw/src/engine.h').and_return('header bytes')
3072
+ allow(@file_wrapper).to receive(:read_binary).with('raw/src/engine.c').and_return('source bytes')
3073
+
3074
+ expect(@partializer_helper).to receive(:mark_inline_elsewhere).with( decls: [tick], text: 'header bytes' )
3075
+ expect(@partializer_helper).to receive(:mark_inline_elsewhere).with( decls: [twice], text: 'source bytes' )
3076
+
3077
+ @partializer.extract_module_contents(@name, both_files)
3078
+ end
3079
+
3080
+ # Only a function the module has no body for can be defined inline elsewhere
3081
+ it "marks only the header declarations whose function has no body in the module" do
3082
+ get = CExtractorTypes::CFunctionDeclaration.new( name: 'engine_get', signature: 'int engine_get(void);' )
3083
+ tick = CExtractorTypes::CFunctionDeclaration.new( name: 'board_tick', signature: 'int board_tick(void);' )
3084
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/engine.h').and_return(
3085
+ CExtractorTypes::CModule.new(function_declarations: [get, tick])
3086
+ )
3087
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/engine.c').and_return(
3088
+ CExtractorTypes::CModule.new(function_definitions: [CExtractorTypes::CFunctionDefinition.new(name: 'engine_get')])
3089
+ )
3090
+ allow(@file_wrapper).to receive(:read_binary).with('raw/src/engine.h').and_return('header bytes')
3091
+
3092
+ expect(@partializer_helper).to receive(:mark_inline_elsewhere).with( decls: [tick], text: 'header bytes' ).once
3093
+
3094
+ @partializer.extract_module_contents(@name, both_files)
3095
+ end
3096
+
3097
+ it "reads no file when every declaration's function has a body in the module" do
3098
+ get = CExtractorTypes::CFunctionDeclaration.new( name: 'engine_get', signature: 'int engine_get(void);' )
3099
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/engine.h').and_return(
3100
+ CExtractorTypes::CModule.new(function_declarations: [get])
3101
+ )
3102
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/engine.c').and_return(
3103
+ CExtractorTypes::CModule.new(function_definitions: [CExtractorTypes::CFunctionDefinition.new(name: 'engine_get')])
3104
+ )
3105
+
3106
+ expect(@file_wrapper).not_to receive(:read_binary)
3107
+ expect(@partializer_helper).not_to receive(:mark_inline_elsewhere)
3108
+
3109
+ @partializer.extract_module_contents(@name, both_files)
3110
+ end
3111
+
3112
+ # A file preprocessed in fallback records no raw copy, whatever an earlier build left on disk
3113
+ it "reads no file and marks nothing for a file whose record names no raw copy" do
3114
+ config.source.raw_directives_only_filepath = nil
3115
+ allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: [twice]))
3116
+
3117
+ expect(@file_wrapper).not_to receive(:read_binary)
3118
+ expect(@partializer_helper).not_to receive(:mark_inline_elsewhere)
3119
+
3120
+ @partializer.extract_module_contents(@name, config)
3121
+ end
3122
+
3123
+ it "reads no file when the file declares no function" do
3124
+ allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new)
3125
+
3126
+ expect(@file_wrapper).not_to receive(:read_binary)
3127
+
3128
+ @partializer.extract_module_contents(@name, config)
3129
+ end
3130
+ end
1901
3131
 
1902
- @partializer.extract_module_contents(@name, config, fallback: false)
3132
+ it "stamps every function with the role of the file it came from" do
3133
+ header_def = CExtractorTypes::CFunctionDefinition.new(name: 'clamp')
3134
+ header_decl = CExtractorTypes::CFunctionDeclaration.new(name: 'tick')
3135
+ source_def = CExtractorTypes::CFunctionDefinition.new(name: 'get')
3136
+ source_decl = CExtractorTypes::CFunctionDeclaration.new(name: 'twice')
3137
+
3138
+ config = PartializerConfig::Config.new(
3139
+ module: 'module1',
3140
+ header: Partials::ConfigFileInfo.new(filepath: '/src/module1.h', assembled_filepath: '/build/preproc/module1.h'),
3141
+ source: Partials::ConfigFileInfo.new(filepath: '/src/module1.c', assembled_filepath: '/build/preproc/module1.c')
3142
+ )
3143
+
3144
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/module1.h').and_return(
3145
+ CExtractorTypes::CModule.new(function_definitions: [header_def], function_declarations: [header_decl])
3146
+ )
3147
+ allow(@c_extractor).to receive(:from_file).with('/build/preproc/module1.c').and_return(
3148
+ CExtractorTypes::CModule.new(function_definitions: [source_def], function_declarations: [source_decl])
3149
+ )
3150
+
3151
+ @partializer.extract_module_contents(@name, config)
3152
+
3153
+ expect([header_def, header_decl].map(&:origin)).to all(eq(:header))
3154
+ expect([source_def, source_decl].map(&:origin)).to all(eq(:source))
1903
3155
  end
1904
3156
  end
1905
3157
 
@@ -2125,7 +3377,7 @@ describe Partializer do
2125
3377
 
2126
3378
  it "merges declaration-only functions into the DEDUCT candidate pool" do
2127
3379
  defn = double('inline_func', name: 'inline_fn')
2128
- decl = double('proto_func', name: 'proto_fn')
3380
+ decl = double('proto_func', name: 'proto_fn', decorators: [], inline_elsewhere: false)
2129
3381
  defs = [defn]
2130
3382
  decls = [decl]
2131
3383
  filtered = [double('iface_inline'), double('iface_proto')]
@@ -2145,7 +3397,7 @@ describe Partializer do
2145
3397
 
2146
3398
  it "merges declaration-only functions into the PUBLIC candidate pool too" do
2147
3399
  defn = double('def_func', name: 'pub_def')
2148
- decl = double('decl_func', name: 'pub_decl')
3400
+ decl = double('decl_func', name: 'pub_decl', decorators: [], inline_elsewhere: false)
2149
3401
  defs = [defn]
2150
3402
  decls = [decl]
2151
3403
  filtered = [double('iface_func')]
@@ -2163,9 +3415,66 @@ describe Partializer do
2163
3415
  expect(result).to eq(filtered)
2164
3416
  end
2165
3417
 
3418
+ # Its body lives in a header the module includes, so a mock could never replace it. Mocking
3419
+ # it would only define the function twice.
3420
+ [Partials::DEDUCT, Partials::PRIVATE].each do |type|
3421
+ it "keeps a declaration-only inline function out of the #{type} candidate pool" do
3422
+ defn = double('def_func', name: 'engine_get')
3423
+ foreign = double('extern_inline', name: 'engine_get_twice', decorators: ['extern', 'inline'])
3424
+ filtered = [double('iface_func')]
3425
+ pf = make_pf(type: type)
3426
+
3427
+ expect(@partializer_helper).to receive(:filter_and_transform_funcs)
3428
+ .with([defn], type, :interface).and_return(filtered)
3429
+ allow(@partializer_helper).to receive(:subtract_funcs).and_return(filtered)
3430
+
3431
+ @partializer.extract_interface_functions(
3432
+ test: 'test_mod', partial: 'mod',
3433
+ definitions: [defn], declarations: [foreign], config: make_config(mocks: pf)
3434
+ )
3435
+ end
3436
+ end
3437
+
3438
+ # Declared without `inline`, it is still a function whose body another header holds
3439
+ it "keeps a declaration of a function another header defines inline out of the PUBLIC candidate pool" do
3440
+ defn = double('def_func', name: 'engine_get')
3441
+ foreign = CExtractorTypes::CFunctionDeclaration.new(
3442
+ name: 'engine_get_twice', signature: 'int engine_get_twice(void);', inline_elsewhere: true
3443
+ )
3444
+ filtered = [double('iface_func')]
3445
+ pf = make_pf(type: Partials::PUBLIC)
3446
+
3447
+ expect(@partializer_helper).to receive(:filter_and_transform_funcs)
3448
+ .with([defn], Partials::PUBLIC, :interface).and_return(filtered)
3449
+ allow(@partializer_helper).to receive(:subtract_funcs).and_return(filtered)
3450
+
3451
+ @partializer.extract_interface_functions(
3452
+ test: 'test_mod', partial: 'mod',
3453
+ definitions: [defn], declarations: [foreign], config: make_config(mocks: pf)
3454
+ )
3455
+ end
3456
+
3457
+ it "lists a declaration-only inline function it keeps out, at debug verbosity" do
3458
+ foreign = double('extern_inline', name: 'engine_get_twice', decorators: ['extern', 'inline'])
3459
+ pf = make_pf(type: Partials::DEDUCT)
3460
+ allow(@partializer_helper).to receive(:filter_and_transform_funcs).and_return([])
3461
+ allow(@partializer_helper).to receive(:subtract_funcs).and_return([])
3462
+
3463
+ expect(@loginator).to receive(:log_list).with(
3464
+ ['`engine_get_twice`'],
3465
+ 'Not mockable for Partial test_mod::mod (inline, body outside module):',
3466
+ Verbosity::DEBUG
3467
+ )
3468
+
3469
+ @partializer.extract_interface_functions(
3470
+ test: 'test_mod', partial: 'mod',
3471
+ definitions: [], declarations: [foreign], config: make_config(mocks: pf)
3472
+ )
3473
+ end
3474
+
2166
3475
  it "excludes a declaration already present as a definition with the same name (dedup)" do
2167
3476
  defn = double('def_func', name: 'shared')
2168
- decl = double('decl_func', name: 'shared') # e.g. header prototype for the same function
3477
+ decl = double('decl_func', name: 'shared', decorators: [], inline_elsewhere: false) # e.g. header prototype for the same function
2169
3478
  defs = [defn]
2170
3479
  decls = [decl]
2171
3480
  filtered = [double('iface_func')]
@@ -2206,7 +3515,7 @@ describe Partializer do
2206
3515
 
2207
3516
  it "searches definitions then declarations for additions" do
2208
3517
  defs = []
2209
- decls = [double('decl', name: 'decl_only')]
3518
+ decls = [double('decl', name: 'decl_only', decorators: [], inline_elsewhere: false)]
2210
3519
  found = double('iface_func', name: 'decl_only')
2211
3520
  pf = make_pf(type: Partials::ACCUMULATE, additions: ['decl_only'])
2212
3521