ceedling 1.2.2 → 1.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. checksums.yaml +4 -4
  2. data/GIT_COMMIT_SHA +1 -1
  3. data/README.md +1 -1
  4. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
  5. data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
  6. data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
  7. data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
  8. data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
  9. data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
  10. data/docs/BreakingChanges.md +16 -0
  11. data/docs/Changelog.md +71 -0
  12. data/docs/KnownIssues.md +91 -4
  13. data/examples/wondrous_forest/README.md +29 -1
  14. data/examples/wondrous_forest/src/ForestUnits.h +23 -0
  15. data/examples/wondrous_forest/src/RainGauge.c +59 -0
  16. data/examples/wondrous_forest/src/RainGauge.h +39 -0
  17. data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
  18. data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
  19. data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
  20. data/lib/ceedling/c_extractor/README.md +15 -7
  21. data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
  22. data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
  23. data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
  24. data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
  25. data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
  26. data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
  27. data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
  28. data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
  29. data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
  30. data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
  31. data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
  32. data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
  33. data/lib/ceedling/c_identifier.rb +21 -0
  34. data/lib/ceedling/ceedling.h +8 -0
  35. data/lib/ceedling/config/configurator.rb +4 -3
  36. data/lib/ceedling/config/configurator_builder.rb +17 -0
  37. data/lib/ceedling/config/configurator_setup.rb +29 -5
  38. data/lib/ceedling/constants.rb +5 -1
  39. data/lib/ceedling/defaults.rb +31 -1
  40. data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
  41. data/lib/ceedling/dependencies/README.md +1 -1
  42. data/lib/ceedling/dependencies/dependency_cache_store.rb +30 -25
  43. data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
  44. data/lib/ceedling/dependencies/dependinator.rb +13 -1
  45. data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
  46. data/lib/ceedling/diagnostics/README.md +5 -0
  47. data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
  48. data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
  49. data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
  50. data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
  51. data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
  52. data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
  53. data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
  54. data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
  55. data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
  56. data/lib/ceedling/filesystem/PATH_HANDLING.md +83 -27
  57. data/lib/ceedling/filesystem/README.md +6 -1
  58. data/lib/ceedling/filesystem/build_roots.rb +105 -0
  59. data/lib/ceedling/filesystem/build_subpath.rb +110 -25
  60. data/lib/ceedling/filesystem/file_finder.rb +76 -110
  61. data/lib/ceedling/filesystem/file_finder_helper.rb +33 -11
  62. data/lib/ceedling/filesystem/file_path_utils.rb +113 -91
  63. data/lib/ceedling/filesystem/file_wrapper.rb +105 -28
  64. data/lib/ceedling/filesystem/path_matcher.rb +21 -0
  65. data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
  66. data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
  67. data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
  68. data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
  69. data/lib/ceedling/generators/generator.rb +27 -64
  70. data/lib/ceedling/generators/generator_helper.rb +0 -44
  71. data/lib/ceedling/generators/generator_mocks.rb +5 -0
  72. data/lib/ceedling/generators/generator_partials.rb +305 -243
  73. data/lib/ceedling/generators/generator_test_runner.rb +5 -8
  74. data/lib/ceedling/generators/partial_header_writer.rb +95 -0
  75. data/lib/ceedling/generators/partial_source_writer.rb +137 -0
  76. data/lib/ceedling/includes/header_search.rb +225 -0
  77. data/lib/ceedling/includes/include_factory.rb +9 -12
  78. data/lib/ceedling/includes/include_pathinator.rb +53 -31
  79. data/lib/ceedling/includes/includes.rb +149 -37
  80. data/lib/ceedling/objects.yml +89 -4
  81. data/lib/ceedling/partials/README.md +110 -16
  82. data/lib/ceedling/partials/carry_plan.rb +71 -0
  83. data/lib/ceedling/partials/definition_head.rb +74 -0
  84. data/lib/ceedling/partials/include_groups.rb +37 -0
  85. data/lib/ceedling/partials/interface_extras.rb +25 -0
  86. data/lib/ceedling/partials/partializer.rb +599 -120
  87. data/lib/ceedling/partials/partializer_config.rb +5 -0
  88. data/lib/ceedling/partials/partializer_helper.rb +851 -145
  89. data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
  90. data/lib/ceedling/partials/partializer_utils.rb +89 -109
  91. data/lib/ceedling/partials/partials.rb +153 -10
  92. data/lib/ceedling/partials/type_macros.rb +126 -0
  93. data/lib/ceedling/preprocess/README.md +43 -33
  94. data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
  95. data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
  96. data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +31 -75
  97. data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
  98. data/lib/ceedling/setupinator.rb +16 -3
  99. data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
  100. data/lib/ceedling/test_invoker/PIPELINE.md +57 -16
  101. data/lib/ceedling/test_invoker/README.md +1 -1
  102. data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
  103. data/lib/ceedling/test_invoker/mock_locator.rb +116 -9
  104. data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
  105. data/lib/ceedling/test_invoker/partials_manager.rb +265 -308
  106. data/lib/ceedling/test_invoker/standin_headerinator.rb +8 -15
  107. data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
  108. data/lib/ceedling/test_invoker/test_build_executor.rb +338 -198
  109. data/lib/ceedling/test_invoker/test_build_planner.rb +13 -19
  110. data/lib/ceedling/test_invoker/test_build_setup.rb +26 -6
  111. data/lib/ceedling/test_invoker/test_build_validations.rb +23 -20
  112. data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
  113. data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +1 -2
  114. data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
  115. data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
  116. data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +5 -3
  117. data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
  118. data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
  119. data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
  120. data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
  121. data/lib/ceedling/tools/shell_quoting.rb +45 -0
  122. data/lib/ceedling/tools/tool_quoting.rb +79 -0
  123. data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
  124. data/lib/version.rb +1 -1
  125. data/plugins/bullseye/bullseye.rake +1 -3
  126. data/plugins/bullseye/lib/bullseye.rb +15 -2
  127. data/plugins/command_hooks/lib/command_hooks.rb +1 -1
  128. data/plugins/fff/lib/fff.rb +42 -15
  129. data/plugins/fff/lib/fff_mock_generator.rb +12 -9
  130. data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +134 -0
  131. data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
  132. data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
  133. data/plugins/gcov/lib/console_reportinator.rb +25 -19
  134. data/plugins/gcov/lib/reportgenerator_reportinator.rb +2 -1
  135. data/site-local/404.html +2 -2
  136. data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
  137. data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
  138. data/site-local/configuration/environment-vars.html +2 -2
  139. data/site-local/configuration/global-collections.html +3 -3
  140. data/site-local/configuration/index.html +2 -2
  141. data/site-local/configuration/loading.html +2 -2
  142. data/site-local/configuration/mixins.html +2 -2
  143. data/site-local/configuration/parallel-builds.html +2 -2
  144. data/site-local/configuration/project-file.html +2 -2
  145. data/site-local/configuration/reference/cexception.html +2 -2
  146. data/site-local/configuration/reference/cmock.html +5 -2
  147. data/site-local/configuration/reference/defines.html +2 -2
  148. data/site-local/configuration/reference/environment.html +2 -2
  149. data/site-local/configuration/reference/extension.html +2 -2
  150. data/site-local/configuration/reference/files.html +56 -9
  151. data/site-local/configuration/reference/flags.html +2 -2
  152. data/site-local/configuration/reference/index.html +2 -2
  153. data/site-local/configuration/reference/libraries.html +2 -2
  154. data/site-local/configuration/reference/mixins.html +2 -2
  155. data/site-local/configuration/reference/partials.html +84 -2
  156. data/site-local/configuration/reference/paths.html +7 -2
  157. data/site-local/configuration/reference/plugins.html +2 -2
  158. data/site-local/configuration/reference/project.html +247 -5
  159. data/site-local/configuration/reference/release-build.html +2 -2
  160. data/site-local/configuration/reference/test-build.html +2 -2
  161. data/site-local/configuration/reference/test-runner.html +2 -2
  162. data/site-local/configuration/reference/tools.html +49 -4
  163. data/site-local/configuration/reference/unity.html +2 -2
  164. data/site-local/configuration/which-ceedling.html +2 -2
  165. data/site-local/development/index.html +2 -2
  166. data/site-local/development/plugins/configuration.html +2 -2
  167. data/site-local/development/plugins/index.html +2 -2
  168. data/site-local/development/plugins/plugin-subclass.html +5 -4
  169. data/site-local/development/plugins/rake-tasks.html +2 -2
  170. data/site-local/development/releases.html +2 -2
  171. data/site-local/development/workflow.html +2 -2
  172. data/site-local/getting-started/builds.html +2 -2
  173. data/site-local/getting-started/command-line.html +2 -2
  174. data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
  175. data/site-local/getting-started/example-projects/index.html +2 -2
  176. data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
  177. data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
  178. data/site-local/getting-started/index.html +2 -2
  179. data/site-local/getting-started/installation.html +2 -2
  180. data/site-local/getting-started/quick-start.html +2 -2
  181. data/site-local/help.html +2 -2
  182. data/site-local/index.html +2 -2
  183. data/site-local/overview/build-system.html +2 -2
  184. data/site-local/overview/index.html +2 -2
  185. data/site-local/overview/test-environments.html +2 -2
  186. data/site-local/overview/tools-and-frameworks.html +2 -2
  187. data/site-local/plugins/beep.html +2 -2
  188. data/site-local/plugins/bullseye/index.html +45 -38
  189. data/site-local/plugins/bullseye/licensing.html +2 -2
  190. data/site-local/plugins/command-hooks.html +4 -4
  191. data/site-local/plugins/compile-commands-json-db.html +2 -2
  192. data/site-local/plugins/cppcheck.html +2 -2
  193. data/site-local/plugins/dependencies.html +2 -2
  194. data/site-local/plugins/fff.html +16 -2
  195. data/site-local/plugins/gcov/examples.html +2 -2
  196. data/site-local/plugins/gcov/gcovr.html +8 -2
  197. data/site-local/plugins/gcov/index.html +2 -2
  198. data/site-local/plugins/gcov/overview.html +2 -2
  199. data/site-local/plugins/gcov/reportgenerator.html +18 -14
  200. data/site-local/plugins/gcov/reporting.html +2 -2
  201. data/site-local/plugins/gcov/setup.html +2 -2
  202. data/site-local/plugins/gcov/tool-versions.html +2 -2
  203. data/site-local/plugins/gcov/troubleshooting.html +2 -2
  204. data/site-local/plugins/index.html +2 -2
  205. data/site-local/plugins/module-generator.html +2 -2
  206. data/site-local/plugins/report-build-warnings-log.html +2 -2
  207. data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
  208. data/site-local/plugins/report-tests-ide-stdout.html +2 -2
  209. data/site-local/plugins/report-tests-log-factory.html +2 -2
  210. data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
  211. data/site-local/plugins/report-tests-raw-output-log.html +2 -2
  212. data/site-local/plugins/report-tests-teamcity-stdout.html +2 -2
  213. data/site-local/plugins/sanitize.html +2 -2
  214. data/site-local/plugins/valgrind.html +2 -2
  215. data/site-local/project/index.html +2 -2
  216. data/site-local/project/release-history.html +2 -2
  217. data/site-local/project/sbom.html +2 -2
  218. data/site-local/project/upgrade.html +2 -2
  219. data/site-local/reference/build-directives.html +2 -2
  220. data/site-local/reference/command-line.html +2 -2
  221. data/site-local/reference/environment-vars.html +2 -2
  222. data/site-local/reference/gcov-plugin.html +2 -2
  223. data/site-local/reference/global-collections.html +12 -12
  224. data/site-local/reference/index.html +2 -2
  225. data/site-local/reference/partials-macros.html +47 -2
  226. data/site-local/reference/project-configuration.html +2 -2
  227. data/site-local/sitemap.xml.gz +0 -0
  228. data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
  229. data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
  230. data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
  231. data/site-local/testing-guide/build-directives.html +2 -2
  232. data/site-local/testing-guide/conventions.html +67 -22
  233. data/site-local/testing-guide/frameworks.html +2 -2
  234. data/site-local/testing-guide/index.html +2 -2
  235. data/site-local/testing-guide/partials/configuration.html +31 -4
  236. data/site-local/testing-guide/partials/conventions.html +509 -8
  237. data/site-local/testing-guide/partials/directives.html +4 -3
  238. data/site-local/testing-guide/partials/example.html +2 -2
  239. data/site-local/testing-guide/partials/index.html +2 -2
  240. data/site-local/testing-guide/partials/overview.html +30 -12
  241. data/site-local/testing-guide/partials/variables.html +169 -4
  242. data/site-local/testing-guide/test-cases.html +2 -2
  243. data/site-local/testing-guide/test-sample.html +2 -2
  244. data/site-local/testing-guide/test-suite-anatomy.html +2 -2
  245. data/spec/integration/build_step_doctor_spec.rb +270 -0
  246. data/spec/integration/c_extractor_composition_spec.rb +254 -4
  247. data/spec/integration/includes_extraction_spec.rb +27 -14
  248. data/spec/integration/nested_test_artifacts_spec.rb +1 -1
  249. data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
  250. data/spec/integration/partials_carry_spec.rb +520 -0
  251. data/spec/integration/partials_declarations_spec.rb +655 -0
  252. data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
  253. data/spec/integration/partials_function_pointers_spec.rb +277 -0
  254. data/spec/integration/partials_header_composition_spec.rb +268 -35
  255. data/spec/integration/partials_macro_decorators_spec.rb +267 -0
  256. data/spec/integration/partials_module_resolution_spec.rb +26 -19
  257. data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
  258. data/spec/integration/path_length_reporting_spec.rb +64 -0
  259. data/spec/integration/path_scenarios_spec.rb +80 -3
  260. data/spec/integration/quote_include_isolator_spec.rb +56 -0
  261. data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
  262. data/spec/integration/test_includes_extractinator_spec.rb +70 -5
  263. data/spec/integration/test_naming_spec.rb +6 -3
  264. data/spec/integration/test_source_file_checks_spec.rb +5 -3
  265. data/spec/integration/tool_executor_spec.rb +1 -1
  266. data/spec/integration/tool_validator_spec.rb +2 -2
  267. data/spec/integration/win_long_paths_probe_spec.rb +46 -0
  268. data/spec/integration/win_path_limit_spec.rb +53 -0
  269. data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
  270. data/spec/support/integration/configurator_integration_helper.rb +8 -3
  271. data/spec/support/integration/partial_files_harness.rb +181 -0
  272. data/spec/support/integration/partials_generation_integration_helper.rb +237 -141
  273. data/spec/support/integration/path_scenario_harness.rb +4 -2
  274. data/spec/support/integration/spec_integration_helper.rb +8 -3
  275. data/spec/support/integration/test_includes_harness.rb +56 -35
  276. data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
  277. data/spec/system/bullseye_deployment_spec.rb +2 -0
  278. data/spec/system/delta_builds_spec.rb +26 -12
  279. data/spec/system/encoding_stress_spec.rb +4 -4
  280. data/spec/system/example_wondrous_forest_spec.rb +2 -2
  281. data/spec/system/gcov_deployment_spec.rb +2 -0
  282. data/spec/system/header_include_path_validation_spec.rb +4 -4
  283. data/spec/system/header_search_paths_spec.rb +1083 -0
  284. data/spec/system/mock_include_folders_spec.rb +121 -0
  285. data/spec/system/mockable_header_reassembly_spec.rb +184 -0
  286. data/spec/system/partials_carry_spec.rb +581 -0
  287. data/spec/system/partials_delta_builds_spec.rb +280 -0
  288. data/spec/system/partials_function_pointers_spec.rb +106 -0
  289. data/spec/system/partials_macro_decorators_spec.rb +127 -0
  290. data/spec/system/partials_module_disambiguation_spec.rb +125 -0
  291. data/spec/system/path_handling_probes_spec.rb +16 -12
  292. data/spec/system/pinned_thread_count_spec.rb +4 -4
  293. data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
  294. data/spec/system/short_build_paths_spec.rb +87 -0
  295. data/spec/system/sibling_header_collision_spec.rb +30 -6
  296. data/spec/system/support/bullseye_common_test_cases.rb +42 -0
  297. data/spec/system/support/common_test_cases.rb +2 -2
  298. data/spec/system/support/gcov_partials_test_cases.rb +48 -0
  299. data/spec/system/test_build_layout_spec.rb +209 -0
  300. data/spec/system/test_source_file_directive_spec.rb +35 -5
  301. data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
  302. data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
  303. data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
  304. data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
  305. data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
  306. data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
  307. data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
  308. data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
  309. data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
  310. data/spec/units/c_identifier_spec.rb +35 -0
  311. data/spec/units/config/configurator_builder_spec.rb +24 -0
  312. data/spec/units/config/configurator_setup_spec.rb +72 -4
  313. data/spec/units/config/configurator_spec.rb +27 -1
  314. data/spec/units/dependencies/dependency_cache_store_spec.rb +68 -3
  315. data/spec/units/dependencies/dependency_tracker_spec.rb +25 -0
  316. data/spec/units/dependencies/dependinator_spec.rb +17 -2
  317. data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
  318. data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
  319. data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
  320. data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
  321. data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
  322. data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
  323. data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
  324. data/spec/units/encodinator_spec.rb +3 -4
  325. data/spec/units/filesystem/build_roots_spec.rb +131 -0
  326. data/spec/units/filesystem/build_subpath_spec.rb +113 -0
  327. data/spec/units/filesystem/file_finder_helper_spec.rb +80 -0
  328. data/spec/units/filesystem/file_finder_spec.rb +242 -58
  329. data/spec/units/filesystem/file_path_utils_spec.rb +251 -118
  330. data/spec/units/filesystem/file_wrapper_spec.rb +191 -6
  331. data/spec/units/filesystem/path_matcher_spec.rb +36 -0
  332. data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
  333. data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
  334. data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
  335. data/spec/units/generators/generator_helper_spec.rb +0 -60
  336. data/spec/units/generators/generator_mocks_spec.rb +13 -0
  337. data/spec/units/generators/generator_partials_spec.rb +656 -55
  338. data/spec/units/generators/generator_spec.rb +26 -0
  339. data/spec/units/generators/generator_test_runner_spec.rb +9 -5
  340. data/spec/units/generators/partial_source_writer_spec.rb +129 -0
  341. data/spec/units/includes/header_search_spec.rb +406 -0
  342. data/spec/units/includes/include_factory_spec.rb +22 -5
  343. data/spec/units/includes/include_pathinator_spec.rb +77 -13
  344. data/spec/units/includes/include_spec.rb +14 -0
  345. data/spec/units/includes/includes_spec.rb +176 -19
  346. data/spec/units/loginator_spec.rb +31 -0
  347. data/spec/units/mock_locator_spec.rb +199 -5
  348. data/spec/units/partials/include_groups_spec.rb +42 -0
  349. data/spec/units/partials/partializer_config_spec.rb +25 -0
  350. data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
  351. data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
  352. data/spec/units/partials/partializer_helper_spec.rb +529 -277
  353. data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
  354. data/spec/units/partials/partializer_spec.rb +1578 -270
  355. data/spec/units/partials/partializer_utils_spec.rb +269 -232
  356. data/spec/units/partials/partials_rename_spec.rb +160 -0
  357. data/spec/units/partials_manager_spec.rb +554 -261
  358. data/spec/units/plugins/bullseye_spec.rb +34 -0
  359. data/spec/units/plugins/console_reportinator_spec.rb +58 -9
  360. data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +1 -1
  361. data/spec/units/plugins/reportgenerator_reportinator_spec.rb +51 -3
  362. data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
  363. data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
  364. data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
  365. data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
  366. data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
  367. data/spec/units/setupinator_spec.rb +51 -0
  368. data/spec/units/standin_headerinator_spec.rb +27 -11
  369. data/spec/units/test_build_executor_spec.rb +780 -166
  370. data/spec/units/test_build_planner_spec.rb +116 -28
  371. data/spec/units/test_build_setup_spec.rb +83 -18
  372. data/spec/units/test_context_extractor_spec.rb +11 -2
  373. data/spec/units/test_derived_search_paths_spec.rb +259 -0
  374. data/spec/units/test_includes_extractinator_spec.rb +56 -8
  375. data/spec/units/test_invoker/objects_wiring_spec.rb +20 -3
  376. data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
  377. data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
  378. data/spec/units/test_invoker_types_spec.rb +8 -7
  379. data/spec/units/test_pipeline_manager_spec.rb +54 -13
  380. data/spec/units/test_runner_generatinator_spec.rb +93 -1
  381. data/spec/units/test_search_paths_spec.rb +73 -5
  382. data/spec/units/{default_tools_quoting_spec.rb → tools/default_tools_quoting_spec.rb} +39 -5
  383. data/spec/units/tools/shell_quoting_spec.rb +76 -0
  384. data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
  385. data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +1 -1
  386. data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
  387. data/spec/units/windows_registry_query_tool_spec.rb +53 -0
  388. metadata +161 -16
  389. /data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +0 -0
  390. /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
