ceedling 1.2.1 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (545) hide show
  1. checksums.yaml +4 -4
  2. data/GIT_COMMIT_SHA +1 -1
  3. data/README.md +11 -9
  4. data/Rakefile +2 -1
  5. data/assets/features/ceedling +1 -1
  6. data/assets/fixtures/test_source_file_duplicate_basenames/test_calc_typo.c +14 -0
  7. data/assets/fixtures/tests_with_duplicate_test_names/test_foo.c +21 -0
  8. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
  9. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
  10. data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
  11. data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
  12. data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
  13. data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
  14. data/bin/actionator.rb +6 -12
  15. data/bin/app_cfg.rb +14 -1
  16. data/bin/ceedling +13 -3
  17. data/bin/cli.rb +25 -6
  18. data/bin/cli_handler.rb +113 -73
  19. data/bin/cli_helper.rb +51 -78
  20. data/bin/installation_selector.rb +81 -0
  21. data/bin/launchinator.rb +69 -0
  22. data/bin/mixin_resolvinator.rb +26 -36
  23. data/bin/objects.yml +13 -0
  24. data/bin/path_validator.rb +25 -29
  25. data/bin/versionator.rb +47 -48
  26. data/ceedling.gemspec +19 -15
  27. data/docs/BreakingChanges.md +86 -1
  28. data/docs/Changelog.md +145 -3
  29. data/docs/KnownIssues.md +179 -6
  30. data/docs/ReleaseNotes.md +13 -0
  31. data/examples/wondrous_forest/README.md +29 -1
  32. data/examples/wondrous_forest/src/ForestUnits.h +23 -0
  33. data/examples/wondrous_forest/src/RainGauge.c +59 -0
  34. data/examples/wondrous_forest/src/RainGauge.h +39 -0
  35. data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
  36. data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
  37. data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
  38. data/lib/ceedling/build_log_writer.rb +33 -0
  39. data/lib/ceedling/c_extractor/README.md +15 -7
  40. data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
  41. data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
  42. data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
  43. data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
  44. data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
  45. data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
  46. data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
  47. data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
  48. data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
  49. data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
  50. data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
  51. data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
  52. data/lib/ceedling/c_identifier.rb +21 -0
  53. data/lib/ceedling/ceedling.h +8 -0
  54. data/lib/ceedling/config/build_root_policy.rb +70 -0
  55. data/lib/ceedling/config/configurator.rb +18 -19
  56. data/lib/ceedling/config/configurator_builder.rb +75 -28
  57. data/lib/ceedling/config/configurator_paths_validator.rb +179 -0
  58. data/lib/ceedling/config/configurator_plugins.rb +1 -1
  59. data/lib/ceedling/config/configurator_setup.rb +44 -33
  60. data/lib/ceedling/config/configurator_validator.rb +1 -110
  61. data/lib/ceedling/constants.rb +5 -1
  62. data/lib/ceedling/defaults.rb +35 -5
  63. data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
  64. data/lib/ceedling/dependencies/README.md +18 -16
  65. data/lib/ceedling/dependencies/dependency_cache_store.rb +43 -21
  66. data/lib/ceedling/dependencies/dependency_hasher.rb +35 -1
  67. data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
  68. data/lib/ceedling/dependencies/dependinator.rb +13 -1
  69. data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
  70. data/lib/ceedling/diagnostics/README.md +5 -0
  71. data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
  72. data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
  73. data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
  74. data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
  75. data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
  76. data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
  77. data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
  78. data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
  79. data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
  80. data/lib/ceedling/filename_extension.rb +7 -1
  81. data/lib/ceedling/filesystem/FILE_TREE.md +253 -0
  82. data/lib/ceedling/filesystem/PATH_HANDLING.md +360 -0
  83. data/lib/ceedling/filesystem/README.md +46 -0
  84. data/lib/ceedling/filesystem/build_roots.rb +105 -0
  85. data/lib/ceedling/filesystem/build_subpath.rb +187 -0
  86. data/lib/ceedling/filesystem/destination_collision.rb +25 -0
  87. data/lib/ceedling/{file_finder.rb → filesystem/file_finder.rb} +177 -156
  88. data/lib/ceedling/filesystem/file_finder_helper.rb +154 -0
  89. data/lib/ceedling/filesystem/file_path_collection_utils.rb +183 -0
  90. data/lib/ceedling/{file_path_utils.rb → filesystem/file_path_utils.rb} +200 -167
  91. data/lib/ceedling/{file_system_wrapper.rb → filesystem/file_system_wrapper.rb} +6 -5
  92. data/lib/ceedling/filesystem/file_tree.rb +241 -0
  93. data/lib/ceedling/{file_wrapper.rb → filesystem/file_wrapper.rb} +149 -65
  94. data/lib/ceedling/filesystem/path_exclusions.rb +30 -0
  95. data/lib/ceedling/{path_matcher.rb → filesystem/path_matcher.rb} +48 -23
  96. data/lib/ceedling/{path_mirror.rb → filesystem/path_mirror.rb} +19 -18
  97. data/lib/ceedling/filesystem/path_spellings.rb +55 -0
  98. data/lib/ceedling/filesystem/project_paths.rb +184 -0
  99. data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
  100. data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
  101. data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
  102. data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
  103. data/lib/ceedling/filesystem/working_dir.rb +40 -0
  104. data/lib/ceedling/generators/generator.rb +32 -70
  105. data/lib/ceedling/generators/generator_helper.rb +0 -44
  106. data/lib/ceedling/generators/generator_mocks.rb +5 -0
  107. data/lib/ceedling/generators/generator_partials.rb +306 -244
  108. data/lib/ceedling/generators/generator_test_results_backtrace.rb +7 -7
  109. data/lib/ceedling/generators/generator_test_runner.rb +5 -8
  110. data/lib/ceedling/generators/partial_header_writer.rb +95 -0
  111. data/lib/ceedling/generators/partial_source_writer.rb +137 -0
  112. data/lib/ceedling/handoff.rb +121 -0
  113. data/lib/ceedling/includes/header_search.rb +225 -0
  114. data/lib/ceedling/includes/include_factory.rb +9 -12
  115. data/lib/ceedling/includes/include_pathinator.rb +112 -33
  116. data/lib/ceedling/includes/includes.rb +150 -38
  117. data/lib/ceedling/installation.rb +92 -0
  118. data/lib/ceedling/library_resolver.rb +99 -0
  119. data/lib/ceedling/objects.yml +112 -6
  120. data/lib/ceedling/partials/README.md +110 -16
  121. data/lib/ceedling/partials/carry_plan.rb +71 -0
  122. data/lib/ceedling/partials/definition_head.rb +74 -0
  123. data/lib/ceedling/partials/include_groups.rb +37 -0
  124. data/lib/ceedling/partials/interface_extras.rb +25 -0
  125. data/lib/ceedling/partials/partializer.rb +603 -124
  126. data/lib/ceedling/partials/partializer_config.rb +8 -1
  127. data/lib/ceedling/partials/partializer_helper.rb +851 -145
  128. data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
  129. data/lib/ceedling/partials/partializer_utils.rb +89 -109
  130. data/lib/ceedling/partials/partials.rb +153 -10
  131. data/lib/ceedling/partials/type_macros.rb +126 -0
  132. data/lib/ceedling/plugins/report_log_writer_plugin.rb +3 -5
  133. data/lib/ceedling/preprocess/README.md +43 -33
  134. data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
  135. data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
  136. data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +32 -76
  137. data/lib/ceedling/preprocess/preprocessinator_includes_handler.rb +1 -1
  138. data/lib/ceedling/preprocess/preprocessinator_line_marker_includes_extractor.rb +1 -1
  139. data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
  140. data/lib/ceedling/rake_app/rakefile_component_resolver.rb +10 -17
  141. data/lib/ceedling/rakefile.rb +15 -1
  142. data/lib/ceedling/rakefiles/base/tasks_base.rake +1 -1
  143. data/lib/ceedling/rakefiles/release/rules_release.rake +4 -7
  144. data/lib/ceedling/release_invoker/release_build_executor.rb +33 -44
  145. data/lib/ceedling/release_invoker/release_build_planner.rb +14 -6
  146. data/lib/ceedling/reportinator.rb +3 -4
  147. data/lib/ceedling/setupinator.rb +104 -87
  148. data/lib/ceedling/test_context_extractor.rb +5 -1
  149. data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
  150. data/lib/ceedling/test_invoker/PIPELINE.md +62 -19
  151. data/lib/ceedling/test_invoker/README.md +1 -1
  152. data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
  153. data/lib/ceedling/test_invoker/mock_locator.rb +175 -10
  154. data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
  155. data/lib/ceedling/test_invoker/partials_manager.rb +271 -302
  156. data/lib/ceedling/test_invoker/standin_headerinator.rb +19 -17
  157. data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
  158. data/lib/ceedling/test_invoker/test_build_executor.rb +358 -234
  159. data/lib/ceedling/test_invoker/test_build_planner.rb +46 -33
  160. data/lib/ceedling/test_invoker/test_build_setup.rb +43 -18
  161. data/lib/ceedling/test_invoker/test_build_validations.rb +35 -47
  162. data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
  163. data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +2 -3
  164. data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
  165. data/lib/ceedling/test_invoker/test_invoker.rb +6 -1
  166. data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
  167. data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +6 -4
  168. data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
  169. data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
  170. data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
  171. data/lib/ceedling/test_invoker/test_source_file_directive_resolver.rb +40 -20
  172. data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
  173. data/lib/ceedling/tools/shell_quoting.rb +45 -0
  174. data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +9 -3
  175. data/lib/ceedling/tools/tool_quoting.rb +79 -0
  176. data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
  177. data/lib/ceedling/yaml_wrapper.rb +3 -2
  178. data/lib/version.rb +1 -1
  179. data/plugins/bullseye/bullseye.rake +1 -3
  180. data/plugins/bullseye/config/defaults_bullseye.rb +1 -1
  181. data/plugins/bullseye/lib/bullseye.rb +24 -9
  182. data/plugins/command_hooks/lib/command_hooks.rb +1 -1
  183. data/plugins/cppcheck/config/defaults_cppcheck.rb +1 -1
  184. data/plugins/dependencies/config/defaults.yml +6 -6
  185. data/plugins/dependencies/dependencies.rake +4 -1
  186. data/plugins/dependencies/lib/dependencies.rb +18 -8
  187. data/plugins/dependencies/lib/dependency_spec.rb +17 -5
  188. data/plugins/fff/lib/fff.rb +79 -46
  189. data/plugins/fff/lib/fff_mock_generator.rb +12 -9
  190. data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +262 -0
  191. data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
  192. data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
  193. data/plugins/gcov/config/defaults_gcov.rb +1 -1
  194. data/plugins/gcov/lib/console_reportinator.rb +28 -36
  195. data/plugins/gcov/lib/gcov.rb +9 -2
  196. data/plugins/gcov/lib/gcovr_reportinator.rb +8 -40
  197. data/plugins/gcov/lib/gcovr_thresholds.rb +74 -0
  198. data/plugins/gcov/lib/reportgenerator_reportinator.rb +3 -2
  199. data/plugins/module_generator/lib/module_generator.rb +3 -3
  200. data/plugins/report_tests_teamcity_stdout/lib/report_tests_teamcity_stdout.rb +53 -80
  201. data/plugins/sanitize/lib/sanitize_records.rb +3 -6
  202. data/plugins/valgrind/lib/valgrind.rb +14 -7
  203. data/site-local/404.html +2 -2
  204. data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
  205. data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
  206. data/site-local/configuration/environment-vars.html +2 -2
  207. data/site-local/configuration/global-collections.html +3 -3
  208. data/site-local/configuration/index.html +2 -2
  209. data/site-local/configuration/loading.html +2 -2
  210. data/site-local/configuration/mixins.html +2 -2
  211. data/site-local/configuration/parallel-builds.html +2 -2
  212. data/site-local/configuration/project-file.html +2 -2
  213. data/site-local/configuration/reference/cexception.html +2 -2
  214. data/site-local/configuration/reference/cmock.html +7 -3
  215. data/site-local/configuration/reference/defines.html +2 -2
  216. data/site-local/configuration/reference/environment.html +2 -2
  217. data/site-local/configuration/reference/extension.html +2 -2
  218. data/site-local/configuration/reference/files.html +65 -12
  219. data/site-local/configuration/reference/flags.html +2 -2
  220. data/site-local/configuration/reference/index.html +2 -2
  221. data/site-local/configuration/reference/libraries.html +23 -5
  222. data/site-local/configuration/reference/mixins.html +2 -2
  223. data/site-local/configuration/reference/partials.html +84 -2
  224. data/site-local/configuration/reference/paths.html +36 -8
  225. data/site-local/configuration/reference/plugins.html +2 -2
  226. data/site-local/configuration/reference/project.html +264 -12
  227. data/site-local/configuration/reference/release-build.html +4 -2
  228. data/site-local/configuration/reference/test-build.html +2 -2
  229. data/site-local/configuration/reference/test-runner.html +2 -2
  230. data/site-local/configuration/reference/tools.html +58 -4
  231. data/site-local/configuration/reference/unity.html +2 -2
  232. data/site-local/configuration/which-ceedling.html +379 -19
  233. data/site-local/development/index.html +2 -2
  234. data/site-local/development/plugins/configuration.html +2 -2
  235. data/site-local/development/plugins/index.html +2 -2
  236. data/site-local/development/plugins/plugin-subclass.html +5 -4
  237. data/site-local/development/plugins/rake-tasks.html +2 -2
  238. data/site-local/development/releases.html +7 -3
  239. data/site-local/development/workflow.html +50 -45
  240. data/site-local/getting-started/builds.html +4 -2
  241. data/site-local/getting-started/command-line.html +58 -6
  242. data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
  243. data/site-local/getting-started/example-projects/index.html +2 -2
  244. data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
  245. data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
  246. data/site-local/getting-started/index.html +2 -2
  247. data/site-local/getting-started/installation.html +2 -2
  248. data/site-local/getting-started/quick-start.html +2 -2
  249. data/site-local/help.html +2 -2
  250. data/site-local/index.html +2 -2
  251. data/site-local/overview/build-system.html +2 -2
  252. data/site-local/overview/index.html +2 -2
  253. data/site-local/overview/test-environments.html +2 -2
  254. data/site-local/overview/tools-and-frameworks.html +2 -2
  255. data/site-local/plugins/beep.html +2 -2
  256. data/site-local/plugins/bullseye/index.html +45 -38
  257. data/site-local/plugins/bullseye/licensing.html +2 -2
  258. data/site-local/plugins/command-hooks.html +4 -4
  259. data/site-local/plugins/compile-commands-json-db.html +2 -2
  260. data/site-local/plugins/cppcheck.html +2 -2
  261. data/site-local/plugins/dependencies.html +8 -5
  262. data/site-local/plugins/fff.html +58 -13
  263. data/site-local/plugins/gcov/examples.html +2 -2
  264. data/site-local/plugins/gcov/gcovr.html +23 -14
  265. data/site-local/plugins/gcov/index.html +2 -2
  266. data/site-local/plugins/gcov/overview.html +2 -2
  267. data/site-local/plugins/gcov/reportgenerator.html +18 -14
  268. data/site-local/plugins/gcov/reporting.html +2 -2
  269. data/site-local/plugins/gcov/setup.html +4 -3
  270. data/site-local/plugins/gcov/tool-versions.html +2 -2
  271. data/site-local/plugins/gcov/troubleshooting.html +2 -2
  272. data/site-local/plugins/index.html +2 -2
  273. data/site-local/plugins/module-generator.html +2 -2
  274. data/site-local/plugins/report-build-warnings-log.html +2 -2
  275. data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
  276. data/site-local/plugins/report-tests-ide-stdout.html +2 -2
  277. data/site-local/plugins/report-tests-log-factory.html +2 -2
  278. data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
  279. data/site-local/plugins/report-tests-raw-output-log.html +5 -3
  280. data/site-local/plugins/report-tests-teamcity-stdout.html +8 -5
  281. data/site-local/plugins/sanitize.html +9 -8
  282. data/site-local/plugins/valgrind.html +10 -9
  283. data/site-local/project/index.html +2 -2
  284. data/site-local/project/release-history.html +2 -2
  285. data/site-local/project/sbom.html +2 -2
  286. data/site-local/project/upgrade.html +5 -2
  287. data/site-local/reference/build-directives.html +2 -2
  288. data/site-local/reference/command-line.html +11 -4
  289. data/site-local/reference/environment-vars.html +2 -2
  290. data/site-local/reference/gcov-plugin.html +2 -2
  291. data/site-local/reference/global-collections.html +12 -12
  292. data/site-local/reference/index.html +2 -2
  293. data/site-local/reference/partials-macros.html +47 -2
  294. data/site-local/reference/project-configuration.html +2 -2
  295. data/site-local/sitemap.xml.gz +0 -0
  296. data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
  297. data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
  298. data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
  299. data/site-local/snapshot/plugins/bullseye/config/defaults_bullseye.rb +1 -1
  300. data/site-local/snapshot/plugins/gcov/config/defaults_gcov.rb +1 -1
  301. data/site-local/testing-guide/build-directives.html +2 -2
  302. data/site-local/testing-guide/conventions.html +113 -15
  303. data/site-local/testing-guide/frameworks.html +2 -2
  304. data/site-local/testing-guide/index.html +2 -2
  305. data/site-local/testing-guide/partials/configuration.html +31 -4
  306. data/site-local/testing-guide/partials/conventions.html +509 -8
  307. data/site-local/testing-guide/partials/directives.html +4 -3
  308. data/site-local/testing-guide/partials/example.html +2 -2
  309. data/site-local/testing-guide/partials/index.html +2 -2
  310. data/site-local/testing-guide/partials/overview.html +30 -12
  311. data/site-local/testing-guide/partials/variables.html +169 -4
  312. data/site-local/testing-guide/test-cases.html +2 -2
  313. data/site-local/testing-guide/test-sample.html +2 -2
  314. data/site-local/testing-guide/test-suite-anatomy.html +2 -2
  315. data/spec/integration/actionator_file_operations_spec.rb +91 -1
  316. data/spec/integration/build_step_doctor_spec.rb +270 -0
  317. data/spec/integration/c_extractor_composition_spec.rb +254 -4
  318. data/spec/integration/compile_commands_json_db_spec.rb +1 -1
  319. data/spec/integration/configurator_validation_spec.rb +1 -1
  320. data/spec/integration/dependencies/dependency_tracker_cache_hardening_spec.rb +26 -0
  321. data/spec/integration/dependencies/dependency_tracker_core_spec.rb +22 -0
  322. data/spec/integration/includes_extraction_spec.rb +27 -14
  323. data/spec/integration/launcher_handoff_spec.rb +297 -0
  324. data/spec/integration/mixin_loading_spec.rb +1 -1
  325. data/spec/integration/module_generator_spec.rb +3 -3
  326. data/spec/integration/nested_test_artifacts_spec.rb +99 -0
  327. data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
  328. data/spec/integration/partials_carry_spec.rb +520 -0
  329. data/spec/integration/partials_declarations_spec.rb +655 -0
  330. data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
  331. data/spec/integration/partials_function_pointers_spec.rb +277 -0
  332. data/spec/integration/partials_header_composition_spec.rb +268 -35
  333. data/spec/integration/partials_macro_decorators_spec.rb +267 -0
  334. data/spec/integration/partials_module_resolution_spec.rb +33 -23
  335. data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
  336. data/spec/integration/path_intake_scenarios_spec.rb +101 -0
  337. data/spec/integration/path_length_reporting_spec.rb +64 -0
  338. data/spec/integration/path_scenarios_spec.rb +399 -0
  339. data/spec/integration/quote_include_isolator_spec.rb +57 -1
  340. data/spec/integration/report_build_warnings_log_spec.rb +1 -1
  341. data/spec/integration/report_tests_log_factory_spec.rb +1 -1
  342. data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
  343. data/spec/integration/test_executable_manifest_spec.rb +1 -1
  344. data/spec/integration/test_includes_extractinator_spec.rb +69 -3
  345. data/spec/integration/test_naming_spec.rb +201 -0
  346. data/spec/integration/test_source_file_checks_spec.rb +168 -0
  347. data/spec/integration/tool_executor_spec.rb +1 -1
  348. data/spec/integration/tool_validator_spec.rb +3 -3
  349. data/spec/integration/upgrade_docs_spec.rb +84 -0
  350. data/spec/integration/vendor_copy_transient_io_retry_spec.rb +74 -5
  351. data/spec/integration/win_long_paths_probe_spec.rb +46 -0
  352. data/spec/integration/win_path_limit_spec.rb +53 -0
  353. data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
  354. data/spec/support/file_tree_helper.rb +88 -0
  355. data/spec/support/integration/configurator_integration_helper.rb +14 -9
  356. data/spec/support/integration/dependency_tracker_integration_helper.rb +1 -1
  357. data/spec/support/integration/partial_files_harness.rb +181 -0
  358. data/spec/support/integration/partials_generation_integration_helper.rb +239 -143
  359. data/spec/support/integration/path_scenario_harness.rb +175 -0
  360. data/spec/support/integration/spec_integration_helper.rb +9 -4
  361. data/spec/support/integration/test_includes_harness.rb +69 -37
  362. data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
  363. data/spec/support/spec_helper.rb +2 -0
  364. data/spec/support/system/spec_system_helper.rb +7 -6
  365. data/spec/support/system/system_context.rb +21 -3
  366. data/spec/support/working_dir_tracking.rb +49 -0
  367. data/spec/system/build_output_mirroring_spec.rb +2 -2
  368. data/spec/system/bullseye_deployment_spec.rb +2 -0
  369. data/spec/system/conditional_mock_includes_spec.rb +1 -1
  370. data/spec/system/delta_builds_spec.rb +163 -23
  371. data/spec/system/encoding_stress_spec.rb +4 -4
  372. data/spec/system/example_wondrous_forest_spec.rb +2 -2
  373. data/spec/system/gcov_deployment_spec.rb +3 -0
  374. data/spec/system/header_include_path_validation_spec.rb +4 -4
  375. data/spec/system/header_search_paths_spec.rb +1083 -0
  376. data/spec/system/launcher_handoff_spec.rb +82 -0
  377. data/spec/system/mock_include_folders_spec.rb +212 -0
  378. data/spec/system/mockable_header_reassembly_spec.rb +184 -0
  379. data/spec/system/parent_directory_reference_spec.rb +5 -3
  380. data/spec/system/partials_carry_spec.rb +581 -0
  381. data/spec/system/partials_delta_builds_spec.rb +280 -0
  382. data/spec/system/partials_function_pointers_spec.rb +106 -0
  383. data/spec/system/partials_macro_decorators_spec.rb +127 -0
  384. data/spec/system/partials_module_disambiguation_spec.rb +125 -0
  385. data/spec/system/path_handling_probes_spec.rb +196 -0
  386. data/spec/system/pinned_thread_count_spec.rb +4 -4
  387. data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
  388. data/spec/system/preprocessing_parameterized_tests_spec.rb +1 -1
  389. data/spec/system/rake_release_task_path_disambiguation_spec.rb +6 -6
  390. data/spec/system/rake_test_task_path_disambiguation_spec.rb +85 -0
  391. data/spec/system/short_build_paths_spec.rb +87 -0
  392. data/spec/system/sibling_header_collision_spec.rb +30 -6
  393. data/spec/system/special_path_characters_spec.rb +86 -0
  394. data/spec/system/support/bullseye_common_test_cases.rb +42 -0
  395. data/spec/system/support/common_test_cases.rb +23 -21
  396. data/spec/system/support/gcov_common_test_cases.rb +37 -9
  397. data/spec/system/support/gcov_partials_test_cases.rb +48 -0
  398. data/spec/system/support/sanitize_common_test_cases.rb +2 -2
  399. data/spec/system/support/valgrind_common_test_cases.rb +12 -12
  400. data/spec/system/test_build_layout_spec.rb +209 -0
  401. data/spec/system/test_pipeline_stop_points_spec.rb +4 -4
  402. data/spec/system/test_runner_system_include_spec.rb +1 -1
  403. data/spec/system/test_source_file_directive_spec.rb +64 -5
  404. data/spec/units/bin/actionator_spec.rb +14 -17
  405. data/spec/units/bin/app_cfg_spec.rb +37 -0
  406. data/spec/units/bin/cli_handler_spec.rb +282 -6
  407. data/spec/units/bin/cli_helper_spec.rb +116 -45
  408. data/spec/units/bin/installation_selector_spec.rb +114 -0
  409. data/spec/units/bin/launchinator_spec.rb +171 -0
  410. data/spec/units/bin/path_validator_spec.rb +10 -0
  411. data/spec/units/bin/versionator_spec.rb +38 -6
  412. data/spec/units/build_log_writer_spec.rb +57 -0
  413. data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
  414. data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
  415. data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
  416. data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
  417. data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
  418. data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
  419. data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
  420. data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
  421. data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
  422. data/spec/units/c_identifier_spec.rb +35 -0
  423. data/spec/units/config/build_root_policy_spec.rb +61 -0
  424. data/spec/units/config/configurator_builder_spec.rb +61 -6
  425. data/spec/units/config/configurator_paths_validator_spec.rb +292 -0
  426. data/spec/units/config/configurator_setup_spec.rb +80 -68
  427. data/spec/units/config/configurator_spec.rb +54 -6
  428. data/spec/units/config/configurator_validator_spec.rb +1 -172
  429. data/spec/units/dependencies/dependency_cache_store_spec.rb +98 -2
  430. data/spec/units/dependencies/dependency_debug_tree_spec.rb +1 -1
  431. data/spec/units/dependencies/dependency_hasher_spec.rb +42 -1
  432. data/spec/units/dependencies/dependency_path_normalizer_spec.rb +1 -1
  433. data/spec/units/dependencies/dependency_tracker_spec.rb +28 -1
  434. data/spec/units/dependencies/dependinator_spec.rb +17 -2
  435. data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
  436. data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
  437. data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
  438. data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
  439. data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
  440. data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
  441. data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
  442. data/spec/units/encodinator_spec.rb +3 -4
  443. data/spec/units/filename_extension_spec.rb +11 -0
  444. data/spec/units/filesystem/build_roots_spec.rb +131 -0
  445. data/spec/units/filesystem/build_subpath_spec.rb +235 -0
  446. data/spec/units/filesystem/destination_collision_spec.rb +30 -0
  447. data/spec/units/{file_finder_helper_spec.rb → filesystem/file_finder_helper_spec.rb} +126 -1
  448. data/spec/units/filesystem/file_finder_spec.rb +845 -0
  449. data/spec/units/{file_path_collection_utils_spec.rb → filesystem/file_path_collection_utils_spec.rb} +181 -1
  450. data/spec/units/{file_path_utils_spec.rb → filesystem/file_path_utils_spec.rb} +435 -185
  451. data/spec/units/filesystem/file_system_wrapper_spec.rb +33 -0
  452. data/spec/units/filesystem/file_tree_spec.rb +511 -0
  453. data/spec/units/filesystem/file_tree_windows_spec.rb +78 -0
  454. data/spec/units/{file_wrapper_spec.rb → filesystem/file_wrapper_spec.rb} +286 -18
  455. data/spec/units/{path_matcher_spec.rb → filesystem/path_matcher_spec.rb} +48 -1
  456. data/spec/units/{path_mirror_spec.rb → filesystem/path_mirror_spec.rb} +32 -4
  457. data/spec/units/filesystem/project_paths_spec.rb +147 -0
  458. data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
  459. data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
  460. data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
  461. data/spec/units/filesystem/working_dir_spec.rb +71 -0
  462. data/spec/units/generators/generator_helper_spec.rb +0 -60
  463. data/spec/units/generators/generator_mocks_spec.rb +13 -0
  464. data/spec/units/generators/generator_partials_spec.rb +656 -55
  465. data/spec/units/generators/generator_spec.rb +38 -6
  466. data/spec/units/generators/generator_test_results_backtrace_spec.rb +50 -46
  467. data/spec/units/generators/generator_test_results_spec.rb +1 -1
  468. data/spec/units/generators/generator_test_runner_spec.rb +9 -5
  469. data/spec/units/generators/partial_source_writer_spec.rb +129 -0
  470. data/spec/units/handoff_spec.rb +205 -0
  471. data/spec/units/includes/header_search_spec.rb +406 -0
  472. data/spec/units/includes/include_factory_spec.rb +23 -6
  473. data/spec/units/includes/include_pathinator_spec.rb +118 -8
  474. data/spec/units/includes/include_spec.rb +14 -0
  475. data/spec/units/includes/includes_spec.rb +176 -19
  476. data/spec/units/installation_spec.rb +228 -0
  477. data/spec/units/library_resolver_spec.rb +157 -0
  478. data/spec/units/loginator_spec.rb +31 -0
  479. data/spec/units/mock_locator_spec.rb +275 -6
  480. data/spec/units/partials/include_groups_spec.rb +42 -0
  481. data/spec/units/partials/partializer_config_spec.rb +32 -0
  482. data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
  483. data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
  484. data/spec/units/partials/partializer_helper_spec.rb +529 -277
  485. data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
  486. data/spec/units/partials/partializer_spec.rb +1579 -270
  487. data/spec/units/partials/partializer_utils_spec.rb +269 -232
  488. data/spec/units/partials/partials_rename_spec.rb +160 -0
  489. data/spec/units/partials_manager_spec.rb +561 -251
  490. data/spec/units/plugins/bullseye_spec.rb +49 -2
  491. data/spec/units/plugins/console_reportinator_spec.rb +73 -26
  492. data/spec/units/plugins/dependencies_spec.rb +33 -7
  493. data/spec/units/plugins/dependency_spec_spec.rb +17 -0
  494. data/spec/units/plugins/gcov_spec.rb +28 -3
  495. data/spec/units/plugins/gcovr_reportinator_spec.rb +19 -47
  496. data/spec/units/plugins/gcovr_thresholds_spec.rb +95 -0
  497. data/spec/units/plugins/module_generator_spec.rb +5 -5
  498. data/spec/units/plugins/report_build_warnings_log_spec.rb +3 -3
  499. data/spec/units/plugins/report_log_writer_plugin_spec.rb +10 -1
  500. data/spec/units/plugins/report_tests_raw_output_log_spec.rb +13 -2
  501. data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +77 -3
  502. data/spec/units/plugins/reportgenerator_reportinator_spec.rb +52 -4
  503. data/spec/units/plugins/sanitize_records_spec.rb +3 -1
  504. data/spec/units/plugins/sanitize_spec.rb +1 -1
  505. data/spec/units/plugins/valgrind_spec.rb +23 -8
  506. data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
  507. data/spec/units/preprocess/preprocessinator_comment_stripper_spec.rb +1 -1
  508. data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
  509. data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
  510. data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
  511. data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
  512. data/spec/units/rake_app/rakefile_component_resolver_spec.rb +21 -0
  513. data/spec/units/release_build_executor_spec.rb +53 -14
  514. data/spec/units/release_build_planner_spec.rb +15 -3
  515. data/spec/units/reportinator_spec.rb +5 -5
  516. data/spec/units/setupinator_spec.rb +51 -0
  517. data/spec/units/standin_headerinator_spec.rb +55 -9
  518. data/spec/units/test_build_executor_spec.rb +842 -166
  519. data/spec/units/test_build_planner_spec.rb +205 -15
  520. data/spec/units/test_build_setup_spec.rb +179 -30
  521. data/spec/units/test_context_extractor_spec.rb +36 -2
  522. data/spec/units/test_derived_search_paths_spec.rb +259 -0
  523. data/spec/units/test_file_preprocessinator_spec.rb +17 -1
  524. data/spec/units/test_includes_extractinator_spec.rb +61 -9
  525. data/spec/units/test_invoker/objects_wiring_spec.rb +24 -4
  526. data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
  527. data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
  528. data/spec/units/test_invoker_spec.rb +14 -1
  529. data/spec/units/test_invoker_types_spec.rb +8 -7
  530. data/spec/units/test_pipeline_manager_spec.rb +54 -13
  531. data/spec/units/test_runner_generatinator_spec.rb +93 -1
  532. data/spec/units/test_search_paths_spec.rb +73 -5
  533. data/spec/units/test_source_file_directive_resolver_spec.rb +38 -7
  534. data/spec/units/tools/default_tools_quoting_spec.rb +117 -0
  535. data/spec/units/tools/shell_quoting_spec.rb +76 -0
  536. data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
  537. data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +27 -1
  538. data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
  539. data/spec/units/windows_registry_query_tool_spec.rb +53 -0
  540. data/spec/units/yaml_wrapper_spec.rb +11 -0
  541. metadata +265 -36
  542. data/lib/ceedling/file_finder_helper.rb +0 -127
  543. data/lib/ceedling/file_path_collection_utils.rb +0 -164
  544. data/spec/units/file_finder_spec.rb +0 -495
  545. /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
