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.
- checksums.yaml +4 -4
- data/GIT_COMMIT_SHA +1 -1
- data/README.md +11 -9
- data/Rakefile +2 -1
- data/assets/features/ceedling +1 -1
- data/assets/fixtures/test_source_file_duplicate_basenames/test_calc_typo.c +14 -0
- data/assets/fixtures/tests_with_duplicate_test_names/test_foo.c +21 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
- data/bin/actionator.rb +6 -12
- data/bin/app_cfg.rb +14 -1
- data/bin/ceedling +13 -3
- data/bin/cli.rb +25 -6
- data/bin/cli_handler.rb +113 -73
- data/bin/cli_helper.rb +51 -78
- data/bin/installation_selector.rb +81 -0
- data/bin/launchinator.rb +69 -0
- data/bin/mixin_resolvinator.rb +26 -36
- data/bin/objects.yml +13 -0
- data/bin/path_validator.rb +25 -29
- data/bin/versionator.rb +47 -48
- data/ceedling.gemspec +19 -15
- data/docs/BreakingChanges.md +86 -1
- data/docs/Changelog.md +145 -3
- data/docs/KnownIssues.md +179 -6
- data/docs/ReleaseNotes.md +13 -0
- data/examples/wondrous_forest/README.md +29 -1
- data/examples/wondrous_forest/src/ForestUnits.h +23 -0
- data/examples/wondrous_forest/src/RainGauge.c +59 -0
- data/examples/wondrous_forest/src/RainGauge.h +39 -0
- data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
- data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
- data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
- data/lib/ceedling/build_log_writer.rb +33 -0
- data/lib/ceedling/c_extractor/README.md +15 -7
- data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
- data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
- data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
- data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
- data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
- data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
- data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
- data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
- data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
- data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
- data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
- data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
- data/lib/ceedling/c_identifier.rb +21 -0
- data/lib/ceedling/ceedling.h +8 -0
- data/lib/ceedling/config/build_root_policy.rb +70 -0
- data/lib/ceedling/config/configurator.rb +18 -19
- data/lib/ceedling/config/configurator_builder.rb +75 -28
- data/lib/ceedling/config/configurator_paths_validator.rb +179 -0
- data/lib/ceedling/config/configurator_plugins.rb +1 -1
- data/lib/ceedling/config/configurator_setup.rb +44 -33
- data/lib/ceedling/config/configurator_validator.rb +1 -110
- data/lib/ceedling/constants.rb +5 -1
- data/lib/ceedling/defaults.rb +35 -5
- data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
- data/lib/ceedling/dependencies/README.md +18 -16
- data/lib/ceedling/dependencies/dependency_cache_store.rb +43 -21
- data/lib/ceedling/dependencies/dependency_hasher.rb +35 -1
- data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
- data/lib/ceedling/dependencies/dependinator.rb +13 -1
- data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
- data/lib/ceedling/diagnostics/README.md +5 -0
- data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
- data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
- data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
- data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
- data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
- data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
- data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
- data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
- data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
- data/lib/ceedling/filename_extension.rb +7 -1
- data/lib/ceedling/filesystem/FILE_TREE.md +253 -0
- data/lib/ceedling/filesystem/PATH_HANDLING.md +360 -0
- data/lib/ceedling/filesystem/README.md +46 -0
- data/lib/ceedling/filesystem/build_roots.rb +105 -0
- data/lib/ceedling/filesystem/build_subpath.rb +187 -0
- data/lib/ceedling/filesystem/destination_collision.rb +25 -0
- data/lib/ceedling/{file_finder.rb → filesystem/file_finder.rb} +177 -156
- data/lib/ceedling/filesystem/file_finder_helper.rb +154 -0
- data/lib/ceedling/filesystem/file_path_collection_utils.rb +183 -0
- data/lib/ceedling/{file_path_utils.rb → filesystem/file_path_utils.rb} +200 -167
- data/lib/ceedling/{file_system_wrapper.rb → filesystem/file_system_wrapper.rb} +6 -5
- data/lib/ceedling/filesystem/file_tree.rb +241 -0
- data/lib/ceedling/{file_wrapper.rb → filesystem/file_wrapper.rb} +149 -65
- data/lib/ceedling/filesystem/path_exclusions.rb +30 -0
- data/lib/ceedling/{path_matcher.rb → filesystem/path_matcher.rb} +48 -23
- data/lib/ceedling/{path_mirror.rb → filesystem/path_mirror.rb} +19 -18
- data/lib/ceedling/filesystem/path_spellings.rb +55 -0
- data/lib/ceedling/filesystem/project_paths.rb +184 -0
- data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
- data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
- data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
- data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
- data/lib/ceedling/filesystem/working_dir.rb +40 -0
- data/lib/ceedling/generators/generator.rb +32 -70
- data/lib/ceedling/generators/generator_helper.rb +0 -44
- data/lib/ceedling/generators/generator_mocks.rb +5 -0
- data/lib/ceedling/generators/generator_partials.rb +306 -244
- data/lib/ceedling/generators/generator_test_results_backtrace.rb +7 -7
- data/lib/ceedling/generators/generator_test_runner.rb +5 -8
- data/lib/ceedling/generators/partial_header_writer.rb +95 -0
- data/lib/ceedling/generators/partial_source_writer.rb +137 -0
- data/lib/ceedling/handoff.rb +121 -0
- data/lib/ceedling/includes/header_search.rb +225 -0
- data/lib/ceedling/includes/include_factory.rb +9 -12
- data/lib/ceedling/includes/include_pathinator.rb +112 -33
- data/lib/ceedling/includes/includes.rb +150 -38
- data/lib/ceedling/installation.rb +92 -0
- data/lib/ceedling/library_resolver.rb +99 -0
- data/lib/ceedling/objects.yml +112 -6
- data/lib/ceedling/partials/README.md +110 -16
- data/lib/ceedling/partials/carry_plan.rb +71 -0
- data/lib/ceedling/partials/definition_head.rb +74 -0
- data/lib/ceedling/partials/include_groups.rb +37 -0
- data/lib/ceedling/partials/interface_extras.rb +25 -0
- data/lib/ceedling/partials/partializer.rb +603 -124
- data/lib/ceedling/partials/partializer_config.rb +8 -1
- data/lib/ceedling/partials/partializer_helper.rb +851 -145
- data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
- data/lib/ceedling/partials/partializer_utils.rb +89 -109
- data/lib/ceedling/partials/partials.rb +153 -10
- data/lib/ceedling/partials/type_macros.rb +126 -0
- data/lib/ceedling/plugins/report_log_writer_plugin.rb +3 -5
- data/lib/ceedling/preprocess/README.md +43 -33
- data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
- data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
- data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +32 -76
- data/lib/ceedling/preprocess/preprocessinator_includes_handler.rb +1 -1
- data/lib/ceedling/preprocess/preprocessinator_line_marker_includes_extractor.rb +1 -1
- data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
- data/lib/ceedling/rake_app/rakefile_component_resolver.rb +10 -17
- data/lib/ceedling/rakefile.rb +15 -1
- data/lib/ceedling/rakefiles/base/tasks_base.rake +1 -1
- data/lib/ceedling/rakefiles/release/rules_release.rake +4 -7
- data/lib/ceedling/release_invoker/release_build_executor.rb +33 -44
- data/lib/ceedling/release_invoker/release_build_planner.rb +14 -6
- data/lib/ceedling/reportinator.rb +3 -4
- data/lib/ceedling/setupinator.rb +104 -87
- data/lib/ceedling/test_context_extractor.rb +5 -1
- data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
- data/lib/ceedling/test_invoker/PIPELINE.md +62 -19
- data/lib/ceedling/test_invoker/README.md +1 -1
- data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
- data/lib/ceedling/test_invoker/mock_locator.rb +175 -10
- data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
- data/lib/ceedling/test_invoker/partials_manager.rb +271 -302
- data/lib/ceedling/test_invoker/standin_headerinator.rb +19 -17
- data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
- data/lib/ceedling/test_invoker/test_build_executor.rb +358 -234
- data/lib/ceedling/test_invoker/test_build_planner.rb +46 -33
- data/lib/ceedling/test_invoker/test_build_setup.rb +43 -18
- data/lib/ceedling/test_invoker/test_build_validations.rb +35 -47
- data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
- data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +2 -3
- data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
- data/lib/ceedling/test_invoker/test_invoker.rb +6 -1
- data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
- data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +6 -4
- data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
- data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
- data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
- data/lib/ceedling/test_invoker/test_source_file_directive_resolver.rb +40 -20
- data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
- data/lib/ceedling/tools/shell_quoting.rb +45 -0
- data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +9 -3
- data/lib/ceedling/tools/tool_quoting.rb +79 -0
- data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
- data/lib/ceedling/yaml_wrapper.rb +3 -2
- data/lib/version.rb +1 -1
- data/plugins/bullseye/bullseye.rake +1 -3
- data/plugins/bullseye/config/defaults_bullseye.rb +1 -1
- data/plugins/bullseye/lib/bullseye.rb +24 -9
- data/plugins/command_hooks/lib/command_hooks.rb +1 -1
- data/plugins/cppcheck/config/defaults_cppcheck.rb +1 -1
- data/plugins/dependencies/config/defaults.yml +6 -6
- data/plugins/dependencies/dependencies.rake +4 -1
- data/plugins/dependencies/lib/dependencies.rb +18 -8
- data/plugins/dependencies/lib/dependency_spec.rb +17 -5
- data/plugins/fff/lib/fff.rb +79 -46
- data/plugins/fff/lib/fff_mock_generator.rb +12 -9
- data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +262 -0
- data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
- data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
- data/plugins/gcov/config/defaults_gcov.rb +1 -1
- data/plugins/gcov/lib/console_reportinator.rb +28 -36
- data/plugins/gcov/lib/gcov.rb +9 -2
- data/plugins/gcov/lib/gcovr_reportinator.rb +8 -40
- data/plugins/gcov/lib/gcovr_thresholds.rb +74 -0
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +3 -2
- data/plugins/module_generator/lib/module_generator.rb +3 -3
- data/plugins/report_tests_teamcity_stdout/lib/report_tests_teamcity_stdout.rb +53 -80
- data/plugins/sanitize/lib/sanitize_records.rb +3 -6
- data/plugins/valgrind/lib/valgrind.rb +14 -7
- data/site-local/404.html +2 -2
- data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
- data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
- data/site-local/configuration/environment-vars.html +2 -2
- data/site-local/configuration/global-collections.html +3 -3
- data/site-local/configuration/index.html +2 -2
- data/site-local/configuration/loading.html +2 -2
- data/site-local/configuration/mixins.html +2 -2
- data/site-local/configuration/parallel-builds.html +2 -2
- data/site-local/configuration/project-file.html +2 -2
- data/site-local/configuration/reference/cexception.html +2 -2
- data/site-local/configuration/reference/cmock.html +7 -3
- data/site-local/configuration/reference/defines.html +2 -2
- data/site-local/configuration/reference/environment.html +2 -2
- data/site-local/configuration/reference/extension.html +2 -2
- data/site-local/configuration/reference/files.html +65 -12
- data/site-local/configuration/reference/flags.html +2 -2
- data/site-local/configuration/reference/index.html +2 -2
- data/site-local/configuration/reference/libraries.html +23 -5
- data/site-local/configuration/reference/mixins.html +2 -2
- data/site-local/configuration/reference/partials.html +84 -2
- data/site-local/configuration/reference/paths.html +36 -8
- data/site-local/configuration/reference/plugins.html +2 -2
- data/site-local/configuration/reference/project.html +264 -12
- data/site-local/configuration/reference/release-build.html +4 -2
- data/site-local/configuration/reference/test-build.html +2 -2
- data/site-local/configuration/reference/test-runner.html +2 -2
- data/site-local/configuration/reference/tools.html +58 -4
- data/site-local/configuration/reference/unity.html +2 -2
- data/site-local/configuration/which-ceedling.html +379 -19
- data/site-local/development/index.html +2 -2
- data/site-local/development/plugins/configuration.html +2 -2
- data/site-local/development/plugins/index.html +2 -2
- data/site-local/development/plugins/plugin-subclass.html +5 -4
- data/site-local/development/plugins/rake-tasks.html +2 -2
- data/site-local/development/releases.html +7 -3
- data/site-local/development/workflow.html +50 -45
- data/site-local/getting-started/builds.html +4 -2
- data/site-local/getting-started/command-line.html +58 -6
- data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
- data/site-local/getting-started/example-projects/index.html +2 -2
- data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
- data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
- data/site-local/getting-started/index.html +2 -2
- data/site-local/getting-started/installation.html +2 -2
- data/site-local/getting-started/quick-start.html +2 -2
- data/site-local/help.html +2 -2
- data/site-local/index.html +2 -2
- data/site-local/overview/build-system.html +2 -2
- data/site-local/overview/index.html +2 -2
- data/site-local/overview/test-environments.html +2 -2
- data/site-local/overview/tools-and-frameworks.html +2 -2
- data/site-local/plugins/beep.html +2 -2
- data/site-local/plugins/bullseye/index.html +45 -38
- data/site-local/plugins/bullseye/licensing.html +2 -2
- data/site-local/plugins/command-hooks.html +4 -4
- data/site-local/plugins/compile-commands-json-db.html +2 -2
- data/site-local/plugins/cppcheck.html +2 -2
- data/site-local/plugins/dependencies.html +8 -5
- data/site-local/plugins/fff.html +58 -13
- data/site-local/plugins/gcov/examples.html +2 -2
- data/site-local/plugins/gcov/gcovr.html +23 -14
- data/site-local/plugins/gcov/index.html +2 -2
- data/site-local/plugins/gcov/overview.html +2 -2
- data/site-local/plugins/gcov/reportgenerator.html +18 -14
- data/site-local/plugins/gcov/reporting.html +2 -2
- data/site-local/plugins/gcov/setup.html +4 -3
- data/site-local/plugins/gcov/tool-versions.html +2 -2
- data/site-local/plugins/gcov/troubleshooting.html +2 -2
- data/site-local/plugins/index.html +2 -2
- data/site-local/plugins/module-generator.html +2 -2
- data/site-local/plugins/report-build-warnings-log.html +2 -2
- data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
- data/site-local/plugins/report-tests-ide-stdout.html +2 -2
- data/site-local/plugins/report-tests-log-factory.html +2 -2
- data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
- data/site-local/plugins/report-tests-raw-output-log.html +5 -3
- data/site-local/plugins/report-tests-teamcity-stdout.html +8 -5
- data/site-local/plugins/sanitize.html +9 -8
- data/site-local/plugins/valgrind.html +10 -9
- data/site-local/project/index.html +2 -2
- data/site-local/project/release-history.html +2 -2
- data/site-local/project/sbom.html +2 -2
- data/site-local/project/upgrade.html +5 -2
- data/site-local/reference/build-directives.html +2 -2
- data/site-local/reference/command-line.html +11 -4
- data/site-local/reference/environment-vars.html +2 -2
- data/site-local/reference/gcov-plugin.html +2 -2
- data/site-local/reference/global-collections.html +12 -12
- data/site-local/reference/index.html +2 -2
- data/site-local/reference/partials-macros.html +47 -2
- data/site-local/reference/project-configuration.html +2 -2
- data/site-local/sitemap.xml.gz +0 -0
- data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
- data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
- data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
- data/site-local/snapshot/plugins/bullseye/config/defaults_bullseye.rb +1 -1
- data/site-local/snapshot/plugins/gcov/config/defaults_gcov.rb +1 -1
- data/site-local/testing-guide/build-directives.html +2 -2
- data/site-local/testing-guide/conventions.html +113 -15
- data/site-local/testing-guide/frameworks.html +2 -2
- data/site-local/testing-guide/index.html +2 -2
- data/site-local/testing-guide/partials/configuration.html +31 -4
- data/site-local/testing-guide/partials/conventions.html +509 -8
- data/site-local/testing-guide/partials/directives.html +4 -3
- data/site-local/testing-guide/partials/example.html +2 -2
- data/site-local/testing-guide/partials/index.html +2 -2
- data/site-local/testing-guide/partials/overview.html +30 -12
- data/site-local/testing-guide/partials/variables.html +169 -4
- data/site-local/testing-guide/test-cases.html +2 -2
- data/site-local/testing-guide/test-sample.html +2 -2
- data/site-local/testing-guide/test-suite-anatomy.html +2 -2
- data/spec/integration/actionator_file_operations_spec.rb +91 -1
- data/spec/integration/build_step_doctor_spec.rb +270 -0
- data/spec/integration/c_extractor_composition_spec.rb +254 -4
- data/spec/integration/compile_commands_json_db_spec.rb +1 -1
- data/spec/integration/configurator_validation_spec.rb +1 -1
- data/spec/integration/dependencies/dependency_tracker_cache_hardening_spec.rb +26 -0
- data/spec/integration/dependencies/dependency_tracker_core_spec.rb +22 -0
- data/spec/integration/includes_extraction_spec.rb +27 -14
- data/spec/integration/launcher_handoff_spec.rb +297 -0
- data/spec/integration/mixin_loading_spec.rb +1 -1
- data/spec/integration/module_generator_spec.rb +3 -3
- data/spec/integration/nested_test_artifacts_spec.rb +99 -0
- data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
- data/spec/integration/partials_carry_spec.rb +520 -0
- data/spec/integration/partials_declarations_spec.rb +655 -0
- data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
- data/spec/integration/partials_function_pointers_spec.rb +277 -0
- data/spec/integration/partials_header_composition_spec.rb +268 -35
- data/spec/integration/partials_macro_decorators_spec.rb +267 -0
- data/spec/integration/partials_module_resolution_spec.rb +33 -23
- data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
- data/spec/integration/path_intake_scenarios_spec.rb +101 -0
- data/spec/integration/path_length_reporting_spec.rb +64 -0
- data/spec/integration/path_scenarios_spec.rb +399 -0
- data/spec/integration/quote_include_isolator_spec.rb +57 -1
- data/spec/integration/report_build_warnings_log_spec.rb +1 -1
- data/spec/integration/report_tests_log_factory_spec.rb +1 -1
- data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
- data/spec/integration/test_executable_manifest_spec.rb +1 -1
- data/spec/integration/test_includes_extractinator_spec.rb +69 -3
- data/spec/integration/test_naming_spec.rb +201 -0
- data/spec/integration/test_source_file_checks_spec.rb +168 -0
- data/spec/integration/tool_executor_spec.rb +1 -1
- data/spec/integration/tool_validator_spec.rb +3 -3
- data/spec/integration/upgrade_docs_spec.rb +84 -0
- data/spec/integration/vendor_copy_transient_io_retry_spec.rb +74 -5
- data/spec/integration/win_long_paths_probe_spec.rb +46 -0
- data/spec/integration/win_path_limit_spec.rb +53 -0
- data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
- data/spec/support/file_tree_helper.rb +88 -0
- data/spec/support/integration/configurator_integration_helper.rb +14 -9
- data/spec/support/integration/dependency_tracker_integration_helper.rb +1 -1
- data/spec/support/integration/partial_files_harness.rb +181 -0
- data/spec/support/integration/partials_generation_integration_helper.rb +239 -143
- data/spec/support/integration/path_scenario_harness.rb +175 -0
- data/spec/support/integration/spec_integration_helper.rb +9 -4
- data/spec/support/integration/test_includes_harness.rb +69 -37
- data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
- data/spec/support/spec_helper.rb +2 -0
- data/spec/support/system/spec_system_helper.rb +7 -6
- data/spec/support/system/system_context.rb +21 -3
- data/spec/support/working_dir_tracking.rb +49 -0
- data/spec/system/build_output_mirroring_spec.rb +2 -2
- data/spec/system/bullseye_deployment_spec.rb +2 -0
- data/spec/system/conditional_mock_includes_spec.rb +1 -1
- data/spec/system/delta_builds_spec.rb +163 -23
- data/spec/system/encoding_stress_spec.rb +4 -4
- data/spec/system/example_wondrous_forest_spec.rb +2 -2
- data/spec/system/gcov_deployment_spec.rb +3 -0
- data/spec/system/header_include_path_validation_spec.rb +4 -4
- data/spec/system/header_search_paths_spec.rb +1083 -0
- data/spec/system/launcher_handoff_spec.rb +82 -0
- data/spec/system/mock_include_folders_spec.rb +212 -0
- data/spec/system/mockable_header_reassembly_spec.rb +184 -0
- data/spec/system/parent_directory_reference_spec.rb +5 -3
- data/spec/system/partials_carry_spec.rb +581 -0
- data/spec/system/partials_delta_builds_spec.rb +280 -0
- data/spec/system/partials_function_pointers_spec.rb +106 -0
- data/spec/system/partials_macro_decorators_spec.rb +127 -0
- data/spec/system/partials_module_disambiguation_spec.rb +125 -0
- data/spec/system/path_handling_probes_spec.rb +196 -0
- data/spec/system/pinned_thread_count_spec.rb +4 -4
- data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
- data/spec/system/preprocessing_parameterized_tests_spec.rb +1 -1
- data/spec/system/rake_release_task_path_disambiguation_spec.rb +6 -6
- data/spec/system/rake_test_task_path_disambiguation_spec.rb +85 -0
- data/spec/system/short_build_paths_spec.rb +87 -0
- data/spec/system/sibling_header_collision_spec.rb +30 -6
- data/spec/system/special_path_characters_spec.rb +86 -0
- data/spec/system/support/bullseye_common_test_cases.rb +42 -0
- data/spec/system/support/common_test_cases.rb +23 -21
- data/spec/system/support/gcov_common_test_cases.rb +37 -9
- data/spec/system/support/gcov_partials_test_cases.rb +48 -0
- data/spec/system/support/sanitize_common_test_cases.rb +2 -2
- data/spec/system/support/valgrind_common_test_cases.rb +12 -12
- data/spec/system/test_build_layout_spec.rb +209 -0
- data/spec/system/test_pipeline_stop_points_spec.rb +4 -4
- data/spec/system/test_runner_system_include_spec.rb +1 -1
- data/spec/system/test_source_file_directive_spec.rb +64 -5
- data/spec/units/bin/actionator_spec.rb +14 -17
- data/spec/units/bin/app_cfg_spec.rb +37 -0
- data/spec/units/bin/cli_handler_spec.rb +282 -6
- data/spec/units/bin/cli_helper_spec.rb +116 -45
- data/spec/units/bin/installation_selector_spec.rb +114 -0
- data/spec/units/bin/launchinator_spec.rb +171 -0
- data/spec/units/bin/path_validator_spec.rb +10 -0
- data/spec/units/bin/versionator_spec.rb +38 -6
- data/spec/units/build_log_writer_spec.rb +57 -0
- data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
- data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
- data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
- data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
- data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
- data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
- data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
- data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
- data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
- data/spec/units/c_identifier_spec.rb +35 -0
- data/spec/units/config/build_root_policy_spec.rb +61 -0
- data/spec/units/config/configurator_builder_spec.rb +61 -6
- data/spec/units/config/configurator_paths_validator_spec.rb +292 -0
- data/spec/units/config/configurator_setup_spec.rb +80 -68
- data/spec/units/config/configurator_spec.rb +54 -6
- data/spec/units/config/configurator_validator_spec.rb +1 -172
- data/spec/units/dependencies/dependency_cache_store_spec.rb +98 -2
- data/spec/units/dependencies/dependency_debug_tree_spec.rb +1 -1
- data/spec/units/dependencies/dependency_hasher_spec.rb +42 -1
- data/spec/units/dependencies/dependency_path_normalizer_spec.rb +1 -1
- data/spec/units/dependencies/dependency_tracker_spec.rb +28 -1
- data/spec/units/dependencies/dependinator_spec.rb +17 -2
- data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
- data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
- data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
- data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
- data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
- data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
- data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
- data/spec/units/encodinator_spec.rb +3 -4
- data/spec/units/filename_extension_spec.rb +11 -0
- data/spec/units/filesystem/build_roots_spec.rb +131 -0
- data/spec/units/filesystem/build_subpath_spec.rb +235 -0
- data/spec/units/filesystem/destination_collision_spec.rb +30 -0
- data/spec/units/{file_finder_helper_spec.rb → filesystem/file_finder_helper_spec.rb} +126 -1
- data/spec/units/filesystem/file_finder_spec.rb +845 -0
- data/spec/units/{file_path_collection_utils_spec.rb → filesystem/file_path_collection_utils_spec.rb} +181 -1
- data/spec/units/{file_path_utils_spec.rb → filesystem/file_path_utils_spec.rb} +435 -185
- data/spec/units/filesystem/file_system_wrapper_spec.rb +33 -0
- data/spec/units/filesystem/file_tree_spec.rb +511 -0
- data/spec/units/filesystem/file_tree_windows_spec.rb +78 -0
- data/spec/units/{file_wrapper_spec.rb → filesystem/file_wrapper_spec.rb} +286 -18
- data/spec/units/{path_matcher_spec.rb → filesystem/path_matcher_spec.rb} +48 -1
- data/spec/units/{path_mirror_spec.rb → filesystem/path_mirror_spec.rb} +32 -4
- data/spec/units/filesystem/project_paths_spec.rb +147 -0
- data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
- data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
- data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
- data/spec/units/filesystem/working_dir_spec.rb +71 -0
- data/spec/units/generators/generator_helper_spec.rb +0 -60
- data/spec/units/generators/generator_mocks_spec.rb +13 -0
- data/spec/units/generators/generator_partials_spec.rb +656 -55
- data/spec/units/generators/generator_spec.rb +38 -6
- data/spec/units/generators/generator_test_results_backtrace_spec.rb +50 -46
- data/spec/units/generators/generator_test_results_spec.rb +1 -1
- data/spec/units/generators/generator_test_runner_spec.rb +9 -5
- data/spec/units/generators/partial_source_writer_spec.rb +129 -0
- data/spec/units/handoff_spec.rb +205 -0
- data/spec/units/includes/header_search_spec.rb +406 -0
- data/spec/units/includes/include_factory_spec.rb +23 -6
- data/spec/units/includes/include_pathinator_spec.rb +118 -8
- data/spec/units/includes/include_spec.rb +14 -0
- data/spec/units/includes/includes_spec.rb +176 -19
- data/spec/units/installation_spec.rb +228 -0
- data/spec/units/library_resolver_spec.rb +157 -0
- data/spec/units/loginator_spec.rb +31 -0
- data/spec/units/mock_locator_spec.rb +275 -6
- data/spec/units/partials/include_groups_spec.rb +42 -0
- data/spec/units/partials/partializer_config_spec.rb +32 -0
- data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
- data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
- data/spec/units/partials/partializer_helper_spec.rb +529 -277
- data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
- data/spec/units/partials/partializer_spec.rb +1579 -270
- data/spec/units/partials/partializer_utils_spec.rb +269 -232
- data/spec/units/partials/partials_rename_spec.rb +160 -0
- data/spec/units/partials_manager_spec.rb +561 -251
- data/spec/units/plugins/bullseye_spec.rb +49 -2
- data/spec/units/plugins/console_reportinator_spec.rb +73 -26
- data/spec/units/plugins/dependencies_spec.rb +33 -7
- data/spec/units/plugins/dependency_spec_spec.rb +17 -0
- data/spec/units/plugins/gcov_spec.rb +28 -3
- data/spec/units/plugins/gcovr_reportinator_spec.rb +19 -47
- data/spec/units/plugins/gcovr_thresholds_spec.rb +95 -0
- data/spec/units/plugins/module_generator_spec.rb +5 -5
- data/spec/units/plugins/report_build_warnings_log_spec.rb +3 -3
- data/spec/units/plugins/report_log_writer_plugin_spec.rb +10 -1
- data/spec/units/plugins/report_tests_raw_output_log_spec.rb +13 -2
- data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +77 -3
- data/spec/units/plugins/reportgenerator_reportinator_spec.rb +52 -4
- data/spec/units/plugins/sanitize_records_spec.rb +3 -1
- data/spec/units/plugins/sanitize_spec.rb +1 -1
- data/spec/units/plugins/valgrind_spec.rb +23 -8
- data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
- data/spec/units/preprocess/preprocessinator_comment_stripper_spec.rb +1 -1
- data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
- data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
- data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
- data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
- data/spec/units/rake_app/rakefile_component_resolver_spec.rb +21 -0
- data/spec/units/release_build_executor_spec.rb +53 -14
- data/spec/units/release_build_planner_spec.rb +15 -3
- data/spec/units/reportinator_spec.rb +5 -5
- data/spec/units/setupinator_spec.rb +51 -0
- data/spec/units/standin_headerinator_spec.rb +55 -9
- data/spec/units/test_build_executor_spec.rb +842 -166
- data/spec/units/test_build_planner_spec.rb +205 -15
- data/spec/units/test_build_setup_spec.rb +179 -30
- data/spec/units/test_context_extractor_spec.rb +36 -2
- data/spec/units/test_derived_search_paths_spec.rb +259 -0
- data/spec/units/test_file_preprocessinator_spec.rb +17 -1
- data/spec/units/test_includes_extractinator_spec.rb +61 -9
- data/spec/units/test_invoker/objects_wiring_spec.rb +24 -4
- data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
- data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
- data/spec/units/test_invoker_spec.rb +14 -1
- data/spec/units/test_invoker_types_spec.rb +8 -7
- data/spec/units/test_pipeline_manager_spec.rb +54 -13
- data/spec/units/test_runner_generatinator_spec.rb +93 -1
- data/spec/units/test_search_paths_spec.rb +73 -5
- data/spec/units/test_source_file_directive_resolver_spec.rb +38 -7
- data/spec/units/tools/default_tools_quoting_spec.rb +117 -0
- data/spec/units/tools/shell_quoting_spec.rb +76 -0
- data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
- data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +27 -1
- data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
- data/spec/units/windows_registry_query_tool_spec.rb +53 -0
- data/spec/units/yaml_wrapper_spec.rb +11 -0
- metadata +265 -36
- data/lib/ceedling/file_finder_helper.rb +0 -127
- data/lib/ceedling/file_path_collection_utils.rb +0 -164
- data/spec/units/file_finder_spec.rb +0 -495
- /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
|
@@ -14,18 +14,104 @@ require 'ceedling/c_extractor/c_extractor'
|
|
|
14
14
|
require 'ceedling/c_extractor/c_extractor_constants'
|
|
15
15
|
require 'ceedling/c_extractor/c_extractor_types'
|
|
16
16
|
require 'ceedling/constants'
|
|
17
|
-
require 'ceedling/
|
|
17
|
+
require 'ceedling/filesystem/path_matcher'
|
|
18
|
+
require 'ceedling/filesystem/project_paths'
|
|
19
|
+
require 'ceedling/filesystem/path_mirror'
|
|
18
20
|
require 'ceedling/encodinator'
|
|
19
21
|
|
|
20
22
|
class Partializer
|
|
21
23
|
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
24
|
+
# Holds the place between a generated header's include groups while a list is remapped.
|
|
25
|
+
# Matched by identity, and named so no real include or module can match it.
|
|
26
|
+
INCLUDE_BOUNDARY = UserInclude.new( '<ceedling include group boundary>' ) unless const_defined?(:INCLUDE_BOUNDARY, false)
|
|
27
|
+
|
|
28
|
+
# Holds the place of a module's own header in a list from a source that never includes it.
|
|
29
|
+
# Matched by identity, so it names no module. Whatever replaces the header takes its place.
|
|
30
|
+
OWN_HEADER_PLACE = UserInclude.new( '<ceedling own header place>' ) unless const_defined?(:OWN_HEADER_PLACE, false)
|
|
31
|
+
|
|
32
|
+
# A typedef of a struct or union, whose type a variable may hold before it is complete
|
|
33
|
+
AGGREGATE_TYPEDEF = /\Atypedef\s+(?:struct|union)(?![\w$])/ unless const_defined?(:AGGREGATE_TYPEDEF, false)
|
|
34
|
+
|
|
35
|
+
# Explains helpers a Partial leaves behind because the module header has no include guard
|
|
36
|
+
UNGUARDED_HELPERS_NOTICE = <<~NOTICE unless const_defined?(:UNGUARDED_HELPERS_NOTICE, false)
|
|
37
|
+
Partial %<partial>s ⏩️ Not carrying %<noun>s %<helpers>s from %<header>s.
|
|
38
|
+
Selected functions call %<these>s, but %<header>s has no include guard. Without a guard
|
|
39
|
+
a Partial cannot stand in for the header everywhere it is included, and a carried copy could
|
|
40
|
+
collide with the real one.
|
|
41
|
+
|
|
42
|
+
OPTIONS:
|
|
43
|
+
1. Give %<header>s an include guard so the Partial can stand in for it.
|
|
44
|
+
2. Select the %<noun>s with `+name` (for example `+%<first>s`). This works only when no other
|
|
45
|
+
header this module includes pulls in %<header>s.
|
|
46
|
+
|
|
47
|
+
See the docs on Partials conventions.
|
|
48
|
+
NOTICE
|
|
49
|
+
|
|
50
|
+
# Explains what a mock-only Partial leaves behind because its module header has no include guard
|
|
51
|
+
UNGUARDED_EXTRAS_NOTICE = <<~NOTICE unless const_defined?(:UNGUARDED_EXTRAS_NOTICE, false)
|
|
52
|
+
Partial %<partial>s ⏩️ Its mock leaves %<items>s from %<header>s behind.
|
|
53
|
+
%<header>s has no include guard. Without a guard the mock can't stand in for the header everywhere
|
|
54
|
+
it's included, and a copy could collide with the real one. Code that uses %<these>s compiles only where
|
|
55
|
+
another #include brings in the real header.
|
|
56
|
+
|
|
57
|
+
Give %<header>s an include guard so the mock keeps %<them>s.
|
|
58
|
+
|
|
59
|
+
See the docs on Partials conventions.
|
|
60
|
+
NOTICE
|
|
61
|
+
|
|
62
|
+
# The same for a header that guards itself with `#pragma once`, which no generated file can
|
|
63
|
+
# define the way it defines an include guard
|
|
64
|
+
PRAGMA_ONCE_EXTRAS_NOTICE = <<~NOTICE unless const_defined?(:PRAGMA_ONCE_EXTRAS_NOTICE, false)
|
|
65
|
+
Partial %<partial>s ⏩️ Its mock leaves %<items>s from %<header>s behind.
|
|
66
|
+
|
|
67
|
+
HOW THIS HAPPENS:
|
|
68
|
+
• %<header>s uses `#pragma once`, which is not an include guard.
|
|
69
|
+
• A mock stands in for a header everywhere it's included by defining the header's include guard. Ceedling relies on include guards for this.
|
|
70
|
+
• Without one, a kept copy could collide with the real one, so the mock leaves %<them>s out.
|
|
71
|
+
• Code that uses %<these>s compiles only where another #include brings in the real header.
|
|
72
|
+
|
|
73
|
+
Replace `#pragma once` in %<header>s with an include guard so the mock keeps %<them>s.
|
|
74
|
+
|
|
75
|
+
See the docs on Partials conventions.
|
|
76
|
+
NOTICE
|
|
77
|
+
|
|
78
|
+
# The same for a module header that guards itself with `#pragma once`
|
|
79
|
+
PRAGMA_ONCE_HELPERS_NOTICE = <<~NOTICE unless const_defined?(:PRAGMA_ONCE_HELPERS_NOTICE, false)
|
|
80
|
+
Partial %<partial>s ⏩️ Not carrying %<noun>s %<helpers>s from %<header>s.
|
|
81
|
+
|
|
82
|
+
HOW THIS HAPPENS:
|
|
83
|
+
• Selected functions call %<these>s.
|
|
84
|
+
• %<header>s uses `#pragma once`, which is not an include guard.
|
|
85
|
+
• A Partial stands in for a header everywhere it's included by defining the header's include guard. Ceedling relies on include guards for this.
|
|
86
|
+
• Without one, a carried copy could collide with the real one.
|
|
87
|
+
|
|
88
|
+
OPTIONS:
|
|
89
|
+
1. Replace `#pragma once` in %<header>s with an include guard so the Partial can stand in for it.
|
|
90
|
+
2. Select the %<noun>s with `+name` (for example `+%<first>s`). This works only when no other header this module includes pulls in %<header>s.
|
|
91
|
+
|
|
92
|
+
See the docs on Partials conventions.
|
|
93
|
+
NOTICE
|
|
94
|
+
|
|
95
|
+
# Explains what other Partials go without from a module a test both tests and mocks. The
|
|
96
|
+
# notice follows the linker failure guidance: what happened, why, then numbered options.
|
|
97
|
+
TESTED_MOCK_NOTICE = <<~NOTICE unless const_defined?(:TESTED_MOCK_NOTICE, false)
|
|
98
|
+
Partial %<partial>s ⏩️ Other Partials in this test include %<header>s's mock, which leaves %<items>s out.
|
|
99
|
+
|
|
100
|
+
HOW THIS HAPPENS:
|
|
101
|
+
• A module both tested and mocked in one test keeps its header's helpers and static variables in its own implementation.
|
|
102
|
+
• Every other Partial that includes %<header>s gets the mock's interface in its place, which declares only the mocked functions.
|
|
103
|
+
• Code in those Partials that uses %<them>s fails to compile or link.
|
|
104
|
+
|
|
105
|
+
OPTIONS:
|
|
106
|
+
1. Test %<module>s in a test file of its own, and only mock it in this one.
|
|
107
|
+
2. Move what the other Partials use into a header that %<header>s includes, which the mock keeps.
|
|
108
|
+
|
|
109
|
+
See the docs on Partials conventions.
|
|
110
|
+
NOTICE
|
|
25
111
|
|
|
26
112
|
include Partials
|
|
27
113
|
|
|
28
|
-
constructor :configurator, :partializer_helper, :file_finder, :c_extractor, :file_path_utils,
|
|
114
|
+
constructor :configurator, :partializer_helper, :partializer_reconciler, :file_finder, :c_extractor, :file_path_utils,
|
|
29
115
|
:preprocessinator_reconstructor, :file_wrapper, :reportinator, :loginator
|
|
30
116
|
|
|
31
117
|
def setup()
|
|
@@ -33,7 +119,7 @@ class Partializer
|
|
|
33
119
|
@helper = @partializer_helper
|
|
34
120
|
end
|
|
35
121
|
|
|
36
|
-
def validate_config(c_module:, config:, name
|
|
122
|
+
def validate_config(c_module:, config:, name:)
|
|
37
123
|
msg = @reportinator.generate_progress("Validating Partial config for '#{name}'")
|
|
38
124
|
@loginator.log(msg, Verbosity::DEBUG)
|
|
39
125
|
@helper.validate_function_names_exist(c_module, config, name)
|
|
@@ -43,7 +129,7 @@ class Partializer
|
|
|
43
129
|
# Fallback preprocessing resolves strictly less than the accurate pass, and two module
|
|
44
130
|
# shapes are knowably beyond it. Reading the original text happens here, at the I/O edge,
|
|
45
131
|
# so the check itself stays pure.
|
|
46
|
-
return unless fallback
|
|
132
|
+
return unless config.fallback?
|
|
47
133
|
|
|
48
134
|
@helper.validate_fallback_sufficiency(
|
|
49
135
|
name: name,
|
|
@@ -52,13 +138,70 @@ class Partializer
|
|
|
52
138
|
)
|
|
53
139
|
end
|
|
54
140
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
141
|
+
# Removes the include guards the module's macros carry, from both macro_definitions and the
|
|
142
|
+
# element_sequence that references them. A generated guard belongs to a header Ceedling wrote.
|
|
143
|
+
# The real header's own guard survives preprocessing too, and every generated file already
|
|
144
|
+
# states it deliberately, so a carried copy would only repeat it. Only a guard defined bare
|
|
145
|
+
# counts, so a macro whose name merely begins with the guard's, or one giving it a value, stays.
|
|
146
|
+
def sanitize(c_module, include_guard: nil)
|
|
147
|
+
real = include_guard && /\A\s*#\s*define\s+#{Regexp.escape( include_guard )}\s*\z/
|
|
148
|
+
c_module.remove!( c_module.macro_definitions.select { |m| m.text.match?( GENERATED_INCLUDE_GUARD_PATTERN ) or (real and m.text.match?( real )) } )
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
# Decides what the Partial's implementation source carries beyond its selected functions.
|
|
152
|
+
# See PartializerHelper#plan_carry for the categories it applies.
|
|
153
|
+
#
|
|
154
|
+
# @param test [String] Test name (for log messages)
|
|
155
|
+
# @param c_module [CExtractorTypes::CModule] The module's merged contents
|
|
156
|
+
# @param impl [Array<Partials::FunctionDefinition>] Functions selected to test
|
|
157
|
+
# @param interface [Array<Partials::FunctionDeclaration>, nil] Functions selected to mock
|
|
158
|
+
# @param header_guarded [Boolean] Whether the module header has an include guard
|
|
159
|
+
# @param config [PartializerConfig::Config] The Partial, whose files are searched for
|
|
160
|
+
# carried prototypes and named in notices
|
|
161
|
+
# @return [Partials::CarryPlan]
|
|
162
|
+
def plan_carry(test:, c_module:, impl:, interface:, header_guarded:, config:)
|
|
163
|
+
plan = @helper.plan_carry(
|
|
164
|
+
c_module: c_module, impl: impl, interface: interface, fallback: config.fallback?, header_guarded: header_guarded
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
_locate_carried( plan, { header: config.header.filepath, source: config.source.filepath } )
|
|
168
|
+
plan.incomplete.merge( _incomplete_variables( c_module, config ) )
|
|
169
|
+
|
|
170
|
+
_log_plan( test, config.module, plan, config.header.filepath )
|
|
171
|
+
return plan
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# Decides what a mock-only Partial's extras header keeps of its real header beyond the mocked
|
|
175
|
+
# functions. See PartializerHelper#plan_interface_extras for what it keeps and withholds.
|
|
176
|
+
#
|
|
177
|
+
# @param test [String] Test name (for log messages)
|
|
178
|
+
# @param c_module [CExtractorTypes::CModule] The module's merged contents
|
|
179
|
+
# @param interface [Array<Partials::FunctionDeclaration>] Functions selected to mock
|
|
180
|
+
# @param header_guarded [Boolean] Whether the module header has an include guard
|
|
181
|
+
# @param config [PartializerConfig::Config] The Partial, named in notices
|
|
182
|
+
# @return [Partials::InterfaceExtras]
|
|
183
|
+
def plan_interface_extras(test:, c_module:, interface:, header_guarded:, config:)
|
|
184
|
+
extras = @helper.plan_interface_extras(
|
|
185
|
+
c_module: c_module, interface: interface, fallback: config.fallback?, header_guarded: header_guarded
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
_log_extras( "#{test}::#{config.module}", extras, config.header.filepath )
|
|
189
|
+
return extras
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Explains what other Partials go without from a module the test both tests and mocks: its
|
|
193
|
+
# implementation carries what its own code uses, but its interface keeps no extras, so another
|
|
194
|
+
# Partial including its header gets only the mocked functions. Names only what the code of
|
|
195
|
+
# the other Partials including the header uses, and says nothing when that's nothing.
|
|
196
|
+
def explain_tested_mock(test:, c_module:, interface:, header_guarded:, config:, partials:)
|
|
197
|
+
items = _extras_others_use( c_module, interface, header_guarded, config, partials )
|
|
198
|
+
return if items.empty?
|
|
199
|
+
|
|
200
|
+
notice = format(
|
|
201
|
+
TESTED_MOCK_NOTICE, partial: "#{test}::#{config.module}", header: config.header.filepath, module: config.module,
|
|
202
|
+
items: _withheld_phrase( items ), them: items.size > 1 ? 'them' : 'it'
|
|
203
|
+
)
|
|
204
|
+
@loginator.log( notice, Verbosity::COMPLAIN, LogLabels::NOTICE )
|
|
62
205
|
end
|
|
63
206
|
|
|
64
207
|
def validate_extracted_functions(name:, partial:, impl:, interface:)
|
|
@@ -124,7 +267,7 @@ class Partializer
|
|
|
124
267
|
def _find_module_source(_module, header_filepath)
|
|
125
268
|
return @file_finder.find_source_file(_module, :ignore) if _names_directory?(_module)
|
|
126
269
|
|
|
127
|
-
subdir = header_filepath.nil? ? '' : PathMirror.
|
|
270
|
+
subdir = header_filepath.nil? ? '' : PathMirror.relative_subdir_from_clean_roots( header_filepath, _header_roots )
|
|
128
271
|
|
|
129
272
|
unless subdir.empty?
|
|
130
273
|
found = @file_finder.find_source_file(File.join(subdir, _module), :ignore)
|
|
@@ -135,9 +278,9 @@ class Partializer
|
|
|
135
278
|
end
|
|
136
279
|
|
|
137
280
|
# Roots a header can sit beneath, which is what its mirrored directory is measured
|
|
138
|
-
# against
|
|
281
|
+
# against: those the project-wide header collection is built from, spelled canonically.
|
|
139
282
|
def _header_roots
|
|
140
|
-
@configurator.
|
|
283
|
+
@configurator.collection_mirror_roots_headers
|
|
141
284
|
end
|
|
142
285
|
|
|
143
286
|
# Either separator counts. The qualifier validation already rejects a backslash-rooted
|
|
@@ -162,15 +305,16 @@ class Partializer
|
|
|
162
305
|
)
|
|
163
306
|
end
|
|
164
307
|
|
|
165
|
-
# Includes for the generated implementation header
|
|
166
|
-
# the shared types header at its original list position;
|
|
167
|
-
# include is dropped.
|
|
308
|
+
# Includes for the generated implementation header, in groups (see _remap_include_groups). This
|
|
309
|
+
# module's own header is replaced by the shared types header at its original list position;
|
|
310
|
+
# every other partialized module's include is dropped.
|
|
168
311
|
#
|
|
169
312
|
# When `test:` is provided, logs the resulting includes at OBNOXIOUS.
|
|
170
|
-
def remap_implementation_header_includes(name:,
|
|
171
|
-
|
|
313
|
+
def remap_implementation_header_includes(name:, source_includes:, partials:, header_includes: [], types_header: nil, test: nil)
|
|
314
|
+
_remap_include_groups(
|
|
172
315
|
name: name,
|
|
173
|
-
|
|
316
|
+
source: source_includes,
|
|
317
|
+
header: header_includes,
|
|
174
318
|
partials: partials,
|
|
175
319
|
replacement: types_header,
|
|
176
320
|
others: :drop,
|
|
@@ -184,10 +328,11 @@ class Partializer
|
|
|
184
328
|
# in one test file still gets exactly one definition of each of its types.
|
|
185
329
|
#
|
|
186
330
|
# When `test:` is provided, logs the resulting includes at OBNOXIOUS.
|
|
187
|
-
def remap_interface_header_includes(name:,
|
|
188
|
-
|
|
331
|
+
def remap_interface_header_includes(name:, source_includes:, partials:, header_includes: [], types_header: nil, test: nil)
|
|
332
|
+
_remap_include_groups(
|
|
189
333
|
name: name,
|
|
190
|
-
|
|
334
|
+
source: source_includes,
|
|
335
|
+
header: header_includes,
|
|
191
336
|
partials: partials,
|
|
192
337
|
replacement: types_header,
|
|
193
338
|
others: :drop,
|
|
@@ -205,7 +350,7 @@ class Partializer
|
|
|
205
350
|
def remap_implementation_source_includes(name:, includes:, partials:, test: nil)
|
|
206
351
|
_remap_includes(
|
|
207
352
|
name: name,
|
|
208
|
-
includes: includes,
|
|
353
|
+
includes: _own_header_index( name, includes, partials ) ? includes : includes + [OWN_HEADER_PLACE],
|
|
209
354
|
partials: partials,
|
|
210
355
|
replacement: @file_path_utils.form_partial_implementation_header_filename(name),
|
|
211
356
|
others: :mock_or_keep,
|
|
@@ -221,10 +366,11 @@ class Partializer
|
|
|
221
366
|
# very content that module's own Partial replaced.
|
|
222
367
|
#
|
|
223
368
|
# When `test:` is provided, logs the resulting includes at OBNOXIOUS.
|
|
224
|
-
def remap_types_header_includes(name:,
|
|
225
|
-
|
|
369
|
+
def remap_types_header_includes(name:, source_includes:, partials:, header_includes: [], test: nil)
|
|
370
|
+
_remap_include_groups(
|
|
226
371
|
name: name,
|
|
227
|
-
|
|
372
|
+
source: source_includes,
|
|
373
|
+
header: header_includes,
|
|
228
374
|
partials: partials,
|
|
229
375
|
replacement: nil,
|
|
230
376
|
others: :mock_or_drop,
|
|
@@ -243,7 +389,7 @@ class Partializer
|
|
|
243
389
|
def extract_module_include_guard(filepath)
|
|
244
390
|
return nil if filepath.nil?
|
|
245
391
|
|
|
246
|
-
text = @file_wrapper.read( filepath
|
|
392
|
+
text = @file_wrapper.read( filepath ).clean_encoding
|
|
247
393
|
@preprocessinator_reconstructor.extract_include_guard( text )
|
|
248
394
|
end
|
|
249
395
|
|
|
@@ -255,10 +401,8 @@ class Partializer
|
|
|
255
401
|
# CModule structure.
|
|
256
402
|
#
|
|
257
403
|
# @param name [String] The test this extraction is running for (log/error context).
|
|
258
|
-
# @param config [
|
|
404
|
+
# @param config [PartializerConfig::Config] The Partial's own config, carrying `header`/
|
|
259
405
|
# `source` (each a ConfigFileInfo) and `module`, the module name.
|
|
260
|
-
# @param fallback [Boolean] Passed through to `associate_function_line_numbers` --
|
|
261
|
-
# whether to fall back to plain (non-directives-only) line-number association.
|
|
262
406
|
#
|
|
263
407
|
# @return [CExtractorTypes::CModule] A merged CModule containing all extracted contents
|
|
264
408
|
# from both files. The structure includes:
|
|
@@ -268,59 +412,24 @@ class Partializer
|
|
|
268
412
|
#
|
|
269
413
|
# @note The method always starts with an empty CModule and merges in contents
|
|
270
414
|
# from any provided files using the CModule's + operator for combining structures.
|
|
271
|
-
def extract_module_contents(name, config
|
|
415
|
+
def extract_module_contents(name, config)
|
|
272
416
|
# Array for CModule structs
|
|
273
417
|
contents = [CExtractorTypes::CModule.new()]
|
|
274
418
|
|
|
275
419
|
# Process the C module source and/or header associated with the Partial config
|
|
276
420
|
[config.header, config.source].zip(['header', 'source']).each do |c_file, file_type|
|
|
277
|
-
#
|
|
278
|
-
next unless c_file.
|
|
279
|
-
|
|
280
|
-
c_module = @c_extractor.from_file( c_file.directives_only_filepath )
|
|
281
|
-
|
|
282
|
-
_log_module_contents(name, config.module, file_type, c_module)
|
|
283
|
-
|
|
284
|
-
# Update function signatures from fully preprocessed output when available.
|
|
285
|
-
# Replaces signature/decorators/signature_stripped (but NOT code_block) so that
|
|
286
|
-
# macros wrapping `static` and `inline` are resolved before visibility filtering.
|
|
287
|
-
if c_file.full_expansion_filepath
|
|
288
|
-
@helper.update_signatures_from_full_expansion(
|
|
289
|
-
funcs: c_module.function_definitions,
|
|
290
|
-
full_expansion_filepath: c_file.full_expansion_filepath,
|
|
291
|
-
name: name,
|
|
292
|
-
module_name: config.module,
|
|
293
|
-
file_type: file_type
|
|
294
|
-
)
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
# Align extracted function definitions with line markers in preprocessor output.
|
|
298
|
-
# This perfectly remaps functions found in expanded preprocessor output with
|
|
299
|
-
# original source location.
|
|
300
|
-
# This routine depends on original, unaltered function definitions.
|
|
301
|
-
@helper.associate_function_line_numbers(
|
|
302
|
-
name: name,
|
|
303
|
-
funcs: c_module.function_definitions,
|
|
304
|
-
filepath: c_file.filepath,
|
|
305
|
-
fallback: fallback
|
|
306
|
-
)
|
|
307
|
-
|
|
308
|
-
# 1. Find any function-scope static variable declarations.
|
|
309
|
-
# 2. Replace them in function definitions with no-ops (for proper coverage reporting).
|
|
310
|
-
# 3. Promote the function-scoped variables to be module-level variables.
|
|
311
|
-
decls = @helper.extract_function_scope_static_vars(
|
|
312
|
-
c_module.function_definitions,
|
|
313
|
-
name: name, module_name: config.module, file_type: file_type
|
|
314
|
-
)
|
|
315
|
-
c_module.variable_declarations.concat(decls)
|
|
316
|
-
c_module.element_sequence.concat(decls) unless decls.empty?
|
|
421
|
+
# Skip a file preprocessing never assembled, such as the absent source of a header-only Partial mock
|
|
422
|
+
next unless c_file.assembled_filepath
|
|
317
423
|
|
|
318
|
-
contents <<
|
|
424
|
+
contents << _extract_file_contents( name, config, c_file, file_type )
|
|
319
425
|
end
|
|
320
426
|
|
|
321
427
|
# Use `+` operator for CModule to merge everything
|
|
322
428
|
contents = contents.reduce(&:+)
|
|
323
429
|
|
|
430
|
+
# Only the merged module knows which functions have a body
|
|
431
|
+
_mark_inline_elsewhere( config, contents )
|
|
432
|
+
|
|
324
433
|
return contents
|
|
325
434
|
end
|
|
326
435
|
|
|
@@ -411,12 +520,7 @@ class Partializer
|
|
|
411
520
|
Verbosity::DEBUG
|
|
412
521
|
)
|
|
413
522
|
|
|
414
|
-
|
|
415
|
-
# function (no body found anywhere in this module's merged content) is just as valid a
|
|
416
|
-
# candidate as one with a definition -- unlike extract_implementation_functions, which
|
|
417
|
-
# needs real code to inject and so stays definitions-only. A function named in both
|
|
418
|
-
# (declared in the header, defined in the paired source) is only counted once.
|
|
419
|
-
candidates = definitions + declarations.reject { |d| definitions.any? { |f| f.name == d.name } }
|
|
523
|
+
candidates = _mock_candidates( test, partial, definitions, declarations )
|
|
420
524
|
|
|
421
525
|
# Build initial list by visibility; ACCUMULATE yields []
|
|
422
526
|
funcs = @helper.filter_and_transform_funcs(candidates, pf.type, :interface)
|
|
@@ -453,6 +557,295 @@ class Partializer
|
|
|
453
557
|
|
|
454
558
|
private
|
|
455
559
|
|
|
560
|
+
# Extracts one of a module's files, a header or a source, ready to merge with the other.
|
|
561
|
+
def _extract_file_contents(name, config, c_file, file_type)
|
|
562
|
+
c_module = @c_extractor.from_file( c_file.assembled_filepath )
|
|
563
|
+
@helper.validate_function_names_readable( c_module, name, config.module )
|
|
564
|
+
|
|
565
|
+
_log_module_contents(name, config.module, file_type, c_module)
|
|
566
|
+
|
|
567
|
+
_reconcile( name, config, c_file, file_type, c_module ) if c_file.expansion_filepath
|
|
568
|
+
_locate_contents( c_file, c_module )
|
|
569
|
+
_promote_function_scope_statics( name, config, file_type, c_module )
|
|
570
|
+
Partials.name_defined_types( c_module, config.module )
|
|
571
|
+
|
|
572
|
+
return c_module.stamp_origin!( file_type.to_sym )
|
|
573
|
+
end
|
|
574
|
+
|
|
575
|
+
# Each item takes from its twin in the file's expanded code what a macro can hide, before
|
|
576
|
+
# visibility filtering reads it. What line location reads stays as written.
|
|
577
|
+
def _reconcile(name, config, c_file, file_type, c_module)
|
|
578
|
+
@partializer_reconciler.reconcile(
|
|
579
|
+
c_module: c_module, expansion_filepath: c_file.expansion_filepath, name: name, module_name: config.module, file_type: file_type
|
|
580
|
+
)
|
|
581
|
+
end
|
|
582
|
+
|
|
583
|
+
# A header a file includes may define inline a function the module declares but never
|
|
584
|
+
# defines. Under C99 the declaring file then holds that function's external definition. Each
|
|
585
|
+
# file's raw directives-only copy holds every header it includes, so the inline body is
|
|
586
|
+
# looked for there. A function the module defines is never looked for, since nothing reads
|
|
587
|
+
# its mark. The copy is read as bytes, which is all the scan needs.
|
|
588
|
+
def _mark_inline_elsewhere(config, c_module)
|
|
589
|
+
undefined = _declaration_only( c_module.function_definitions, c_module.function_declarations )
|
|
590
|
+
|
|
591
|
+
{ header: config.header, source: config.source }.each do |origin, c_file|
|
|
592
|
+
decls = undefined.select { |decl| decl.origin == origin }
|
|
593
|
+
_mark_from_raw_copy( c_file, decls ) unless decls.empty?
|
|
594
|
+
end
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
# A file preprocessed in fallback has no raw copy, so nothing is marked from it
|
|
598
|
+
def _mark_from_raw_copy(c_file, decls)
|
|
599
|
+
raw = c_file.raw_directives_only_filepath
|
|
600
|
+
return if raw.nil?
|
|
601
|
+
|
|
602
|
+
@helper.mark_inline_elsewhere( decls: decls, text: @file_wrapper.read_binary( raw ) )
|
|
603
|
+
end
|
|
604
|
+
|
|
605
|
+
# The declarations of functions with no definition among `definitions`
|
|
606
|
+
def _declaration_only(definitions, declarations)
|
|
607
|
+
defined = Set.new( definitions.map( &:name ) )
|
|
608
|
+
return declarations.reject { |decl| defined.include?( decl.name ) }
|
|
609
|
+
end
|
|
610
|
+
|
|
611
|
+
def _locate_contents(c_file, c_module)
|
|
612
|
+
# Align extracted function definitions with line markers in preprocessor output.
|
|
613
|
+
# This perfectly remaps functions found in expanded preprocessor output with
|
|
614
|
+
# original source location.
|
|
615
|
+
# This routine depends on original, unaltered function definitions.
|
|
616
|
+
@helper.associate_function_line_numbers(
|
|
617
|
+
funcs: c_module.function_definitions, filepath: c_file.filepath, raw_filepath: c_file.raw_directives_only_filepath
|
|
618
|
+
)
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
# 1. Find any function-scope static variable declarations.
|
|
622
|
+
# 2. Replace them in function definitions with no-ops (for proper coverage reporting).
|
|
623
|
+
# 3. Promote the function-scoped variables to be module-level variables.
|
|
624
|
+
def _promote_function_scope_statics(name, config, file_type, c_module)
|
|
625
|
+
@helper.promote_function_scope_statics( c_module, name: name, module_name: config.module, file_type: file_type )
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
# A mock interface only ever needs a signature, never a body, so a declaration-only
|
|
629
|
+
# function (no body found anywhere in this module's merged content) is just as valid a
|
|
630
|
+
# candidate as one with a definition -- unlike extract_implementation_functions, which
|
|
631
|
+
# needs real code to inject and so stays definitions-only. A function named in both
|
|
632
|
+
# (declared in the header, defined in the paired source) is only counted once.
|
|
633
|
+
#
|
|
634
|
+
# An inline function the module only declares has its body in a header it includes. A mock
|
|
635
|
+
# can never replace that body, so mocking it would only define the function twice. It stays
|
|
636
|
+
# out, and the implementation source carries its prototype when the module is also tested.
|
|
637
|
+
def _mock_candidates(test, partial, definitions, declarations)
|
|
638
|
+
declaration_only = _declaration_only( definitions, declarations )
|
|
639
|
+
foreign_inline = Set.new( declaration_only.select { |d| Partials.foreign_inline?( d ) }.map( &:name ) )
|
|
640
|
+
|
|
641
|
+
_log_not_mockable( test, partial, foreign_inline )
|
|
642
|
+
return definitions + declaration_only.reject { |d| foreign_inline.include?( d.name ) }
|
|
643
|
+
end
|
|
644
|
+
|
|
645
|
+
def _log_not_mockable(test, partial, names)
|
|
646
|
+
return if names.empty?
|
|
647
|
+
|
|
648
|
+
@loginator.log_list(
|
|
649
|
+
names.map { |n| "`#{n}`" },
|
|
650
|
+
"Not mockable for Partial #{test}::#{partial} (inline, body outside module):",
|
|
651
|
+
Verbosity::DEBUG
|
|
652
|
+
)
|
|
653
|
+
end
|
|
654
|
+
|
|
655
|
+
# Variables the module declares `extern` whose struct or union type is never completed,
|
|
656
|
+
# directly or through a typedef the module makes. No definition of one compiles, weak or not.
|
|
657
|
+
# The module's own files are searched for the completing definition, and so are their raw
|
|
658
|
+
# directives-only copies where those exist, since a copy holds every header its file includes.
|
|
659
|
+
def _incomplete_variables(c_module, config)
|
|
660
|
+
candidates = _extern_aggregates( c_module )
|
|
661
|
+
return Set.new if candidates.empty?
|
|
662
|
+
|
|
663
|
+
texts = _translation_unit_texts( config )
|
|
664
|
+
return Set.new( candidates.filter_map { |var, tag| var.name unless _completed?( tag, texts ) } )
|
|
665
|
+
end
|
|
666
|
+
|
|
667
|
+
# Each extern variable whose type names a struct or union by value, paired with its tag. A
|
|
668
|
+
# declarator in parentheses makes a pointer, which holds no struct by value.
|
|
669
|
+
def _extern_aggregates(c_module)
|
|
670
|
+
tags = _aggregate_tags( c_module )
|
|
671
|
+
plain = c_module.variable_declarations.select { |v| v.extern? and v.declarator.nil? }
|
|
672
|
+
return plain.filter_map { |v| [v, tags[Partials.named_type( v )]] if tags.key?( Partials.named_type( v ) ) }
|
|
673
|
+
end
|
|
674
|
+
|
|
675
|
+
# Each type a variable may name by value that is a struct or union tag, keyed to its tag. A
|
|
676
|
+
# pointer to an incomplete type is complete itself, so only `struct x` and typedef names count.
|
|
677
|
+
def _aggregate_tags(c_module)
|
|
678
|
+
tags = {}
|
|
679
|
+
c_module.variable_declarations.each do |v|
|
|
680
|
+
tag = Partials.named_type( v )[/\A(?:struct|union)\s+([\w$]+)\z/, 1]
|
|
681
|
+
tags[Partials.named_type( v )] = tag if tag
|
|
682
|
+
end
|
|
683
|
+
c_module.type_definitions.each do |typedef|
|
|
684
|
+
tags[typedef.type_name] = typedef.tag if typedef.tag and typedef.type_name and typedef.text.match?( AGGREGATE_TYPEDEF )
|
|
685
|
+
end
|
|
686
|
+
|
|
687
|
+
return tags
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
# Each of the module's files and its raw copy where one exists, read as bytes, which is all
|
|
691
|
+
# the search needs.
|
|
692
|
+
# Transcoding a raw copy would cost far more than reading it.
|
|
693
|
+
def _translation_unit_texts(config)
|
|
694
|
+
files = [config.header, config.source].select( &:filepath )
|
|
695
|
+
paths = files.map( &:filepath ) + files.filter_map( &:raw_directives_only_filepath )
|
|
696
|
+
return paths.map { |path| @file_wrapper.read_binary( path ) }
|
|
697
|
+
end
|
|
698
|
+
|
|
699
|
+
def _completed?(tag, texts)
|
|
700
|
+
return texts.any? { |text| text.match?( /(?<![\w$])(?:struct|union)\s+#{Regexp.escape( tag )}\s*\{/ ) }
|
|
701
|
+
end
|
|
702
|
+
|
|
703
|
+
# A carried prototype is written behind a #line naming its own file and line. Each is found in
|
|
704
|
+
# its original file's own text, where no included header's lines can be mistaken for it. Only
|
|
705
|
+
# carried prototypes are located, since each costs a search of the file.
|
|
706
|
+
def _locate_carried(plan, filepaths)
|
|
707
|
+
plan.prototypes.map( &:item ).group_by( &:origin ).each do |origin, decls|
|
|
708
|
+
filepath = filepaths[origin]
|
|
709
|
+
next if filepath.nil?
|
|
710
|
+
|
|
711
|
+
@helper.associate_declaration_line_numbers(
|
|
712
|
+
decls: decls, filepath: filepath, text: @file_wrapper.read( filepath ).clean_encoding
|
|
713
|
+
)
|
|
714
|
+
end
|
|
715
|
+
end
|
|
716
|
+
|
|
717
|
+
def _log_plan(test, partial, plan, header_filepath)
|
|
718
|
+
_log_carried( test, partial, plan )
|
|
719
|
+
plan.skipped.each { |skipped| _log_not_carried( test, partial, skipped ) }
|
|
720
|
+
|
|
721
|
+
unguarded = plan.skipped.select { |skipped| skipped.kind == :unguarded_helper }.map( &:item )
|
|
722
|
+
_log_unguarded_helpers( test, partial, unguarded, header_filepath ) unless unguarded.empty?
|
|
723
|
+
end
|
|
724
|
+
|
|
725
|
+
# Lists what a Partial carries and why, so a user can trace what its implementation holds
|
|
726
|
+
def _log_carried(test, partial, plan)
|
|
727
|
+
entries = plan.prototypes.map { |carried| "`#{carried.item.signature.strip}` (#{carried.reason})" }
|
|
728
|
+
entries += plan.helpers.map { |name, carried| "`#{name}()` (#{carried.reason})" }
|
|
729
|
+
return if entries.empty?
|
|
730
|
+
|
|
731
|
+
@loginator.log_list( entries, "Carried into Partial #{test}::#{partial} implementation:", Verbosity::DEBUG )
|
|
732
|
+
end
|
|
733
|
+
|
|
734
|
+
# A skipped name is one a selected function may need, so each gets a notice saying why
|
|
735
|
+
def _log_not_carried(test, partial, skipped)
|
|
736
|
+
msg = _not_carried_message( skipped.kind, skipped.item )
|
|
737
|
+
@loginator.log( "Partial #{test}::#{partial} ⏩️ #{msg}", Verbosity::COMPLAIN, LogLabels::NOTICE ) if msg
|
|
738
|
+
end
|
|
739
|
+
|
|
740
|
+
def _not_carried_message(kind, name)
|
|
741
|
+
case kind
|
|
742
|
+
when :helper_conflict
|
|
743
|
+
return "Not carrying helper `#{name}()`: fallback preprocessing found more than one definition. " \
|
|
744
|
+
"Add `+#{name}` if a selected function needs it"
|
|
745
|
+
when :prototype_conflict
|
|
746
|
+
return "Not carrying `#{name}()`: fallback preprocessing found conflicting declarations"
|
|
747
|
+
end
|
|
748
|
+
|
|
749
|
+
return nil
|
|
750
|
+
end
|
|
751
|
+
|
|
752
|
+
# A header without an include guard can't be stood in for, so its helpers stay behind. The
|
|
753
|
+
# notice follows the linker failure guidance: what happened, why, then numbered options.
|
|
754
|
+
def _log_unguarded_helpers(test, partial, names, header)
|
|
755
|
+
many = names.size > 1
|
|
756
|
+
notice = format(
|
|
757
|
+
_pragma_once?( header ) ? PRAGMA_ONCE_HELPERS_NOTICE : UNGUARDED_HELPERS_NOTICE,
|
|
758
|
+
partial: "#{test}::#{partial}", header: header, first: names.first,
|
|
759
|
+
helpers: names.map { |n| "`#{n}()`" }.join( ', ' ),
|
|
760
|
+
noun: many ? 'helpers' : 'helper', these: many ? 'these helpers' : 'this helper'
|
|
761
|
+
)
|
|
762
|
+
|
|
763
|
+
@loginator.log( notice, Verbosity::COMPLAIN, LogLabels::NOTICE )
|
|
764
|
+
end
|
|
765
|
+
|
|
766
|
+
# Lists what a mock-only Partial keeps, and explains what an unguarded header's mock leaves behind
|
|
767
|
+
def _log_extras(partial, extras, header)
|
|
768
|
+
entries = extras.items.map { |item| _extras_entry( item ) }
|
|
769
|
+
@loginator.log_list( entries, "Kept in the mock of Partial #{partial}:", Verbosity::DEBUG ) unless entries.empty?
|
|
770
|
+
return if extras.withheld.empty?
|
|
771
|
+
|
|
772
|
+
many = extras.withheld.size > 1
|
|
773
|
+
notice = _pragma_once?( header ) ? PRAGMA_ONCE_EXTRAS_NOTICE : UNGUARDED_EXTRAS_NOTICE
|
|
774
|
+
@loginator.log(
|
|
775
|
+
format( notice, partial: partial, header: header, items: _withheld_phrase( extras.withheld ),
|
|
776
|
+
these: many ? 'these' : 'it', them: many ? 'them' : 'it' ),
|
|
777
|
+
Verbosity::COMPLAIN, LogLabels::NOTICE
|
|
778
|
+
)
|
|
779
|
+
end
|
|
780
|
+
|
|
781
|
+
# The header is read again only when something stays behind, to say what guards it
|
|
782
|
+
def _pragma_once?(header)
|
|
783
|
+
return @preprocessinator_reconstructor.pragma_once?( @file_wrapper.read( header ).clean_encoding )
|
|
784
|
+
end
|
|
785
|
+
|
|
786
|
+
def _extras_entry(item)
|
|
787
|
+
case item
|
|
788
|
+
when CExtractorTypes::CFunctionDefinition then return "`#{item.name}()` (helper)"
|
|
789
|
+
when CExtractorTypes::CFunctionDeclaration then return "`#{item.name}()` (prototype)"
|
|
790
|
+
end
|
|
791
|
+
|
|
792
|
+
return "`#{item.name}` (#{item.extern? ? 'extern declaration' : 'static variable'})"
|
|
793
|
+
end
|
|
794
|
+
|
|
795
|
+
# As in "helper `twice()` and variables `a`, `b`", or "helper `twice()`, variable `a` and prototype `get()`"
|
|
796
|
+
def _withheld_phrase(items)
|
|
797
|
+
phrases = EXTRAS_NOUNS.filter_map do |kind, noun|
|
|
798
|
+
named = items.select { |item| item.is_a?( kind ) }
|
|
799
|
+
_named( noun, named.map { |item| kind == CExtractorTypes::CVariableDeclaration ? "`#{item.name}`" : "`#{item.name}()`" } ) unless named.empty?
|
|
800
|
+
end
|
|
801
|
+
|
|
802
|
+
return phrases.size > 1 ? "#{phrases[0..-2].join( ', ' )} and #{phrases.last}" : phrases.join
|
|
803
|
+
end
|
|
804
|
+
|
|
805
|
+
# What an extras item is called in a notice
|
|
806
|
+
EXTRAS_NOUNS = {
|
|
807
|
+
CExtractorTypes::CFunctionDefinition => 'helper',
|
|
808
|
+
CExtractorTypes::CVariableDeclaration => 'variable',
|
|
809
|
+
CExtractorTypes::CFunctionDeclaration => 'prototype'
|
|
810
|
+
}.freeze unless const_defined?(:EXTRAS_NOUNS, false)
|
|
811
|
+
|
|
812
|
+
# What a module's mock would keep in extras that the code of other Partials including its header uses
|
|
813
|
+
def _extras_others_use(c_module, interface, header_guarded, config, partials)
|
|
814
|
+
extras = @helper.plan_interface_extras(
|
|
815
|
+
c_module: c_module, interface: interface, fallback: config.fallback?, header_guarded: header_guarded
|
|
816
|
+
)
|
|
817
|
+
return [] if extras.items.empty?
|
|
818
|
+
|
|
819
|
+
used = _names_used_by_includers( config.module, partials )
|
|
820
|
+
return extras.items.select { |item| used.include?( item.name ) }
|
|
821
|
+
end
|
|
822
|
+
|
|
823
|
+
# The names the code of every other Partial including the module's header uses, from each
|
|
824
|
+
# file's full expansion, which shows a use through a macro, or else the file stages 6 and 7
|
|
825
|
+
# assembled for it
|
|
826
|
+
def _names_used_by_includers(_module, partials)
|
|
827
|
+
paths = _includers( _module, partials ).flat_map { |config| _module_files( config ) }.filter_map do |file|
|
|
828
|
+
file.expansion_filepath || file.assembled_filepath
|
|
829
|
+
end
|
|
830
|
+
|
|
831
|
+
return paths.each_with_object( Set.new ) { |path, used| used.merge( @helper.names_in( @file_wrapper.read( path ).clean_encoding ) ) }
|
|
832
|
+
end
|
|
833
|
+
|
|
834
|
+
# Every other Partial whose files include the module's header
|
|
835
|
+
def _includers(_module, partials)
|
|
836
|
+
return partials.reject { |other, _| other == _module }.values.select do |config|
|
|
837
|
+
_module_files( config ).flat_map { |file| Array( file.includes ) }.any? { |include| _names_module?( include, _module, partials ) }
|
|
838
|
+
end
|
|
839
|
+
end
|
|
840
|
+
|
|
841
|
+
def _module_files(config)
|
|
842
|
+
return [config.source, config.header].compact
|
|
843
|
+
end
|
|
844
|
+
|
|
845
|
+
def _named(noun, names)
|
|
846
|
+
return "#{noun}#{'s' if names.size > 1} #{names.join( ', ' )}"
|
|
847
|
+
end
|
|
848
|
+
|
|
456
849
|
# Log all user-defined (non-function) C content extracted from a module's source/header at OBNOXIOUS level.
|
|
457
850
|
# Covers the four categories that are injected into generated Partial files:
|
|
458
851
|
# variable declarations, type definitions, macro definitions, and aggregate definitions
|
|
@@ -507,16 +900,42 @@ class Partializer
|
|
|
507
900
|
)
|
|
508
901
|
end
|
|
509
902
|
|
|
510
|
-
# The module
|
|
511
|
-
#
|
|
903
|
+
# The text of each module file preprocessed in fallback, keyed by filepath. Fallback's limits
|
|
904
|
+
# belong to the file that fell back, so a file preprocessed accurately isn't checked. A
|
|
905
|
+
# declaration-only Partial has no paired source, which leaves that filepath legitimately nil.
|
|
512
906
|
def _module_file_texts(config)
|
|
513
907
|
[config.header, config.source].filter_map do |file_info|
|
|
514
|
-
next if file_info.nil? || file_info.filepath.nil?
|
|
908
|
+
next if file_info.nil? || file_info.filepath.nil? || !file_info.fallback
|
|
515
909
|
|
|
516
910
|
[file_info.filepath, @file_wrapper.read( file_info.filepath ).clean_encoding]
|
|
517
911
|
end.to_h
|
|
518
912
|
end
|
|
519
913
|
|
|
914
|
+
# A generated header's includes in the order the source compiles them: the source's includes
|
|
915
|
+
# ahead of the module's header, the header's own, then the source's after it. The last make
|
|
916
|
+
# up the following group (see Partials::IncludeGroups).
|
|
917
|
+
#
|
|
918
|
+
# A source that never includes its own header, or a header-only module's absent source, is
|
|
919
|
+
# read as including it last. OWN_HEADER_PLACE holds that place, so whatever replaces the
|
|
920
|
+
# module's header lands there, in the leading group, ahead of the declarations. The following
|
|
921
|
+
# group is then empty.
|
|
922
|
+
#
|
|
923
|
+
# The whole list is remapped at once, so deduplication, redirects, and sorting see every
|
|
924
|
+
# include. An include in both groups keeps its earlier place. A marker holds the boundary.
|
|
925
|
+
def _remap_include_groups(name:, source:, header:, **remap)
|
|
926
|
+
index = _own_header_index( name, source, remap[:partials] )
|
|
927
|
+
leading = index.nil? ? source + [OWN_HEADER_PLACE] : source[0..index]
|
|
928
|
+
following = index.nil? ? [] : source[(index + 1)..]
|
|
929
|
+
remapped = _remap_includes( name: name, includes: leading + header + [INCLUDE_BOUNDARY] + following, **remap )
|
|
930
|
+
|
|
931
|
+
return Partials::IncludeGroups.split( remapped, INCLUDE_BOUNDARY )
|
|
932
|
+
end
|
|
933
|
+
|
|
934
|
+
# Where the source includes the module's own header, or nil when it never does
|
|
935
|
+
def _own_header_index(name, source, partials)
|
|
936
|
+
return source.index { |include| _names_module?( include, name, partials ) }
|
|
937
|
+
end
|
|
938
|
+
|
|
520
939
|
# One body behind all four public remaps. Each differs only in what replaces this module's
|
|
521
940
|
# own header, what becomes of other partialized modules, and the noun it logs under -- the
|
|
522
941
|
# splice, the sanitize, and the logging are identical in every case.
|
|
@@ -529,12 +948,12 @@ class Partializer
|
|
|
529
948
|
_includes = includes.clone()
|
|
530
949
|
|
|
531
950
|
# A nil replacement strips this module's own header and substitutes nothing.
|
|
532
|
-
_includes = splice_in_replacement( includes: _includes, name: name, replacement: replacement )
|
|
951
|
+
_includes = splice_in_replacement( includes: _includes, name: name, replacement: replacement, partials: partials )
|
|
533
952
|
|
|
534
953
|
_includes =
|
|
535
954
|
case others
|
|
536
955
|
when :drop
|
|
537
|
-
remove_matching_includes( includes: _includes, modules: (partials.keys - [name]) )
|
|
956
|
+
remove_matching_includes( includes: _includes, modules: (partials.keys - [name]), partials: partials )
|
|
538
957
|
when :mock_or_keep, :mock_or_drop
|
|
539
958
|
# The types header differs from the generated source in two ways at once, which is why
|
|
540
959
|
# both flags below read from one condition.
|
|
@@ -555,17 +974,19 @@ class Partializer
|
|
|
555
974
|
name: name,
|
|
556
975
|
partials: partials,
|
|
557
976
|
drop_unmocked: shared_types_header,
|
|
558
|
-
skip_self: shared_types_header
|
|
977
|
+
skip_self: shared_types_header,
|
|
978
|
+
replacement: replacement
|
|
559
979
|
)
|
|
560
980
|
else
|
|
561
981
|
PartializerRuntime.raise_on_option( others )
|
|
562
982
|
end
|
|
563
983
|
|
|
564
|
-
# Remove any duplicates
|
|
984
|
+
# Remove any duplicates, and fallback's unresolved text beside the header it names
|
|
565
985
|
Includes.sanitize!(_includes)
|
|
986
|
+
Includes.drop_shadowed!(_includes)
|
|
566
987
|
|
|
567
988
|
@loginator.log_list(
|
|
568
|
-
_includes,
|
|
989
|
+
_includes.reject { |include| include.equal?( INCLUDE_BOUNDARY ) },
|
|
569
990
|
"#{noun} #{test}::#{name}:",
|
|
570
991
|
Verbosity::OBNOXIOUS
|
|
571
992
|
) if test
|
|
@@ -573,10 +994,10 @@ class Partializer
|
|
|
573
994
|
return _includes
|
|
574
995
|
end
|
|
575
996
|
|
|
576
|
-
#
|
|
577
|
-
# named
|
|
578
|
-
# being generated counts as one of them,
|
|
579
|
-
# see the call site.
|
|
997
|
+
# Puts the generated interface header of each mocked partialized module the original list
|
|
998
|
+
# named where that module's real header was, then removes any other copies of the real
|
|
999
|
+
# headers. `skip_self` decides whether the module being generated counts as one of them,
|
|
1000
|
+
# which it does everywhere except the types header -- see the call site.
|
|
580
1001
|
#
|
|
581
1002
|
# Mutates `includes`, which always arrives fresh from splice_in_replacement.
|
|
582
1003
|
#
|
|
@@ -585,24 +1006,44 @@ class Partializer
|
|
|
585
1006
|
# added later without updating the check, so a module mocked via either was silently never
|
|
586
1007
|
# redirected: its real header, and any static inline or static function bodies in it, stayed
|
|
587
1008
|
# #include'd verbatim and compiled straight past the mock.
|
|
588
|
-
def _redirect_mocked_partials(includes:, original:, name:, partials:, drop_unmocked:, skip_self:)
|
|
1009
|
+
def _redirect_mocked_partials(includes:, original:, name:, partials:, drop_unmocked:, skip_self:, replacement:)
|
|
589
1010
|
retired = []
|
|
590
1011
|
|
|
591
1012
|
partials.each do |_module, config|
|
|
592
1013
|
next if skip_self && _module == name
|
|
593
|
-
next unless
|
|
1014
|
+
next unless _named_in?( original, _module, name, partials )
|
|
594
1015
|
|
|
595
1016
|
if config.mocks.type.nil?
|
|
596
1017
|
retired << _module if drop_unmocked
|
|
597
1018
|
else
|
|
598
|
-
includes
|
|
599
|
-
@file_path_utils.form_partial_interface_header_filename(_module)
|
|
600
|
-
)
|
|
1019
|
+
_place_interface_header( includes, _module, (_module == name) ? replacement : nil, partials )
|
|
601
1020
|
retired << _module
|
|
602
1021
|
end
|
|
603
1022
|
end
|
|
604
1023
|
|
|
605
|
-
remove_matching_includes( includes: includes, modules: retired )
|
|
1024
|
+
remove_matching_includes( includes: includes, modules: retired, partials: partials )
|
|
1025
|
+
end
|
|
1026
|
+
|
|
1027
|
+
# Whether a list names a partialized module. The module being generated is named by the
|
|
1028
|
+
# place a source that never includes its own header holds for it, too.
|
|
1029
|
+
def _named_in?(includes, _module, name, partials)
|
|
1030
|
+
return includes.any? { |include| (_module == name) ? _own_header?( include, name, partials ) : _names_module?( include, _module, partials ) }
|
|
1031
|
+
end
|
|
1032
|
+
|
|
1033
|
+
# An interface header declares what its module's real header declared, which the includes
|
|
1034
|
+
# after it may rely on. So it takes that header's place. The module being generated has
|
|
1035
|
+
# already had its header replaced, so its interface header follows the replacement. With
|
|
1036
|
+
# neither in the list, it goes last.
|
|
1037
|
+
def _place_interface_header(includes, _module, replacement, partials)
|
|
1038
|
+
interface = UserInclude.new( @file_path_utils.form_partial_interface_header_filename(_module) )
|
|
1039
|
+
|
|
1040
|
+
index = includes.index { |include| _names_module?( include, _module, partials ) }
|
|
1041
|
+
return includes[index] = interface if index
|
|
1042
|
+
|
|
1043
|
+
index = replacement && includes.index { |include| include.filename == File.basename( replacement ) }
|
|
1044
|
+
return includes.insert( index + 1, interface ) if index
|
|
1045
|
+
|
|
1046
|
+
includes << interface
|
|
606
1047
|
end
|
|
607
1048
|
|
|
608
1049
|
# Swaps `name`'s own header include for `replacement` at that same list position,
|
|
@@ -622,40 +1063,78 @@ class Partializer
|
|
|
622
1063
|
# depends on that came before it in the source's own working include order (e.g. a
|
|
623
1064
|
# shared Types.h), while still landing ahead of anything transitively re-reaching the
|
|
624
1065
|
# real header afterward.
|
|
625
|
-
def splice_in_replacement(includes:, name:, replacement:)
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
else
|
|
634
|
-
include
|
|
635
|
-
end
|
|
1066
|
+
def splice_in_replacement(includes:, name:, replacement:, partials: {})
|
|
1067
|
+
spliced = includes.dup
|
|
1068
|
+
index = spliced.index { |include| _own_header?( include, name, partials ) }
|
|
1069
|
+
|
|
1070
|
+
# Every remap holds a place for the module's own header (see OWN_HEADER_PLACE). A list
|
|
1071
|
+
# without one has no position to preserve, so the replacement goes last.
|
|
1072
|
+
if replacement
|
|
1073
|
+
index ? (spliced[index] = UserInclude.new( replacement )) : (spliced << UserInclude.new( replacement ))
|
|
636
1074
|
end
|
|
637
|
-
# This module's own header wasn't in the includes list at all -- no original
|
|
638
|
-
# position to preserve, so fall back to appending.
|
|
639
|
-
spliced << UserInclude.new(replacement) unless replaced
|
|
640
1075
|
|
|
641
1076
|
# A duplicate/case-variant entry beyond the first match (e.g. both 'module.h' and
|
|
642
|
-
# 'MODULE.H' present) has no meaningful position of its own to preserve -- drop it
|
|
643
|
-
|
|
644
|
-
spliced = remove_matching_includes(includes: spliced, modules: [name])
|
|
645
|
-
spliced
|
|
1077
|
+
# 'MODULE.H' present) has no meaningful position of its own to preserve -- drop it too.
|
|
1078
|
+
return spliced.reject { |include| _own_header?( include, name, partials ) }
|
|
646
1079
|
end
|
|
647
1080
|
|
|
648
|
-
#
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
1081
|
+
# The module's own header, or the place a source that never includes it holds for it
|
|
1082
|
+
def _own_header?(include, name, partials)
|
|
1083
|
+
return (include.equal?( OWN_HEADER_PLACE ) or _names_module?( include, name, partials ))
|
|
1084
|
+
end
|
|
652
1085
|
|
|
653
|
-
|
|
1086
|
+
# Remove includes that name any of the given modules (see _names_module?)
|
|
1087
|
+
# Returns a new array with matching includes removed
|
|
1088
|
+
def remove_matching_includes(includes:, modules:, partials: {})
|
|
654
1089
|
return includes.reject do |include|
|
|
655
|
-
|
|
1090
|
+
modules.any? { |_module| _names_module?( include, _module, partials ) }
|
|
656
1091
|
end
|
|
657
1092
|
end
|
|
658
1093
|
|
|
1094
|
+
# Whether `include` names partialized module `_module`: its filename, less extension and in
|
|
1095
|
+
# any case, is the module's basename.
|
|
1096
|
+
#
|
|
1097
|
+
# A module named without a directory is named by its basename alone, as its own #include
|
|
1098
|
+
# spells it, short of a header a same-named module named by directory claims. Naming a
|
|
1099
|
+
# module by directory says its basename isn't enough, since another header, partialized or
|
|
1100
|
+
# not, may share it, so that module's header path decides (see _same_header_path?). One
|
|
1101
|
+
# whose header path is unknown is named by basename alone.
|
|
1102
|
+
def _names_module?(include, _module, partials)
|
|
1103
|
+
return false unless include.filename.ext().downcase() == module_basename( _module )
|
|
1104
|
+
return !_claimed_by_directory?( include, _module, partials ) if File.dirname( _module ) == '.'
|
|
1105
|
+
|
|
1106
|
+
header = partials.dig( _module )&.header&.filepath
|
|
1107
|
+
return true if header.nil? or _unanchored?( include )
|
|
1108
|
+
|
|
1109
|
+
return _same_header_path?( include.filepath, header )
|
|
1110
|
+
end
|
|
1111
|
+
|
|
1112
|
+
# Fallback anchors a `..` #include to its file's own directory. One naming no file there was
|
|
1113
|
+
# found elsewhere through a search path, so its path says nothing and its filename decides.
|
|
1114
|
+
def _unanchored?(include)
|
|
1115
|
+
return (include.directory_relative? and !@file_wrapper.exist?( include.filepath ))
|
|
1116
|
+
end
|
|
1117
|
+
|
|
1118
|
+
# Whether a module sharing `_module`'s basename, named by directory, claims `include` by its header's path
|
|
1119
|
+
def _claimed_by_directory?(include, _module, partials)
|
|
1120
|
+
headers = partials.filter_map do |other, config|
|
|
1121
|
+
config&.header&.filepath if File.dirname( other ) != '.' and module_basename( other ) == module_basename( _module )
|
|
1122
|
+
end
|
|
1123
|
+
|
|
1124
|
+
return headers.any? { |header| _same_header_path?( include.filepath, header ) }
|
|
1125
|
+
end
|
|
1126
|
+
|
|
1127
|
+
# Whether an include's path ends the way a header's path does, in any case, as a
|
|
1128
|
+
# case-insensitive filesystem reaches the header by either. A bare #include, as fallback
|
|
1129
|
+
# preprocessing leaves one, ends any such path. An absolute path and a relative one, such as
|
|
1130
|
+
# `../shared/x.h` from a project's paths, are compared as the absolute paths they name.
|
|
1131
|
+
def _same_header_path?(include_path, header_path)
|
|
1132
|
+
return true if PathMatcher.correspond?( include_path.downcase(), header_path.downcase() )
|
|
1133
|
+
return false unless PathMatcher.absolute?( include_path ) or PathMatcher.absolute?( header_path )
|
|
1134
|
+
|
|
1135
|
+
return ProjectPaths.absolute( include_path ).downcase() == ProjectPaths.absolute( header_path ).downcase()
|
|
1136
|
+
end
|
|
1137
|
+
|
|
659
1138
|
# A module name reduced to what an #include actually carries. An #include names a
|
|
660
1139
|
# file, not a module, so a module named by directory still has to be recognized by
|
|
661
1140
|
# the basename its own header include spells out.
|