ceedling 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. checksums.yaml +4 -4
  2. data/GIT_COMMIT_SHA +1 -1
  3. data/README.md +1 -1
  4. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
  5. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
  6. data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
  7. data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
  8. data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
  9. data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
  10. data/docs/BreakingChanges.md +16 -0
  11. data/docs/Changelog.md +71 -0
  12. data/docs/KnownIssues.md +91 -4
  13. data/examples/wondrous_forest/README.md +29 -1
  14. data/examples/wondrous_forest/src/ForestUnits.h +23 -0
  15. data/examples/wondrous_forest/src/RainGauge.c +59 -0
  16. data/examples/wondrous_forest/src/RainGauge.h +39 -0
  17. data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
  18. data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
  19. data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
  20. data/lib/ceedling/c_extractor/README.md +15 -7
  21. data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
  22. data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
  23. data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
  24. data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
  25. data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
  26. data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
  27. data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
  28. data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
  29. data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
  30. data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
  31. data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
  32. data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
  33. data/lib/ceedling/c_identifier.rb +21 -0
  34. data/lib/ceedling/ceedling.h +8 -0
  35. data/lib/ceedling/config/configurator.rb +4 -3
  36. data/lib/ceedling/config/configurator_builder.rb +17 -0
  37. data/lib/ceedling/config/configurator_setup.rb +29 -5
  38. data/lib/ceedling/constants.rb +5 -1
  39. data/lib/ceedling/defaults.rb +31 -1
  40. data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
  41. data/lib/ceedling/dependencies/README.md +1 -1
  42. data/lib/ceedling/dependencies/dependency_cache_store.rb +30 -25
  43. data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
  44. data/lib/ceedling/dependencies/dependinator.rb +13 -1
  45. data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
  46. data/lib/ceedling/diagnostics/README.md +5 -0
  47. data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
  48. data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
  49. data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
  50. data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
  51. data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
  52. data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
  53. data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
  54. data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
  55. data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
  56. data/lib/ceedling/filesystem/PATH_HANDLING.md +83 -27
  57. data/lib/ceedling/filesystem/README.md +6 -1
  58. data/lib/ceedling/filesystem/build_roots.rb +105 -0
  59. data/lib/ceedling/filesystem/build_subpath.rb +110 -25
  60. data/lib/ceedling/filesystem/file_finder.rb +76 -110
  61. data/lib/ceedling/filesystem/file_finder_helper.rb +33 -11
  62. data/lib/ceedling/filesystem/file_path_utils.rb +113 -91
  63. data/lib/ceedling/filesystem/file_wrapper.rb +105 -28
  64. data/lib/ceedling/filesystem/path_matcher.rb +21 -0
  65. data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
  66. data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
  67. data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
  68. data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
  69. data/lib/ceedling/generators/generator.rb +27 -64
  70. data/lib/ceedling/generators/generator_helper.rb +0 -44
  71. data/lib/ceedling/generators/generator_mocks.rb +5 -0
  72. data/lib/ceedling/generators/generator_partials.rb +305 -243
  73. data/lib/ceedling/generators/generator_test_runner.rb +5 -8
  74. data/lib/ceedling/generators/partial_header_writer.rb +95 -0
  75. data/lib/ceedling/generators/partial_source_writer.rb +137 -0
  76. data/lib/ceedling/includes/header_search.rb +225 -0
  77. data/lib/ceedling/includes/include_factory.rb +9 -12
  78. data/lib/ceedling/includes/include_pathinator.rb +53 -31
  79. data/lib/ceedling/includes/includes.rb +149 -37
  80. data/lib/ceedling/objects.yml +89 -4
  81. data/lib/ceedling/partials/README.md +110 -16
  82. data/lib/ceedling/partials/carry_plan.rb +71 -0
  83. data/lib/ceedling/partials/definition_head.rb +74 -0
  84. data/lib/ceedling/partials/include_groups.rb +37 -0
  85. data/lib/ceedling/partials/interface_extras.rb +25 -0
  86. data/lib/ceedling/partials/partializer.rb +599 -120
  87. data/lib/ceedling/partials/partializer_config.rb +5 -0
  88. data/lib/ceedling/partials/partializer_helper.rb +851 -145
  89. data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
  90. data/lib/ceedling/partials/partializer_utils.rb +89 -109
  91. data/lib/ceedling/partials/partials.rb +153 -10
  92. data/lib/ceedling/partials/type_macros.rb +126 -0
  93. data/lib/ceedling/preprocess/README.md +43 -33
  94. data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
  95. data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
  96. data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +31 -75
  97. data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
  98. data/lib/ceedling/setupinator.rb +16 -3
  99. data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
  100. data/lib/ceedling/test_invoker/PIPELINE.md +57 -16
  101. data/lib/ceedling/test_invoker/README.md +1 -1
  102. data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
  103. data/lib/ceedling/test_invoker/mock_locator.rb +116 -9
  104. data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
  105. data/lib/ceedling/test_invoker/partials_manager.rb +265 -308
  106. data/lib/ceedling/test_invoker/standin_headerinator.rb +8 -15
  107. data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
  108. data/lib/ceedling/test_invoker/test_build_executor.rb +338 -198
  109. data/lib/ceedling/test_invoker/test_build_planner.rb +13 -19
  110. data/lib/ceedling/test_invoker/test_build_setup.rb +26 -6
  111. data/lib/ceedling/test_invoker/test_build_validations.rb +23 -20
  112. data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
  113. data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +1 -2
  114. data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
  115. data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
  116. data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +5 -3
  117. data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
  118. data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
  119. data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
  120. data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
  121. data/lib/ceedling/tools/shell_quoting.rb +45 -0
  122. data/lib/ceedling/tools/tool_quoting.rb +79 -0
  123. data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
  124. data/lib/version.rb +1 -1
  125. data/plugins/bullseye/bullseye.rake +1 -3
  126. data/plugins/bullseye/lib/bullseye.rb +15 -2
  127. data/plugins/command_hooks/lib/command_hooks.rb +1 -1
  128. data/plugins/fff/lib/fff.rb +42 -15
  129. data/plugins/fff/lib/fff_mock_generator.rb +12 -9
  130. data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +134 -0
  131. data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
  132. data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
  133. data/plugins/gcov/lib/console_reportinator.rb +25 -19
  134. data/plugins/gcov/lib/reportgenerator_reportinator.rb +2 -1
  135. data/site-local/404.html +2 -2
  136. data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
  137. data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
  138. data/site-local/configuration/environment-vars.html +2 -2
  139. data/site-local/configuration/global-collections.html +3 -3
  140. data/site-local/configuration/index.html +2 -2
  141. data/site-local/configuration/loading.html +2 -2
  142. data/site-local/configuration/mixins.html +2 -2
  143. data/site-local/configuration/parallel-builds.html +2 -2
  144. data/site-local/configuration/project-file.html +2 -2
  145. data/site-local/configuration/reference/cexception.html +2 -2
  146. data/site-local/configuration/reference/cmock.html +5 -2
  147. data/site-local/configuration/reference/defines.html +2 -2
  148. data/site-local/configuration/reference/environment.html +2 -2
  149. data/site-local/configuration/reference/extension.html +2 -2
  150. data/site-local/configuration/reference/files.html +56 -9
  151. data/site-local/configuration/reference/flags.html +2 -2
  152. data/site-local/configuration/reference/index.html +2 -2
  153. data/site-local/configuration/reference/libraries.html +2 -2
  154. data/site-local/configuration/reference/mixins.html +2 -2
  155. data/site-local/configuration/reference/partials.html +84 -2
  156. data/site-local/configuration/reference/paths.html +7 -2
  157. data/site-local/configuration/reference/plugins.html +2 -2
  158. data/site-local/configuration/reference/project.html +247 -5
  159. data/site-local/configuration/reference/release-build.html +2 -2
  160. data/site-local/configuration/reference/test-build.html +2 -2
  161. data/site-local/configuration/reference/test-runner.html +2 -2
  162. data/site-local/configuration/reference/tools.html +49 -4
  163. data/site-local/configuration/reference/unity.html +2 -2
  164. data/site-local/configuration/which-ceedling.html +2 -2
  165. data/site-local/development/index.html +2 -2
  166. data/site-local/development/plugins/configuration.html +2 -2
  167. data/site-local/development/plugins/index.html +2 -2
  168. data/site-local/development/plugins/plugin-subclass.html +5 -4
  169. data/site-local/development/plugins/rake-tasks.html +2 -2
  170. data/site-local/development/releases.html +2 -2
  171. data/site-local/development/workflow.html +2 -2
  172. data/site-local/getting-started/builds.html +2 -2
  173. data/site-local/getting-started/command-line.html +2 -2
  174. data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
  175. data/site-local/getting-started/example-projects/index.html +2 -2
  176. data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
  177. data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
  178. data/site-local/getting-started/index.html +2 -2
  179. data/site-local/getting-started/installation.html +2 -2
  180. data/site-local/getting-started/quick-start.html +2 -2
  181. data/site-local/help.html +2 -2
  182. data/site-local/index.html +2 -2
  183. data/site-local/overview/build-system.html +2 -2
  184. data/site-local/overview/index.html +2 -2
  185. data/site-local/overview/test-environments.html +2 -2
  186. data/site-local/overview/tools-and-frameworks.html +2 -2
  187. data/site-local/plugins/beep.html +2 -2
  188. data/site-local/plugins/bullseye/index.html +45 -38
  189. data/site-local/plugins/bullseye/licensing.html +2 -2
  190. data/site-local/plugins/command-hooks.html +4 -4
  191. data/site-local/plugins/compile-commands-json-db.html +2 -2
  192. data/site-local/plugins/cppcheck.html +2 -2
  193. data/site-local/plugins/dependencies.html +2 -2
  194. data/site-local/plugins/fff.html +16 -2
  195. data/site-local/plugins/gcov/examples.html +2 -2
  196. data/site-local/plugins/gcov/gcovr.html +8 -2
  197. data/site-local/plugins/gcov/index.html +2 -2
  198. data/site-local/plugins/gcov/overview.html +2 -2
  199. data/site-local/plugins/gcov/reportgenerator.html +18 -14
  200. data/site-local/plugins/gcov/reporting.html +2 -2
  201. data/site-local/plugins/gcov/setup.html +2 -2
  202. data/site-local/plugins/gcov/tool-versions.html +2 -2
  203. data/site-local/plugins/gcov/troubleshooting.html +2 -2
  204. data/site-local/plugins/index.html +2 -2
  205. data/site-local/plugins/module-generator.html +2 -2
  206. data/site-local/plugins/report-build-warnings-log.html +2 -2
  207. data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
  208. data/site-local/plugins/report-tests-ide-stdout.html +2 -2
  209. data/site-local/plugins/report-tests-log-factory.html +2 -2
  210. data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
  211. data/site-local/plugins/report-tests-raw-output-log.html +2 -2
  212. data/site-local/plugins/report-tests-teamcity-stdout.html +2 -2
  213. data/site-local/plugins/sanitize.html +2 -2
  214. data/site-local/plugins/valgrind.html +2 -2
  215. data/site-local/project/index.html +2 -2
  216. data/site-local/project/release-history.html +2 -2
  217. data/site-local/project/sbom.html +2 -2
  218. data/site-local/project/upgrade.html +2 -2
  219. data/site-local/reference/build-directives.html +2 -2
  220. data/site-local/reference/command-line.html +2 -2
  221. data/site-local/reference/environment-vars.html +2 -2
  222. data/site-local/reference/gcov-plugin.html +2 -2
  223. data/site-local/reference/global-collections.html +12 -12
  224. data/site-local/reference/index.html +2 -2
  225. data/site-local/reference/partials-macros.html +47 -2
  226. data/site-local/reference/project-configuration.html +2 -2
  227. data/site-local/sitemap.xml.gz +0 -0
  228. data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
  229. data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
  230. data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
  231. data/site-local/testing-guide/build-directives.html +2 -2
  232. data/site-local/testing-guide/conventions.html +67 -22
  233. data/site-local/testing-guide/frameworks.html +2 -2
  234. data/site-local/testing-guide/index.html +2 -2
  235. data/site-local/testing-guide/partials/configuration.html +31 -4
  236. data/site-local/testing-guide/partials/conventions.html +509 -8
  237. data/site-local/testing-guide/partials/directives.html +4 -3
  238. data/site-local/testing-guide/partials/example.html +2 -2
  239. data/site-local/testing-guide/partials/index.html +2 -2
  240. data/site-local/testing-guide/partials/overview.html +30 -12
  241. data/site-local/testing-guide/partials/variables.html +169 -4
  242. data/site-local/testing-guide/test-cases.html +2 -2
  243. data/site-local/testing-guide/test-sample.html +2 -2
  244. data/site-local/testing-guide/test-suite-anatomy.html +2 -2
  245. data/spec/integration/build_step_doctor_spec.rb +270 -0
  246. data/spec/integration/c_extractor_composition_spec.rb +254 -4
  247. data/spec/integration/includes_extraction_spec.rb +27 -14
  248. data/spec/integration/nested_test_artifacts_spec.rb +1 -1
  249. data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
  250. data/spec/integration/partials_carry_spec.rb +520 -0
  251. data/spec/integration/partials_declarations_spec.rb +655 -0
  252. data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
  253. data/spec/integration/partials_function_pointers_spec.rb +277 -0
  254. data/spec/integration/partials_header_composition_spec.rb +268 -35
  255. data/spec/integration/partials_macro_decorators_spec.rb +267 -0
  256. data/spec/integration/partials_module_resolution_spec.rb +26 -19
  257. data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
  258. data/spec/integration/path_length_reporting_spec.rb +64 -0
  259. data/spec/integration/path_scenarios_spec.rb +80 -3
  260. data/spec/integration/quote_include_isolator_spec.rb +56 -0
  261. data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
  262. data/spec/integration/test_includes_extractinator_spec.rb +70 -5
  263. data/spec/integration/test_naming_spec.rb +6 -3
  264. data/spec/integration/test_source_file_checks_spec.rb +5 -3
  265. data/spec/integration/tool_executor_spec.rb +1 -1
  266. data/spec/integration/tool_validator_spec.rb +2 -2
  267. data/spec/integration/win_long_paths_probe_spec.rb +46 -0
  268. data/spec/integration/win_path_limit_spec.rb +53 -0
  269. data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
  270. data/spec/support/integration/configurator_integration_helper.rb +8 -3
  271. data/spec/support/integration/partial_files_harness.rb +181 -0
  272. data/spec/support/integration/partials_generation_integration_helper.rb +237 -141
  273. data/spec/support/integration/path_scenario_harness.rb +4 -2
  274. data/spec/support/integration/spec_integration_helper.rb +8 -3
  275. data/spec/support/integration/test_includes_harness.rb +56 -35
  276. data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
  277. data/spec/system/bullseye_deployment_spec.rb +2 -0
  278. data/spec/system/delta_builds_spec.rb +26 -12
  279. data/spec/system/encoding_stress_spec.rb +4 -4
  280. data/spec/system/example_wondrous_forest_spec.rb +2 -2
  281. data/spec/system/gcov_deployment_spec.rb +2 -0
  282. data/spec/system/header_include_path_validation_spec.rb +4 -4
  283. data/spec/system/header_search_paths_spec.rb +1083 -0
  284. data/spec/system/mock_include_folders_spec.rb +121 -0
  285. data/spec/system/mockable_header_reassembly_spec.rb +184 -0
  286. data/spec/system/partials_carry_spec.rb +581 -0
  287. data/spec/system/partials_delta_builds_spec.rb +280 -0
  288. data/spec/system/partials_function_pointers_spec.rb +106 -0
  289. data/spec/system/partials_macro_decorators_spec.rb +127 -0
  290. data/spec/system/partials_module_disambiguation_spec.rb +125 -0
  291. data/spec/system/path_handling_probes_spec.rb +16 -12
  292. data/spec/system/pinned_thread_count_spec.rb +4 -4
  293. data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
  294. data/spec/system/short_build_paths_spec.rb +87 -0
  295. data/spec/system/sibling_header_collision_spec.rb +30 -6
  296. data/spec/system/support/bullseye_common_test_cases.rb +42 -0
  297. data/spec/system/support/common_test_cases.rb +2 -2
  298. data/spec/system/support/gcov_partials_test_cases.rb +48 -0
  299. data/spec/system/test_build_layout_spec.rb +209 -0
  300. data/spec/system/test_source_file_directive_spec.rb +35 -5
  301. data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
  302. data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
  303. data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
  304. data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
  305. data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
  306. data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
  307. data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
  308. data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
  309. data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
  310. data/spec/units/c_identifier_spec.rb +35 -0
  311. data/spec/units/config/configurator_builder_spec.rb +24 -0
  312. data/spec/units/config/configurator_setup_spec.rb +72 -4
  313. data/spec/units/config/configurator_spec.rb +27 -1
  314. data/spec/units/dependencies/dependency_cache_store_spec.rb +68 -3
  315. data/spec/units/dependencies/dependency_tracker_spec.rb +25 -0
  316. data/spec/units/dependencies/dependinator_spec.rb +17 -2
  317. data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
  318. data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
  319. data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
  320. data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
  321. data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
  322. data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
  323. data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
  324. data/spec/units/encodinator_spec.rb +3 -4
  325. data/spec/units/filesystem/build_roots_spec.rb +131 -0
  326. data/spec/units/filesystem/build_subpath_spec.rb +113 -0
  327. data/spec/units/filesystem/file_finder_helper_spec.rb +80 -0
  328. data/spec/units/filesystem/file_finder_spec.rb +242 -58
  329. data/spec/units/filesystem/file_path_utils_spec.rb +251 -118
  330. data/spec/units/filesystem/file_wrapper_spec.rb +191 -6
  331. data/spec/units/filesystem/path_matcher_spec.rb +36 -0
  332. data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
  333. data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
  334. data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
  335. data/spec/units/generators/generator_helper_spec.rb +0 -60
  336. data/spec/units/generators/generator_mocks_spec.rb +13 -0
  337. data/spec/units/generators/generator_partials_spec.rb +656 -55
  338. data/spec/units/generators/generator_spec.rb +26 -0
  339. data/spec/units/generators/generator_test_runner_spec.rb +9 -5
  340. data/spec/units/generators/partial_source_writer_spec.rb +129 -0
  341. data/spec/units/includes/header_search_spec.rb +406 -0
  342. data/spec/units/includes/include_factory_spec.rb +22 -5
  343. data/spec/units/includes/include_pathinator_spec.rb +77 -13
  344. data/spec/units/includes/include_spec.rb +14 -0
  345. data/spec/units/includes/includes_spec.rb +176 -19
  346. data/spec/units/loginator_spec.rb +31 -0
  347. data/spec/units/mock_locator_spec.rb +199 -5
  348. data/spec/units/partials/include_groups_spec.rb +42 -0
  349. data/spec/units/partials/partializer_config_spec.rb +25 -0
  350. data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
  351. data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
  352. data/spec/units/partials/partializer_helper_spec.rb +529 -277
  353. data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
  354. data/spec/units/partials/partializer_spec.rb +1578 -270
  355. data/spec/units/partials/partializer_utils_spec.rb +269 -232
  356. data/spec/units/partials/partials_rename_spec.rb +160 -0
  357. data/spec/units/partials_manager_spec.rb +554 -261
  358. data/spec/units/plugins/bullseye_spec.rb +34 -0
  359. data/spec/units/plugins/console_reportinator_spec.rb +58 -9
  360. data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +1 -1
  361. data/spec/units/plugins/reportgenerator_reportinator_spec.rb +51 -3
  362. data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
  363. data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
  364. data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
  365. data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
  366. data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
  367. data/spec/units/setupinator_spec.rb +51 -0
  368. data/spec/units/standin_headerinator_spec.rb +27 -11
  369. data/spec/units/test_build_executor_spec.rb +780 -166
  370. data/spec/units/test_build_planner_spec.rb +116 -28
  371. data/spec/units/test_build_setup_spec.rb +83 -18
  372. data/spec/units/test_context_extractor_spec.rb +11 -2
  373. data/spec/units/test_derived_search_paths_spec.rb +259 -0
  374. data/spec/units/test_includes_extractinator_spec.rb +56 -8
  375. data/spec/units/test_invoker/objects_wiring_spec.rb +20 -3
  376. data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
  377. data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
  378. data/spec/units/test_invoker_types_spec.rb +8 -7
  379. data/spec/units/test_pipeline_manager_spec.rb +54 -13
  380. data/spec/units/test_runner_generatinator_spec.rb +93 -1
  381. data/spec/units/test_search_paths_spec.rb +73 -5
  382. data/spec/units/{default_tools_quoting_spec.rb → tools/default_tools_quoting_spec.rb} +39 -5
  383. data/spec/units/tools/shell_quoting_spec.rb +76 -0
  384. data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
  385. data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +1 -1
  386. data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
  387. data/spec/units/windows_registry_query_tool_spec.rb +53 -0
  388. metadata +161 -16
  389. /data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +0 -0
  390. /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