@@ -9,10 +9,12 @@ require 'spec_helper'
9
9
  require 'ceedling/filename_extension'
10
10
  require 'rake'
11
11
  require 'ceedling/test_invoker/test_build_executor'
12
+ require 'ceedling/test_invoker/mock_locator'
12
13
  require 'ceedling/test_invoker/test_invoker_types'
13
14
  require 'ceedling/partials/partials'
14
15
  require 'ceedling/test_context_extractor'
15
16
  require 'ceedling/quote_include_isolator'
17
+ require 'ceedling/test_invoker/test_substitutions'
16
18
 
17
19
  PROJECT_BUILD_VENDOR_UNITY_PATH = 'build/vendor/unity' unless defined?(PROJECT_BUILD_VENDOR_UNITY_PATH)
18
20
  UNITY_C_FILE = 'unity.c' unless defined?(UNITY_C_FILE)
@@ -34,7 +36,9 @@ describe TestBuildExecutor do
34
36
  @test_source_file_directive_resolver = double( "TestSourceFileDirectiveResolver" )
35
37
  @gcc_dependency_parser = double( "GccDependencyParser" )
36
38
  @quote_include_isolator = double( "QuoteIncludeIsolator" )
37
- @generator_helper = double( "GeneratorHelper" )
39
+ @build_step_doctor = double( "BuildStepDoctor" )
40
+ @library_resolver = double( "LibraryResolver" )
41
+ @test_search_paths = double( "TestSearchPaths" )
38
42
 