@@ -9,15 +9,17 @@ require 'rubygems'
9
9
  require 'rake' # for ext()
10
10
  require 'fileutils'
11
11
  require 'pathname'
12
+ require 'yaml'
12
13
  require 'ceedling/exceptions'
13
- require 'set'
14
14
  require 'ceedling/system_wrapper'
15
15
  require 'ceedling/constants'
16
16
  require 'ceedling/filesystem/path_mirror'
17
17
  require 'ceedling/filesystem/path_matcher'
18
18
  require 'ceedling/filesystem/project_paths'
19
19
  require 'ceedling/filesystem/build_subpath'
20
+ require 'ceedling/filesystem/build_roots'
20
21
  require 'ceedling/filesystem/destination_collision'
22
+ require 'ceedling/filesystem/test_build_layout'
21
23
 
22
24
  # global utility methods (for plugins, project files, etc.)
23
25
  def ceedling_form_filepath(destination_path, original_filepath, new_extension=nil)
@@ -28,12 +30,7 @@ end
28
30
 
29
31
  class FilePathUtils
30
32
 
31
- constructor :configurator, :file_wrapper
32
-
33
- def setup
34
- @formed_lock = Mutex.new
35
- @formed_paths = Set.new
36
- end
33
+ constructor :configurator, :file_wrapper, :test_build_layout
37
34
 