@@ -14,6 +14,7 @@ require 'ceedling/test_invoker/test_invoker_types'
14
14
  require 'ceedling/partials/partials'
15
15
  require 'ceedling/test_context_extractor'
16
16
  require 'ceedling/quote_include_isolator'
17
+ require 'ceedling/test_invoker/test_substitutions'
17
18
 
18
19
  PROJECT_BUILD_VENDOR_UNITY_PATH = 'build/vendor/unity' unless defined?(PROJECT_BUILD_VENDOR_UNITY_PATH)
19
20
  UNITY_C_FILE = 'unity.c' unless defined?(UNITY_C_FILE)
@@ -35,8 +36,9 @@ describe TestBuildExecutor do
35
36
  @test_source_file_directive_resolver = double( "TestSourceFileDirectiveResolver" )
36
37
  @gcc_dependency_parser = double( "GccDependencyParser" )
37
38
  @quote_include_isolator = double( "QuoteIncludeIsolator" )
38
- @generator_helper = double( "GeneratorHelper" )
39
+ @build_step_doctor = double( "BuildStepDoctor" )
39
40
  @library_resolver = double( "LibraryResolver" )
41
+ @test_search_paths = double( "TestSearchPaths" )
40
42
 
41
43
  @tools_test_compiler = { name: 'fake compiler' }
42
44
  @tools_test_assembler = { name: 'fake assembler' }
@@ -44,6 +46,7 @@ describe TestBuildExecutor do
44
46
  @tools_test_fixture = { name: 'fake fixture' }
45
47
  @tools_test_bare_includes_preprocessor = { name: 'fake bare includes preprocessor' }
46
48
  @tools_test_file_directives_only_preprocessor = { name: 'fake directives-only preprocessor' }
49
+ @tools_test_file_full_preprocessor = { name: 'fake full preprocessor' }
47
50
  @tools_test_backtrace_gdb = { name: 'fake gdb backtrace' }
48
51
  @tools_test_fixture_simple_backtrace = { name: 'fake simple backtrace' }
49
52
 
@@ -55,6 +58,7 @@ describe TestBuildExecutor do
55
58
  allow(@configurator).to receive(:tools_test_fixture).and_return( @tools_test_fixture )