39
43
  @tools_test_compiler = { name: 'fake compiler' }
40
44
  @tools_test_assembler = { name: 'fake assembler' }
@@ -42,6 +46,7 @@ describe TestBuildExecutor do
42
46
  @tools_test_fixture = { name: 'fake fixture' }
43
47
  @tools_test_bare_includes_preprocessor = { name: 'fake bare includes preprocessor' }
44
48
  @tools_test_file_directives_only_preprocessor = { name: 'fake directives-only preprocessor' }
49
+ @tools_test_file_full_preprocessor = { name: 'fake full preprocessor' }
45
50
  @tools_test_backtrace_gdb = { name: 'fake gdb backtrace' }
46
51
  @tools_test_fixture_simple_backtrace = { name: 'fake simple backtrace' }
47
52
 
@@ -53,6 +58,7 @@ describe TestBuildExecutor do
53
58
  allow(@configurator).to receive(:tools_test_fixture).and_return( @tools_test_fixture )
54
59
  allow(@configurator).to receive(:tools_test_bare_includes_preprocessor).and_return( @tools_test_bare_includes_preprocessor )
55
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 )
56
62
  # tools_test_backtrace_gdb is deliberately NOT stubbed here -- the real Configurator
57
63
  # only defines it at all when :use_backtrace is :gdb (see test_build_executor.rb's
