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
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
# Finds the library files a link's :libraries entries name, so a link can depend on their
|
|
9
|
+
# contents. Which file a toolchain links is its own choice, so every candidate that exists
|
|
10
|
+
# is found. A library only the toolchain's own search paths hold is not found, and a link
|
|
11
|
+
# never depends on a file that doesn't exist, which would read as changed on every build.
|
|
12
|
+
class LibraryResolver
|
|
13
|
+
|
|
14
|
+
# Library extensions toolchains search for beyond a project's own :extension ↳ :libraries
|
|
15
|
+
TOOLCHAIN_EXTENSIONS = ['.a', '.so', '.dylib', '.tbd', '.dll.a', '.lib'].freeze
|
|
16
|
+
|
|
17
|
+
constructor :file_wrapper, :file_path_collection_utils
|
|
18
|
+
|
|
19
|
+
def setup
|
|
20
|
+
@lock = Mutex.new
|
|
21
|
+
@directories = {}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# entries: :libraries entries, each a bare name, an `-l:` filename, or a path
|
|
25
|
+
# search_paths: :paths ↳ :libraries, decorated and globbed as configured
|
|
26
|
+
# files: library files known exactly, as a plugin knows those it builds
|
|
27
|
+
def resolve(entries:, search_paths:, files: [])
|
|
28
|
+
return resolve_within( entries, @file_path_collection_utils.collect_paths( search_paths ), files )
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# The library files a link with these :libraries entries depends on: those the entries
|
|
32
|
+
# resolve to on :paths ↳ :libraries, and those plugins publish in LIBRARIES_LINK_FILES
|
|
33
|
+
def link_files(entries)
|
|
34
|
+
return resolve_within( entries, search_directories(), ((defined? LIBRARIES_LINK_FILES) ? LIBRARIES_LINK_FILES : nil) || [] )
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# A link's library search path arguments: each directory of search_directories in
|
|
38
|
+
# :libraries ↳ :path_flag
|
|
39
|
+
def search_path_arguments
|
|
40
|
+
directories = search_directories()
|
|
41
|
+
return directories unless defined?( LIBRARIES_PATH_FLAG )
|
|
42
|
+
|
|
43
|
+
return directories.map { |directory| LIBRARIES_PATH_FLAG.gsub( '${1}' ) { directory } }
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# The directories :paths ↳ :libraries names, decorated and globbed as configured, with
|
|
47
|
+
# those plugins add once configuration is done. Collected once for a set of paths, since
|
|
48
|
+
# every link asks.
|
|
49
|
+
def search_directories
|
|
50
|
+
paths = ((defined? PATHS_LIBRARIES) ? PATHS_LIBRARIES : nil) || []
|
|
51
|
+
return @lock.synchronize { @directories[paths.dup] ||= @file_path_collection_utils.collect_paths( paths ) }
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def resolve_within(entries, directories, files)
|
|
57
|
+
candidates = Array( entries ).flatten.compact.flat_map { |entry| candidates_for( entry.to_s, directories ) }
|
|
58
|
+
candidates += Array( files )
|
|
59
|
+
|
|
60
|
+
found = candidates.map { |path| @file_path_collection_utils.shortest_path_from_working( File.expand_path( path ) ) }
|
|
61
|
+
return found.select { |path| library_file?( path ) }.uniq
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# An `-l:` entry names its exact filename, a path names itself, and a bare name names every
|
|
65
|
+
# library filename a toolchain makes of it
|
|
66
|
+
def candidates_for(entry, directories)
|
|
67
|
+
return within( directories, entry.delete_prefix( ':' ) ) if entry.start_with?( ':' )
|
|
68
|
+
return [entry] if absolute?( entry )
|
|
69
|
+
return [entry] + within( directories, entry ) if path?( entry )
|
|
70
|
+
|
|
71
|
+
return within( directories, *library_filenames( entry ) )
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def within(directories, *names)
|
|
75
|
+
return directories.product( names ).map { |directory, name| File.join( directory, name ) }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def library_filenames(name)
|
|
79
|
+
return ["lib#{name}", name].product( extensions ).map( &:join )
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# A path, or a filename with a library extension, rather than a name the linker expands
|
|
83
|
+
def path?(entry)
|
|
84
|
+
return entry.match?( %r{[/\\]} ) || extensions.any? { |extension| entry.end_with?( extension ) }
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def absolute?(entry)
|
|
88
|
+
return File.expand_path( entry ) == entry || entry.match?( %r{\A[A-Za-z]:[/\\]} )
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def extensions
|
|
92
|
+
@extensions ||= ((defined?( EXTENSION_LIBRARIES ) ? EXTENSION_LIBRARIES.to_a : []) + TOOLCHAIN_EXTENSIONS).uniq
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def library_file?(path)
|
|
96
|
+
return @file_wrapper.exist?( path ) && !@file_wrapper.directory?( path )
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
data/lib/ceedling/objects.yml
CHANGED
|
@@ -14,6 +14,12 @@ file_wrapper:
|
|
|
14
14
|
- loginator
|
|
15
15
|
- verbosinator
|
|
16
16
|
|
|
17
|
+
win_path_prober:
|
|
18
|
+
compose:
|
|
19
|
+
- configurator
|
|
20
|
+
- tool_executor
|
|
21
|
+
- loginator
|
|
22
|
+
|
|
17
23
|
file_system_wrapper:
|
|
18
24
|
|
|
19
25
|
rake_wrapper:
|
|
@@ -39,6 +45,12 @@ system_utils:
|
|
|
39
45
|
- system_wrapper
|
|
40
46
|
|
|
41
47
|
file_path_utils:
|
|
48
|
+
compose:
|
|
49
|
+
- configurator
|
|
50
|
+
- file_wrapper
|
|
51
|
+
- test_build_layout
|
|
52
|
+
|
|
53
|
+
test_build_layout:
|
|
42
54
|
compose:
|
|
43
55
|
- configurator
|
|
44
56
|
- file_wrapper
|
|
@@ -87,6 +99,7 @@ configurator_setup:
|
|
|
87
99
|
compose:
|
|
88
100
|
- configurator_builder
|
|
89
101
|
- configurator_validator
|
|
102
|
+
- configurator_paths_validator
|
|
90
103
|
- loginator
|
|
91
104
|
- reportinator
|
|
92
105
|
- file_wrapper
|
|
@@ -101,11 +114,17 @@ configurator_plugins:
|
|
|
101
114
|
configurator_validator:
|
|
102
115
|
compose:
|
|
103
116
|
- config_walkinator
|
|
104
|
-
- file_wrapper
|
|
105
117
|
- loginator
|
|
106
118
|
- reportinator
|
|
107
119
|
- tool_validator
|
|
108
120
|
|
|
121
|
+
configurator_paths_validator:
|
|
122
|
+
compose:
|
|
123
|
+
- config_walkinator
|
|
124
|
+
- file_wrapper
|
|
125
|
+
- loginator
|
|
126
|
+
- reportinator
|
|
127
|
+
|
|
109
128
|
configurator_builder:
|
|
110
129
|
compose:
|
|
111
130
|
- file_path_collection_utils
|
|
@@ -148,6 +167,10 @@ plugin_reportinator_helper:
|
|
|
148
167
|
|
|
149
168
|
verbosinator:
|
|
150
169
|
|
|
170
|
+
build_log_writer:
|
|
171
|
+
compose:
|
|
172
|
+
- file_wrapper
|
|
173
|
+
|
|
151
174
|
file_finder:
|
|
152
175
|
compose:
|
|
153
176
|
- configurator
|
|
@@ -155,6 +178,7 @@ file_finder:
|
|
|
155
178
|
- file_path_utils
|
|
156
179
|
- file_wrapper
|
|
157
180
|
- yaml_wrapper
|
|
181
|
+
- test_build_layout
|
|
158
182
|
|
|
159
183
|
file_finder_helper:
|
|
160
184
|
compose: loginator
|
|
@@ -164,6 +188,7 @@ parsing_parcels:
|
|
|
164
188
|
include_factory:
|
|
165
189
|
compose:
|
|
166
190
|
- configurator
|
|
191
|
+
- test_build_layout
|
|
167
192
|
|
|
168
193
|
test_context_extractor:
|
|
169
194
|
compose:
|
|
@@ -247,7 +272,7 @@ generator_test_results_backtrace:
|
|
|
247
272
|
- generator_test_results
|
|
248
273
|
- generator_helper
|
|
249
274
|
- file_path_utils
|
|
250
|
-
-
|
|
275
|
+
- build_log_writer
|
|
251
276
|
- loginator
|
|
252
277
|
|
|
253
278
|
generator_test_results_sanity_checker:
|
|
@@ -324,6 +349,7 @@ preprocessinator_file_assembler:
|
|
|
324
349
|
- parsing_parcels
|
|
325
350
|
- loginator
|
|
326
351
|
- reportinator
|
|
352
|
+
- build_step_doctor
|
|
327
353
|
|
|
328
354
|
preprocessinator_code_finder:
|
|
329
355
|
compose:
|
|
@@ -367,12 +393,15 @@ partializer_utils:
|
|
|
367
393
|
- preprocessinator_code_finder
|
|
368
394
|
- loginator
|
|
369
395
|
|
|
396
|
+
partializer_reconciler:
|
|
397
|
+
compose:
|
|
398
|
+
- c_extractor
|
|
399
|
+
- loginator
|
|
400
|
+
|
|
370
401
|
partializer_helper:
|
|
371
402
|
compose:
|
|
372
403
|
- partializer_utils
|
|
373
|
-
- c_extractor
|
|
374
404
|
- c_extractor_declarations
|
|
375
|
-
- file_path_utils
|
|
376
405
|
- parsing_parcels
|
|
377
406
|
- loginator
|
|
378
407
|
|
|
@@ -380,6 +409,7 @@ partializer:
|
|
|
380
409
|
compose:
|
|
381
410
|
- configurator
|
|
382
411
|
- partializer_helper
|
|
412
|
+
- partializer_reconciler
|
|
383
413
|
- file_finder
|
|
384
414
|
- c_extractor
|
|
385
415
|
- file_path_utils
|
|
@@ -402,12 +432,14 @@ test_invoker:
|
|
|
402
432
|
- loginator
|
|
403
433
|
- verbosinator
|
|
404
434
|
- test_pipeline_manager
|
|
435
|
+
- include_pathinator
|
|
405
436
|
|
|
406
437
|
test_pipeline_manager:
|
|
407
438
|
compose:
|
|
408
439
|
- test_build_setup
|
|
409
440
|
- test_includes_extractinator
|
|
410
441
|
- test_build_planner
|
|
442
|
+
- partial_files_preprocessinator
|
|
411
443
|
- partials_manager
|
|
412
444
|
- test_build_executor
|
|
413
445
|
- test_file_preprocessinator
|
|
@@ -434,6 +466,8 @@ test_build_setup:
|
|
|
434
466
|
- dependinator
|
|
435
467
|
- test_search_paths
|
|
436
468
|
- mock_locator
|
|
469
|
+
- test_derived_search_paths
|
|
470
|
+
- test_source_file_directive_resolver
|
|
437
471
|
|
|
438
472
|
test_includes_extractinator:
|
|
439
473
|
compose:
|
|
@@ -452,6 +486,7 @@ test_bare_includes_extractinator:
|
|
|
452
486
|
- dependinator
|
|
453
487
|
- test_search_paths
|
|
454
488
|
- standin_headerinator
|
|
489
|
+
- mock_locator
|
|
455
490
|
|
|
456
491
|
test_includes_preprocessinator:
|
|
457
492
|
compose:
|
|
@@ -513,10 +548,21 @@ test_build_planner:
|
|
|
513
548
|
- test_source_file_directive_resolver
|
|
514
549
|
- mock_locator
|
|
515
550
|
|
|
551
|
+
test_derived_search_paths:
|
|
552
|
+
compose:
|
|
553
|
+
- configurator
|
|
554
|
+
- include_pathinator
|
|
555
|
+
- test_search_paths
|
|
556
|
+
- test_context_extractor
|
|
557
|
+
- file_finder
|
|
558
|
+
- file_wrapper
|
|
559
|
+
- loginator
|
|
560
|
+
|
|
516
561
|
mock_locator:
|
|
517
562
|
compose:
|
|
518
563
|
- configurator
|
|
519
564
|
- include_pathinator
|
|
565
|
+
- test_search_paths
|
|
520
566
|
- file_finder
|
|
521
567
|
- file_path_utils
|
|
522
568
|
|
|
@@ -542,6 +588,7 @@ test_runner_generatinator:
|
|
|
542
588
|
- generator
|
|
543
589
|
- test_context_extractor
|
|
544
590
|
- dependinator
|
|
591
|
+
- mock_locator
|
|
545
592
|
|
|
546
593
|
test_build_executor:
|
|
547
594
|
compose:
|
|
@@ -558,19 +605,35 @@ test_build_executor:
|
|
|
558
605
|
- dependinator
|
|
559
606
|
- gcc_dependency_parser
|
|
560
607
|
- quote_include_isolator
|
|
561
|
-
-
|
|
608
|
+
- test_substitutions
|
|
609
|
+
- build_step_doctor
|
|
610
|
+
- library_resolver
|
|
611
|
+
- mock_locator
|
|
612
|
+
- test_search_paths
|
|
562
613
|
|
|
563
|
-
|
|
614
|
+
partial_files_preprocessinator:
|
|
564
615
|
compose:
|
|
565
616
|
- configurator
|
|
566
617
|
- loginator
|
|
567
618
|
- reportinator
|
|
568
619
|
- batchinator
|
|
569
620
|
- preprocessinator
|
|
621
|
+
- file_path_utils
|
|
622
|
+
- file_wrapper
|
|
623
|
+
- dependinator
|
|
624
|
+
|
|
625
|
+
partials_manager:
|
|
626
|
+
compose:
|
|
627
|
+
- configurator
|
|
628
|
+
- loginator
|
|
629
|
+
- reportinator
|
|
630
|
+
- batchinator
|
|
570
631
|
- partializer
|
|
571
632
|
- generator
|
|
572
633
|
- dependinator
|
|
573
634
|
- file_path_utils
|
|
635
|
+
- file_wrapper
|
|
636
|
+
- mock_locator
|
|
574
637
|
|
|
575
638
|
release_invoker:
|
|
576
639
|
compose:
|
|
@@ -603,9 +666,52 @@ release_build_executor:
|
|
|
603
666
|
- file_wrapper
|
|
604
667
|
- file_path_utils
|
|
605
668
|
- dependinator
|
|
669
|
+
- library_resolver
|
|
670
|
+
|
|
671
|
+
library_resolver:
|
|
672
|
+
compose:
|
|
673
|
+
- file_wrapper
|
|
674
|
+
- file_path_collection_utils
|
|
606
675
|
|
|
607
676
|
gcc_dependency_parser:
|
|
608
677
|
|
|
678
|
+
test_substitutions:
|
|
679
|
+
compose:
|
|
680
|
+
- configurator
|
|
681
|
+
|
|
682
|
+
build_step_doctor:
|
|
683
|
+
compose:
|
|
684
|
+
- loginator
|
|
685
|
+
- header_collision_specialist
|
|
686
|
+
- missing_symbol_specialist
|
|
687
|
+
- duplicate_symbol_specialist
|
|
688
|
+
- partial_name_specialist
|
|
689
|
+
- include_depth_specialist
|
|
690
|
+
|
|
691
|
+
header_collision_specialist:
|
|
692
|
+
compose:
|
|
693
|
+
- configurator
|
|
694
|
+
- test_substitutions
|
|
695
|
+
- gcc_dependency_parser
|
|
696
|
+
- file_wrapper
|
|
697
|
+
|
|
698
|
+
missing_symbol_specialist:
|
|
699
|
+
compose:
|
|
700
|
+
- configurator
|
|
701
|
+
|
|
702
|
+
duplicate_symbol_specialist:
|
|
703
|
+
compose:
|
|
704
|
+
- configurator
|
|
705
|
+
|
|
706
|
+
partial_name_specialist:
|
|
707
|
+
compose:
|
|
708
|
+
- configurator
|
|
709
|
+
- file_wrapper
|
|
710
|
+
|
|
711
|
+
include_depth_specialist:
|
|
712
|
+
compose:
|
|
713
|
+
- file_wrapper
|
|
714
|
+
|
|
609
715
|
quote_include_isolator:
|
|
610
716
|
compose:
|
|
611
717
|
- file_wrapper
|
|
@@ -1,53 +1,147 @@
|
|
|
1
1
|
# Partials
|
|
2
2
|
|
|
3
|
-
Partials allow a test to exercise a C module
|
|
3
|
+
Partials allow a test to exercise a C module’s features in ways otherwise impossible. Partials copies selected functions and variables out of their home source file and into a file generated just for one test. Selected functions are stripped of `static`, `extern` and `inline`, and variables of `static`, whether the module spells them directly or through a macro. A test can then access the variables and call the functions, and CMock can mock the functions like any other. This not only allows access to functions that previously required source rewrites, but it also allows mocking of individual functions inside a module instead of mocking all functions in a header file. The generated file also carries what the selected functions rely on, such as prototypes of functions defined elsewhere and helpers the module header defines, so the selection compiles and links on its own.
|
|
4
4
|
|
|
5
5
|
See the detailed documentation for using Partials in `docs/mkdocs/testing-guide/partials/`. This documentation discusses Partials' implementation.
|
|
6
6
|
|
|
7
7
|
## Where This Fits in a Test Build
|
|
8
8
|
|
|
9
|
-
Ceedling
|
|
9
|
+
Ceedling’s test pipeline drives this subsystem through a handful of stages dedicated to Partials. Those stages read a test’s Partial configuration, preprocess the real header and source files that a test’s Partials depend on, and then generate the Partial files themselves. The stage-by-stage view of that pipeline lives in this codebase’s `test_invoker/` documentation.
|
|
10
10
|
|
|
11
11
|
## Choosing Functions With Macros
|
|
12
12
|
|
|
13
13
|
A test file selects its Partials through macros typically located near the top of the file, such as `TEST_PARTIAL_PRIVATE_MODULE(calculator)`. Each macro names a module and a selection mode.
|
|
14
14
|
|
|
15
|
-
Four selection modes exist, and each answers a different question about where to start. A public mode begins with every one of the module
|
|
15
|
+
Four selection modes exist, and each answers a different question about where to start. A public mode begins with every one of the module’s ordinary, non-`static` functions. A private mode begins with every one of the module’s `static` or `inline` functions instead, the header’s helpers included. An accumulate mode begins with nothing at all. A deduct mode begins with everything, public and private alike.
|
|
16
16
|
|
|
17
17
|
A second macro, `TEST_PARTIAL_CONFIG` or `MOCK_PARTIAL_CONFIG`, can add or remove specific functions by name to the list the macros described above create. A name written plainly, or with a leading `+`, is an addition. A name written with a leading `-` is a subtraction. An accumulate mode has no baseline to subtract from, so subtractions are not allowed there. A deduct mode already starts with everything, so additions are not allowed there either. Both rules exist because either combination would be a contradiction rather than a meaningful instruction.
|
|
18
18
|
|
|
19
|
-
A single test file can select both a test side and a mock side for the same module, or for two different modules entirely. It is common, for example, to test a module
|
|
19
|
+
A single test file can select both a test side and a mock side for the same module, or for two different modules entirely. It is common, for example, to test a module’s public functions directly while mocking one of its private helpers, all from within one test file.
|
|
20
20
|
|
|
21
|
-
## Reading a Test
|
|
21
|
+
## Reading a Test’s Configuration
|
|
22
22
|
|
|
23
|
-
Before any real C file is touched, a class called `PartializerConfig` scans a test file
|
|
23
|
+
Before any real C file is touched, a class called `PartializerConfig` scans a test file’s own source text for the macro calls discussed in the previous section. It works in three passes. The first pass reads every `MODULE` macro and starts a `PartializerConfig::Config` record for each module it names. The second pass reads every `CONFIG` macro and fills in that module’s additions and subtractions. The third pass checks everything the first two passes built. Each `Config` record describes, for one module, what its Partialized test side and mock side should contain. The records describing a module’s files and functions live in a shared module called `Partials`, alongside the rest of this subsystem’s common vocabulary.
|
|
24
24
|
|
|
25
|
-
This scan enforces a few rules of its own. A `CONFIG` macro must refer to a module already named by an earlier `MODULE` macro, since a configuration with nothing to configure is meaningless. A module
|
|
25
|
+
This scan enforces a few rules of its own. A `CONFIG` macro must refer to a module already named by an earlier `MODULE` macro, since a configuration with nothing to configure is meaningless. A module’s test side or mock side may only be declared once, since declaring it twice would leave two contradictory instructions in place at once. An accumulate mode with no additions at all is also rejected, since it would describe a Partial with nothing in it.
|
|
26
26
|
|
|
27
|
-
A further round of checks happens later, once the module
|
|
27
|
+
A further round of checks happens later, once the module’s real functions are known. Every function named in an addition or a subtraction must genuinely exist in the module. No function may be named as both an addition and a subtraction on the same side. And subtractions on a public or private side must actually match that side’s own visibility, since subtracting a private function from a public selection would be removing something that was never there to begin with.
|
|
28
28
|
|
|
29
29
|
## Extracting the Real Content
|
|
30
30
|
|
|
31
|
-
Once a module
|
|
31
|
+
Once a module’s configuration is known, a class called `Partializer` locates its real header and source files and hands them off for preprocessing. The preprocessed result is then handed to the c_extractor subsystem, which returns a structured picture of every function, variable, and type the module contains. The header’s picture and the source’s picture are merged into one combined view of the whole module.
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Each file is extracted on its own before the merge, so every item can record where it came from. `CModule#stamp_origin!` marks each function, variable, and statement `:header` or `:source`. The extractor reads text alone and cannot know a file’s role, so `Partializer` stamps it. Deciding what a Partial carries depends on that origin. So does where a generated header writes the source’s later includes.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
Every statement records its kind, `:macro`, `:typedef`, `:aggregate` or `:invocation`, which matches the `CModule` list that holds it. A type statement also records the tag it names and, for a typedef, the one name it gives.
|
|
36
|
+
|
|
37
|
+
A declaration can define its type and declare variables at once, as in `static struct { int count; } s_ctx;`. The extractor reads it as two things (`CExtractorDefinedType`). The type becomes an aggregate statement ahead of its variables. Each variable names it through `CVariableDeclaration#defined_type`, and its own `type` and `text` hold only what follows the type. The extractor can't know the module, so `Partials.name_defined_types` names each such type after its first variable once promotion is done (`Partials.type_name`). The name is `ceedling_partial_<module>_<variable>_t`, the module folded as `CIdentifier.fold` folds it, and `ceedling.h`’s `PARTIAL_TYPE()` builds the same name. A struct or union forward declaration, as in `struct node;`, is a type statement too.
|
|
38
|
+
|
|
39
|
+
`PartializerReconciler` pairs each item extracted from a file with its twin in a fully macro-expanded copy of the same file. A project can hide `static` behind a macro of its own, such as `#define PRIVATE static`. A file preprocessed only far enough to preserve macros cannot see through that indirection, and a fully expanded file can. Reconciliation runs on each file before the merge. It never changes a code block, so line tracing still finds the written text.
|
|
40
|
+
|
|
41
|
+
- **Definitions** pair by name. Each takes its decorators, signatures and body from its twin, where a call hidden inside a macro becomes visible. Each also records the decorators its written head doesn't spell, as `hidden_decorators`.
|
|
42
|
+
- **Declarations** pair by name, then by order. Each takes its decorators and stripped signature, and keeps its signature as written.
|
|
43
|
+
- **File-scope variables** pair by name, then by order, and only where a name appears as often in both copies. Fallback can keep both branches of a conditional, so a count that differs pairs nothing. A variable whose storage class disagrees with its twin's takes every parsed field from it, since a mix could read `extern static`. A macro that supplies only a qualifier, as `#define ROM const`, leaves the variable as written. A type the macro hid ahead of the variable is adopted from the twin.
|
|
44
|
+
- **Type attributes** a macro writes after a type's closing brace rejoin the type (`Partials::TypeMacros`). The written text reads `PACKED` in `struct pk { … } PACKED;` as a variable, and in `struct pk { … } PACKED inst;` as the start of the variable's type. The expansion shows the attribute joined the type, so the type takes the macro back and keeps its layout. A macro that gives a variable a storage class or a qualifier stays with the variable.
|
|
45
|
+
|
|
46
|
+
Next, `PartializerHelper` finishes preparing the combined view. It traces every function back to its original line number, following it through preprocessing to the real file it came from. This traceability matters later, when a generated file needs to point a coverage tool, a debugger, or a compiler message back at the true home of what it holds, rather than at the generated Partial standing in for it. `PartializerHelper` leans on a lower layer of its own, `PartializerUtils`, for the actual text work this requires.
|
|
47
|
+
|
|
48
|
+
Under C99, a file declaring a function that an included header defines inline holds that function’s external definition, unless every declaration says `inline` without `extern`. Only a function the module never defines can have its body elsewhere. After merging the header and source, `Partializer` reads the raw directives-only copy of each file that declares such a function, as bytes. That copy holds every header the file includes. `PartializerHelper#mark_inline_elsewhere` then marks each such declaration whose inline body the copy holds as `inline_elsewhere`. A file preprocessed its fallback way has no raw copy, so nothing is marked for it, and only a declaration that says `inline` itself counts.
|
|
49
|
+
|
|
50
|
+
Splitting a signature into its decorators and the rest removes only the storage-class keywords `static` and `extern` and the inline specifiers (`inline`, `__inline`, `__inline__` and `__forceinline`). Every other word before the function name keeps its place, qualifiers, attributes and `_Noreturn` included. `_Noreturn` stays on a selected function. Only a mock’s signature drops it, along with every other noreturn marking, since a mock always returns.
|
|
36
51
|
|
|
37
52
|
## Promoting Function-Scoped Statics
|
|
38
53
|
|
|
39
54
|
C allows a `static` variable to live inside a single function, retaining its value between calls while staying invisible to the rest of the file. Once that function is copied into a generated Partial file, this kind of variable becomes a problem. It needs a home at module scope in the new file, with a name that cannot collide with anything else.
|
|
40
55
|
|
|
41
|
-
`PartializerHelper` solves this by renaming the variable to something unique, built from the function
|
|
56
|
+
`PartializerHelper` solves this by renaming the variable to something unique, built from the function’s name and the variable’s own name, and moving its declaration out to module scope in the generated file. It reads the declarations that open the function’s body, recording where each statement of statics sits in the function’s code block. Each statement is replaced in place with one harmless no-op per variable, followed by a comment holding the statement. The comment keeps the statement’s line breaks, so the function’s line count holds, keeping line numbers and coverage data lined up correctly. The text around the statements is renamed with `Partials::Rename`. A test author reaches a promoted variable through a small macro of its own, letting a test read or reset the variable between calls without needing to know the generated name directly.
|
|
57
|
+
|
|
58
|
+
A promoted static can define its type, as in `static struct { int n; } last;`. The type moves to module scope with it, ahead of the variable and just ahead of the function, like every promoted item. It is named `ceedling_partial_<module>_<function>_<variable>_t`. A tag the function defines takes that name as its tag, since a tag local to the function can collide at module scope, and the function’s other uses of the tag follow. A struct or union body holding a promoted name renames its members alike wherever they’re used, and a promoted type’s body counts though it no longer sits in the function.
|
|
59
|
+
|
|
60
|
+
## Deciding What’s Tested and What’s Mocked
|
|
42
61
|
|
|
43
|
-
|
|
62
|
+
With the module’s content extracted, and its configuration validated, `Partializer` splits the functions into two lists. One list holds `FunctionDefinition` records for the functions destined to be tested directly, each complete with its body. The other holds `FunctionDeclaration` records for the functions destined to be mocked, each needing only its signature. Both record shapes live in the shared `Partials` module.
|
|
44
63
|
|
|
45
|
-
|
|
64
|
+
A function the module only declares can be mocked, since a mock needs only a signature. A function the module only declares and another header defines inline is the exception. Its body lives in a header the module includes, which a mock cannot replace, so it never becomes a mock candidate.
|
|
46
65
|
|
|
47
|
-
A module often has `typedef`s and struct definitions that both lists would otherwise need to repeat. Rather than duplicate that content, and risk defining the same type twice in one test file, it is written once to a shared types file. Both the testable file and the mockable file then include that shared file relying on its internal `#include` guards instead of restating its contents.
|
|
66
|
+
A module often has `typedef`s and struct definitions that both lists would otherwise need to repeat. Rather than duplicate that content, and risk defining the same type twice in one test file, it is written once to a shared types file. Both the testable file and the mockable file then include that shared file relying on its internal `#include` guards instead of restating its contents. A type a declaration defines is written there as a typedef of its body with the name the Partial gives it, so its variables can name it and an anonymous type stays one type.
|
|
48
67
|
|
|
49
68
|
A function can never appear in both lists at once. Being directly tested means its real body is compiled into the test. Being mocked means the linker is provided a mock in its place instead. These two things cannot both be true of the same function in the same test, so this case is rejected outright.
|
|
50
69
|
|
|
70
|
+
## Carrying What the Selected Functions Rely On
|
|
71
|
+
|
|
72
|
+
A Partial’s implementation source carries more than the selected functions. The module’s code relies on prototypes of functions defined elsewhere, and on small `static` or `inline` helpers its header defines. Without them, selected code fails to compile, or an `extern inline` function never gets its external definition. `PartializerHelper#plan_carry` decides what comes along, and `Partializer#plan_carry` logs that decision. `PartialsManager` plans only when it regenerates the implementation source, so the plan’s notices appear with that build.
|
|
73
|
+
|
|
74
|
+
The decision is made per function name, from facts extraction already recorded. Those facts are whether the module defines a body for the name, whether the test selected it, which file each item came from, and its reconciled storage class. Each name falls into one category.
|
|
75
|
+
|
|
76
|
+
- **Selected to test or to mock.** Nothing is carried. The selection itself is written, and its own prototypes stay behind.
|
|
77
|
+
- **External.** The module declares the function but never defines it. A prototype that is not `static` is carried when kept code uses the name. A prototype of an inline function another header defines is carried regardless, since it makes this file hold the function’s external definition.
|
|
78
|
+
- **Header helper.** Every body for the name sits in the module header and is `static` or `inline`. The body and its prototypes are carried when kept code uses it.
|
|
79
|
+
- **Left out.** Any other unselected body. Prototypes that are neither `static` nor `inline` are carried when kept code uses the name, so a test stub for a subtracted function links.
|
|
80
|
+
|
|
81
|
+
Kept code is the selected bodies, the variables and macro invocations the implementation source writes, and each helper already carried. Each is scanned once for the names it uses. Code uses any name it holds, so a callback passed by name counts as surely as a call. A body is read from its expanded copy, where a macro’s call is visible. Its own parameters and local variables are taken away, since they only share a name with any function. Literals and comments are blanked first, and member accesses and struct, union and enum tags are dropped, so a field or a type sharing a function’s name never counts. Under fallback preprocessing, macro definitions count as kept code too, since expansion is unreliable there. Helpers are followed transitively, and the prototypes are decided once the helpers are known. Apart from a prototype of an inline function another header defines, nothing is carried unless something uses it. Carrying therefore never forces unneeded code to compile, nor puts a prototype where a later header’s macro could mangle it.
|
|
82
|
+
|
|
83
|
+
Two rules hold helpers back. A module header without an include guard cannot be stood in for, so the real header may still arrive through another include, helpers and all. Its referenced helpers are skipped and named in a notice. Fallback preprocessing can also leave two different copies of one name. Carrying both would fail to compile, so neither is carried and a notice names the function.
|
|
84
|
+
|
|
85
|
+
The result is a `Partials::CarryPlan`. It holds the carried prototypes, the carried helpers by name, and the skipped names, each with a one-line reason. Prototypes are indexed by object identity, since the generator later walks the very declarations the plan chose. `Partializer#plan_carry` then locates each carried prototype in its original file’s own text, reading each file once, so its `#line` can name the right file and line.
|
|
86
|
+
|
|
87
|
+
The plan also names each `extern` variable whose struct or union type the module never completes. No definition of such a variable compiles, weak or not. `Partializer#plan_carry` looks for the type’s completing definition in the module’s files and in their raw directives-only copies, which hold every header each file includes. It reads them all as bytes. A file preprocessed its fallback way has no raw copy, so for that file it searches the file alone.
|
|
88
|
+
|
|
89
|
+
## Keeping a Mocked Header’s Content
|
|
90
|
+
|
|
91
|
+
A mocked Partial’s interface header stands in for the real header everywhere the test build includes it, since it spoofs that header’s guard. The interface declares only the mocked functions, and CMock mocks everything it declares. Whatever else the real header supplied would vanish. A module the test mocks but doesn’t test therefore keeps the rest in an extras header, `ceedling_partial_<module>_extras.h`, which the interface includes and CMock never reads. The extras header exists only when it keeps something. `PartializerHelper#plan_interface_extras` decides what it keeps, and `Partializer#plan_interface_extras` logs that decision. `PartialsManager` plans only when it regenerates the interface, and only when the test has no implementation for the module.
|
|
92
|
+
|
|
93
|
+
The result is a `Partials::InterfaceExtras`. It holds the kept items in the module’s order, and the items withheld from a header without an include guard. It keeps four kinds of header-origin items:
|
|
94
|
+
|
|
95
|
+
- **Helpers** the mock leaves out, written as the header writes them, with their prototypes and the statics promoted from them. Every such helper is kept, used or not, since the extras stand in for the header in every file that includes it. Each promoted static records its function in `CVariableDeclaration#promoted_from`.
|
|
96
|
+
- **`static` variables**, written with `static` and the variable’s definition.
|
|
97
|
+
- **`extern` declarations**, written as the header declares them, since the source may size or type the variable with what the extras never see.
|
|
98
|
+
- **Plain prototypes** of functions the mock leaves out.
|
|
99
|
+
|
|
100
|
+
The extras compile and link in every file of the test that includes the interface, which shapes what stays behind. Nothing from the source comes along, nor a definition without `static`, which each of those files would define again. A `static` or `inline` prototype comes along only with its helper. A prototype that a function-like macro of its name rewrites stays behind, since calls use the macro. Fallback’s duplicate copies of a name come along once when alike and not at all when they differ. A variable’s tentative definitions come along with its one initialized definition, which C allows.
|
|
101
|
+
|
|
102
|
+
GCC emits an unused `static` variable or non-inline `static` function at `-O0`, so one that names a module function the mock leaves undefined breaks the link. `_drop_unlinkable` withholds each kept static variable, promoted static, and non-inline helper that names such a function. It withholds any item, inline helpers too, that names a function with conflicting prototypes. Then it follows a worklist. Whatever names a withheld item is withheld too, and a withheld promoted static takes its function along. Names are read through the module’s macros, transitively, from each item’s expansion: a helper’s expanded body, and a variable’s `CVariableDeclaration#expanded_text`, which reconciliation sets from its twin. Under fallback, an item’s written text counts too, since fallback may pair a variable with the other side of a conditional.
|
|
103
|
+
|
|
104
|
+
A header without an include guard may still arrive through another include, so its helpers and static variables are withheld rather than kept. Its externs and prototypes stay, since declarations repeat safely. A notice names what is withheld.
|
|
105
|
+
|
|
106
|
+
`GeneratorPartials#generate_extras` writes the header, with its own guard, through a `PartialSourceWriter`. A helper keeps its `#line` to the real header. The interface includes the extras header where the module header’s items end, ahead of the source’s later includes. The real header may still arrive first, through another header or the test file, and then supplied everything already. So the interface defines a flag, `<extras guard>_WANTED`, only when the real header’s guard isn’t yet defined, just ahead of its spoof. The extras hold their items under that flag. A header without a guard has no flag, since its extras hold only declarations.
|
|
107
|
+
|
|
108
|
+
A module the test both tests and mocks gets no extras. Its implementation carries what its own code uses, but other Partials including its header get the interface alone. `Partializer#explain_tested_mock` logs a notice naming what those other Partials’ code uses, read from their expansion copies, and stays quiet when that’s nothing.
|
|
109
|
+
|
|
51
110
|
## Writing the Generated Files
|
|
52
111
|
|
|
53
|
-
Once both lists are settled, a separate class named `GeneratorPartials` writes the actual files to disk. It lives outside this directory, alongside Ceedling
|
|
112
|
+
Once both lists are settled, a separate class named `GeneratorPartials` writes the actual files to disk. It lives outside this directory, alongside Ceedling’s other file-writing classes, deliberately kept apart from the classes that decide what belongs in a Partial. A tested module gets an implementation header and source. A mocked module gets an interface header, in the same shape CMock expects for any other header it mocks. A module mocked but not tested may also get an extras header (see [Keeping a Mocked Header’s Content](#keeping-a-mocked-headers-content)). Each promoted function is written with a line marker (`#line`) immediately ahead of it, pointing a coverage tool or a debugger back at the function’s real, original location rather than at the generated file holding it.
|
|
113
|
+
|
|
114
|
+
A selected definition whose head a macro made `static` is written from its expanded signature (`Partials::DefinitionHead`), since stripping can’t remove a `static` the head never spells. The head through its declarator’s last `)` becomes the stripped signature on one line, followed by the line breaks it held, so every body line keeps its line. Its `#line` names the function name’s line, where a coverage tool places the function. The implementation header declares the same signature, so the two agree. A K&R definition, a brace inside the parameter list, or a signature holding a directive keeps its head as written.
|
|
115
|
+
|
|
116
|
+
Every generated header orders its includes the way the module’s source compiles them. Each header first spoofs the real header’s include guard, so a header that includes the real one finds it already satisfied. That header then needs the module’s types and macros written ahead of it. So the includes come in two groups, split where the source includes the module’s own header:
|
|
117
|
+
|
|
118
|
+
- The leading group holds the source’s includes ahead of the module’s header, then the header’s own includes.
|
|
119
|
+
- The following group holds the source’s includes after the module’s header. It is written between the header’s items and the source’s.
|
|
120
|
+
|
|
121
|
+
A source that never includes the module’s header, and a module with no source, are read as including it last. `Partializer::OWN_HEADER_PLACE` holds that place, so the types header lands after the source’s includes, ahead of the header’s own includes and its items, and the following group is empty. The marker is matched by identity, so it can never pass for another module’s header.
|
|
122
|
+
|
|
123
|
+
An include names a partialized module when its filename, in any case, is the module’s basename (`Partializer#_names_module?`). A module named by directory, as an `_AT` macro names one, must also match by its header’s path, in any case, so another header sharing its filename is never taken for it. Paths compare as absolute paths when either one is absolute. A module named without a directory is named by basename alone, unless a same-named module named by directory claims the include by path. Fallback anchors a `..` include to its file’s own directory, so one naming no file there is matched by filename alone.
|
|
124
|
+
|
|
125
|
+
`PartialsManager` spells each of the module’s includes before any of this. An include’s spelling is the text it names its header by, and each include gets one that reaches its header through the test’s search paths or, where no spelling reaches it, its header’s absolute path (`Include#spelled_by`, through `HeaderSearch#spelling`). [Finding a test’s headers](../test_invoker/PIPELINE.md#finding-a-tests-headers) defines the term. A generated file then reaches `drivers/foo.h` through `src/` exactly as the module’s own files did. An include names the header the compiler found. A preprocessed file’s include holds that header’s path, which names the header itself (`HeaderSearch#at`), since a later search path joined with it could name another. Fallback’s text scan holds an include as written, which names a header beside its file first, as the compiler’s quote rule does. An include keeps its text wherever that already reaches the header, so the paths reconciliation tells same-named headers apart by stay. The spelled include takes the header as its path, so a module is matched against the exact header. An include whose header no search path reaches by any spelling takes the header's absolute path, whether the preprocessor entered it or fallback's text scan names it beside its file. A generated header in the build root keeps its text instead, since the compiler's own search paths reach it. A text scan's include with no header beside its file is spelled by the header the search paths find. One whose header isn't found keeps its text. Generated siblings, such as the types header, keep their filenames.
|
|
126
|
+
|
|
127
|
+
The types header also writes the header’s macros ahead of the following group, even a macro no type follows. A mocked Partial’s interface header takes the place of the real header it replaces. `Partializer` forms the groups as `Partials::IncludeGroups`, and `GeneratorPartials` writes them. A `PartialHeaderWriter` writes each header, keeping the state that spans items: the blank lines around functions and where the following group goes. `GeneratorPartials` decides what each item is by its kind. The real header’s own guard is removed from the extracted macros along with generated guards (`Partializer#sanitize`), since every generated file states it deliberately.
|
|
128
|
+
|
|
129
|
+
The implementation source also writes the carry plan. It walks the module’s items in their original order after every include, so a carried item sees each header the module’s code saw, the module’s own mock interface included. `GeneratorPartials` decides what each item is, and a `PartialSourceWriter` writes it. The writer keeps the state that spans items: an open run of prototypes, the file a `#line` last named, and the line count of the file so far.
|
|
130
|
+
|
|
131
|
+
A carried prototype is written as the user spelled it, behind a `#line` naming its original file and line. A run of carried prototypes sits inside GCC diagnostic pragmas that quiet `-Wredundant-decls`, unless `:partials` ↳ `:suppress_redundant_decls` is off. A carried helper is written as its header wrote it, any function-scope `static` promoted, and anchored with `#line` like a selected body. After any located item, a `#line` hands attribution back to the generated file before the next item without a location of its own. Every `#line` path uses forward slashes, since a backslash in its string starts an escape sequence. Nothing carried is written to a header, so the test file and runner compile exactly what the selection gives them.
|
|
132
|
+
|
|
133
|
+
Variables follow two rules of their own. The implementation header writes one `extern` declaration per variable name, taken from the variable’s definition when the module has one, so an array keeps its size. A variable the module only declares `extern` lives elsewhere. Under `:partials` ↳ `:extern_variables`, the implementation source gives it one weak definition that a real one overrides (`:weak`, the default), or none at all (`:test`). A variable of a type the module never completes gets no definition either way.
|
|
134
|
+
|
|
135
|
+
## Regenerating Partials
|
|
136
|
+
|
|
137
|
+
A delta build writes a Partial’s files again only when something generation reads has changed. The generated files of a module share one record of those inputs:
|
|
138
|
+
|
|
139
|
+
- The module’s original header and source, and each file’s preprocessed copies: the assembled copy extraction parses, the raw directives-only copy, and the expanded code reconciliation reads. The copies connect generation to preprocessing. Whatever rewrites them regenerates the Partial, such as forced fallback preprocessing, a different preprocessor, or an edit to a header the module includes. An unchanged rebuild rewrites nothing.
|
|
140
|
+
- The test’s selection for the module: each side’s selection mode, additions, and subtractions.
|
|
141
|
+
- The includes of each generated file, group by group, spelled as the test’s search paths reach them. They depend on the test’s other Partial modules and how each is selected. The record’s lists leave out the types header and the extras header, since the module’s files decide whether there is one.
|
|
142
|
+
- The real header’s include guard, which every generated file spoofs.
|
|
143
|
+
- The preprocessing flags, defines, and search paths, and the project’s `:partials` settings.
|
|
144
|
+
|
|
145
|
+
The record depends on nothing extraction finds, so a build checks it before extracting. A module whose implementation and interface are both fresh is not extracted at all. Each of those files records the types header it includes as an output, and the interface records its extras header too, so a missing or edited one regenerates them. A types header left by an earlier build, once the module has no types, is removed when the Partial next regenerates. So is an extras header the interface no longer includes.
|
|
146
|
+
|
|
147
|
+
The code that composes Partials is not among these inputs. A Ceedling upgrade that changes what Partials contain leaves existing generated files in place until the build is clobbered.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
require 'set'
|
|
9
|
+
|
|
10
|
+
module Partials
|
|
11
|
+
# A function a Partial carries forward and the reason why, or a name it skips and the kind of skip.
|
|
12
|
+
# The reason feeds debug logging so a user can trace what a Partial contains. The kind picks a notice.
|
|
13
|
+
CarriedItem = Struct.new(
|
|
14
|
+
:item, # CFunctionDeclaration or Partials::FunctionDefinition, or a bare name when skipped
|
|
15
|
+
:reason, # Short explanation such as "external: no body in module"
|
|
16
|
+
:kind, # For a skipped name, why it was skipped (:unguarded_helper, :helper_conflict, :prototype_conflict)
|
|
17
|
+
keyword_init: true
|
|
18
|
+
) unless const_defined?(:CarriedItem, false)
|
|
19
|
+
|
|
20
|
+
# Everything a Partial's implementation source holds beyond its selected functions.
|
|
21
|
+
# PartializerHelper#plan_carry decides it. GeneratorPartials#generate_source writes it.
|
|
22
|
+
# Prototypes are matched by object identity. The generator walks element_sequence,
|
|
23
|
+
# which holds the very declarations the plan chose.
|
|
24
|
+
CarryPlan = Struct.new(
|
|
25
|
+
:prototypes, # Array of CarriedItem wrapping a CFunctionDeclaration written word for word
|
|
26
|
+
:helpers, # Hash of function name => CarriedItem wrapping a Partials::FunctionDefinition
|
|
27
|
+
:skipped, # Array of CarriedItem naming functions left out that kept code uses
|
|
28
|
+
:incomplete, # Set of names of variables declared extern whose type is never completed
|
|
29
|
+
keyword_init: true
|
|
30
|
+
) do
|
|
31
|
+
def initialize(prototypes: [], helpers: {}, skipped: [], incomplete: Set.new)
|
|
32
|
+
super
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# No definition of a variable whose type is never completed can compile
|
|
36
|
+
def incomplete?(name)
|
|
37
|
+
return incomplete.include?( name )
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def add_prototype(decl, reason)
|
|
41
|
+
return if prototype?( decl )
|
|
42
|
+
|
|
43
|
+
prototypes << CarriedItem.new( item: decl, reason: reason )
|
|
44
|
+
_identities[decl] = true
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# The generator asks once per declaration, so lookup is by identity in a hash, not a scan
|
|
48
|
+
def prototype?(decl)
|
|
49
|
+
return _identities.key?( decl )
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def _identities
|
|
53
|
+
@identities ||= prototypes.each_with_object( {}.compare_by_identity ) { |carried, index| index[carried.item] = true }
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def add_helper(func, reason)
|
|
57
|
+
helpers[func.name] ||= CarriedItem.new( item: func, reason: reason )
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# The helper's definition ready to write, or nil when the name is not carried
|
|
61
|
+
def helper(name)
|
|
62
|
+
return helpers[name]&.item
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def skip(name, kind)
|
|
66
|
+
return if skipped.any? { |s| s.item == name and s.kind == kind }
|
|
67
|
+
|
|
68
|
+
skipped << CarriedItem.new( item: name, kind: kind )
|
|
69
|
+
end
|
|
70
|
+
end unless const_defined?(:CarryPlan, false)
|
|
71
|
+
end
|