56
59
  allow(@configurator).to receive(:tools_test_bare_includes_preprocessor).and_return( @tools_test_bare_includes_preprocessor )
57
60
  allow(@configurator).to receive(:tools_test_file_directives_only_preprocessor).and_return( @tools_test_file_directives_only_preprocessor )
61
+ allow(@configurator).to receive(:tools_test_file_full_preprocessor).and_return( @tools_test_file_full_preprocessor )
58
62
  # tools_test_backtrace_gdb is deliberately NOT stubbed here -- the real Configurator
59
63
  # only defines it at all when :use_backtrace is :gdb (see test_build_executor.rb's
60
64
  # own comment at its one call site), so leaving it unstubbed here means any example
@@ -81,7 +85,8 @@ describe TestBuildExecutor do
81
85
  # The real literal scan over the doubled file layer, so each example's read stubs decide it
82
86
  real_isolator = QuoteIncludeIsolator.new( { :file_wrapper => @file_wrapper, :loginator => @loginator } )
83
87
  allow(@quote_include_isolator).to receive(:includes_by_name?) { |file, name| real_isolator.includes_by_name?( file, name ) }
84
- allow(@generator_helper).to receive(:explain_possible_mock_partial_collision).and_return( nil )
88
+ allow(@build_step_doctor).to receive(:diagnose).and_return( [] )
89
+ allow(@build_step_doctor).to receive(:attend) { |**, &step| step.call }
85
90
 
86
91
  allow(@reportinator).to receive(:generate_module_progress).and_return( '' )
87
92
  allow(@reportinator).to receive(:generate_progress).and_return( '' )
@@ -127,10 +132,13 @@ describe TestBuildExecutor do
127
132
  :dependinator => @dependinator,
128
133
  :gcc_dependency_parser => @gcc_dependency_parser,
129
134
  :quote_include_isolator => @quote_include_isolator,
130
- :generator_helper => @generator_helper,
135
+ :test_substitutions => TestSubstitutions.new( configurator: @configurator ),
136
+ :build_step_doctor => @build_step_doctor,
131
137
  :library_resolver => @library_resolver,
138
+ :test_search_paths => @test_search_paths,
132
139
  :mock_locator => MockLocator.new(
133
- configurator: @configurator, include_pathinator: double( 'include_pathinator' ), file_finder: @file_finder, file_path_utils: @file_path_utils
140
+ configurator: @configurator, include_pathinator: double( 'include_pathinator' ), test_search_paths: double( 'test_search_paths' ),
141
+ file_finder: @file_finder, file_path_utils: @file_path_utils
134
142
  )
135
143
  }
136
144
  )
@@ -154,7 +162,7 @@ describe TestBuildExecutor do
154
162
  # stubbed to synchronously yield every `things` entry to the given block,
155
163
  # matching its real per-item iteration contract without pulling in Parallel.
156
164
  def stub_batchinator_exec
157
- allow(@batchinator).to receive(:exec) do |workload:, things:, &block|
165
+ allow(@batchinator).to receive(:exec) do |things:, **, &block|
158
166
  things.each { |k, v| block.call(k, v) }
159
167
  end
160
168
  end
@@ -324,14 +332,6 @@ describe TestBuildExecutor do
324
332
  )
325
333
  end
326
334
 
327
- # A test's own file compile is the one point where its full, transitive dependency
328
- # closure is freshly known -- reached headers a mock or Partial never sees directly,
329
- # since substitution only ever looks at what the test file itself #includes. When
330
- # that closure reveals a real header sharing a directory with one this test mocks or
331
- # Partializes, quote-include's own same-directory-first rule could let that real
332
- # content slip past the substitution entirely; isolating the sibling and retrying
333
- # with corrected search paths closes that gap without ever touching the original
334
- # compile's own registered dependencies.
335
335
  # A source beside a header mocked under :treat_inlines :include would find the real
336
336
  # header first and run its inline bodies. It compiles from an isolated copy instead.
337
337
  context "a source sharing a directory with a header mocked with inline shadowing" do
@@ -463,8 +463,18 @@ describe TestBuildExecutor do
463
463
  end
464
464
  end
465
465
 
466
+ # A test's own file compile is the one point where its full, transitive dependency
467
+ # closure is freshly known -- reached headers a mock never sees directly, since
468
+ # substitution only ever looks at what the test file itself #includes. When that
469
+ # closure reveals a real header sharing a directory with one CMock copies by name,
470
+ # quote-include's own same-directory-first rule could let that real content slip past
471
+ # the substitution entirely; isolating the sibling and retrying with corrected search
472
+ # paths closes that gap without ever touching the original compile's own registered
473
+ # dependencies.
466
474
  context "sibling-header isolation retry" do
467
475
  before(:each) do
476
+ allow(@configurator).to receive(:project_use_mocks).and_return( true )
477
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :include )
468
478
  allow(@file_wrapper).to receive(:extname).with( 'test/a_test.c' ).and_return( '.c' )
469
479
  allow(@configurator).to receive(:test_build_use_assembly).and_return( false )
470
480
  allow(@file_wrapper).to receive(:exist_with_retry?).with( 'build/deps' ).and_return( true )
@@ -492,7 +502,7 @@ describe TestBuildExecutor do
492
502
 
493
503
  it "retries the compile with corrected search paths when a sibling risk is found, and clears an initial failure" do
494
504
  allow(@quote_include_isolator).to receive(:isolate)
495
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
505
+ .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'], preserve_location: true )
496
506
  .and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
497
507
 
498
508
  ex = ShellException.new( shell_result: { output: 'redeclaration of struct gpio' }, name: 'compiler' )
@@ -511,7 +521,7 @@ describe TestBuildExecutor do
511
521
 
512
522
  expect( @generator ).to have_received( :generate_object_file_c ).twice
513
523
  expect( @state.testables[:a_test].search_paths ).to include( 'build/test/out/a_test/isolated_headers/xyz' )
514
- expect( @state.testables[:a_test].isolated_headers_path ).to eq( 'build/test/out/a_test/isolated_headers/xyz' )
524
+ expect( @state.testables[:a_test].header_isolation.dir ).to eq( 'build/test/out/a_test/isolated_headers/xyz' )
515
525
  end
516
526
 
517
527
  it "retries against a separate, throwaway dependencies path, and registers only the original .d file" do
@@ -606,7 +616,7 @@ describe TestBuildExecutor do
606
616
  it "applies whatever isolation the existing .d file already reveals even when this object is not stale" do
607
617
  allow(@dependinator).to receive(:stale?).with( 'build/foo.o' ).and_return( false )
608
618
  allow(@quote_include_isolator).to receive(:isolate)
609
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
619
+ .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'], preserve_location: true )
610
620
  .and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
611
621
 
612
622
  expect(@generator).to_not receive(:generate_object_file_c)
@@ -617,7 +627,7 @@ describe TestBuildExecutor do
617
627
  )
618
628
 
619
629
  expect( @state.testables[:a_test].search_paths ).to include( 'build/test/out/a_test/isolated_headers/xyz' )
620
- expect( @state.testables[:a_test].isolated_headers_path ).to eq( 'build/test/out/a_test/isolated_headers/xyz' )
630
+ expect( @state.testables[:a_test].header_isolation.dir ).to eq( 'build/test/out/a_test/isolated_headers/xyz' )
621
631
  end
622
632
 
623
633
  it "does not attempt isolation on a skip when there is no existing .d file yet" do
@@ -635,10 +645,9 @@ describe TestBuildExecutor do
635
645
 
636
646
  # A Partial's own generated content never gives isolation an alternative same-named
637
647
  # file for a search path to fall through to, so a redeclaration/conflicting-types
638
- # failure can survive every attempt here. Logging the likely cause alongside the raw
639
- # compiler error, rather than raising it bare, is the deliberate fallback for exactly
640
- # that case -- and for any other collision isolation doesn't resolve.
641
- it "logs the guidance from generator_helper and still raises, when the compile fails with no isolation to try" do
648
+ # failure can survive every attempt here. The build step doctor explains it beside the
649
+ # raw compiler error, which is still raised.
650
+ it "asks the doctor about a failed compile with no isolation to try, then raises" do
642
651
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
643
652
  { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
644
653
  )
@@ -646,28 +655,30 @@ describe TestBuildExecutor do
646
655
  ex = ShellException.new( shell_result: { output: 'redeclaration of struct gpio' }, name: 'compiler' )
647
656
  allow(@generator).to receive(:generate_object_file_c).and_raise( ex )
648
657
 
649
- allow(@generator_helper).to receive(:explain_possible_mock_partial_collision)
650
- .with( output: 'redeclaration of struct gpio', mocked_headers: { 'gpio.h' => '/project/library/gpio.h' } )
651
- .and_return( 'explanatory notice text' )
652
-
653
- expect(@loginator).to receive(:log).with( 'explanatory notice text', Verbosity::ERRORS, LogLabels::NOTICE )
654
-
655
658
  expect {
656
659
  @executor.send(
657
660
  :compile_test_component,
658
661
  :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
659
662
  )
660
663
  }.to raise_error( ShellException )
664
+
665
+ expect(@build_step_doctor).to have_received(:diagnose).with(
666
+ step: :compile,
667
+ output: 'redeclaration of struct gpio',
668
+ inputs: hash_including(
669
+ tool: @tools_test_compiler, source: 'test/a_test.c', object: 'build/foo.o',
670
+ dependencies: 'build/deps', testable: @state.testables[:a_test]
671
+ )
672
+ )
661
673
  end
662
674
 
663
- it "logs the guidance after a retry that also fails" do
675
+ # The first attempt's .d file names the real headers. The retry's names the isolated
676
+ # copies, and is never registered.
677
+ it "asks the doctor after a retry that also fails, with the first attempt's .d file" do
664
678
  allow(@quote_include_isolator).to receive(:isolate).and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
665
679
 
666
680
  ex = ShellException.new( shell_result: { output: 'redeclaration of struct gpio' }, name: 'compiler' )
667
681
  allow(@generator).to receive(:generate_object_file_c).and_raise( ex )
668
- allow(@generator_helper).to receive(:explain_possible_mock_partial_collision).and_return( 'explanatory notice text' )
669
-
670
- expect(@loginator).to receive(:log).with( 'explanatory notice text', Verbosity::ERRORS, LogLabels::NOTICE )
671
682
 
672
683
  expect {
673
684
  @executor.send(
@@ -675,23 +686,87 @@ describe TestBuildExecutor do
675
686
  :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
676
687
  )
677
688
  }.to raise_error( ShellException )
689
+
690
+ expect(@generator).to have_received(:generate_object_file_c).twice
691
+ expect(@build_step_doctor).to have_received(:diagnose).once.with(
692
+ step: :compile, output: 'redeclaration of struct gpio', inputs: hash_including( dependencies: 'build/deps' )
693
+ )
678
694
  end
679
695
 