58
64
  # own comment at its one call site), so leaving it unstubbed here means any example
@@ -79,7 +85,8 @@ describe TestBuildExecutor do
79
85
  # The real literal scan over the doubled file layer, so each example's read stubs decide it
80
86
  real_isolator = QuoteIncludeIsolator.new( { :file_wrapper => @file_wrapper, :loginator => @loginator } )
81
87
  allow(@quote_include_isolator).to receive(:includes_by_name?) { |file, name| real_isolator.includes_by_name?( file, name ) }
82
- 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 }
83
90
 
84
91
  allow(@reportinator).to receive(:generate_module_progress).and_return( '' )
85
92
  allow(@reportinator).to receive(:generate_progress).and_return( '' )
@@ -107,6 +114,8 @@ describe TestBuildExecutor do
107
114
  allow(@dependinator).to receive(:stale?).and_return( true )
108
115
  allow(@dependinator).to receive(:mark_fresh)
109
116
  allow(@test_source_file_directive_resolver).to receive(:validate!)
117
+ allow(@library_resolver).to receive(:link_files).and_return( [] )
118
+ allow(@library_resolver).to receive(:search_path_arguments).and_return( [] )
110
119
 
111
120
  @executor = described_class.new(
112
121
  {
@@ -123,7 +132,14 @@ describe TestBuildExecutor do
123
132
  :dependinator => @dependinator,
124
133
  :gcc_dependency_parser => @gcc_dependency_parser,
125
134
  :quote_include_isolator => @quote_include_isolator,
126
- :generator_helper => @generator_helper
135
+ :test_substitutions => TestSubstitutions.new( configurator: @configurator ),
136
+ :build_step_doctor => @build_step_doctor,
137
+ :library_resolver => @library_resolver,
138
+ :test_search_paths => @test_search_paths,
139
+ :mock_locator => MockLocator.new(
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
142
+ )
127
143
  }
128
144
  )