38
35
  ######### Class methods ##########
39
36
 
@@ -192,8 +189,10 @@ class FilePathUtils
192
189
  return subdir.empty? ? File.join(root, basename) : File.join(root, subdir, basename)
193
190
  end
194
191
 
192
+ # A release build has no per-test directories, so it places each file by its release spelling
193
+ # (see BuildSubpath)
195
194
  def form_release_build_objects_filelist(files)
196
- return mirror_build_objects( files, root: @configurator.project_release_build_output_path, ext: @configurator.extension_object.primary )
195
+ return mirror_build_objects( files, root: @configurator.project_release_build_output_path, ext: @configurator.extension_object.primary, release: true )
197
196
  end
198
197
 
199
198
  # `filepath` is an already-mirrored object path -- its own directory is exactly where its
@@ -203,7 +202,7 @@ class FilePathUtils
203
202
  end
204
203
 
205
204
  def form_release_dependencies_filelist(files)
206
- return mirror_build_objects( files, root: @configurator.project_release_dependencies_path, ext: @configurator.extension_dependencies.primary )
205
+ return mirror_build_objects( files, root: @configurator.project_release_dependencies_path, ext: @configurator.extension_dependencies.primary, release: true )
207
206
  end
208
207
 
209
208
  ### Tests ###