680
- it "logs nothing extra when generator_helper finds no explanation" do
681
- allow(@gcc_dependency_parser).to receive(:parse).and_return(
682
- { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
696
+ it "asks the doctor nothing when the compile succeeds" do
697
+ allow(@quote_include_isolator).to receive(:isolate).and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
698
+ allow(@generator).to receive(:generate_object_file_c)
699
+
700
+ @executor.send(
701
+ :compile_test_component,
702
+ :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
683
703
  )
684
- ex = ShellException.new( shell_result: { output: 'totally unrelated failure' }, name: 'compiler' )
685
- allow(@generator).to receive(:generate_object_file_c).and_raise( ex )
686
704
 
687
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::ERRORS, LogLabels::NOTICE )
705
+ expect(@build_step_doctor).not_to have_received(:diagnose)
706
+ end
707
+ end
688
708
 
689
- expect {
690
- @executor.send(
691
- :compile_test_component,
692
- :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
693
- )
694
- }.to raise_error( ShellException )
709
+ # The isolation directory takes a new name every build. A later object's staleness
710
+ # weighs the isolated originals in its place, so an unchanged rebuild compiles nothing.
711
+ context "an object compiled after its test's header isolation" do
712
+ let(:isolation) do
713
+ QuoteIncludeIsolator::Isolation.new(
714
+ 'build/test/out/a_test/d1', { '/project/library/driverlib.h' => 'build/test/out/a_test/d1/driverlib.h' }
715
+ )
716
+ end
717
+
718
+ before(:each) do
719
+ allow(@configurator).to receive(:test_build_use_assembly).and_return( true )
720
+ allow(@configurator).to receive(:collection_paths_support).and_return( [] )
721
+ allow(@generator).to receive(:generate_object_file_c)
722
+ allow(@generator).to receive(:generate_object_file_asm)
723
+ allow(@quote_include_isolator).to receive(:restore_dependencies)
724
+
725
+ @state.testables[:a_test].filepath = 'test/a_test.c'
726
+ @state.testables[:a_test].search_paths = ['build/test/out/a_test/d1', 'test/support']
727
+ @state.testables[:a_test].header_isolation = isolation
728
+ end
729
+
730
+ def compile(source)
731
+ @executor.send(
732
+ :compile_test_component,
733
+ :context => :test, :test => :a_test, :source => source, :object => 'build/other.o', :state => @state
734
+ )
735
+ end
736
+
737
+ it "registers the isolated originals in place of the isolation directory" do
738
+ expect(@dependinator).to receive(:register).with(
739
+ 'build/other.o', files: ['src/other.c'],
740
+ meta: hash_including( search_paths: ['test/support'], isolated: ['/project/library/driverlib.h'] )
741
+ )
742
+
743
+ compile( 'src/other.c' )
744
+ end
745
+
746
+ it "registers the same for an assembly source" do
747
+ expect(@dependinator).to receive(:register).with(
748
+ 'build/other.o', files: ['src/start.asm'],
749
+ meta: hash_including( search_paths: ['test/support'], isolated: ['/project/library/driverlib.h'] )
750
+ )
751
+
752
+ compile( 'src/start.asm' )
753
+ end
754
+
755
+ it "leaves the isolation out of an object whose search paths never held it" do
756
+ expect(@dependinator).to receive(:register) do |_object, meta:, **|
757
+ expect( meta ).not_to have_key( :isolated )
758
+ end
759
+
760
+ compile( File.join( PROJECT_BUILD_VENDOR_UNITY_PATH, UNITY_C_FILE ) )
761
+ end
762
+
763
+ it "restores the dependency file to the originals before registering it" do
764
+ allow(@file_wrapper).to receive(:exist_with_retry?).with( 'build/deps' ).and_return( true )
765
+
766
+ expect(@quote_include_isolator).to receive(:restore_dependencies).with( isolation, 'build/deps' ).ordered
767
+ expect(@dependinator).to receive(:register_gcc_deps_file).with( 'build/deps' ).ordered
768
+
769
+ compile( 'src/other.c' )
695
770
  end
696
771
  end
697
772
  end
@@ -704,6 +779,9 @@ describe TestBuildExecutor do
704
779
  :paths => { build: 'build/test/out/a_test' }
705
780
  )
706
781
 
782
+ # CMock writes a same-name copy of each mocked header only under inline handling
783
+ allow(@configurator).to receive(:project_use_mocks).and_return( true )
784
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :include )
707
785
  allow(@file_wrapper).to receive(:read).with( 'build/deps' ).and_return( '' )
708
786
  end
709
787
 
@@ -767,15 +845,14 @@ describe TestBuildExecutor do
767
845
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
768
846
  { 'a.o' => ['test/a_test.c', '/project/library/gpio.h', '/project/library/driverlib.h'] }
769
847
  )
848
+ isolation = isolation_in( 'build/test/out/a_test/isolated_headers/xyz' )
770
849
  allow(@quote_include_isolator).to receive(:isolate)
771
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
772
- .and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
773
-
774
- result = call_it()
850
+ .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'], preserve_location: true )
851
+ .and_return( isolation )
775
852
 
776
- expect( result ).to eq(
777
- search_paths: ['build/test/out/a_test/isolated_headers/xyz', 'test/support'],
778
- isolation_dir: 'build/test/out/a_test/isolated_headers/xyz'
853
+ expect( call_it() ).to eq(
854
+ search_paths: ['build/test/out/a_test/isolated_headers/xyz', 'test/support'],
855
+ isolation: isolation
779
856
  )
780
857
  end
781
858
 
@@ -804,7 +881,9 @@ describe TestBuildExecutor do
804
881
  expect( call_it() ).to be_nil
805
882
  end
806
883
 
807
- it "reports, but does not isolate, another shared directory elsewhere in the dependency list" do
884
+ # Nothing designates which occupant of an unsubstituted shared directory should win.
885
+ # A compilation failure there is the build step doctor's to explain.
886
+ it "neither reports nor isolates another shared directory elsewhere in the dependency list" do
808
887
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
809
888
  {
810
889
  'a.o' => [
@@ -814,79 +893,42 @@ describe TestBuildExecutor do
814
893
  }
815
894
  )
816
895
  allow(@quote_include_isolator).to receive(:isolate)
817
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
896
+ .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'], preserve_location: true )
818
897
  .and_return( isolation_in( 'isolated/dir' ) )
819
898
 
820
- expect(@loginator).to receive(:log).with(
821
- a_string_including( '/project/other/x.h' ).and( a_string_including( '/project/other/y.h' ) ),
822
- Verbosity::COMPLAIN, LogLabels::NOTICE
823
- )
824
-
825
899
  result = call_it()
826
900
 
827
901
  expect( result[:search_paths] ).to_not include( a_string_including( '/project/other' ) )
902
+ expect(@loginator).to_not have_received(:log).with( a_string_including( '/project/other' ), anything, anything )
828
903
  end
829
904
 
830
- it "logs nothing at all when there is no risk anywhere in the dependency list" do
831
- allow(@gcc_dependency_parser).to receive(:parse).and_return(
832
- { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
833
- )
834
-
835
- expect(@loginator).to_not receive(:log).with( anything, anything, LogLabels::NOTICE )
836
-
837
- call_it()
838
- end
839
-
840
- # This test's own mocks output directory routinely holds several generated files
841
- # side by side (a mock's own interface header, and -- when :treat_inlines: :include
842
- # is configured -- a same-basename shadow of the real header too), and Unity's own
843
- # vendor directory ships more than one header as a matter of course. Neither is a
844
- # real project header directory a quote-include could ambiguously resolve within,
845
- # so neither belongs in the "worth investigating" heads-up.
846
- it "does not report co-resident files inside this test's own mocks output directory or a vendor framework directory" do
847
- @testable.paths = { build: 'build/test/out/a_test', mocks: 'build/test/mocks/a_test' }
848
-
905
+ # Without CMock's same-name copy, the sibling's quoted #include finds the real header
906
+ # through the search paths too, so isolating it would change nothing
907
+ it "isolates nothing when inline handling excludes inline functions" do
908
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :exclude )
849
909
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
850
- {
851
- 'a.o' => [
852
- 'test/a_test.c', '/project/library/gpio.h',
853
- 'build/test/mocks/a_test/mock_gpio.h', 'build/test/mocks/a_test/gpio.h',
854
- PROJECT_BUILD_VENDOR_UNITY_PATH + '/unity.h', PROJECT_BUILD_VENDOR_UNITY_PATH + '/unity_internals.h'
855
- ]
856
- }
910
+ { 'a.o' => ['test/a_test.c', '/project/library/gpio.h', '/project/library/driverlib.h'] }
857
911
  )
858
912
 
859
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::COMPLAIN, anything )
860
-
861
- call_it()
913
+ expect(@quote_include_isolator).to_not receive(:isolate)
914
+ expect( call_it() ).to be_nil
862
915
  end
863
916
 
864
- # A test's own Partials output directory is shaped exactly the same way as its
865
- # mocks output directory -- several generated headers (a types header, an
866
- # interface header, and more) routinely sit side by side there, one set per
867
- # Partialized module, none of it a real project header.
868
- it "does not report co-resident files inside this test's own Partials output directory" do
869
- @testable.paths = { build: 'build/test/out/a_test', partials: 'build/test/partials/a_test' }
870
-
917
+ it "logs nothing at all when there is no risk anywhere in the dependency list" do
871
918
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
872
- {
873
- 'a.o' => [
874
- 'test/a_test.c', '/project/library/gpio.h',
875
- 'build/test/partials/a_test/ceedling_partial_moduleA_impl.h',
876
- 'build/test/partials/a_test/ceedling_partial_gpio_interface.h',
877
- 'build/test/partials/a_test/ceedling_partial_gpio_types.h'
878
- ]
879
- }
919
+ { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
880
920
  )
881
921
 
882
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::COMPLAIN, anything )
922
+ expect(@loginator).to_not receive(:log).with( anything, anything, LogLabels::NOTICE )
883
923
 
884
924
  call_it()
885
925
  end
886
926
  end
887
927
 
928
+ # A Partial writes no file under its module header's name, so the sibling's quoted
929
+ # #include would find the real header through the search paths too
888
930
  context "with a Partialized header" do
889
- it "isolates a real header sharing a directory with the Partial's own header" do
931
+ it "isolates nothing beside the Partial's own header" do
890
932
  @testable.partials = TestInvokerTypes::TestablePartials.new(
891
933
  configs: { moduleA: double( "PartialConfig", header: double( "HeaderFile", filepath: '/project/library/moduleA.h' ) ) },
892
934
  tests: [], mocks: []
@@ -897,11 +939,9 @@ describe TestBuildExecutor do
897
939
  )
898
940
  allow(@file_wrapper).to receive(:exist?).with( '/project/library/driverlib.h' ).and_return( true )
899
941
  allow(@file_wrapper).to receive(:read).with( '/project/library/driverlib.h' ).and_return( "#include \"moduleA.h\"\n" )
900
- allow(@quote_include_isolator).to receive(:isolate)
901
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
902
- .and_return( isolation_in( 'isolated/dir' ) )
903
942
 
904
- expect( call_it() ).to_not be_nil
943
+ expect(@quote_include_isolator).to_not receive(:isolate)
944
+ expect( call_it() ).to be_nil
905
945
  end
906
946
  end
907
947
  end
@@ -972,7 +1012,7 @@ describe TestBuildExecutor do
972
1012
  end
973
1013
 
974
1014
  it "removes a testable's isolated headers directory once, after both batches complete" do
975
- @testable.isolated_headers_path = 'build/test/out/a_test/isolated_headers/xyz'
1015
+ @testable.header_isolation = isolation_in( 'build/test/out/a_test/isolated_headers/xyz' )
976
1016
  allow(@dependinator).to receive(:stale?).and_return( false )
977
1017
 
978
1018
  expect(@quote_include_isolator).to receive(:release).with( 'build/test/out/a_test/isolated_headers/xyz' ).once
@@ -980,6 +1020,17 @@ describe TestBuildExecutor do
980
1020
  @executor.stage_build_objects( @state )
981
1021
  end
982
1022
 
1023
+ it "removes a testable's isolated headers directory when a compile fails" do
1024
+ @testable.header_isolation = isolation_in( 'build/test/out/a_test/isolated_headers/xyz' )
1025
+ allow(@generator).to receive(:generate_object_file_c).and_raise(
1026
+ ShellException.new( shell_result: { output: 'error' }, name: 'compiler' )
1027
+ )
1028
+
1029
+ expect(@quote_include_isolator).to receive(:release).with( 'build/test/out/a_test/isolated_headers/xyz' ).once
1030
+
1031
+ expect { @executor.stage_build_objects( @state ) }.to raise_error( ShellException )
1032
+ end
1033
+
983
1034
  it "attempts no cleanup for a testable that never isolated anything" do