129
145
 
@@ -146,7 +162,7 @@ describe TestBuildExecutor do
146
162
  # stubbed to synchronously yield every `things` entry to the given block,
147
163
  # matching its real per-item iteration contract without pulling in Parallel.
148
164
  def stub_batchinator_exec
149
- allow(@batchinator).to receive(:exec) do |workload:, things:, &block|
165
+ allow(@batchinator).to receive(:exec) do |things:, **, &block|
150
166
  things.each { |k, v| block.call(k, v) }
151
167
  end
152
168
  end
@@ -316,14 +332,6 @@ describe TestBuildExecutor do
316
332
  )
317
333
  end
318
334
 
319
- # A test's own file compile is the one point where its full, transitive dependency
320
- # closure is freshly known -- reached headers a mock or Partial never sees directly,
321
- # since substitution only ever looks at what the test file itself #includes. When
322
- # that closure reveals a real header sharing a directory with one this test mocks or
323
- # Partializes, quote-include's own same-directory-first rule could let that real
324
- # content slip past the substitution entirely; isolating the sibling and retrying
325
- # with corrected search paths closes that gap without ever touching the original
326
- # compile's own registered dependencies.
327
335
  # A source beside a header mocked under :treat_inlines :include would find the real
328
336
  # header first and run its inline bodies. It compiles from an isolated copy instead.
329
337
  context "a source sharing a directory with a header mocked with inline shadowing" do
@@ -455,8 +463,18 @@ describe TestBuildExecutor do
455
463
  end
456
464
  end
457
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.
458
474
  context "sibling-header isolation retry" do
459
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 )
460
478
  allow(@file_wrapper).to receive(:extname).with( 'test/a_test.c' ).and_return( '.c' )
461
479
  allow(@configurator).to receive(:test_build_use_assembly).and_return( false )
462
480
  allow(@file_wrapper).to receive(:exist_with_retry?).with( 'build/deps' ).and_return( true )
@@ -484,7 +502,7 @@ describe TestBuildExecutor do
484
502
 
485
503
  it "retries the compile with corrected search paths when a sibling risk is found, and clears an initial failure" do
486
504
  allow(@quote_include_isolator).to receive(:isolate)
487
- .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 )
488
506
  .and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
489
507
 
490
508
  ex = ShellException.new( shell_result: { output: 'redeclaration of struct gpio' }, name: 'compiler' )
@@ -503,7 +521,7 @@ describe TestBuildExecutor do
503
521
 
504
522
  expect( @generator ).to have_received( :generate_object_file_c ).twice
505
523
  expect( @state.testables[:a_test].search_paths ).to include( 'build/test/out/a_test/isolated_headers/xyz' )
506
- 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' )
507
525
  end
508
526
 
509
527
  it "retries against a separate, throwaway dependencies path, and registers only the original .d file" do