@@ -217,14 +216,50 @@ class FilePathUtils
217
216
  return BuildSubpath.encode( filepath.to_s.ext( '' ) )
218
217
  end
219
218
 
219
+ # The configured roots that build paths spell by a short marker (see BuildRoots), built
220
+ # once per configured list. Build threads may build it together harmlessly, since every
221
+ # table of one list is the same.
222
+ def build_roots
223
+ roots = @configurator.collection_build_roots
224
+ cached = @build_roots
225
+ return cached.last if cached&.first.equal?( roots )
226
+
227
+ table = BuildRoots.table( roots )
228
+ @build_roots = [roots, table].freeze
229
+ return table
230
+ end
231
+
232
+ # Writes each shortened root and its marker to the build root, for tracing a marker to its
233
+ # root, or removes the map when no root is shortened, and returns them
234
+ def publish_build_roots
235
+ entries = build_roots.entries
236
+ path = File.join( @configurator.project_build_root, BUILD_ROOTS_MAP_FILE )
237
+ return entries.tap { @file_wrapper.rm_f( path ) } if entries.empty?
238
+
239
+ @file_wrapper.mkdir( @configurator.project_build_root )
240
+ @file_wrapper.write( path, YAML.dump( entries.to_h { |root, marker| [marker, root] } ) )
241
+ return entries
242
+ end
243
+
244
+ # A build path as it would be spelled without shortened roots: each marker segment becomes
245
+ # its root's encoded spelling. For matching patterns written against build paths.
246
+ def expanded_build_path(path)
247
+ table = build_roots
248
+ return path if table.empty?
249
+
250
+ return path.split( '/', -1 ).map { |segment| (root = table.root_for( segment )).nil? ? segment : BuildSubpath.encode( root ) }.join( '/' )
251
+ end
252
+
253
+ # A test's own output directory (TestBuildLayout), or the context's output root itself for
254
+ # no test, where a context's own sources outside any test build
220
255
  def form_test_build_path(name, context: nil)
221
- form_build_context_path(BUILD_OUT_DIR, name: name, context: context)
256
+ return @test_build_layout.root( :out, name, context: context ) || @test_build_layout.base( :out, context: context )
222
257
  end
223
258
 
224
259
  # Where a build places the object of `filepath`: below its test's build path, or below the
225
260
  # context's own output root for a source compiled outside any test
226
261
  def form_test_object_filepath(filepath, name: nil, context: nil)
227
- root = form_build_context_path( BUILD_OUT_DIR, name: name, context: context )
262
+ root = form_test_build_path( name, context: context )
228
263
  return build_filepath( filepath, root: root, ext: @configurator.extension_object.primary, generated_roots: generated_roots( name ) )
229
264
  end
230
265
 
@@ -247,15 +282,16 @@ class FilePathUtils
247
282
  File.join( *parts )
248
283
  end
249
284
 
285
+ # As `form_test_build_path`, for dependencies files
250
286
  def form_test_dependencies_path(name, context: nil)
251
- form_build_context_path(BUILD_DEPENDENCIES_DIR, name: name, context: context)
287
+ return @test_build_layout.root( :dependencies, name, context: context ) || @test_build_layout.base( :dependencies, context: context )
252
288
  end
253
289
 
254
290
  # `filepath` is an object path. Its dependencies file sits at the object's own place below
255
291
  # the dependencies root, so it never collides with another same-named object's. Without a
256
292
  # test, that place is below the context's own output root.
257
293
  def form_test_dependencies_filepath(filepath, name: nil, context: nil)
258
- root = form_build_context_path(BUILD_DEPENDENCIES_DIR, name: name, context: context)
294
+ root = form_test_dependencies_path( name, context: context )
259
295
  basename = File.basename(filepath).ext(@configurator.extension_dependencies.primary)
260
296
 
261
297
  subdir = ProjectPaths.subdir_below( form_test_build_path( name, context: context ), File.dirname( filepath ) ) || ''
@@ -263,49 +299,49 @@ class FilePathUtils
263
299
  end
264
300
 