984
1035
  allow(@dependinator).to receive(:stale?).and_return( false )
985
1036
 
@@ -1096,7 +1147,7 @@ describe TestBuildExecutor do
1096
1147
  allow(@dependinator).to receive(:stale?).and_return( false )
1097
1148
  @testable.objects = FileList.new.tap { |list| list << 'build/foo.o' }
1098
1149
 
1099
- expect(@dependinator).to receive(:register).with( 'build/a_test.out', files: ['build/foo.o'], meta: hash_including( objects: ['build/foo.o'] ) ) do |_, files:, meta:|
1150
+ expect(@dependinator).to receive(:register).with( 'build/a_test.out', files: ['build/foo.o'], meta: hash_including( objects: ['build/foo.o'] ) ) do |_, meta:, **|
1100
1151
  expect(meta[:objects]).to be_an_instance_of( Array )
1101
1152
  end
1102
1153
 
@@ -1116,7 +1167,7 @@ describe TestBuildExecutor do
1116
1167
  context "#generate_executable" do
1117
1168
  before(:each) do
1118
1169
  allow(@file_path_utils).to receive(:form_test_build_map_filepath).and_return( 'build/map' )
1119
- allow(@configurator).to receive(:project_use_mocks).and_return( false )
1170
+ @testable = @state.testables[:a_test]
1120
1171
  end
1121
1172
 
1122
1173
  def build_args
@@ -1128,64 +1179,30 @@ describe TestBuildExecutor do
1128
1179
  flags: [],
1129
1180
  lib_args: [],
1130
1181
  lib_paths: [],
1131
- tool: { name: 'fake linker' }
1182
+ tool: { name: 'fake linker' },
1183
+ testable: @testable
1132
1184
  }
1133
1185
  end
1134
1186
 
1135
- it "re-raises a ShellException from the linker" do
1136
- ex = ShellException.new( shell_result: { output: 'some unrelated linker failure' }, name: 'linker' )
1137
- allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1138
- allow(@loginator).to receive(:log)
1139
-
1140
- expect {
1141
- @executor.generate_executable( **build_args )
1142
- }.to raise_error( ShellException )
1143
- end
1144
-
1145
- it "logs missing-symbols guidance when the shell output mentions a symbol, before re-raising" do
1187
+ it "links under the doctor's attention, with its inputs, and raises a failed link" do
1146
1188
  ex = ShellException.new( shell_result: { output: 'undefined reference to symbol foo' }, name: 'linker' )
1147
1189
  allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1148
1190
 
1149
- expect(@loginator).to receive(:log).with(
1150
- a_string_matching(/missing symbols/i),
1151
- Verbosity::COMPLAIN,
1152
- LogLabels::NOTICE
1153
- )
1154
-
1155
- expect {
1156
- @executor.generate_executable( **build_args )
1157
- }.to raise_error( ShellException )
1158
- end
1159
-
1160
- it "does not log guidance when the shell output does not mention a symbol" do
1161
- ex = ShellException.new( shell_result: { output: 'some unrelated linker failure' }, name: 'linker' )
1162
- allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1163
-
1164
- expect(@loginator).to_not receive(:log)
1165
-
1166
1191
  expect {
1167
1192
  @executor.generate_executable( **build_args )
1168
- }.to raise_error( ShellException )
1169
- end
1193
+ }.to raise_error( ex )
1170
1194
 
1171
- it "includes mock-specific guidance only when the project uses mocks" do
1172
- ex = ShellException.new( shell_result: { output: 'missing symbol foo' }, name: 'linker' )
1173
- allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1174
- allow(@configurator).to receive(:project_use_mocks).and_return( true )
1175
-
1176
- expect(@loginator).to receive(:log).with(
1177
- a_string_matching(/needed mocks/i),
1178
- Verbosity::COMPLAIN,
1179
- LogLabels::NOTICE
1195
+ expect(@build_step_doctor).to have_received(:attend).with(
1196
+ step: :link,
1197
+ inputs: {
1198
+ tool: { name: 'fake linker' }, objects: ['build/foo.o'], executable: 'build/a_test.out',
1199
+ flags: [], lib_args: [], lib_paths: [], testable: @testable
1200
+ }
1180
1201
  )
1181
-
1182
- expect {
1183
- @executor.generate_executable( **build_args )
1184
- }.to raise_error( ShellException )
1185
1202
  end
1186
1203
 
1187
- it "does not raise when the linker succeeds" do
1188
- allow(@generator).to receive(:generate_executable_file)
1204
+ it "links once when the linker succeeds" do
1205
+ expect(@generator).to receive(:generate_executable_file).once
1189
1206
 
1190
1207
  expect { @executor.generate_executable( **build_args ) }.to_not raise_error
1191
1208
  end
@@ -1488,6 +1505,85 @@ describe TestBuildExecutor do
1488
1505
  :directives_only_filepath => nil
1489
1506
  )
1490
1507
  @state = TestInvokerTypes::PipelineState.new( :testables => { :a_test => @testable }, :mocks_list => [mock], :context => :test, :options => [] )
1508
+ allow(@executor.instance_variable_get( :@mock_locator )).to receive(:header_search).and_return( double( 'HeaderSearch' ) )
1509
+ allow(@test_search_paths).to receive(:mock_preprocess_paths).and_return( [] )
1510
+
1511
+ # The full expansion's line markers name the headers the mocked header entered
1512
+ allow(@configurator).to receive(:project_build_root).and_return( 'build' )
1513
+ allow(@file_path_utils).to receive(:form_preprocessed_file_full_expansion_filepath).with( 'src/Foo.h', 'a_test' ).and_return( 'build/preprocess/full/Foo.h' )
1514
+ allow(@preprocessinator).to receive(:preprocessed_dependencies).and_return( [] )
1515
+ end
1516
+
1517
+ context "with the headers its full expansion entered" do
1518
+ before(:each) do
1519
+ allow(@preprocessinator).to receive(:preprocessed_dependencies).with( preprocessed_filepath: 'build/preprocess/full/Foo.h' )
1520
+ .and_return( ['src/Foo.h', 'src/drivers/bar.h', 'build/vendor/ceedling/ceedling.h'] )
1521
+ end
1522
+
1523
+ # An edit to a header the mocked header includes makes the target stale
1524
+ it "registers the previous run's entered project headers before settling staleness" do
1525
+ allow(@file_wrapper).to receive(:exist?).with( 'build/preprocess/full/Foo.h' ).and_return( true )
1526
+
1527
+ expect(@dependinator).to receive(:register).with( 'build/preprocess/MockFoo.h', files: ['src/Foo.h', 'src/drivers/bar.h'] ).ordered
1528
+ expect(@dependinator).to receive(:stale?).with( 'build/preprocess/MockFoo.h' ).ordered.and_return( false )
1529
+
1530
+ @executor.stage_preprocess_mocks( @state )
1531
+ end
1532
+
1533
+ it "registers no entered header before settling staleness when no previous expansion exists" do
1534
+ allow(@dependinator).to receive(:stale?).and_return( false )
1535
+
1536
+ expect(@preprocessinator).to_not receive(:preprocessed_dependencies)
1537
+
1538
+ @executor.stage_preprocess_mocks( @state )
1539
+ end
1540
+
1541
+ it "registers this run's entered project headers before marking the target fresh" do
1542
+ allow(@dependinator).to receive(:stale?).and_return( true )
1543
+
1544
+ expect(@preprocessinator).to receive(:preprocess_mockable_header_file).ordered
1545
+ expect(@dependinator).to receive(:register).with( 'build/preprocess/MockFoo.h', files: ['src/Foo.h', 'src/drivers/bar.h'] ).ordered
1546
+ expect(@dependinator).to receive(:mark_fresh).with( 'build/preprocess/MockFoo.h' ).ordered
1547
+
1548
+ @executor.stage_preprocess_mocks( @state )
1549
+ end
1550
+ end
1551
+
1552
+ context "through the test's mock preprocess paths" do
1553
+ before(:each) do
1554
+ @testable.search_paths = ['build/test/mocks/a_test', 'src']
1555
+ allow(@test_search_paths).to receive(:mock_preprocess_paths).with( @testable ).and_return( ['src'] )
1556
+ allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
1557
+ allow(@dependinator).to receive(:stale?).and_return( true )
1558
+ allow(@preprocessinator).to receive(:generate_directives_only_output).and_return( 'build/preprocess/directives_only/Foo.h' )
1559
+ allow(@preprocessinator).to receive(:preprocess_mockable_header_file)
1560
+ end
1561
+
1562
+ # The mock root holds CMock's copies of headers, which no real header is read through
1563
+ it "preprocesses the mockable header through its test's mock preprocess paths, never its full search paths" do
1564
+ @executor.stage_preprocess_mocks( @state )
1565
+
1566
+ expect(@preprocessinator).to have_received(:generate_directives_only_output).with( hash_including( include_paths: ['src'] ) )
1567
+ expect(@preprocessinator).to have_received(:preprocess_mockable_header_file).with( hash_including( include_paths: ['src'] ) )
1568
+ end
1569
+
1570
+ it "registers its test's mock preprocess paths as the target's search paths" do
1571
+ expect(@dependinator).to receive(:register).with( 'build/preprocess/MockFoo.h', files: ['src/Foo.h'], meta: hash_including( search_paths: ['src'] ) )
1572
+
1573
+ @executor.stage_preprocess_mocks( @state )
1574
+ end
1575
+
1576
+ it "composes a test's mock preprocess paths once for all its mocks" do
1577
+ bar = @state.mocks_list.first.dup
1578
+ bar.details = TestInvokerTypes::MockDetails.new( :source => 'src/Bar.h', :path => 'sub' )
1579
+ @state.mocks_list << bar
1580
+ allow(@file_path_utils).to receive(:form_preprocessed_file_full_expansion_filepath).with( 'src/Bar.h', 'a_test' ).and_return( 'build/preprocess/full/Bar.h' )
1581
+
1582
+ @executor.stage_preprocess_mocks( @state )
1583
+
1584
+ expect(@test_search_paths).to have_received(:mock_preprocess_paths).once
1585
+ expect(@preprocessinator).to have_received(:preprocess_mockable_header_file).with( hash_including( include_paths: ['src'] ) ).twice
1586
+ end
1491
1587
  end
1492
1588
 
1493
1589
  it "preprocesses and marks fresh the mockable header when the dependency tracker reports it stale" do
@@ -1498,6 +1594,17 @@ describe TestBuildExecutor do
1498
1594
  @executor.stage_preprocess_mocks( @state )
1499
1595
  end
1500
1596
 
1597
+ it "hands mockable header preprocessing the test's header search" do
1598
+ search = double( 'HeaderSearch' )
1599
+ allow(@dependinator).to receive(:stale?).and_return( true )
1600
+ allow(@dependinator).to receive(:mark_fresh)
1601
+ allow(@executor.instance_variable_get( :@mock_locator )).to receive(:header_search).with( @testable ).and_return( search )
1602
+
1603
+ expect(@preprocessinator).to receive(:preprocess_mockable_header_file).with( hash_including( include_search: search ) )
1604
+
1605
+ @executor.stage_preprocess_mocks( @state )
1606
+ end
1607
+
1501
1608
  it "skips preprocessing the mockable header when the dependency tracker reports it unchanged" do
1502
1609
  allow(@dependinator).to receive(:stale?).and_return( false )
1503
1610
  expect(@preprocessinator).to_not receive(:preprocess_mockable_header_file)
@@ -1515,7 +1622,7 @@ describe TestBuildExecutor do
1515
1622
  @executor.stage_preprocess_mocks( @state )