@@ -598,7 +616,7 @@ describe TestBuildExecutor do
598
616
  it "applies whatever isolation the existing .d file already reveals even when this object is not stale" do
599
617
  allow(@dependinator).to receive(:stale?).with( 'build/foo.o' ).and_return( false )
600
618
  allow(@quote_include_isolator).to receive(:isolate)
601
- .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 )
602
620
  .and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
603
621
 
604
622
  expect(@generator).to_not receive(:generate_object_file_c)
@@ -609,7 +627,7 @@ describe TestBuildExecutor do
609
627
  )
610
628
 
611
629
  expect( @state.testables[:a_test].search_paths ).to include( 'build/test/out/a_test/isolated_headers/xyz' )
612
- 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' )
613
631
  end
614
632
 
615
633
  it "does not attempt isolation on a skip when there is no existing .d file yet" do
@@ -627,10 +645,9 @@ describe TestBuildExecutor do
627
645
 
628
646
  # A Partial's own generated content never gives isolation an alternative same-named
629
647
  # file for a search path to fall through to, so a redeclaration/conflicting-types
630
- # failure can survive every attempt here. Logging the likely cause alongside the raw
631
- # compiler error, rather than raising it bare, is the deliberate fallback for exactly
632
- # that case -- and for any other collision isolation doesn't resolve.
633
- 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
634
651
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
635
652
  { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
636
653
  )
@@ -638,28 +655,30 @@ describe TestBuildExecutor do
638
655
  ex = ShellException.new( shell_result: { output: 'redeclaration of struct gpio' }, name: 'compiler' )
639
656
  allow(@generator).to receive(:generate_object_file_c).and_raise( ex )
640
657
 
641
- allow(@generator_helper).to receive(:explain_possible_mock_partial_collision)
642
- .with( output: 'redeclaration of struct gpio', mocked_headers: { 'gpio.h' => '/project/library/gpio.h' } )
643
- .and_return( 'explanatory notice text' )
644
-
645
- expect(@loginator).to receive(:log).with( 'explanatory notice text', Verbosity::ERRORS, LogLabels::NOTICE )
646
-
647
658
  expect {
648
659
  @executor.send(
649
660
  :compile_test_component,
650
661
  :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
651
662
  )
652
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
+ )
653
673
  end
654
674
 
655
- 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
656
678
  allow(@quote_include_isolator).to receive(:isolate).and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
657
679
 
658
680
  ex = ShellException.new( shell_result: { output: 'redeclaration of struct gpio' }, name: 'compiler' )
659
681
  allow(@generator).to receive(:generate_object_file_c).and_raise( ex )
660
- allow(@generator_helper).to receive(:explain_possible_mock_partial_collision).and_return( 'explanatory notice text' )
661
-
662
- expect(@loginator).to receive(:log).with( 'explanatory notice text', Verbosity::ERRORS, LogLabels::NOTICE )
663
682
 
664
683
  expect {
665
684
  @executor.send(
@@ -667,23 +686,87 @@ describe TestBuildExecutor do
667
686
  :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
668
687
  )
669
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
+ )
670
694
  end
671
695
 
672
- it "logs nothing extra when generator_helper finds no explanation" do
673
- allow(@gcc_dependency_parser).to receive(:parse).and_return(
674
- { '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
675
703
  )
676
- ex = ShellException.new( shell_result: { output: 'totally unrelated failure' }, name: 'compiler' )
677
- allow(@generator).to receive(:generate_object_file_c).and_raise( ex )
678
704
 
679
- 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
680
708
 
681
- expect {
682
- @executor.send(
683
- :compile_test_component,
684
- :context => :test, :test => :a_test, :source => 'test/a_test.c', :object => 'build/foo.o', :state => @state
685
- )
686
- }.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' )
687
770
  end
688
771
  end
689
772
  end
@@ -696,6 +779,9 @@ describe TestBuildExecutor do
696
779
  :paths => { build: 'build/test/out/a_test' }
697
780
  )
698
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 )
699
785
  allow(@file_wrapper).to receive(:read).with( 'build/deps' ).and_return( '' )
700
786
  end
701
787
 
@@ -759,15 +845,14 @@ describe TestBuildExecutor do
759
845
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
760
846
  { 'a.o' => ['test/a_test.c', '/project/library/gpio.h', '/project/library/driverlib.h'] }
761
847
  )
848
+ isolation = isolation_in( 'build/test/out/a_test/isolated_headers/xyz' )
762
849
  allow(@quote_include_isolator).to receive(:isolate)
763
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
764
- .and_return( isolation_in( 'build/test/out/a_test/isolated_headers/xyz' ) )
765
-
766
- result = call_it()
850
+ .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'], preserve_location: true )
851
+ .and_return( isolation )
767
852
 
768
- expect( result ).to eq(
769
- search_paths: ['build/test/out/a_test/isolated_headers/xyz', 'test/support'],
770
- 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
771
856
  )
772
857
  end
773
858
 
@@ -796,7 +881,9 @@ describe TestBuildExecutor do
796
881
  expect( call_it() ).to be_nil
797
882
  end
798
883
 
799
- 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
800
887
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
801
888
  {
802
889
  'a.o' => [
@@ -806,79 +893,42 @@ describe TestBuildExecutor do
806
893
  }
807
894
  )
808
895
  allow(@quote_include_isolator).to receive(:isolate)
809
- .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 )
810
897
  .and_return( isolation_in( 'isolated/dir' ) )
811
898
 
812
- expect(@loginator).to receive(:log).with(
813
- a_string_including( '/project/other/x.h' ).and( a_string_including( '/project/other/y.h' ) ),
814
- Verbosity::COMPLAIN, LogLabels::NOTICE
815
- )
816
-
817
899
  result = call_it()
818
900
 
819
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 )
820
903
  end
821
904
 
822
- it "logs nothing at all when there is no risk anywhere in the dependency list" do
823
- allow(@gcc_dependency_parser).to receive(:parse).and_return(
824
- { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
825
- )
826
-
827
- expect(@loginator).to_not receive(:log).with( anything, anything, LogLabels::NOTICE )
828
-
829
- call_it()
830
- end
831
-
832
- # This test's own mocks output directory routinely holds several generated files
833
- # side by side (a mock's own interface header, and -- when :treat_inlines: :include
834
- # is configured -- a same-basename shadow of the real header too), and Unity's own
835
- # vendor directory ships more than one header as a matter of course. Neither is a
836
- # real project header directory a quote-include could ambiguously resolve within,
837
- # so neither belongs in the "worth investigating" heads-up.
838
- it "does not report co-resident files inside this test's own mocks output directory or a vendor framework directory" do
839
- @testable.paths = { build: 'build/test/out/a_test', mocks: 'build/test/mocks/a_test' }
840
-
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 )
841
909
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
842
- {
843
- 'a.o' => [
844
- 'test/a_test.c', '/project/library/gpio.h',
845
- 'build/test/mocks/a_test/mock_gpio.h', 'build/test/mocks/a_test/gpio.h',
846
- PROJECT_BUILD_VENDOR_UNITY_PATH + '/unity.h', PROJECT_BUILD_VENDOR_UNITY_PATH + '/unity_internals.h'
847
- ]
848
- }
910
+ { 'a.o' => ['test/a_test.c', '/project/library/gpio.h', '/project/library/driverlib.h'] }
849
911
  )
850
912
 
851
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::COMPLAIN, anything )
852
-
853
- call_it()
913
+ expect(@quote_include_isolator).to_not receive(:isolate)
914
+ expect( call_it() ).to be_nil
854
915
  end
855
916
 
856
- # A test's own Partials output directory is shaped exactly the same way as its
857
- # mocks output directory -- several generated headers (a types header, an
858
- # interface header, and more) routinely sit side by side there, one set per
859
- # Partialized module, none of it a real project header.
860
- it "does not report co-resident files inside this test's own Partials output directory" do
861
- @testable.paths = { build: 'build/test/out/a_test', partials: 'build/test/partials/a_test' }
862
-
917
+ it "logs nothing at all when there is no risk anywhere in the dependency list" do
863
918
  allow(@gcc_dependency_parser).to receive(:parse).and_return(
864
- {
865
- 'a.o' => [
866
- 'test/a_test.c', '/project/library/gpio.h',
867
- 'build/test/partials/a_test/ceedling_partial_moduleA_impl.h',
868
- 'build/test/partials/a_test/ceedling_partial_gpio_interface.h',
869
- 'build/test/partials/a_test/ceedling_partial_gpio_types.h'
870
- ]
871
- }
919
+ { 'a.o' => ['test/a_test.c', '/project/library/gpio.h'] }
872
920
  )