265
301
  def form_test_mocks_path(name)
266
- form_named_path(@configurator.cmock_mock_path, name)
302
+ return @test_build_layout.root( :mocks, name )
267
303
  end
268
304
 
269
305
  def form_test_partials_path(name)
270
- form_named_path(@configurator.project_test_partials_path, name)
306
+ return @test_build_layout.root( :partials, name )
271
307
  end
272
308
 
273
309
  def form_test_preprocess_includes_path(name)
274
- form_named_path(@configurator.project_test_preprocess_includes_path, name)
310
+ return @test_build_layout.root( :preprocess_includes, name )
275
311
  end
276
312
 
277
313
  def form_test_preprocess_files_path(name)
278
- form_named_path(@configurator.project_test_preprocess_files_path, name)
314
+ return @test_build_layout.root( :preprocess_files, name )
279
315
  end
280
316
 
281
317
  def form_test_preprocess_files_full_expansion_path(name)
282
- form_named_path(@configurator.project_test_preprocess_files_path, name, subdir: PREPROCESS_FULL_EXPANSION_DIR)
318
+ return @test_build_layout.file( :preprocess_files, name, PREPROCESS_FULL_EXPANSION_DIR )
283
319
  end
284
320
 
285
321
  def form_test_preprocess_files_directives_only_path(name)
286
- form_named_path(@configurator.project_test_preprocess_files_path, name, subdir: PREPROCESS_DIRECTIVES_ONLY_DIR)
322
+ return @test_build_layout.file( :preprocess_files, name, PREPROCESS_DIRECTIVES_ONLY_DIR )
287
323
  end
288
324
 
289
325
  def form_test_preprocess_files_raw_directives_only_path(name)
290
- form_named_path(@configurator.project_test_preprocess_files_path, name, subdir: PREPROCESS_RAW_DIRECTIVES_ONLY_DIR)
326
+ return @test_build_layout.file( :preprocess_files, name, PREPROCESS_RAW_DIRECTIVES_ONLY_DIR )
291
327
  end
292
328
 
293
329
  def form_test_preprocess_build_directives_path(name)
294
- form_named_path(@configurator.project_test_preprocess_build_directives_path, name)
330
+ return @test_build_layout.root( :build_directives, name )
295
331
  end
296
332
 
297
333
  # Where a test file's own #include/build-directive scan results are cached, keyed by
298
334
  # the test file's own name so each test's cache lives alongside its other
299
335
  # preprocessing artifacts.
300
- def form_test_build_directives_cache_filepath(filepath, subdir)
301
- return File.join( @configurator.project_test_preprocess_build_directives_path, subdir, File.basename(filepath) + EXTENSION_CORE_YAML )
336
+ def form_test_build_directives_cache_filepath(filepath, name)
337
+ return @test_build_layout.file( :build_directives, name, File.basename(filepath) + EXTENSION_CORE_YAML )
302
338
  end
303
339
 
304
340
  # Where a test file's TEST_SOURCE_FILE() results are cached once its preprocessed
305
341
  # output has been generated -- kept distinct from the raw-file cache above since the
306
342
  # two are populated at different points in the pipeline from different content.
307
- def form_preprocessed_source_files_cache_filepath(filepath, subdir)
308
- return File.join( @configurator.project_test_preprocess_build_directives_path, subdir, File.basename(filepath) + '_source_files' + EXTENSION_CORE_YAML )
343
+ def form_preprocessed_source_files_cache_filepath(filepath, name)
344
+ return @test_build_layout.file( :build_directives, name, File.basename(filepath) + '_source_files' + EXTENSION_CORE_YAML )
309
345
  end
310
346
 
311
347
  def form_pass_results_filepath(build_output_path, filepath)
@@ -372,62 +408,53 @@ class FilePathUtils
372
408
  return File.join( subdir, basename )
373
409
  end
374
410
 
375
- # The roots holding one test's own generated files. A mock or a generated Partial sits
376
- # below one of these rather than a configured source root, and two same-named modules
377
- # each produce one, so without these roots both share a single preprocessed artifact.
378
- #
379
- # Each root carries the test's own name, so what mirrors forward is the module's own
380
- # subdirectory rather than the test name a second time.
411
+ # The roots holding one test's own generated files (TestBuildLayout#generated_roots). A
412
+ # mock or a generated Partial sits below one of these rather than a configured source
413
+ # root, and two same-named modules each produce one, so without these roots both share a
414
+ # single preprocessed artifact. What mirrors forward is the module's own subdirectory.
381
415
  def generated_roots(test)
382
- return [] if test.nil?
383
-
384
- roots = []
385
- roots << File.join( @configurator.project_test_partials_path, test ) if @configurator.project_use_partials
386
- roots << File.join( @configurator.cmock_mock_path, test ) if @configurator.project_use_mocks
416
+ return @test_build_layout.generated_roots( test )
417
+ end
387
418
 
388
- return roots
419
+ # Composes a preprocessed artifact's path below the test's root of `kind`, or below the base
420
+ # every test shares for no test, as `form_test_build_path` does. Pure, like
421
+ # every other path builder here: callers that merely restate a path -- a rake target
422
+ # declaration, a staleness check -- must not leave directories behind as a side effect.
423
+ # Whoever writes the file creates its directory, the same way a mock's or a Partial's own
424
+ # writer does.
425
+ def form_preprocessed_filepath(kind, test, kind_dir, filepath, suffix: '')
426
+ root = @test_build_layout.root( kind, test ) || @test_build_layout.base( kind )
427
+ return File.join( *[root, kind_dir, preprocessed_file_subpath( filepath, test ) + suffix].compact )
389
428
  end
390
429
 
391
- # Composes a preprocessed artifact's path. Pure, like every other path builder here:
392
- # callers that merely restate a path -- a rake target declaration, a staleness check --
393
- # must not leave directories behind as a side effect. Whoever writes the file creates
394
- # its directory, the same way a mock's or a Partial's own writer does.
395
- def form_preprocessed_filepath(root, subdir, kind_dir, filepath, suffix: '')
396
- return File.join( *[root, subdir, kind_dir, preprocessed_file_subpath( filepath, subdir ) + suffix].compact )
430
+ def form_preprocessed_includes_list_filepath(filepath, test)
431
+ return form_preprocessed_filepath( :preprocess_includes, test, nil, filepath, suffix: EXTENSION_CORE_YAML )
397
432
  end
398
433
 
399
- def form_preprocessed_includes_list_filepath(filepath, subdir)
400
- return form_preprocessed_filepath(
401
- @configurator.project_test_preprocess_includes_path, subdir, nil, filepath, suffix: EXTENSION_CORE_YAML
402
- )
434
+ def form_preprocessed_file_filepath(filepath, test)
435
+ return form_preprocessed_filepath( :preprocess_files, test, nil, filepath )
403
436
  end
404
437
 