1516
1623
  end
1517
1624
 
1518
- it "registers the bare-includes and directives-only preprocessor tools, and the fallback setting, as meta" do
1625
+ it "registers every preprocessor tool the stage runs, and the fallback setting, as meta" do
1519
1626
  allow(@preprocessinator).to receive(:preprocess_mockable_header_file)
1520
1627
 
1521
1628
  expect(@dependinator).to receive(:register).with(
@@ -1523,7 +1630,7 @@ describe TestBuildExecutor do
1523
1630
  files: ['src/Foo.h'],
1524
1631
  meta: {
1525
1632
  flags: [], defines: [], search_paths: [], extras: false,
1526
- tools: [@tools_test_bare_includes_preprocessor, @tools_test_file_directives_only_preprocessor],
1633
+ tools: [@tools_test_bare_includes_preprocessor, @tools_test_file_directives_only_preprocessor, @tools_test_file_full_preprocessor],
1527
1634
  preprocess_force_fallback: false
1528
1635
  }
1529
1636
  )
@@ -1544,16 +1651,43 @@ describe TestBuildExecutor do
1544
1651
  @executor.stage_preprocess_mocks( @state )
1545
1652
  end
1546
1653
 
1547
- it "skips the extra treat-inlines-aware pass for a Partial mock even when the project configures :treat_inlines: :include -- its own generated header is already inline-free" do
1654
+ # CMock reads a Partial mock's generated interface header itself, so stage 9 has nothing to do for one
1655
+ it "never registers or preprocesses a Partial mock's header" do
1656
+ allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
1548
1657
  @state.mocks_list.first.details.partial = true
1549
- allow(@configurator).to receive(:cmock_treat_inlines).and_return( :include )
1658
+
1659
+ expect(@dependinator).to_not receive(:register)
1660
+ expect(@preprocessinator).to_not receive(:generate_directives_only_output)
1661
+ expect(@preprocessinator).to_not receive(:preprocess_mockable_header_file)
1662
+
1663
+ @executor.stage_preprocess_mocks( @state )
1664
+ end
1665
+
1666
+ # Preprocessinator logs the warning
1667
+ it "falls back without a message of its own when the directives-only run fails" do
1668
+ allow(@configurator).to receive(:test_build_preprocess_directives_only_available).and_return( true )
1669
+ allow(@dependinator).to receive(:stale?).and_return( true )
1670
+ allow(@dependinator).to receive(:mark_fresh)
1671
+ allow(@preprocessinator).to receive(:generate_directives_only_output).and_return( nil )
1550
1672
  allow(@preprocessinator).to receive(:preprocess_mockable_header_file)
1673
+ allow(@loginator).to receive(:log)
1551
1674
 
1552
- expect(@dependinator).to receive(:register).with(
1553
- 'build/preprocess/MockFoo.h',
1554
- files: anything,
1555
- meta: hash_including( extras: false )
1556
- )
1675
+ @executor.stage_preprocess_mocks( @state )
1676
+
1677
+ expect(@preprocessinator).to have_received(:generate_directives_only_output)
1678
+ expect(@loginator).to_not have_received(:log).with( /directive-only/, any_args )
1679
+ expect(@state.mocks_list.first.directives_only_filepath).to be_nil
1680
+ expect(@preprocessinator).to have_received(:preprocess_mockable_header_file).with( hash_including( fallback: true ) )
1681
+ end
1682
+
1683
+ it "preprocesses a plain mock's header beside a Partial mock" do
1684
+ partial = @state.mocks_list.first.dup
1685
+ partial.details = TestInvokerTypes::MockDetails.new( :source => 'build/test/partials/a_test/foo_interface.h', :partial => true )
1686
+ @state.mocks_list.unshift( partial )
1687
+ allow(@dependinator).to receive(:stale?).and_return( true )
1688
+
1689
+ expect(@dependinator).to receive(:register).with( 'build/preprocess/MockFoo.h', files: ['src/Foo.h'], meta: anything ).once
1690
+ expect(@preprocessinator).to receive(:preprocess_mockable_header_file).with( hash_including( filepath: 'src/Foo.h' ) ).once
1557
1691
 
1558
1692
  @executor.stage_preprocess_mocks( @state )
1559
1693
  end
@@ -1566,7 +1700,11 @@ describe TestBuildExecutor do
1566
1700
  allow(@configurator).to receive(:project_config_hash).and_return( {} )
1567
1701
  allow(@configurator).to receive(:get_cmock_config).and_return( { mock_prefix: 'Mock' } )
1568
1702
  allow(@configurator).to receive(:cmock_mock_name_include_folder).and_return( true )
1703
+ allow(@generator).to receive(:mock_generator_name).and_return( 'CMock' )
1704
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :exclude )
1569
1705
  allow(@file_wrapper).to receive(:mkdir)
1706
+ allow(@file_wrapper).to receive(:exist?).and_return( false )
1707
+ allow(@file_wrapper).to receive(:rm_f)
1570
1708
  # Where a mock's files sit is composed in one shared place, so the stage that
1571
1709
  # compiles a mock and the stage that generates it cannot disagree.
1572
1710
  allow(@file_path_utils).to receive(:form_mock_output_path) do |root, subdir|
@@ -1603,6 +1741,40 @@ describe TestBuildExecutor do
1603
1741
  @executor.stage_generate_mocks( @state )
1604
1742
  end
1605
1743
 
1744
+ # A prune before stage 4 removes a copy whose mock only the preprocessor names
1745
+ context "under :treat_inlines :include" do
1746
+ before(:each) do
1747
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :include )
1748
+ allow(@dependinator).to receive(:stale?).and_return( false )
1749
+ allow(@dependinator).to receive(:mark_fresh)
1750
+ @state.mocks_list.first.details.input = 'build/preprocess/foo.h'
1751
+ end
1752
+
1753
+ it "generates a fresh mock again when its header copy is gone" do
1754
+ allow(@file_wrapper).to receive(:exist?).with( 'build/test/mocks/sub/foo.h' ).and_return( false )
1755
+
1756
+ expect(@generator).to receive(:generate_mock)
1757
+
1758
+ @executor.stage_generate_mocks( @state )
1759
+ end
1760
+
1761
+ it "skips a fresh mock whose header copy is in place" do
1762
+ allow(@file_wrapper).to receive(:exist?).with( 'build/test/mocks/sub/foo.h' ).and_return( true )
1763
+
1764
+ expect(@generator).to_not receive(:generate_mock)
1765
+
1766
+ @executor.stage_generate_mocks( @state )
1767
+ end
1768
+
1769
+ it "skips a fresh Partial mock, which has no header copy" do
1770
+ @state.mocks_list.first.details.partial = true
1771
+
1772
+ expect(@generator).to_not receive(:generate_mock)
1773
+
1774
+ @executor.stage_generate_mocks( @state )
1775
+ end
1776
+ end
1777
+
1606
1778
  it "logs a summary line stating how many mocks were recalled from cache" do
1607
1779
  allow(@dependinator).to receive(:stale?).and_return( false )
1608
1780
 
@@ -1631,6 +1803,40 @@ describe TestBuildExecutor do
1631
1803
  @executor.stage_generate_mocks( @state )
1632
1804
  end
1633
1805
 
1806
+ # CMock names a mock's header with the header's own extension, which the test's #include repeats
1807
+ it "tracks a mock's generated header with the extension its #include names" do
1808
+ @state.mocks_list.first.details.include_path = 'sub/MockFoo.hpp'
1809
+ allow(@dependinator).to receive(:stale?).and_return( true )
1810
+ allow(@generator).to receive(:generate_mock)
1811
+ allow(@dependinator).to receive(:mark_fresh)
1812
+
1813
+ expect(@dependinator).to receive(:register).with(
1814
+ 'build/test/mocks/sub/MockFoo.c',
1815
+ files: anything,
1816
+ meta: anything,
1817
+ outputs: ['build/test/mocks/sub/MockFoo.hpp']
1818
+ )
1819
+
1820
+ @executor.stage_generate_mocks( @state )
1821
+ end
1822
+
1823
+ it "keeps the dots of a mock's name in its generated header's path" do
1824
+ @state.mocks_list.first.details.name = 'MockSensor.44'
1825
+ @state.mocks_list.first.details.include_path = 'sub/MockSensor.44.hpp'
1826
+ allow(@dependinator).to receive(:stale?).and_return( true )
1827
+ allow(@generator).to receive(:generate_mock)
1828
+ allow(@dependinator).to receive(:mark_fresh)
1829
+
1830
+ expect(@dependinator).to receive(:register).with(
1831
+ 'build/test/mocks/sub/MockSensor.44.c',
1832
+ files: anything,
1833
+ meta: anything,
1834
+ outputs: ['build/test/mocks/sub/MockSensor.44.hpp']
1835
+ )
1836
+
1837
+ @executor.stage_generate_mocks( @state )
1838
+ end
1839
+
1634
1840
  it "registers CMock's actual configuration as meta, not project_config_hash's flattened (and therefore always-empty) :cmock entry" do
1635
1841
  # project_config_hash is flattened -- CMock's settings live there as individual
1636
1842
  # top-level keys like :cmock_mock_prefix, never as a :cmock section -- so a
@@ -1645,13 +1851,116 @@ describe TestBuildExecutor do
1645
1851
  expect(@dependinator).to receive(:register).with(
1646
1852
  'build/test/mocks/sub/MockFoo.c',
1647
1853
  files: anything,
1648
- meta: { cmock: { mock_prefix: 'Custom' } },
1854
+ meta: hash_including( cmock: { mock_prefix: 'Custom' } ),
1649
1855
  outputs: anything
1650
1856
  )
1651
1857
 
1652
1858
  @executor.stage_generate_mocks( @state )
1653
1859
  end
1654
1860
 