873
921
 
874
- expect(@loginator).to_not receive(:log).with( anything, Verbosity::COMPLAIN, anything )
922
+ expect(@loginator).to_not receive(:log).with( anything, anything, LogLabels::NOTICE )
875
923
 
876
924
  call_it()
877
925
  end
878
926
  end
879
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
880
930
  context "with a Partialized header" do
881
- 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
882
932
  @testable.partials = TestInvokerTypes::TestablePartials.new(
883
933
  configs: { moduleA: double( "PartialConfig", header: double( "HeaderFile", filepath: '/project/library/moduleA.h' ) ) },
884
934
  tests: [], mocks: []
@@ -889,11 +939,9 @@ describe TestBuildExecutor do
889
939
  )
890
940
  allow(@file_wrapper).to receive(:exist?).with( '/project/library/driverlib.h' ).and_return( true )
891
941
  allow(@file_wrapper).to receive(:read).with( '/project/library/driverlib.h' ).and_return( "#include \"moduleA.h\"\n" )
892
- allow(@quote_include_isolator).to receive(:isolate)
893
- .with( parent: 'build/test/out/a_test', files: ['/project/library/driverlib.h'] )
894
- .and_return( isolation_in( 'isolated/dir' ) )
895
942
 
896
- expect( call_it() ).to_not be_nil
943
+ expect(@quote_include_isolator).to_not receive(:isolate)
944
+ expect( call_it() ).to be_nil
897
945
  end
898
946
  end
899
947
  end
@@ -964,7 +1012,7 @@ describe TestBuildExecutor do
964
1012
  end
965
1013
 
966
1014
  it "removes a testable's isolated headers directory once, after both batches complete" do
967
- @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' )
968
1016
  allow(@dependinator).to receive(:stale?).and_return( false )
969
1017
 
970
1018
  expect(@quote_include_isolator).to receive(:release).with( 'build/test/out/a_test/isolated_headers/xyz' ).once
@@ -972,6 +1020,17 @@ describe TestBuildExecutor do
972
1020
  @executor.stage_build_objects( @state )
973
1021
  end
974
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
+
975
1034
  it "attempts no cleanup for a testable that never isolated anything" do
976
1035
  allow(@dependinator).to receive(:stale?).and_return( false )
977
1036
 
@@ -1059,12 +1118,42 @@ describe TestBuildExecutor do
1059
1118
  expect(@dependinator).to receive(:register).with(
1060
1119
  'build/a_test.out',
1061
1120
  files: ['build/foo.o'],
1062
- meta: { flags: [], lib_args: [], lib_paths: [], tools: [@tools_test_linker] }
1121
+ meta: { flags: [], lib_args: [], lib_paths: [], tools: [@tools_test_linker], objects: ['build/foo.o'], libraries: [] }
1122
+ )
1123
+
1124
+ @executor.stage_build_executables( @state )
1125
+ end
1126
+
1127
+ # GH #1368: a library rebuilt under the same name changed nothing a link registered
1128
+ it "registers the library files its libraries resolve to, as files and as meta" do
1129
+ allow(@dependinator).to receive(:stale?).and_return( false )
1130
+ allow(@configurator).to receive(:project_config_hash).and_return( { libraries_test: ['x'] } )
1131
+ stub_const( 'LIBRARIES_SYSTEM', ['m', 'fusion'] )
1132
+
1133
+ expect(@library_resolver).to receive(:link_files).with( ['x', 'm', 'fusion'] ).and_return( ['vendor/lib/libx.a', 'build/deps/libfusion.so.1'] )
1134
+ expect(@dependinator).to receive(:register).with(
1135
+ 'build/a_test.out',
1136
+ files: ['build/foo.o', 'vendor/lib/libx.a', 'build/deps/libfusion.so.1'],
1137
+ meta: hash_including( libraries: ['vendor/lib/libx.a', 'build/deps/libfusion.so.1'] )
1063
1138
  )
1064
1139
 
1065
1140
  @executor.stage_build_executables( @state )
1066
1141
  end
1067
1142
 
1143
+ # Staleness checks only the objects registered this build, so an object dropped from the
1144
+ # link changes nothing they see. The list itself, as meta, does change (a source deleted,
1145
+ # excluded, or moved out of the configured paths).
1146
+ it "registers the objects it links as meta, as a plain list" do
1147
+ allow(@dependinator).to receive(:stale?).and_return( false )
1148
+ @testable.objects = FileList.new.tap { |list| list << 'build/foo.o' }
1149
+
1150
+ expect(@dependinator).to receive(:register).with( 'build/a_test.out', files: ['build/foo.o'], meta: hash_including( objects: ['build/foo.o'] ) ) do |_, meta:, **|
1151
+ expect(meta[:objects]).to be_an_instance_of( Array )
1152
+ end
1153
+
1154
+ @executor.stage_build_executables( @state )
1155
+ end
1156
+
1068
1157
  it "logs a summary line stating how many executables were recalled from cache" do
1069
1158
  allow(@dependinator).to receive(:stale?).and_return( false )
1070
1159
 
@@ -1078,7 +1167,7 @@ describe TestBuildExecutor do
1078
1167
  context "#generate_executable" do
1079
1168
  before(:each) do
1080
1169
  allow(@file_path_utils).to receive(:form_test_build_map_filepath).and_return( 'build/map' )
1081
- allow(@configurator).to receive(:project_use_mocks).and_return( false )
1170
+ @testable = @state.testables[:a_test]
1082
1171
  end
1083
1172
 
1084
1173
  def build_args
@@ -1090,64 +1179,30 @@ describe TestBuildExecutor do
1090
1179
  flags: [],
1091
1180
  lib_args: [],
1092
1181
  lib_paths: [],
1093
- tool: { name: 'fake linker' }
1182
+ tool: { name: 'fake linker' },
1183
+ testable: @testable
1094
1184
  }
1095
1185
  end
1096
1186
 
1097
- it "re-raises a ShellException from the linker" do
1098
- ex = ShellException.new( shell_result: { output: 'some unrelated linker failure' }, name: 'linker' )
1099
- allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1100
- allow(@loginator).to receive(:log)
1101
-
1102
- expect {
1103
- @executor.generate_executable( **build_args )
1104
- }.to raise_error( ShellException )
1105
- end
1106
-
1107
- 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
1108
1188
  ex = ShellException.new( shell_result: { output: 'undefined reference to symbol foo' }, name: 'linker' )
1109
1189
  allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1110
1190
 
1111
- expect(@loginator).to receive(:log).with(
1112
- a_string_matching(/missing symbols/i),
1113
- Verbosity::COMPLAIN,
1114
- LogLabels::NOTICE
1115
- )
1116
-
1117
- expect {
1118
- @executor.generate_executable( **build_args )
1119
- }.to raise_error( ShellException )
1120
- end
1121
-
1122
- it "does not log guidance when the shell output does not mention a symbol" do
1123
- ex = ShellException.new( shell_result: { output: 'some unrelated linker failure' }, name: 'linker' )
1124
- allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1125
-
1126
- expect(@loginator).to_not receive(:log)
1127
-
1128
1191
  expect {
1129
1192
  @executor.generate_executable( **build_args )
1130
- }.to raise_error( ShellException )
1131
- end
1193
+ }.to raise_error( ex )
1132
1194
 
1133
- it "includes mock-specific guidance only when the project uses mocks" do
1134
- ex = ShellException.new( shell_result: { output: 'missing symbol foo' }, name: 'linker' )
1135
- allow(@generator).to receive(:generate_executable_file).and_raise( ex )
1136
- allow(@configurator).to receive(:project_use_mocks).and_return( true )
1137
-
1138
- expect(@loginator).to receive(:log).with(
1139
- a_string_matching(/needed mocks/i),
1140
- Verbosity::COMPLAIN,
1141
- 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
+ }
1142
1201
  )