405
- def form_preprocessed_file_filepath(filepath, subdir)
406
- return form_preprocessed_filepath( @configurator.project_test_preprocess_files_path, subdir, nil, filepath )
438
+ def form_preprocessed_file_full_expansion_filepath(filepath, test)
439
+ return form_preprocessed_filepath( :preprocess_files, test, PREPROCESS_FULL_EXPANSION_DIR, filepath )
407
440
  end
408
441
 
409
- def form_preprocessed_file_full_expansion_filepath(filepath, subdir)
410
- return form_preprocessed_filepath(
411
- @configurator.project_test_preprocess_files_path, subdir, PREPROCESS_FULL_EXPANSION_DIR, filepath
412
- )
442
+ # A file's own lines from its full expansion, as plain code without line markers. The
443
+ # expansion itself stays whole beside it, since its markers name every file it entered.
444
+ def form_preprocessed_file_expanded_code_filepath(filepath, test)
445
+ return form_preprocessed_filepath( :preprocess_files, test, PREPROCESS_EXPANDED_CODE_DIR, filepath )
413
446
  end
414
447
 
415
- def form_preprocessed_file_raw_directives_only_filepath(filepath, subdir)
416
- return form_preprocessed_filepath(
417
- @configurator.project_test_preprocess_files_path, subdir, PREPROCESS_RAW_DIRECTIVES_ONLY_DIR, filepath
418
- )
448
+ def form_preprocessed_file_raw_directives_only_filepath(filepath, test)
449
+ return form_preprocessed_filepath( :preprocess_files, test, PREPROCESS_RAW_DIRECTIVES_ONLY_DIR, filepath )
419
450
  end
420
451
 
421
- def form_preprocessed_file_fallback_expansion_filepath(filepath, subdir)
422
- return form_preprocessed_filepath(
423
- @configurator.project_test_preprocess_files_path, subdir, PREPROCESS_FALLBACK_EXPANSION_DIR, filepath
424
- )
452
+ def form_preprocessed_file_fallback_expansion_filepath(filepath, test)
453
+ return form_preprocessed_filepath( :preprocess_files, test, PREPROCESS_FALLBACK_EXPANSION_DIR, filepath )
425
454
  end
426
455
 
427
- def form_preprocessed_file_compacted_directives_only_filepath(filepath, subdir)
428
- return form_preprocessed_filepath(
429
- @configurator.project_test_preprocess_files_path, subdir, PREPROCESS_DIRECTIVES_ONLY_DIR, filepath
430
- )
456
+ def form_preprocessed_file_compacted_directives_only_filepath(filepath, test)
457
+ return form_preprocessed_filepath( :preprocess_files, test, PREPROCESS_DIRECTIVES_ONLY_DIR, filepath )
431
458
  end
432
459
 
433
460
  # `extra_roots` carries roots known only to the caller. A generated Partial source sits
@@ -447,16 +474,16 @@ class FilePathUtils
447
474
  return File.join( root, subdir )
448
475
  end
449
476
 
450
- def form_mock_header_filepath(subdir, filename)
451
- # @configurator.cmock_mock_path accessor only exists if mocks are enabled
477
+ # A header at `filename` below a test's mock root
478
+ def form_mock_header_filepath(name, filename)
452
479
  raise CeedlingException.new('Mocks are not enabled, but an internal feature dependent on them was accessed.') unless @configurator.project_use_mocks
453
- return File.join(@configurator.cmock_mock_path, subdir, filename.ext(EXTENSION_CORE_HEADER))
480
+ return @test_build_layout.file( :mocks, name, filename.ext(EXTENSION_CORE_HEADER) )
454
481
  end
455
482
 
456
- def form_partial_header_filepath(subdir, filename)
457
- # @configurator.project_test_partials_path accessor only exists if partials are enabled
483
+ # A header at `filename` below a test's Partials root
484
+ def form_partial_header_filepath(name, filename)
458
485
  raise CeedlingException.new('Partials are not enabled, but an internal feature dependent on them was accessed.') unless @configurator.project_use_partials
459
- return File.join( @configurator.project_test_partials_path, subdir, filename.ext(EXTENSION_CORE_HEADER) )
486
+ return @test_build_layout.file( :partials, name, filename.ext(EXTENSION_CORE_HEADER) )
460
487
  end
461
488
 
462
489
  # Every generated Partial filename below is also the text a Partial directive macro
@@ -514,6 +541,12 @@ class FilePathUtils
514
541
  return form_partial_filename( _module, PARTIAL_SUFFIX_TYPES, EXTENSION_CORE_HEADER )
515
542
  end
516
543
 
544
+ # What a mock-only Partial keeps of its real header beyond the mocked functions, which its
545
+ # interface header includes and CMock never reads
546
+ def form_partial_extras_header_filename(_module)
547
+ return form_partial_filename( _module, PARTIAL_SUFFIX_EXTRAS, EXTENSION_CORE_HEADER )
548
+ end
549
+
517
550
  def form_mock_partial_interface_header_filename(_module)
518
551
  return form_partial_filename( _module, PARTIAL_SUFFIX_INTERFACE, EXTENSION_CORE_HEADER, prefix: @configurator.cmock_mock_prefix )
519
552
  end
@@ -550,13 +583,6 @@ class FilePathUtils
550
583
  return path
551
584
  end
552
585
 
553
- # Forms base/name[/subdir]
554
- def form_named_path(base, name, subdir: nil)
555
- path = subdir ? File.join( base, name, subdir ) : File.join( base, name )
556
- @file_wrapper.check_path_length( path, origin: 'FilePathUtils#form_named_path' )
557
- return path
558
- end
559
-
560
586
  # The directories of a test's name, excluding its basename: 'test/unit' for
561
587
  # 'test/unit/test_foo', or '' for a test at the project root.
562
588
  def mirrored_test_subdir(name)
@@ -581,39 +607,35 @@ class FilePathUtils
581
607
  # it contains a literal `[`/`]`. FileWrapper#instantiate_file_list_literal (`<<`, not
582
608
  # `.new`/`.include`) adds every entry as-is, with no glob interpretation at all -- the
583
609
  # correct construction for a list that's already the real, final answer.
584
- def mirror_build_objects(files, root:, ext:, generated_roots: [])
610
+ def mirror_build_objects(files, root:, ext:, generated_roots: [], release: false)
585
611
  sources = @file_wrapper.instantiate_file_list_literal( files ).to_a.uniq { |file| ProjectPaths.absolute( file ) }
586
- objects = sources.map { |file| build_filepath( file, root: root, ext: ext, generated_roots: generated_roots ) }
612
+ objects = sources.map { |file| build_filepath( file, root: root, ext: ext, generated_roots: generated_roots, release: release ) }
587
613
 
588
614
  validate_distinct_build_files!( sources, objects )
589
615
  return @file_wrapper.instantiate_file_list_literal( objects )
590
616
  end
591
617
 
592
- def build_filepath(file, root:, ext:, generated_roots:)
593
- subdir = form_build_subpath( file, generated_roots: generated_roots )
618
+ def build_filepath(file, root:, ext:, generated_roots:, release: false)
619
+ subdir = form_build_subpath( file, generated_roots: generated_roots, release: release )
594
620
  basename = File.basename( file ).ext( ext )