1861
+ # CMock's verbosity changes only what it prints, and Ceedling sets it anew for each mock
1862
+ it "leaves CMock's verbosity out of the mock's record" do
1863
+ allow(@configurator).to receive(:get_cmock_config).and_return( { mock_prefix: 'Mock', verbosity: 4 } )
1864
+ allow(@dependinator).to receive(:stale?).and_return( false )
1865
+
1866
+ expect(@dependinator).to receive(:register).with( anything, files: anything, meta: hash_including( cmock: { mock_prefix: 'Mock' } ), outputs: anything )
1867
+
1868
+ @executor.stage_generate_mocks( @state )
1869
+ end
1870
+
1871
+ # A plugin such as FFF can replace CMock, writing a different file from the same configuration
1872
+ it "records which generator writes the mock" do
1873
+ allow(@generator).to receive(:mock_generator_name).and_return( 'FffCMockWrapper' )
1874
+ allow(@dependinator).to receive(:stale?).and_return( false )
1875
+
1876
+ expect(@dependinator).to receive(:register).with( anything, files: anything, meta: hash_including( generator: 'FffCMockWrapper' ), outputs: anything )
1877
+
1878
+ @executor.stage_generate_mocks( @state )
1879
+ end
1880
+
1881
+ # Under :treat_inlines :include CMock writes a copy of the header beside the mock, which a
1882
+ # later generation without it would leave for the mock's #include to reach
1883
+ context "with a copy of the mocked header beside the mock" do
1884
+ before(:each) do
1885
+ allow(@generator).to receive(:generate_mock)
1886
+ allow(@dependinator).to receive(:mark_fresh)
1887
+ @state.mocks_list.first.details.input = 'build/preprocess/Foo.h'
1888
+ allow(@file_wrapper).to receive(:exist?).with( 'build/test/mocks/sub/Foo.h' ).and_return( true )
1889
+ end
1890
+
1891
+ it "removes the copy before generating the mock again" do
1892
+ allow(@dependinator).to receive(:stale?).and_return( true )
1893
+
1894
+ expect(@file_wrapper).to receive(:rm_f).with( 'build/test/mocks/sub/Foo.h' ).ordered
1895
+ expect(@generator).to receive(:generate_mock).ordered
1896
+
1897
+ @executor.stage_generate_mocks( @state )
1898
+ end
1899
+
1900
+ it "leaves the copy of a mock that is fresh" do
1901
+ allow(@dependinator).to receive(:stale?).and_return( false )
1902
+
1903
+ expect(@file_wrapper).to_not receive(:rm_f)
1904
+
1905
+ @executor.stage_generate_mocks( @state )
1906
+ end
1907
+
1908
+ it "leaves a Partial mock's files alone, since CMock writes it no copy" do
1909
+ allow(@dependinator).to receive(:stale?).and_return( true )
1910
+ @state.mocks_list.first.details.partial = true
1911
+
1912
+ expect(@file_wrapper).to_not receive(:rm_f)
1913
+
1914
+ @executor.stage_generate_mocks( @state )
1915
+ end
1916
+ end
1917
+
1918
+ # A real header named like another mock, as `MockBar.h` is beside a mock of `Bar.h`
1919
+ it "never removes another mock's file as a copy" do
1920
+ allow(@dependinator).to receive(:stale?).and_return( true )
1921
+ allow(@generator).to receive(:generate_mock)
1922
+ allow(@dependinator).to receive(:mark_fresh)
1923
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
1924
+ details = ->(name, input) { TestInvokerTypes::MockDetails.new( source: 'src/x.h', path: 'sub', input: input, name: name ) }
1925
+ @state.mocks_list.replace( [
1926
+ TestInvokerTypes::MockWork.new( details: details.( 'MockBar', 'build/preprocess/Bar.h' ), testable: @testable, name: :MockBar ),
1927
+ TestInvokerTypes::MockWork.new( details: details.( 'MockMockBar', 'build/preprocess/MockBar.h' ), testable: @testable, name: :MockMockBar )
1928
+ ] )
1929
+
1930
+ expect(@file_wrapper).to receive(:rm_f).with( 'build/test/mocks/sub/Bar.h' )
1931
+ expect(@file_wrapper).to_not receive(:rm_f).with( 'build/test/mocks/sub/MockBar.h' )
1932
+
1933
+ @executor.stage_generate_mocks( @state )
1934
+ end
1935
+
1936
+ it "never removes another mock's header with another extension as a copy" do
1937
+ allow(@dependinator).to receive(:stale?).and_return( true )
1938
+ allow(@generator).to receive(:generate_mock)
1939
+ allow(@dependinator).to receive(:mark_fresh)
1940
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
1941
+ details = ->(name, input) { TestInvokerTypes::MockDetails.new( source: 'src/x.hpp', path: 'sub', input: input, name: name, include_path: "sub/#{name}.hpp" ) }
1942
+ @state.mocks_list.replace( [
1943
+ TestInvokerTypes::MockWork.new( details: details.( 'MockBar', 'build/preprocess/Bar.hpp' ), testable: @testable, name: :MockBar ),
1944
+ TestInvokerTypes::MockWork.new( details: details.( 'MockMockBar', 'build/preprocess/MockBar.hpp' ), testable: @testable, name: :MockMockBar )
1945
+ ] )
1946
+
1947
+ expect(@file_wrapper).to receive(:rm_f).with( 'build/test/mocks/sub/Bar.hpp' )
1948
+ expect(@file_wrapper).to_not receive(:rm_f).with( 'build/test/mocks/sub/MockBar.hpp' )
1949
+
1950
+ @executor.stage_generate_mocks( @state )
1951
+ end
1952
+
1953
+ it "never removes the mock's own header as a copy, as an empty mock prefix would name it" do
1954
+ allow(@dependinator).to receive(:stale?).and_return( true )
1955
+ allow(@generator).to receive(:generate_mock)
1956
+ allow(@dependinator).to receive(:mark_fresh)
1957
+ allow(@file_wrapper).to receive(:exist?).and_return( true )
1958
+
1959
+ expect(@file_wrapper).to_not receive(:rm_f)
1960
+
1961
+ @executor.stage_generate_mocks( @state )
1962
+ end
1963
+
1655
1964
  it "generates an ordinary mock with no configuration override" do
1656
1965
  allow(@dependinator).to receive(:stale?).and_return( true )
1657
1966
  allow(@dependinator).to receive(:mark_fresh)
@@ -1671,6 +1980,67 @@ describe TestBuildExecutor do
1671
1980
  @executor.stage_generate_mocks( @state )
1672
1981
  end
1673
1982
 
1983
+ # CMock includes a mock's real header by the folder it is given and the header's filename.
1984
+ # Stage 5 records another text where the test's search paths reach the header only by it.
1985
+ context "with a respelled #include of the mock's real header" do
1986
+ before(:each) do
1987
+ allow(@dependinator).to receive(:stale?).and_return( true )
1988
+ allow(@dependinator).to receive(:mark_fresh)
1989
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :exclude )
1990
+ @state.mocks_list.first.details.include_path = 'drivers/MockFoo.h'
1991
+ @state.mocks_list.first.details.header_include = 'foo.h'
1992
+ end
1993
+
1994
+ it "has CMock include the header by that text, and passes the text on for an FFF fake" do
1995
+ expect(@generator).to receive(:generate_mock)
1996
+ .with( hash_including( overrides: { orig_header_include: 'foo.h', orig_header_include_fmt: '#include "foo.h"' } ) )
1997
+
1998
+ @executor.stage_generate_mocks( @state )
1999
+ end
2000
+
2001
+ it "puts the text in the project's CMock :orig_header_include_fmt" do
2002
+ allow(@configurator).to receive(:get_cmock_config).and_return( { mock_prefix: 'Mock', orig_header_include_fmt: '#include <%s>' } )
2003
+
2004
+ expect(@generator).to receive(:generate_mock)
2005
+ .with( hash_including( overrides: hash_including( orig_header_include_fmt: '#include <foo.h>' ) ) )
2006
+
2007
+ @executor.stage_generate_mocks( @state )
2008
+ end
2009
+
2010
+ # CMock's own text reaches the copy of the header CMock writes beside the mock. A fake
2011
+ # writes no copy.
2012
+ it "keeps CMock's own #include under :treat_inlines :include, passing the text on for an FFF fake" do
2013
+ allow(@configurator).to receive(:cmock_treat_inlines).and_return( :include )
2014
+
2015
+ expect(@generator).to receive(:generate_mock).with( hash_including( overrides: { orig_header_include: 'foo.h' } ) )
2016
+
2017
+ @executor.stage_generate_mocks( @state )
2018
+ end
2019
+
2020
+ # A respelling is never weighed with more around it than quotes. A fake writes no format.
2021
+ it "keeps CMock's own #include under an :orig_header_include_fmt writing more around the text, passing the text on for an FFF fake" do
2022
+ allow(@configurator).to receive(:get_cmock_config).and_return( { mock_prefix: 'Mock', orig_header_include_fmt: '#include "../%s"' } )
2023
+
2024
+ expect(@generator).to receive(:generate_mock).with( hash_including( overrides: { orig_header_include: 'foo.h' } ) )
2025
+
2026
+ @executor.stage_generate_mocks( @state )
2027
+ end
2028
+
2029
+ # The text follows the test's search paths, which CMock's configuration doesn't hold
2030
+ it "records the text as meta, so a change regenerates the mock" do
2031
+ allow(@generator).to receive(:generate_mock)
2032
+
2033
+ expect(@dependinator).to receive(:register).with(
2034
+ 'build/test/mocks/drivers/MockFoo.c',
2035
+ files: anything,
2036
+ meta: { cmock: { mock_prefix: 'Mock' }, generator: 'CMock', folder: 'drivers', header_include: 'foo.h' },
2037
+ outputs: anything
2038
+ )
2039
+
2040
+ @executor.stage_generate_mocks( @state )
2041
+ end
2042
+ end
2043
+
1674
2044
  # CMock and the runner both name a mock by the folder its #include names. CMock writes
1675
2045
  # below its own root at that folder, so the folder must also end the mock's directory.
1676
2046
  context "naming a mock by its #include's folder" do
@@ -1747,6 +2117,28 @@ describe TestBuildExecutor do
1747
2117
  @executor.stage_generate_mocks( @state )
1748
2118
  end
1749
2119
 
2120
+ # CMock names the mock by its folder, which an #include can change while the mock's place stays
2121
+ it "records the folder as meta, so a change of folder regenerates the mock" do
2122
+ include_as( 'sub/MockFoo.h' )
2123
+ allow(@generator).to receive(:generate_mock)
2124
+
2125
+ expect(@dependinator).to receive(:register)
2126
+ .with( 'build/test/mocks/sub/MockFoo.c', files: anything, meta: { cmock: { mock_prefix: 'Mock' }, generator: 'CMock', folder: 'sub' }, outputs: anything )
2127
+
2128
+ @executor.stage_generate_mocks( @state )
2129
+ end
2130
+
2131
+ # A record holding no folder can't tell a mock named without one from one named by a folder it never held
2132
+ it "records a nil folder as meta for a mock named without one" do
2133
+ include_as( 'MockFoo.h' )
2134
+ allow(@generator).to receive(:generate_mock)
2135
+
2136
+ expect(@dependinator).to receive(:register)
2137
+ .with( 'build/test/mocks/sub/MockFoo.c', files: anything, meta: { cmock: { mock_prefix: 'Mock' }, generator: 'CMock', folder: nil }, outputs: anything )
2138
+
2139
+ @executor.stage_generate_mocks( @state )
2140
+ end
2141
+
1750
2142
  it "passes no folder when :mock_name_include_folder is disabled" do
1751
2143
  allow(@configurator).to receive(:cmock_mock_name_include_folder).and_return( false )
1752
2144
  include_as( 'sub/MockFoo.h' )
@@ -1759,6 +2151,228 @@ describe TestBuildExecutor do
1759
2151
  end
1760
2152
  end
1761
2153
 