1143
-
1144
- expect {
1145
- @executor.generate_executable( **build_args )
1146
- }.to raise_error( ShellException )
1147
1202
  end
1148
1203
 
1149
- it "does not raise when the linker succeeds" do
1150
- 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
1151
1206
 
1152
1207
  expect { @executor.generate_executable( **build_args ) }.to_not raise_error
1153
1208
  end
@@ -1450,6 +1505,85 @@ describe TestBuildExecutor do
1450
1505
  :directives_only_filepath => nil
1451
1506
  )
1452
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
1453
1587
  end
1454
1588
 
1455
1589
  it "preprocesses and marks fresh the mockable header when the dependency tracker reports it stale" do
@@ -1460,6 +1594,17 @@ describe TestBuildExecutor do
1460
1594
  @executor.stage_preprocess_mocks( @state )
1461
1595
  end
1462
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
+
1463
1608
  it "skips preprocessing the mockable header when the dependency tracker reports it unchanged" do
1464
1609
  allow(@dependinator).to receive(:stale?).and_return( false )
1465
1610
  expect(@preprocessinator).to_not receive(:preprocess_mockable_header_file)
@@ -1477,7 +1622,7 @@ describe TestBuildExecutor do
1477
1622
  @executor.stage_preprocess_mocks( @state )
1478
1623
  end
1479
1624
 
1480
- 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
1481
1626
  allow(@preprocessinator).to receive(:preprocess_mockable_header_file)
1482
1627
 
1483
1628
  expect(@dependinator).to receive(:register).with(
@@ -1485,7 +1630,7 @@ describe TestBuildExecutor do
1485
1630
  files: ['src/Foo.h'],
1486
1631
  meta: {
1487
1632
  flags: [], defines: [], search_paths: [], extras: false,
1488
- 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],
1489
1634
  preprocess_force_fallback: false
1490
1635
  }
1491
1636
  )
@@ -1506,16 +1651,43 @@ describe TestBuildExecutor do
1506
1651
  @executor.stage_preprocess_mocks( @state )
1507
1652
  end
1508
1653
 
1509
- 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 )
1510
1657
  @state.mocks_list.first.details.partial = true
1511
- 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 )
1512
1672
  allow(@preprocessinator).to receive(:preprocess_mockable_header_file)
1673
+ allow(@loginator).to receive(:log)
1513
1674
 
1514
- expect(@dependinator).to receive(:register).with(
1515
- 'build/preprocess/MockFoo.h',
1516
- files: anything,
1517
- meta: hash_including( extras: false )
1518
- )
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
1519
1691
 
1520
1692
  @executor.stage_preprocess_mocks( @state )
1521
1693
  end
@@ -1528,7 +1700,11 @@ describe TestBuildExecutor do
1528
1700
  allow(@configurator).to receive(:project_config_hash).and_return( {} )
1529
1701
  allow(@configurator).to receive(:get_cmock_config).and_return( { mock_prefix: 'Mock' } )
1530
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 )
1531
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)
1532
1708
  # Where a mock's files sit is composed in one shared place, so the stage that
1533
1709
  # compiles a mock and the stage that generates it cannot disagree.
1534
1710
  allow(@file_path_utils).to receive(:form_mock_output_path) do |root, subdir|
@@ -1565,6 +1741,40 @@ describe TestBuildExecutor do
1565
1741
  @executor.stage_generate_mocks( @state )
1566
1742
  end
1567
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
+
1568
1778
  it "logs a summary line stating how many mocks were recalled from cache" do
1569
1779
  allow(@dependinator).to receive(:stale?).and_return( false )
1570
1780
 
@@ -1593,6 +1803,40 @@ describe TestBuildExecutor do
1593
1803
  @executor.stage_generate_mocks( @state )
1594
1804
  end
1595
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
+
1596
1840
  it "registers CMock's actual configuration as meta, not project_config_hash's flattened (and therefore always-empty) :cmock entry" do
1597
1841
  # project_config_hash is flattened -- CMock's settings live there as individual
1598
1842
  # top-level keys like :cmock_mock_prefix, never as a :cmock section -- so a
@@ -1607,13 +1851,116 @@ describe TestBuildExecutor do
1607
1851
  expect(@dependinator).to receive(:register).with(
1608
1852
  'build/test/mocks/sub/MockFoo.c',
1609
1853
  files: anything,
1610
- meta: { cmock: { mock_prefix: 'Custom' } },
1854
+ meta: hash_including( cmock: { mock_prefix: 'Custom' } ),
1611
1855
  outputs: anything
1612
1856
  )
1613
1857
 
1614
1858
  @executor.stage_generate_mocks( @state )
1615
1859
  end
1616
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
+
1617
1964
  it "generates an ordinary mock with no configuration override" do
1618
1965
  allow(@dependinator).to receive(:stale?).and_return( true )
1619
1966
  allow(@dependinator).to receive(:mark_fresh)
@@ -1633,6 +1980,67 @@ describe TestBuildExecutor do
1633
1980
  @executor.stage_generate_mocks( @state )
1634
1981
  end
1635
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
+
1636
2044
  # CMock and the runner both name a mock by the folder its #include names. CMock writes
1637
2045
  # below its own root at that folder, so the folder must also end the mock's directory.
1638
2046
  context "naming a mock by its #include's folder" do
@@ -1658,7 +2066,7 @@ describe TestBuildExecutor do
1658
2066
  include_as( 'sub/MockFoo.h' )
1659
2067
 
1660
2068
  expect(@generator).to receive(:generate_mock)
1661
- .with( hash_including( output_path: 'build/test/mocks/sub', folder: 'sub' ) )
2069
+ .with( hash_including( output_path: 'build/test/mocks/sub', mock_root: 'build/test/mocks', folder: 'sub' ) )
1662
2070
 
1663
2071
  @executor.stage_generate_mocks( @state )
1664
2072
  end
@@ -1685,6 +2093,52 @@ describe TestBuildExecutor do
1685
2093
  @executor.stage_generate_mocks( @state )
1686
2094
  end
1687
2095
 
2096
+ # The path handling audit around GH #1370: a folder that climbs must not carry the
2097
+ # mock out of its test's mocks directory
2098
+ it "G14: keeps the mock below its test's mocks directory for a folder that climbs" do
2099
+ include_as( '../x/MockFoo.h' )
2100
+
2101
+ expect(@generator).to receive(:generate_mock) do |args|
2102
+ expect(args[:output_path].split( '/' )).to_not include( '..' )
2103
+ end
2104
+
2105
+ @executor.stage_generate_mocks( @state )
2106
+ end
2107
+
2108
+ # The compiler finds the mock as written only through CMock's root, so it must exist
2109
+ it "roots CMock as deep as a climbing folder climbs, and makes that root" do
2110
+ include_as( '../x/MockFoo.h' )
2111
+
2112
+ expect(@file_wrapper).to receive(:mkdir).with( 'build/test/mocks/_up_/x' )
2113
+ expect(@file_wrapper).to receive(:mkdir).with( 'build/test/mocks/_up_/_up_' )
2114
+ expect(@generator).to receive(:generate_mock)
2115
+ .with( hash_including( output_path: 'build/test/mocks/_up_/x', mock_root: 'build/test/mocks/_up_/_up_', folder: '../x' ) )
2116
+
2117
+ @executor.stage_generate_mocks( @state )
2118
+ end
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
+
1688
2142
  it "passes no folder when :mock_name_include_folder is disabled" do
1689
2143
  allow(@configurator).to receive(:cmock_mock_name_include_folder).and_return( false )
1690
2144
  include_as( 'sub/MockFoo.h' )
@@ -1697,6 +2151,228 @@ describe TestBuildExecutor do
1697
2151
  end
1698
2152
  end
1699
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
+
1700
2376
  context "#tailor_search_paths" do
1701
2377
  PROJECT_BUILD_VENDOR_CMOCK_PATH = 'build/vendor/cmock' unless defined?(PROJECT_BUILD_VENDOR_CMOCK_PATH)
1702
2378
  PROJECT_BUILD_VENDOR_CEXCEPTION_PATH = 'build/vendor/cexception' unless defined?(PROJECT_BUILD_VENDOR_CEXCEPTION_PATH)