595
621
  path = subdir.empty? ? File.join( root, basename ) : File.join( root, subdir, basename )
596
622
 
597
- # A source far from the project gains a directory for each level its path climbs. Each
598
- # path is checked once, however often it is formed.
599
- @file_wrapper.check_path_length( path, origin: 'FilePathUtils#build_filepath' ) if first_formed?( path )
623
+ # A source far from the project gains a directory for each level its path climbs.
624
+ # FileWrapper reports each path once, however often it is formed.
625
+ @file_wrapper.check_path_length( path, origin: 'FilePathUtils#build_filepath' )
600
626
  return path
601
627
  end
602
628
 
603
- def first_formed?(path)
604
- return @formed_lock.synchronize { @formed_paths.add?( path ) }
605
- end
606
-
607
629
  # Where below a build output root the build file of `file` lands. A file below one of the
608
630
  # caller's generated roots (a test's mocks or Partials) mirrors below that root; one
609
631
  # below the build root otherwise (vendored frameworks, runners) lands flat; and any other
610
632
  # lands by its own path from the project root, so two sources never share one.
611
- def form_build_subpath(file, generated_roots: [])
633
+ def form_build_subpath(file, generated_roots: [], release: false)
612
634
  generated = PathMirror.relative_subdir_if_rooted_in_clean_roots( file, generated_roots )
613
635
  return generated unless generated.nil?
614
636
  return '' if ProjectPaths.contains?( @configurator.project_build_root, file )
615
637
 
616
- return BuildSubpath.of_directory( File.dirname( file ) )
638
+ return BuildSubpath.of_directory( File.dirname( file ), roots: build_roots, release: release )
617
639
  end
618
640
 
619
641
  # Two sources building to one file would leave one of them out of the build
@@ -14,16 +14,43 @@ require 'tmpdir'
14
14
  # once and single-threaded, settles the class before any thread first reaches for it,
15
15
  # which Digest's lazy autoload does not survive under contention.
16
16
  require 'digest/sha2'
17
+ require 'set'
18
+ require 'ceedling/c_identifier'
17
19
  require 'ceedling/constants'
18
20
  require 'ceedling/system_wrapper'
19
21
  require 'ceedling/exceptions'
20
22
  require 'ceedling/filesystem/file_tree'
23
+ require 'ceedling/filesystem/project_paths'
24
+ require 'ceedling/filesystem/win_long_paths'
25
+ require 'ceedling/filesystem/win_path_limit'
21
26
 
22
27
 
23
28
  class FileWrapper
24
29
 
25
30
  constructor :loginator, :verbosinator
26
31
 
32
+ # The paths already reported by check_path_length. Only a path in the warning band or past
33
+ # the limit is ever recorded, so the record holds the few long paths a build makes, not
34
+ # every path it checks.
35
+ #
36
+ # The Windows path limit starts as the classic one. Setup configures it once the
37
+ # project's configuration exists (see #configure_win_path_limit). Whether long paths are
38
+ # in effect stays unknown until a path first nears the classic limit and the prober answers.
39
+ def setup
40
+ @path_reports = Set.new
41
+ @path_lock = Mutex.new
42
+ @win_path_limit = :classic
43
+ @prober = nil
44
+ @long_paths = nil
45
+ end
46
+
47
+ # :project ↳ :win_path_limit, and the WinPathProber that decides whether long paths are in
48
+ # effect for it
49
+ def configure_win_path_limit(mode:, prober:)
50
+ @win_path_limit = mode
51
+ @prober = prober
52
+ end
53
+
27
54
  # Platform practical filepath length ceilings, used only as a diagnostic heuristic --
28
55
  # neither Ruby nor the host OS exposes a portable, runtime-queryable API for this.
29
56
  # POSIX pathconf(2) is the real mechanism (PATH_MAX can vary by filesystem/mount
@@ -35,7 +62,7 @@ class FileWrapper
35
62
  # headers (a project can opt into longer paths on some platforms, but that's not
36
63
  # safely assumable here, so these stay conservative).
37
64
  PATH_LENGTH_LIMITS = {
38
- windows: 260,
65
+ windows: WinLongPaths::LIMITS[:classic],
39
66
  macos: 1024,
40
67
  linux: 4096,
41
68
  }.freeze unless const_defined?(:PATH_LENGTH_LIMITS, false)
@@ -73,7 +100,7 @@ class FileWrapper
73
100
  # at both ends (GENERATED_INCLUDE_GUARD_PATTERN).
74
101
  def self.generate_include_guard(name)
75
102
  base = name.sub(/\.[^.\/\\]*\z/, '') # Remove any extension, keeping any path
76
- base = base.gsub(/\W/, '_').squeeze('_').delete_prefix('_').delete_suffix('_')
103
+ base = CIdentifier.fold( base ).squeeze('_').delete_prefix('_').delete_suffix('_')
77
104
 
78
105
  head = GENERATED_INCLUDE_GUARD_PREFIX + include_guard_hash( name )
79
106
 
@@ -222,11 +249,7 @@ class FileWrapper
222
249
  # which is how a previous attempt at "fixing" this cop was caught.
223
250
  open(filepath, flags) { |file| yield(file) } # rubocop:disable Security/Open
224
251
  rescue SystemCallError => e
225
- if attempts_remaining.empty?
226
- msg = "Failed to open '#{filepath}' after #{TRANSIENT_IO_RETRY_DELAYS.size} retries ⏩️ #{e.message}"
227
- @loginator.log(msg, Verbosity::ERRORS)
228
- raise CeedlingException, msg
229
- end
252
+ retries_exhausted!(filepath, e) if attempts_remaining.empty?
230
253
  delay = attempts_remaining.shift
231
254
  @loginator.log("Retrying read of '#{filepath}' after a transient error: #{e.message}", Verbosity::DEBUG)
232
255
  sleep(delay)
@@ -342,7 +365,7 @@ class FileWrapper
342
365
  end
343
366
 
344
367
  def mkdir(folder)
345
- check_path_length(folder, origin: 'FileWrapper#mkdir')
368
+ check_path_length(folder, origin: 'FileWrapper#mkdir', directory: true)
346
369
  return FileUtils.mkdir_p(folder)
347
370
  end
348
371
 
@@ -358,7 +381,7 @@ class FileWrapper
358
381
  # the same `parent` -- Dir.mktmpdir retries internally on name clash.
359
382
  def mkdir_tmp(prefix, parent)
360
383
  path = Dir.mktmpdir(prefix, parent)
361
- check_path_length(path, origin: 'FileWrapper#mkdir_tmp')
384
+ check_path_length(path, origin: 'FileWrapper#mkdir_tmp', directory: true)
362
385
  return path
363
386
  end
364
387
 
@@ -373,23 +396,29 @@ class FileWrapper
373
396
  # rejects the path. The calling context (`origin:`) is only included at DEBUG
374
397
  # verbosity -- otherwise the message stays plain, since the path itself is normally