2154
+ # Under :treat_inlines :include, a copy of each mocked header sits beside its mock, on the
2155
+ # test's search path. One no current mock names would shadow its header.
2156
+ context "#stage_prune_header_copies" do
2157
+ before(:each) do
2158
+ allow(@configurator).to receive(:cmock_mock_prefix).and_return( 'Mock' )
2159
+ allow(@configurator).to receive(:cmock_mock_suffix).and_return( '' )
2160
+ allow(@configurator).to receive(:cmock_mock_name_include_folder).and_return( true )
2161
+ allow(@configurator).to receive(:extension_header).and_return( FilenameExtension.new( '.h' ) )
2162
+ allow(@file_path_utils).to receive(:form_mock_output_path) do |root, subdir|
2163
+ subdir.nil? || subdir.empty? ? root : File.join( root, subdir )
2164
+ end
2165
+ allow(@file_wrapper).to receive(:rm_f)
2166
+ allow(@file_wrapper).to receive(:mv)
2167
+ allow(@file_wrapper).to receive(:directory_listing).with( 'build/test/mocks/a_test/_t_/**/*.held' ).and_return( [] )
2168
+ allow(@file_wrapper).to receive(:directory_listing).with( 'build/test/mocks/a_test/_t_/**/*.held_mock' ).and_return( [] )
2169
+
2170
+ @root = 'build/test/mocks/a_test/_t_'
2171
+ @testable = TestInvokerTypes::Testable.new( :name => 'a_test', :paths => { :mocks => @root } )
2172
+ bar = TestInvokerTypes::MockWork.new(
2173
+ :details => TestInvokerTypes::MockDetails.new(
2174
+ :source => 'src/drivers/bar.h', :path => 'drivers', :input => 'src/drivers/bar.h', :name => 'Mockbar'
2175
+ ),
2176
+ :testable => @testable,
2177
+ :name => :'drivers/Mockbar'
2178
+ )
2179
+ @state = TestInvokerTypes::PipelineState.new( :testables => { :a_test => @testable }, :mocks_list => [bar], :lock => Mutex.new, :context => :test, :options => [] )
2180
+ end
2181
+
2182
+ def listing(*paths)
2183
+ allow(@file_wrapper).to receive(:directory_listing).with( "#{@root}/**/*.h" ).and_return( paths.map { |path| File.join( @root, path ) } )
2184
+ end
2185
+
2186
+ def held(*paths)
2187
+ allow(@file_wrapper).to receive(:directory_listing).with( "#{@root}/**/*.held" ).and_return( paths.map { |path| File.join( @root, path ) } )
2188
+ end
2189
+
2190
+ def held_mocks(*paths)
2191
+ allow(@file_wrapper).to receive(:directory_listing).with( "#{@root}/**/*.held_mock" ).and_return( paths.map { |path| File.join( @root, path ) } )
2192
+ end
2193
+
2194
+ # No build removes a mock, so a copy is always beside its mock
2195
+ it "puts back every mock set aside before stage 4, current or not" do
2196
+ listing()
2197
+ held_mocks( 'drivers/Mockbar.h.held_mock', 'drivers/Mockfoo.h.held_mock' )
2198
+
2199
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/drivers/Mockbar.h.held_mock", "#{@root}/drivers/Mockbar.h" )
2200
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/drivers/Mockfoo.h.held_mock", "#{@root}/drivers/Mockfoo.h" )
2201
+
2202
+ @executor.stage_prune_header_copies( @state )
2203
+ end
2204
+
2205
+ it "puts back a copy set aside before stage 4 that a current mock writes" do
2206
+ listing()
2207
+ held( 'drivers/bar.h.held' )
2208
+
2209
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/drivers/bar.h.held", "#{@root}/drivers/bar.h" )
2210
+
2211
+ @executor.stage_prune_header_copies( @state )
2212
+ end
2213
+
2214
+ it "removes a copy set aside before stage 4 that no current mock writes" do
2215
+ listing()
2216
+ held( 'drivers/foo.h.held' )
2217
+
2218
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/foo.h.held" )
2219
+
2220
+ @executor.stage_prune_header_copies( @state )
2221
+ end
2222
+
2223
+ it "removes a copy of a header no current mock names" do
2224
+ listing( 'drivers/Mockbar.h', 'drivers/bar.h', 'drivers/Mockfoo.h', 'drivers/foo.h' )
2225
+
2226
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/foo.h" )
2227
+
2228
+ @executor.stage_prune_header_copies( @state )
2229
+ end
2230
+
2231
+ # A stand-in, a Partial mock, and a mock no longer generated have no mock of their own beside them
2232
+ it "keeps a current mock's copy and every header with no mock beside it" do
2233
+ listing( 'drivers/Mockbar.h', 'drivers/bar.h', 'drivers/Mockfoo.h', 'Mockpartial_baz.h', 'drivers/notes.h' )
2234
+
2235
+ expect(@file_wrapper).to_not receive(:rm_f)
2236
+
2237
+ @executor.stage_prune_header_copies( @state )
2238
+ end
2239
+
2240
+ # The mock root stays on the test's search path when the test has no mocks left
2241
+ it "prunes the mock root of a test with no mocks" do
2242
+ @state.mocks_list = []
2243
+ listing( 'drivers/Mockbar.h', 'drivers/bar.h' )
2244
+
2245
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/bar.h" )
2246
+
2247
+ @executor.stage_prune_header_copies( @state )
2248
+ end
2249
+
2250
+ it "prunes the copy of a header whose name starts with the mock prefix" do
2251
+ allow(@configurator).to receive(:cmock_mock_prefix).and_return( 'm' )
2252
+ listing( 'drivers/mmotor.h', 'drivers/motor.h' )
2253
+
2254
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/motor.h" )
2255
+
2256
+ @executor.stage_prune_header_copies( @state )
2257
+ end
2258
+
2259
+ it "prunes a copy beside a mock named by a suffix alone" do
2260
+ allow(@configurator).to receive(:cmock_mock_prefix).and_return( '' )
2261
+ allow(@configurator).to receive(:cmock_mock_suffix).and_return( '_mock' )
2262
+ listing( 'drivers/foo.h', 'drivers/foo_mock.h' )
2263
+
2264
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/foo.h" )
2265
+ expect(@file_wrapper).to_not receive(:rm_f).with( "#{@root}/drivers/foo_mock.h" )
2266
+
2267
+ @executor.stage_prune_header_copies( @state )
2268
+ end
2269
+
2270
+ # CMock names a mock with its header's own extension
2271
+ it "prunes a copy beside a mock named with the header's extension" do
2272
+ allow(@configurator).to receive(:extension_header).and_return( FilenameExtension.new( ['.h', '.hpp'] ) )
2273
+ listing()
2274
+ allow(@file_wrapper).to receive(:directory_listing).with( "#{@root}/**/*.hpp" ).and_return( ["#{@root}/drivers/Mockfoox.hpp", "#{@root}/drivers/foox.hpp"] )
2275
+
2276
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/foox.hpp" )
2277
+
2278
+ @executor.stage_prune_header_copies( @state )
2279
+ end
2280
+
2281
+ # A Partial mock has no header copy, so only its own header keeps it
2282
+ it "keeps a mock's header with another extension, though a mock of its own name sits beside it" do
2283
+ allow(@configurator).to receive(:extension_header).and_return( FilenameExtension.new( ['.h', '.hpp'] ) )
2284
+ partial = ->(name) { TestInvokerTypes::MockWork.new(
2285
+ :details => TestInvokerTypes::MockDetails.new( :source => "build/test/partials/a_test/#{name}.hpp", :path => 'drivers', :input => "build/test/partials/a_test/#{name}.hpp", :name => name, :partial => true, :include_path => "drivers/#{name}.hpp" ),
2286
+ :testable => @testable, :name => name.to_sym
2287
+ ) }
2288
+ @state.mocks_list.replace( [partial.( 'Mockbar' ), partial.( 'MockMockbar' )] )
2289
+ listing()
2290
+ allow(@file_wrapper).to receive(:directory_listing).with( "#{@root}/**/*.hpp" ).and_return( ["#{@root}/drivers/Mockbar.hpp", "#{@root}/drivers/MockMockbar.hpp"] )
2291
+
2292
+ expect(@file_wrapper).to_not receive(:rm_f)
2293
+
2294
+ @executor.stage_prune_header_copies( @state )
2295
+ end
2296
+
2297
+ # A header can't be its own mock
2298
+ it "prunes nothing named without a prefix or a suffix" do
2299
+ allow(@configurator).to receive(:cmock_mock_prefix).and_return( '' )
2300
+ listing( 'drivers/foo.h' )
2301
+
2302
+ expect(@file_wrapper).to_not receive(:rm_f)
2303
+
2304
+ @executor.stage_prune_header_copies( @state )
2305
+ end
2306
+
2307
+ # Every file below a test's mock root is its own, whatever tests the project holds
2308
+ it "prunes a copy in a folder named like a test nested below this one" do
2309
+ allow(@configurator).to receive(:collection_all_tests).and_return( ['test/a_test.c', 'test/a_test/test_x.c'] )
2310
+ listing( 'drivers/Mockfoo.h', 'drivers/foo.h', 'test_x/drivers/Mockfoo.h', 'test_x/drivers/foo.h' )
2311
+
2312
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/drivers/foo.h" )
2313
+ expect(@file_wrapper).to receive(:rm_f).with( "#{@root}/test_x/drivers/foo.h" )
2314
+
2315
+ @executor.stage_prune_header_copies( @state )
2316
+ end
2317
+
2318
+ it "consults no other test's mock root" do
2319
+ listing( 'drivers/Mockfoo.h', 'drivers/foo.h' )
2320
+
2321
+ expect(@configurator).to_not receive(:collection_all_tests)
2322
+
2323
+ @executor.stage_prune_header_copies( @state )
2324
+ end
2325
+ end
2326
+
2327
+ # Stage 4 preprocesses a test through its mock root, before any mock is planned
2328
+ context "#stage_hold_header_copies" do
2329
+ before(:each) do
2330
+ allow(@configurator).to receive(:cmock_mock_prefix).and_return( 'mock_' )
2331
+ allow(@configurator).to receive(:cmock_mock_suffix).and_return( '' )
2332
+ allow(@configurator).to receive(:extension_header).and_return( FilenameExtension.new( '.h' ) )
2333
+ allow(@file_wrapper).to receive(:mv)
2334
+
2335
+ @root = 'build/test/mocks/a_test/_t_'
2336
+ @testable = TestInvokerTypes::Testable.new( :name => 'a_test', :paths => { :mocks => @root } )
2337
+ @state = TestInvokerTypes::PipelineState.new( :testables => { :a_test => @testable }, :mocks_list => [], :lock => Mutex.new, :context => :test, :options => [] )
2338
+ end
2339
+
2340
+ def listing(*paths)
2341
+ allow(@file_wrapper).to receive(:directory_listing).with( "#{@root}/**/*.h" ).and_return( paths.map { |path| File.join( @root, path ) } )
2342
+ end
2343
+
2344
+ # Stage 4 places a stand-in where the mock was, which includes the real header by a text
2345
+ # that reaches it
2346
+ it "sets aside each copy and the mock beside it under names no search finds" do
2347
+ listing( 'drivers/mock_bar.h', 'drivers/bar.h', 'drivers/notes.h' )
2348
+
2349
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/drivers/bar.h", "#{@root}/drivers/bar.h.held" )
2350
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/drivers/mock_bar.h", "#{@root}/drivers/mock_bar.h.held_mock" )
2351
+ expect(@file_wrapper).to_not receive(:mv).with( "#{@root}/drivers/notes.h", anything )
2352
+
2353
+ @executor.stage_hold_header_copies( @state )
2354
+ end
2355
+
2356
+ # Every file below a test's mock root is its own, whatever tests the project holds
2357
+ it "sets aside a copy in a folder named like a test nested below this one" do
2358
+ allow(@configurator).to receive(:collection_all_tests).and_return( ['test/a_test.c', 'test/a_test/test_x.c'] )
2359
+ listing( 'test_x/drivers/mock_bar.h', 'test_x/drivers/bar.h' )
2360
+
2361
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/test_x/drivers/bar.h", "#{@root}/test_x/drivers/bar.h.held" )
2362
+ expect(@file_wrapper).to receive(:mv).with( "#{@root}/test_x/drivers/mock_bar.h", "#{@root}/test_x/drivers/mock_bar.h.held_mock" )
2363
+
2364
+ @executor.stage_hold_header_copies( @state )
2365
+ end
2366
+
2367
+ it "consults no other test's mock root" do
2368
+ listing( 'drivers/mock_bar.h', 'drivers/bar.h' )
2369
+
2370
+ expect(@configurator).to_not receive(:collection_all_tests)
2371
+
2372
+ @executor.stage_hold_header_copies( @state )
2373
+ end
2374
+ end
2375
+
1762
2376
  context "#tailor_search_paths" do
1763
2377
  PROJECT_BUILD_VENDOR_CMOCK_PATH = 'build/vendor/cmock' unless defined?(PROJECT_BUILD_VENDOR_CMOCK_PATH)
1764
2378
  PROJECT_BUILD_VENDOR_CEXCEPTION_PATH = 'build/vendor/cexception' unless defined?(PROJECT_BUILD_VENDOR_CEXCEPTION_PATH)