375
398
  # enough and repeated origin labels add noise at everyday verbosity levels.
376
- def check_path_length(path, origin:)
377
- limit = path_length_limit
378
- length = File.expand_path(path).length
379
-
380
- prefix = @verbosinator.should_output?(Verbosity::DEBUG) ? "#{origin} ⏩️ " : ''
381
-
382
- if length >= limit
383
- @loginator.log(
384
- "#{prefix}Path length (#{length}) reaches or exceeds this platform's practical limit (#{limit}): #{path}",
385
- Verbosity::ERRORS
386
- )
387
- elsif length >= (limit - WARNING_MARGIN)
388
- @loginator.log(
389
- "#{prefix}Path length (#{length}) is approaching this platform's practical limit (#{limit}): #{path}",
390
- Verbosity::COMPLAIN
391
- )
392
- end
399
+ #
400
+ # A path is measured expanded against the remembered working directory, which costs no
401
+ # system call and remembers nothing. A path below the warning band, nearly every path,
402
+ # returns there, before any lock. One in the band is reported once per process, however
403
+ # many operations check it, keyed by its `ProjectPaths.absolute` spelling so two
404
+ # spellings of one place count once. Only those reported paths are remembered.
405
+ #
406
+ # On Windows, a directory (`directory: true`) stops at 248 characters under the classic
407
+ # limits. The first path to near the classic limit asks the prober whether long paths are
408
+ # in effect, if the project asked for them, and the limit is read again from its answer.
409
+ def check_path_length(path, origin:, directory: false)
410
+ length = File.expand_path( path.to_s, ProjectPaths.working_dir ).length
411
+ limit = path_length_limit( directory )
412
+
413
+ return if length < (limit - WARNING_MARGIN)
414
+
415
+ limit = probed_limit( directory ) if probe_wanted?
416
+ return if length < (limit - WARNING_MARGIN)
417
+
418
+ absolute = ProjectPaths.absolute( path.to_s )
419
+ return unless @path_lock.synchronize { @path_reports.add?( absolute ) }
420
+
421
+ log_path_length( path, length, limit, origin )
393
422
  end
394
423
 
395
424
  private
@@ -403,15 +432,63 @@ class FileWrapper
403
432
  }
404
433
  end
405
434
 
435
+ # #open_with_retry's last attempt failed too
436
+ def retries_exhausted!(filepath, error)
437
+ msg = "Failed to open '#{filepath}' after #{TRANSIENT_IO_RETRY_DELAYS.size} retries ⏩️ #{error.message}"
438
+ @loginator.log(msg, Verbosity::ERRORS)
439
+ raise CeedlingException, msg
440
+ end
441
+
406
442
  def owner_writable(path)
407
443
  mode = File.stat( path ).mode & 0o7777
408
444
  File.chmod( mode | 0o200, path ) if (mode & 0o200).zero?
409
445
  end
410
446
 
411
- def path_length_limit
412
- return PATH_LENGTH_LIMITS[:windows] if SystemWrapper.windows?
447
+ def path_length_limit(directory = false)
448
+ return windows_path_limit( directory ) if SystemWrapper.windows?
413
449
  return PATH_LENGTH_LIMITS[:macos] if SystemWrapper.macos?
414
450
  return PATH_LENGTH_LIMITS[:linux]
415
451
  end
416
452
 
453
+ def windows_path_limit(directory)
454
+ return WinLongPaths::LIMITS[:long_paths] if @long_paths
455
+ return WinLongPaths::LIMITS[directory ? :classic_directory : :classic]
456
+ end
457
+
458
+ # Only a configured FileWrapper has a prober; the launcher's keeps the classic limits
459
+ def probe_wanted?
460
+ return SystemWrapper.windows? && (@win_path_limit != :classic) && @long_paths.nil? && !@prober.nil?
461
+ end
462
+
463
+ # The limit once the prober has answered. Threads that ask together get one answer, since
464
+ # the prober probes once.
465
+ def probed_limit(directory)
466
+ @long_paths = @prober.long_paths?( @win_path_limit )
467
+ return path_length_limit( directory )
468
+ end
469
+
470
+ def log_path_length(path, length, limit, origin)
471
+ prefix = @verbosinator.should_output?(Verbosity::DEBUG) ? "#{origin} ⏩️ " : ''
472
+ subject, bound = length_terms( limit )
473
+
474
+ return @loginator.log( "#{prefix}#{subject} (#{length}) is approaching #{bound}: #{path}", Verbosity::COMPLAIN ) if length < limit
475
+
476
+ message = "#{prefix}#{subject} (#{length}) reaches or exceeds #{bound}: #{path}"
477
+ message += "\nIf this host has long paths enabled, see :project ↳ :win_path_limit." if pointer_wanted?( limit )
478
+ @loginator.log( message, Verbosity::ERRORS )
479
+ end
480
+
481
+ # What a length message calls the path, and the limit it nears or passes
482
+ def length_terms(limit)
483
+ return ['Path length', "this platform's practical limit (#{limit})"] unless SystemWrapper.windows?
484
+
485
+ subject = (limit == WinLongPaths::LIMITS[:classic_directory]) ? 'Directory path length' : 'Path length'
486
+ return [subject, WinPathLimit.limit_name( limit )]
487
+ end
488
+
489
+ # The setting can help only a project still on the classic limits by its own choice
490
+ def pointer_wanted?(limit)
491
+ return SystemWrapper.windows? && (@win_path_limit == :classic) && (limit != WinLongPaths::LIMITS[:long_paths])
492
+ end
493
+
417
494
  end
@@ -134,6 +134,27 @@ class PathMatcher
134
134
  tail_matches?(shorter, longer)
135
135
  end
136
136
 
137
+ # What remains of `path` above `tail`'s segments: `.` when nothing does, and nil when
138
+ # `path` doesn't end in `tail`. A leading `/`, `//` share, or drive letter stays.
139
+ def self.strip_tail(path, tail)
140
+ path_segments = segments(path)
141
+ tail_segments = segments(tail)
142
+ return nil if tail_segments.empty? or !tail_matches?(tail_segments, path_segments)
143
+
144
+ return rooted(path, path_segments[0...-tail_segments.length])
145
+ end
146
+
147
+ # `rest`, the segments of `path` that remain, joined under `path`'s own root
148
+ def self.rooted(path, rest)
149
+ drive = path[/\A[A-Za-z]:(?=[\\\/])/]
150
+ return "#{drive}/#{rest.drop(1).join('/')}" if drive
151
+ return "//#{rest.join('/')}" if path.match?(%r{\A[\\/]{2}[^\\/]})
152
+ return "/#{rest.join('/')}" if path.start_with?('/', '\\')
153
+
154
+ return rest.empty? ? '.' : rest.join('/')
155
+ end
156
+ private_class_method :rooted
157
+
137
158
  # A Unix absolute path or one beginning with a Windows drive letter
138
159
  def self.absolute?(path)
139
160
  path.start_with?('/') || path.match?( /\A[A-Za-z]:[\\\/]/ )