ceedling 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/GIT_COMMIT_SHA +1 -1
- data/README.md +1 -1
- 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/docs/BreakingChanges.md +16 -0
- data/docs/Changelog.md +71 -0
- data/docs/KnownIssues.md +91 -4
- 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/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/configurator.rb +4 -3
- data/lib/ceedling/config/configurator_builder.rb +17 -0
- data/lib/ceedling/config/configurator_setup.rb +29 -5
- data/lib/ceedling/constants.rb +5 -1
- data/lib/ceedling/defaults.rb +31 -1
- data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
- data/lib/ceedling/dependencies/README.md +1 -1
- data/lib/ceedling/dependencies/dependency_cache_store.rb +30 -25
- 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/filesystem/PATH_HANDLING.md +83 -27
- data/lib/ceedling/filesystem/README.md +6 -1
- data/lib/ceedling/filesystem/build_roots.rb +105 -0
- data/lib/ceedling/filesystem/build_subpath.rb +110 -25
- data/lib/ceedling/filesystem/file_finder.rb +76 -110
- data/lib/ceedling/filesystem/file_finder_helper.rb +33 -11
- data/lib/ceedling/filesystem/file_path_utils.rb +113 -91
- data/lib/ceedling/filesystem/file_wrapper.rb +105 -28
- data/lib/ceedling/filesystem/path_matcher.rb +21 -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/generators/generator.rb +27 -64
- 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 +305 -243
- 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/includes/header_search.rb +225 -0
- data/lib/ceedling/includes/include_factory.rb +9 -12
- data/lib/ceedling/includes/include_pathinator.rb +53 -31
- data/lib/ceedling/includes/includes.rb +149 -37
- data/lib/ceedling/objects.yml +89 -4
- 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 +599 -120
- data/lib/ceedling/partials/partializer_config.rb +5 -0
- 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/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 +31 -75
- data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
- data/lib/ceedling/setupinator.rb +16 -3
- data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
- data/lib/ceedling/test_invoker/PIPELINE.md +57 -16
- 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 +116 -9
- data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
- data/lib/ceedling/test_invoker/partials_manager.rb +265 -308
- data/lib/ceedling/test_invoker/standin_headerinator.rb +8 -15
- data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
- data/lib/ceedling/test_invoker/test_build_executor.rb +338 -198
- data/lib/ceedling/test_invoker/test_build_planner.rb +13 -19
- data/lib/ceedling/test_invoker/test_build_setup.rb +26 -6
- data/lib/ceedling/test_invoker/test_build_validations.rb +23 -20
- data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
- data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +1 -2
- data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
- data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
- data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +5 -3
- 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_substitutions.rb +72 -0
- data/lib/ceedling/tools/shell_quoting.rb +45 -0
- data/lib/ceedling/tools/tool_quoting.rb +79 -0
- data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
- data/lib/version.rb +1 -1
- data/plugins/bullseye/bullseye.rake +1 -3
- data/plugins/bullseye/lib/bullseye.rb +15 -2
- data/plugins/command_hooks/lib/command_hooks.rb +1 -1
- data/plugins/fff/lib/fff.rb +42 -15
- data/plugins/fff/lib/fff_mock_generator.rb +12 -9
- data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +134 -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/lib/console_reportinator.rb +25 -19
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +2 -1
- 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 +5 -2
- 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 +56 -9
- 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 +2 -2
- 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 +7 -2
- data/site-local/configuration/reference/plugins.html +2 -2
- data/site-local/configuration/reference/project.html +247 -5
- data/site-local/configuration/reference/release-build.html +2 -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 +49 -4
- data/site-local/configuration/reference/unity.html +2 -2
- data/site-local/configuration/which-ceedling.html +2 -2
- 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 +2 -2
- data/site-local/development/workflow.html +2 -2
- data/site-local/getting-started/builds.html +2 -2
- data/site-local/getting-started/command-line.html +2 -2
- 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 +2 -2
- data/site-local/plugins/fff.html +16 -2
- data/site-local/plugins/gcov/examples.html +2 -2
- data/site-local/plugins/gcov/gcovr.html +8 -2
- 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 +2 -2
- 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 +2 -2
- data/site-local/plugins/report-tests-teamcity-stdout.html +2 -2
- data/site-local/plugins/sanitize.html +2 -2
- data/site-local/plugins/valgrind.html +2 -2
- 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 +2 -2
- data/site-local/reference/build-directives.html +2 -2
- data/site-local/reference/command-line.html +2 -2
- 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/testing-guide/build-directives.html +2 -2
- data/site-local/testing-guide/conventions.html +67 -22
- 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/build_step_doctor_spec.rb +270 -0
- data/spec/integration/c_extractor_composition_spec.rb +254 -4
- data/spec/integration/includes_extraction_spec.rb +27 -14
- data/spec/integration/nested_test_artifacts_spec.rb +1 -1
- 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 +26 -19
- data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
- data/spec/integration/path_length_reporting_spec.rb +64 -0
- data/spec/integration/path_scenarios_spec.rb +80 -3
- data/spec/integration/quote_include_isolator_spec.rb +56 -0
- data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
- data/spec/integration/test_includes_extractinator_spec.rb +70 -5
- data/spec/integration/test_naming_spec.rb +6 -3
- data/spec/integration/test_source_file_checks_spec.rb +5 -3
- data/spec/integration/tool_executor_spec.rb +1 -1
- data/spec/integration/tool_validator_spec.rb +2 -2
- 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/integration/configurator_integration_helper.rb +8 -3
- data/spec/support/integration/partial_files_harness.rb +181 -0
- data/spec/support/integration/partials_generation_integration_helper.rb +237 -141
- data/spec/support/integration/path_scenario_harness.rb +4 -2
- data/spec/support/integration/spec_integration_helper.rb +8 -3
- data/spec/support/integration/test_includes_harness.rb +56 -35
- data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
- data/spec/system/bullseye_deployment_spec.rb +2 -0
- data/spec/system/delta_builds_spec.rb +26 -12
- 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 +2 -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/mock_include_folders_spec.rb +121 -0
- data/spec/system/mockable_header_reassembly_spec.rb +184 -0
- 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 +16 -12
- data/spec/system/pinned_thread_count_spec.rb +4 -4
- data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
- data/spec/system/short_build_paths_spec.rb +87 -0
- data/spec/system/sibling_header_collision_spec.rb +30 -6
- data/spec/system/support/bullseye_common_test_cases.rb +42 -0
- data/spec/system/support/common_test_cases.rb +2 -2
- data/spec/system/support/gcov_partials_test_cases.rb +48 -0
- data/spec/system/test_build_layout_spec.rb +209 -0
- data/spec/system/test_source_file_directive_spec.rb +35 -5
- 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/configurator_builder_spec.rb +24 -0
- data/spec/units/config/configurator_setup_spec.rb +72 -4
- data/spec/units/config/configurator_spec.rb +27 -1
- data/spec/units/dependencies/dependency_cache_store_spec.rb +68 -3
- data/spec/units/dependencies/dependency_tracker_spec.rb +25 -0
- 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/filesystem/build_roots_spec.rb +131 -0
- data/spec/units/filesystem/build_subpath_spec.rb +113 -0
- data/spec/units/filesystem/file_finder_helper_spec.rb +80 -0
- data/spec/units/filesystem/file_finder_spec.rb +242 -58
- data/spec/units/filesystem/file_path_utils_spec.rb +251 -118
- data/spec/units/filesystem/file_wrapper_spec.rb +191 -6
- data/spec/units/filesystem/path_matcher_spec.rb +36 -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/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 +26 -0
- 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/includes/header_search_spec.rb +406 -0
- data/spec/units/includes/include_factory_spec.rb +22 -5
- data/spec/units/includes/include_pathinator_spec.rb +77 -13
- data/spec/units/includes/include_spec.rb +14 -0
- data/spec/units/includes/includes_spec.rb +176 -19
- data/spec/units/loginator_spec.rb +31 -0
- data/spec/units/mock_locator_spec.rb +199 -5
- data/spec/units/partials/include_groups_spec.rb +42 -0
- data/spec/units/partials/partializer_config_spec.rb +25 -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 +1578 -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 +554 -261
- data/spec/units/plugins/bullseye_spec.rb +34 -0
- data/spec/units/plugins/console_reportinator_spec.rb +58 -9
- data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +1 -1
- data/spec/units/plugins/reportgenerator_reportinator_spec.rb +51 -3
- data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
- 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/setupinator_spec.rb +51 -0
- data/spec/units/standin_headerinator_spec.rb +27 -11
- data/spec/units/test_build_executor_spec.rb +780 -166
- data/spec/units/test_build_planner_spec.rb +116 -28
- data/spec/units/test_build_setup_spec.rb +83 -18
- data/spec/units/test_context_extractor_spec.rb +11 -2
- data/spec/units/test_derived_search_paths_spec.rb +259 -0
- data/spec/units/test_includes_extractinator_spec.rb +56 -8
- data/spec/units/test_invoker/objects_wiring_spec.rb +20 -3
- 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_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/{default_tools_quoting_spec.rb → tools/default_tools_quoting_spec.rb} +39 -5
- 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} +1 -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
- metadata +161 -16
- /data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +0 -0
- /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
|
@@ -0,0 +1,661 @@
|
|
|
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 'spec_helper'
|
|
9
|
+
require 'ceedling/partials/partializer_reconciler'
|
|
10
|
+
require 'ceedling/c_extractor/c_extractor_types'
|
|
11
|
+
|
|
12
|
+
describe PartializerReconciler do
|
|
13
|
+
before(:each) do
|
|
14
|
+
@c_extractor = double("CExtractor")
|
|
15
|
+
@loginator = double("Loginator").as_null_object
|
|
16
|
+
|
|
17
|
+
@reconciler = described_class.new( c_extractor: @c_extractor, loginator: @loginator )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Reconciles one file's module, which holds these definitions and declarations
|
|
21
|
+
def reconcile(funcs:, expansion_filepath:, name:, module_name:, file_type:, decls: [])
|
|
22
|
+
@reconciler.reconcile(
|
|
23
|
+
c_module: CExtractorTypes::CModule.new( function_definitions: funcs, function_declarations: decls ),
|
|
24
|
+
expansion_filepath: expansion_filepath, name: name, module_name: module_name, file_type: file_type
|
|
25
|
+
)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
context "#reconcile" do
|
|
29
|
+
def make_expanded_func(name:, signature:, decorators:, signature_stripped:, body: nil)
|
|
30
|
+
CExtractorTypes::CFunctionDefinition.new(
|
|
31
|
+
name: name,
|
|
32
|
+
signature: signature,
|
|
33
|
+
decorators: decorators,
|
|
34
|
+
signature_stripped: signature_stripped,
|
|
35
|
+
body: body
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def make_decl(name:, signature:, decorators:, signature_stripped:)
|
|
40
|
+
CExtractorTypes::CFunctionDeclaration.new(
|
|
41
|
+
name: name,
|
|
42
|
+
signature: signature,
|
|
43
|
+
decorators: decorators,
|
|
44
|
+
signature_stripped: signature_stripped
|
|
45
|
+
)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "replaces signature fields from expanded function when name matches" do
|
|
49
|
+
func = double('func',
|
|
50
|
+
name: 'helper',
|
|
51
|
+
signature: 'MY_STATIC int helper(void)',
|
|
52
|
+
decorators: [],
|
|
53
|
+
signature_stripped: 'int helper(void)'
|
|
54
|
+
)
|
|
55
|
+
allow(func).to receive(:signature=)
|
|
56
|
+
allow(func).to receive(:hidden_decorators=)
|
|
57
|
+
allow(func).to receive(:decorators=)
|
|
58
|
+
allow(func).to receive(:signature_stripped=)
|
|
59
|
+
allow(func).to receive(:expanded_body=)
|
|
60
|
+
|
|
61
|
+
expanded_func = make_expanded_func(
|
|
62
|
+
name: 'helper',
|
|
63
|
+
signature: 'static int helper(void)',
|
|
64
|
+
decorators: ['static'],
|
|
65
|
+
signature_stripped: 'int helper(void)'
|
|
66
|
+
)
|
|
67
|
+
expanded_module = CExtractorTypes::CModule.new(function_definitions: [expanded_func])
|
|
68
|
+
|
|
69
|
+
allow(@c_extractor).to receive(:from_file)
|
|
70
|
+
.with('/build/full_expansion/mod.c')
|
|
71
|
+
.and_return(expanded_module)
|
|
72
|
+
|
|
73
|
+
expect(func).to receive(:signature=).with('static int helper(void)')
|
|
74
|
+
expect(func).to receive(:decorators=).with(['static'])
|
|
75
|
+
expect(func).to receive(:signature_stripped=).with('int helper(void)')
|
|
76
|
+
|
|
77
|
+
reconcile(
|
|
78
|
+
funcs: [func],
|
|
79
|
+
expansion_filepath: '/build/full_expansion/mod.c',
|
|
80
|
+
name: 'TestMod',
|
|
81
|
+
module_name: 'mod',
|
|
82
|
+
file_type: 'source'
|
|
83
|
+
)
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
it "leaves function unchanged when name is not found in expanded module" do
|
|
87
|
+
func = double('func',
|
|
88
|
+
name: 'missing',
|
|
89
|
+
signature: 'MACRO int missing(void)',
|
|
90
|
+
decorators: [],
|
|
91
|
+
signature_stripped: 'int missing(void)'
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
expanded_module = CExtractorTypes::CModule.new(function_definitions: [])
|
|
95
|
+
|
|
96
|
+
allow(@c_extractor).to receive(:from_file).and_return(expanded_module)
|
|
97
|
+
|
|
98
|
+
expect(func).not_to receive(:signature=)
|
|
99
|
+
expect(func).not_to receive(:decorators=)
|
|
100
|
+
expect(func).not_to receive(:signature_stripped=)
|
|
101
|
+
|
|
102
|
+
reconcile(
|
|
103
|
+
funcs: [func],
|
|
104
|
+
expansion_filepath: '/build/full_expansion/mod.c',
|
|
105
|
+
name: 'TestMod',
|
|
106
|
+
module_name: 'mod',
|
|
107
|
+
file_type: 'source'
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
it "updates only matched functions and skips unmatched ones" do
|
|
112
|
+
func_match = double('matched',
|
|
113
|
+
name: 'private_func',
|
|
114
|
+
signature: 'MY_STATIC void private_func(void)',
|
|
115
|
+
decorators: [],
|
|
116
|
+
signature_stripped: 'void private_func(void)'
|
|
117
|
+
)
|
|
118
|
+
allow(func_match).to receive(:signature=)
|
|
119
|
+
allow(func_match).to receive(:hidden_decorators=)
|
|
120
|
+
allow(func_match).to receive(:decorators=)
|
|
121
|
+
allow(func_match).to receive(:signature_stripped=)
|
|
122
|
+
allow(func_match).to receive(:expanded_body=)
|
|
123
|
+
|
|
124
|
+
func_no_match = double('unmatched', name: 'orphan')
|
|
125
|
+
|
|
126
|
+
expanded_func = make_expanded_func(
|
|
127
|
+
name: 'private_func',
|
|
128
|
+
signature: 'static void private_func(void)',
|
|
129
|
+
decorators: ['static'],
|
|
130
|
+
signature_stripped: 'void private_func(void)'
|
|
131
|
+
)
|
|
132
|
+
expanded_module = CExtractorTypes::CModule.new(function_definitions: [expanded_func])
|
|
133
|
+
|
|
134
|
+
allow(@c_extractor).to receive(:from_file).and_return(expanded_module)
|
|
135
|
+
|
|
136
|
+
expect(func_match).to receive(:signature=).with('static void private_func(void)')
|
|
137
|
+
expect(func_match).to receive(:decorators=).with(['static'])
|
|
138
|
+
expect(func_match).to receive(:signature_stripped=).with('void private_func(void)')
|
|
139
|
+
expect(func_no_match).not_to receive(:signature=)
|
|
140
|
+
expect(func_no_match).not_to receive(:decorators=)
|
|
141
|
+
expect(func_no_match).not_to receive(:signature_stripped=)
|
|
142
|
+
|
|
143
|
+
reconcile(
|
|
144
|
+
funcs: [func_match, func_no_match],
|
|
145
|
+
expansion_filepath: '/build/full_expansion/mod.c',
|
|
146
|
+
name: 'TestMod',
|
|
147
|
+
module_name: 'mod',
|
|
148
|
+
file_type: 'source'
|
|
149
|
+
)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it "handles an empty funcs list without error" do
|
|
153
|
+
expanded_module = CExtractorTypes::CModule.new(function_definitions: [])
|
|
154
|
+
allow(@c_extractor).to receive(:from_file).and_return(expanded_module)
|
|
155
|
+
|
|
156
|
+
expect {
|
|
157
|
+
reconcile(
|
|
158
|
+
funcs: [],
|
|
159
|
+
expansion_filepath: '/build/full_expansion/mod.c',
|
|
160
|
+
name: 'TestMod',
|
|
161
|
+
module_name: 'mod',
|
|
162
|
+
file_type: 'source'
|
|
163
|
+
)
|
|
164
|
+
}.not_to raise_error
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
# The helper scan reads calls a macro hid, so it needs the body as the compiler sees it
|
|
168
|
+
it "keeps each matched definition's expanded body" do
|
|
169
|
+
func = CExtractorTypes::CFunctionDefinition.new(name: 'get', signature: 'int get(int v)', body: '{ return CLAMP(v); }')
|
|
170
|
+
expanded = make_expanded_func(
|
|
171
|
+
name: 'get', signature: 'int get(int v)', decorators: [], signature_stripped: 'int get(int v)',
|
|
172
|
+
body: '{ return clamp(v); }'
|
|
173
|
+
)
|
|
174
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_definitions: [expanded]))
|
|
175
|
+
|
|
176
|
+
reconcile(
|
|
177
|
+
funcs: [func], expansion_filepath: '/build/full_expansion/mod.c',
|
|
178
|
+
name: 'TestMod', module_name: 'mod', file_type: 'source'
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
expect(func.expanded_body).to eq('{ return clamp(v); }')
|
|
182
|
+
expect(func.body).to eq('{ return CLAMP(v); }')
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# The written head can't be stripped of a decorator it doesn't spell
|
|
186
|
+
it "notes the decorators the expansion finds that the written head doesn't spell" do
|
|
187
|
+
hidden = CExtractorTypes::CFunctionDefinition.new(name: 'helper', signature: 'PRIVATE int helper(void)', decorators: [])
|
|
188
|
+
written = CExtractorTypes::CFunctionDefinition.new(name: 'tick', signature: 'static int tick(void)', decorators: ['static'])
|
|
189
|
+
expanded = [
|
|
190
|
+
make_expanded_func( name: 'helper', signature: 'static int helper(void)', decorators: ['static'], signature_stripped: 'int helper(void)' ),
|
|
191
|
+
make_expanded_func( name: 'tick', signature: 'static int tick(void)', decorators: ['static'], signature_stripped: 'int tick(void)' )
|
|
192
|
+
]
|
|
193
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_definitions: expanded))
|
|
194
|
+
|
|
195
|
+
reconcile(
|
|
196
|
+
funcs: [hidden, written], expansion_filepath: '/build/full_expansion/mod.c',
|
|
197
|
+
name: 'TestMod', module_name: 'mod', file_type: 'source'
|
|
198
|
+
)
|
|
199
|
+
|
|
200
|
+
expect(hidden.hidden_decorators).to eq(['static'])
|
|
201
|
+
expect(written.hidden_decorators).to eq([])
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
it "notes only the decorators the written head lacks" do
|
|
205
|
+
func = CExtractorTypes::CFunctionDefinition.new(name: 'tick', signature: 'static INLINE int tick(void)', decorators: ['static'])
|
|
206
|
+
expanded = make_expanded_func( name: 'tick', signature: 'static inline int tick(void)', decorators: ['static', 'inline'], signature_stripped: 'int tick(void)' )
|
|
207
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_definitions: [expanded]))
|
|
208
|
+
|
|
209
|
+
reconcile( funcs: [func], expansion_filepath: '/build/full_expansion/mod.c', name: 'TestMod', module_name: 'mod', file_type: 'source' )
|
|
210
|
+
|
|
211
|
+
expect(func.hidden_decorators).to eq(['inline'])
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# A carried prototype is written as the user spelled it, so only what the rules read changes
|
|
215
|
+
it "reconciles a declaration's decorators and stripped signature but keeps its written signature" do
|
|
216
|
+
decl = make_decl(name: 'hidden', signature: 'PRIVATE int hidden(void);', decorators: [], signature_stripped: 'PRIVATE int hidden(void);')
|
|
217
|
+
expanded = make_decl(name: 'hidden', signature: 'static int hidden(void);', decorators: ['static'], signature_stripped: 'int hidden(void);')
|
|
218
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: [expanded]))
|
|
219
|
+
|
|
220
|
+
reconcile(
|
|
221
|
+
funcs: [], decls: [decl], expansion_filepath: '/build/full_expansion/mod.h',
|
|
222
|
+
name: 'TestMod', module_name: 'mod', file_type: 'header'
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
expect(decl.decorators).to eq(['static'])
|
|
226
|
+
expect(decl.signature_stripped).to eq('int hidden(void);')
|
|
227
|
+
expect(decl.signature).to eq('PRIVATE int hidden(void);')
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
it "matches declarations that share a name in the order they appear" do
|
|
231
|
+
first = make_decl(name: 'tick', signature: 'API int tick(void);', decorators: [], signature_stripped: 'API int tick(void);')
|
|
232
|
+
second = make_decl(name: 'tick', signature: 'LOCAL int tick(void);', decorators: [], signature_stripped: 'LOCAL int tick(void);')
|
|
233
|
+
expanded = [
|
|
234
|
+
make_decl(name: 'tick', signature: 'extern int tick(void);', decorators: ['extern'], signature_stripped: 'int tick(void);'),
|
|
235
|
+
make_decl(name: 'tick', signature: 'static int tick(void);', decorators: ['static'], signature_stripped: 'int tick(void);')
|
|
236
|
+
]
|
|
237
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: expanded))
|
|
238
|
+
|
|
239
|
+
reconcile(
|
|
240
|
+
funcs: [], decls: [first, second], expansion_filepath: '/build/full_expansion/mod.c',
|
|
241
|
+
name: 'TestMod', module_name: 'mod', file_type: 'source'
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
expect(first.decorators).to eq(['extern'])
|
|
245
|
+
expect(second.decorators).to eq(['static'])
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
it "leaves a declaration unchanged when the expanded copy lacks it" do
|
|
249
|
+
decl = make_decl(name: 'gone', signature: 'int gone(void);', decorators: [], signature_stripped: 'int gone(void);')
|
|
250
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new)
|
|
251
|
+
|
|
252
|
+
reconcile(
|
|
253
|
+
funcs: [], decls: [decl], expansion_filepath: '/build/full_expansion/mod.c',
|
|
254
|
+
name: 'TestMod', module_name: 'mod', file_type: 'source'
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
expect(decl.decorators).to eq([])
|
|
258
|
+
expect(decl.signature_stripped).to eq('int gone(void);')
|
|
259
|
+
end
|
|
260
|
+
|
|
261
|
+
it "lists a declaration whose decorators changed, marked as a declaration" do
|
|
262
|
+
decl = make_decl(name: 'hidden', signature: 'PRIVATE int hidden(void);', decorators: [], signature_stripped: 'PRIVATE int hidden(void);')
|
|
263
|
+
same = make_decl(name: 'plain', signature: 'int plain(void);', decorators: [], signature_stripped: 'int plain(void);')
|
|
264
|
+
expanded = [
|
|
265
|
+
make_decl(name: 'hidden', signature: 'static int hidden(void);', decorators: ['static'], signature_stripped: 'int hidden(void);'),
|
|
266
|
+
make_decl(name: 'plain', signature: 'int plain(void);', decorators: [], signature_stripped: 'int plain(void);')
|
|
267
|
+
]
|
|
268
|
+
allow(@c_extractor).to receive(:from_file).and_return(CExtractorTypes::CModule.new(function_declarations: expanded))
|
|
269
|
+
|
|
270
|
+
expect(@loginator).to receive(:log_list).with(
|
|
271
|
+
['`hidden` (declaration)'],
|
|
272
|
+
'Reconciled with full expansion for Partial TestMod::mod header:',
|
|
273
|
+
Verbosity::DEBUG
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
reconcile(
|
|
277
|
+
funcs: [], decls: [decl, same], expansion_filepath: '/build/full_expansion/mod.h',
|
|
278
|
+
name: 'TestMod', module_name: 'mod', file_type: 'header'
|
|
279
|
+
)
|
|
280
|
+
end
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
context "#reconcile with file-scope variables" do
|
|
284
|
+
def var(name:, type:, text:, decorators: [], **fields)
|
|
285
|
+
CExtractorTypes::CVariableDeclaration.new( name: name, type: type, text: text, decorators: decorators, original: "orig #{name}", line_num: 7, **fields )
|
|
286
|
+
end
|
|
287
|
+
|
|
288
|
+
def reconcile_vars(written, expanded)
|
|
289
|
+
c_module = CExtractorTypes::CModule.new( variable_declarations: written, element_sequence: written.dup )
|
|
290
|
+
allow(@c_extractor).to receive(:from_file).and_return( CExtractorTypes::CModule.new( variable_declarations: expanded ) )
|
|
291
|
+
@reconciler.reconcile( c_module: c_module, expansion_filepath: "/build/expanded_code/mod.c", name: "TestMod", module_name: "mod", file_type: "source" )
|
|
292
|
+
return c_module
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
it "takes every parsed field from the twin when a macro supplies the storage class" do
|
|
296
|
+
written = var( name: "counter", type: "PRIVATE int", text: "PRIVATE int counter[DEPTH];", array_suffix: "[DEPTH]", origin: :source )
|
|
297
|
+
twin = var(
|
|
298
|
+
name: "counter", type: "int", text: "int (*counter[4])(int) = { 0 };", decorators: ["static"], array_suffix: "",
|
|
299
|
+
declarator: "(*counter[4])(int)", asm_label: "__asm__(\"c\")", line_num: 2
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
reconcile_vars( [written], [twin] )
|
|
303
|
+
|
|
304
|
+
expect( written ).to have_attributes(
|
|
305
|
+
decorators: ["static"], type: "int", text: "int (*counter[4])(int) = { 0 };", array_suffix: "",
|
|
306
|
+
declarator: "(*counter[4])(int)", asm_label: "__asm__(\"c\")"
|
|
307
|
+
)
|
|
308
|
+
expect( written ).to have_attributes( original: "orig counter", line_num: 7, name: "counter", origin: :source )
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
# A mock's extras read what an initializer names after every macro, from any header, expands
|
|
312
|
+
it "records the expanded text of every variable it pairs, written text kept" do
|
|
313
|
+
written = var( name: "handlers", type: "port_fn_t", text: "port_fn_t handlers[] = { PORT_HANDLER };", decorators: ["static"] )
|
|
314
|
+
twin = var( name: "handlers", type: "port_fn_t", text: "port_fn_t handlers[] = { port_a };", decorators: ["static"] )
|
|
315
|
+
|
|
316
|
+
reconcile_vars( [written], [twin] )
|
|
317
|
+
|
|
318
|
+
expect( written ).to have_attributes( text: "port_fn_t handlers[] = { PORT_HANDLER };", expanded_text: "port_fn_t handlers[] = { port_a };" )
|
|
319
|
+
end
|
|
320
|
+
|
|
321
|
+
# Fallback keeps both sides of a conditional, so a name can be written more often than the
|
|
322
|
+
# expansion holds it. Each copy then records every twin's text, so nothing it names hides.
|
|
323
|
+
it "records every twin's expanded text where the counts differ" do
|
|
324
|
+
written = [var( name: "t", type: "fn_t", text: "fn_t t[] = { HANDLER };", decorators: ["static"] ),
|
|
325
|
+
var( name: "t", type: "fn_t", text: "fn_t t[] = { HANDLER };", decorators: ["static"] )]
|
|
326
|
+
twin = var( name: "t", type: "fn_t", text: "fn_t t[] = { ex_a };", decorators: ["static"] )
|
|
327
|
+
|
|
328
|
+
reconcile_vars( written, [twin] )
|
|
329
|
+
|
|
330
|
+
expect( written.map( &:expanded_text ) ).to eq( ["fn_t t[] = { ex_a };", "fn_t t[] = { ex_a };"] )
|
|
331
|
+
expect( written.map( &:text ) ).to eq( ["fn_t t[] = { HANDLER };", "fn_t t[] = { HANDLER };"] )
|
|
332
|
+
end
|
|
333
|
+
|
|
334
|
+
it "takes an extern a macro spells" do
|
|
335
|
+
written = var( name: "shared", type: "EXTERN int", text: "EXTERN int shared;" )
|
|
336
|
+
twin = var( name: "shared", type: "int", text: "int shared;", decorators: ["extern"] )
|
|
337
|
+
|
|
338
|
+
reconcile_vars( [written], [twin] )
|
|
339
|
+
|
|
340
|
+
expect( written.extern? ).to be( true )
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
# A name may be declared and then defined, and each pairs with its own twin
|
|
344
|
+
it "pairs a repeated name with its twins in order" do
|
|
345
|
+
written = [var( name: "g", type: "EXTERN int", text: "EXTERN int g;" ), var( name: "g", type: "int", text: "int g = 1;" )]
|
|
346
|
+
twins = [var( name: "g", type: "int", text: "int g;", decorators: ["extern"] ), var( name: "g", type: "int", text: "int g = 1;" )]
|
|
347
|
+
|
|
348
|
+
reconcile_vars( written, twins )
|
|
349
|
+
|
|
350
|
+
expect( written.map( &:decorators ) ).to eq( [["extern"], []] )
|
|
351
|
+
expect( written.map( &:text ) ).to eq( ["int g;", "int g = 1;"] )
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
# A token-pasted name and a file-scope asm statement both read as nameless
|
|
355
|
+
it "never pairs variables it can read no name for" do
|
|
356
|
+
written = var( name: nil, type: "extern int", text: "extern int CAT(buf, 1)[4];", decorators: ["extern"] )
|
|
357
|
+
twin = var( name: nil, type: "", text: "__asm__(\".text\");" )
|
|
358
|
+
|
|
359
|
+
reconcile_vars( [written], [twin] )
|
|
360
|
+
|
|
361
|
+
expect( written ).to have_attributes( text: "extern int CAT(buf, 1)[4];", decorators: ["extern"] )
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
it "leaves alone a name the expansion holds more often" do
|
|
365
|
+
written = var( name: "mode", type: "PRIVATE int", text: "PRIVATE int mode;" )
|
|
366
|
+
twins = [var( name: "mode", type: "int", text: "int mode;", decorators: ["static"] ), var( name: "mode", type: "int", text: "int mode;", decorators: ["static"] )]
|
|
367
|
+
|
|
368
|
+
reconcile_vars( [written], twins )
|
|
369
|
+
|
|
370
|
+
expect( written.type ).to eq( "PRIVATE int" )
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
it "keeps a type the written declaration already defines" do
|
|
374
|
+
held = CExtractorTypes::CStatement.new( text: "struct { int a; };", kind: :aggregate )
|
|
375
|
+
other = CExtractorTypes::CStatement.new( text: "struct { int a; };", kind: :aggregate )
|
|
376
|
+
written = var( name: "s", type: "", text: "s;", defined_type: held )
|
|
377
|
+
twin = var( name: "s", type: "", text: "s;", decorators: ["static"], defined_type: other )
|
|
378
|
+
|
|
379
|
+
c_module = reconcile_vars( [written], [twin] )
|
|
380
|
+
|
|
381
|
+
expect( written.defined_type ).to be( held )
|
|
382
|
+
expect( c_module.aggregate_definitions ).to be_empty
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
it "reconciles each variable of a compound declaration with its own twin, in order" do
|
|
386
|
+
written = [var( name: "a", type: "PRIVATE int", text: "PRIVATE int a;" ), var( name: "b", type: "PRIVATE int", text: "PRIVATE int b;" )]
|
|
387
|
+
twins = [var( name: "a", type: "int", text: "int a;", decorators: ["static"] ), var( name: "b", type: "int", text: "int b;", decorators: ["static"] )]
|
|
388
|
+
|
|
389
|
+
reconcile_vars( written, twins )
|
|
390
|
+
|
|
391
|
+
expect( written.map( &:text ) ).to eq( ["int a;", "int b;"] )
|
|
392
|
+
end
|
|
393
|
+
|
|
394
|
+
# A qualifier compiles as written, so the written declaration stays
|
|
395
|
+
it "leaves alone a variable whose storage class agrees, as a qualifier-only macro leaves it" do
|
|
396
|
+
written = var( name: "table", type: "ROM int", text: "ROM int table;", decorators: ["static"] )
|
|
397
|
+
twin = var( name: "table", type: "int", text: "int table;", decorators: ["static", "const"] )
|
|
398
|
+
|
|
399
|
+
reconcile_vars( [written], [twin] )
|
|
400
|
+
|
|
401
|
+
expect( written ).to have_attributes( type: "ROM int", text: "ROM int table;", decorators: ["static"] )
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
# Fallback can keep both branches of a conditional, which leaves no sure pairing
|
|
405
|
+
it "leaves alone a name the two copies hold a different number of times" do
|
|
406
|
+
written = [var( name: "mode", type: "PRIVATE int", text: "PRIVATE int mode;" ), var( name: "mode", type: "PRIVATE long", text: "PRIVATE long mode;" )]
|
|
407
|
+
twin = var( name: "mode", type: "int", text: "int mode;", decorators: ["static"] )
|
|
408
|
+
|
|
409
|
+
reconcile_vars( written, [twin] )
|
|
410
|
+
|
|
411
|
+
expect( written.map( &:type ) ).to eq( ["PRIVATE int", "PRIVATE long"] )
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# A macro ahead of the type hid it from the written declaration
|
|
415
|
+
it "places a type the twin defines ahead of the variable, once for all its variables" do
|
|
416
|
+
type = CExtractorTypes::CStatement.new( text: "struct { int a; };", kind: :aggregate )
|
|
417
|
+
written = [var( name: "s", type: "PRIVATE struct { int a; }", text: "PRIVATE struct { int a; } s, t;" ), var( name: "t", type: "PRIVATE struct { int a; }", text: "PRIVATE struct { int a; } s, t;" )]
|
|
418
|
+
twins = [var( name: "s", type: "", text: "s;", decorators: ["static"], defined_type: type ), var( name: "t", type: "", text: "t;", decorators: ["static"], defined_type: type )]
|
|
419
|
+
|
|
420
|
+
c_module = reconcile_vars( written, twins )
|
|
421
|
+
|
|
422
|
+
expect( c_module.aggregate_definitions ).to contain_exactly( be( type ) )
|
|
423
|
+
expect( c_module.element_sequence ).to eq( [type, *written] )
|
|
424
|
+
expect( written.map( &:defined_type ) ).to all( be( type ) )
|
|
425
|
+
end
|
|
426
|
+
|
|
427
|
+
it "lists each variable it reconciles" do
|
|
428
|
+
written = var( name: "counter", type: "PRIVATE int", text: "PRIVATE int counter;" )
|
|
429
|
+
reconcile_vars( [written], [var( name: "counter", type: "int", text: "int counter;", decorators: ["static"] )] )
|
|
430
|
+
|
|
431
|
+
expect(@loginator).to have_received(:log_list).with( ["`counter` (variable)"], anything, Verbosity::DEBUG )
|
|
432
|
+
end
|
|
433
|
+
end
|
|
434
|
+
|
|
435
|
+
context "#reconcile with a type a macro ends" do
|
|
436
|
+
def type(text, tag:)
|
|
437
|
+
CExtractorTypes::CStatement.new( text: text, kind: :aggregate, tag: tag )
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
def variable(name, defined_type, text: "#{name};")
|
|
441
|
+
CExtractorTypes::CVariableDeclaration.new( name: name, type: "", text: text, defined_type: defined_type )
|
|
442
|
+
end
|
|
443
|
+
|
|
444
|
+
# The written module, whose types and variables both sit in element_sequence
|
|
445
|
+
def written(types, vars)
|
|
446
|
+
CExtractorTypes::CModule.new( aggregate_definitions: types, variable_declarations: vars, element_sequence: types + vars )
|
|
447
|
+
end
|
|
448
|
+
|
|
449
|
+
def reconcile_with(c_module, expanded)
|
|
450
|
+
allow(@c_extractor).to receive(:from_file).and_return( expanded )
|
|
451
|
+
@reconciler.reconcile( c_module: c_module, expansion_filepath: "/build/expanded_code/mod.h", name: "TestMod", module_name: "mod", file_type: "header" )
|
|
452
|
+
end
|
|
453
|
+
|
|
454
|
+
it "gives a tagged type back the macro the written text read as its variable" do
|
|
455
|
+
pk = type( "struct pk { char c; int i; };", tag: "pk" )
|
|
456
|
+
macro = variable( "PACKED", pk, text: "PACKED;" )
|
|
457
|
+
c_module = written( [pk], [macro] )
|
|
458
|
+
|
|
459
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new( aggregate_definitions: [type( "struct pk { char c; int i; } __attribute__((packed));", tag: "pk" )] ) )
|
|
460
|
+
|
|
461
|
+
expect( pk.text ).to eq( "struct pk { char c; int i; } PACKED;" )
|
|
462
|
+
expect( c_module.variable_declarations ).to be_empty
|
|
463
|
+
expect( c_module.element_sequence ).to eq( [pk] )
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
# The expansion holds the variable, and defines the type only through it
|
|
467
|
+
it "keeps a variable a macro names" do
|
|
468
|
+
pt = type( "struct pt { int a; };", tag: "pt" )
|
|
469
|
+
named = variable( "MY_VAR", pt )
|
|
470
|
+
c_module = written( [pt], [named] )
|
|
471
|
+
twin_pt = type( "struct pt { int a; };", tag: "pt" )
|
|
472
|
+
|
|
473
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new( aggregate_definitions: [twin_pt], variable_declarations: [variable( "g_var", twin_pt )] ) )
|
|
474
|
+
|
|
475
|
+
expect( c_module.variable_declarations ).to eq( [named] )
|
|
476
|
+
expect( pt.text ).to eq( "struct pt { int a; };" )
|
|
477
|
+
end
|
|
478
|
+
|
|
479
|
+
it "leaves an anonymous type alone" do
|
|
480
|
+
anonymous = type( "struct { int a; };", tag: nil )
|
|
481
|
+
c_module = written( [anonymous], [variable( "PACKED", anonymous, text: "PACKED;" )] )
|
|
482
|
+
|
|
483
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new( aggregate_definitions: [type( "struct { int a; } __attribute__((packed));", tag: nil )] ) )
|
|
484
|
+
|
|
485
|
+
expect( c_module.variable_declarations.size ).to eq( 1 )
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
it "leaves a type alone that defines more than one variable" do
|
|
489
|
+
pk = type( "struct pk { int a; };", tag: "pk" )
|
|
490
|
+
c_module = written( [pk], [variable( "PACKED", pk, text: "PACKED;" ), variable( "other", pk )] )
|
|
491
|
+
|
|
492
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new( aggregate_definitions: [type( "struct pk { int a; };", tag: "pk" )] ) )
|
|
493
|
+
|
|
494
|
+
expect( c_module.variable_declarations.size ).to eq( 2 )
|
|
495
|
+
expect( pk.text ).to eq( "struct pk { int a; };" )
|
|
496
|
+
end
|
|
497
|
+
|
|
498
|
+
# The expansion holding the name settles it, whatever it defines
|
|
499
|
+
it "keeps a variable the expansion also holds by name" do
|
|
500
|
+
pk = type( "struct pk { int a; };", tag: "pk" )
|
|
501
|
+
c_module = written( [pk], [variable( "current", pk )] )
|
|
502
|
+
|
|
503
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new(
|
|
504
|
+
aggregate_definitions: [type( "struct pk { int a; };", tag: "pk" )], variable_declarations: [variable( "current", nil )]
|
|
505
|
+
) )
|
|
506
|
+
|
|
507
|
+
expect( c_module.variable_declarations.size ).to eq( 1 )
|
|
508
|
+
end
|
|
509
|
+
|
|
510
|
+
# A forward declaration defines nothing, so it never shows the tag defined alone
|
|
511
|
+
it "keeps a variable whose tag the expansion only declares ahead" do
|
|
512
|
+
pk = type( "struct pk { int a; };", tag: "pk" )
|
|
513
|
+
named = variable( "MY_VAR", pk )
|
|
514
|
+
c_module = written( [pk], [named] )
|
|
515
|
+
twin_pk = type( "struct pk { int a; };", tag: "pk" )
|
|
516
|
+
|
|
517
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new(
|
|
518
|
+
aggregate_definitions: [type( "struct pk;", tag: "pk" ), twin_pk], variable_declarations: [variable( "g_var", twin_pk )]
|
|
519
|
+
) )
|
|
520
|
+
|
|
521
|
+
expect( c_module.variable_declarations ).to eq( [named] )
|
|
522
|
+
end
|
|
523
|
+
|
|
524
|
+
# A function-like macro, as `ALIGNED(8)`, reads as a variable with no name
|
|
525
|
+
it "rejoins a nameless macro while the expansion holds a nameless declaration of its own" do
|
|
526
|
+
al = type( "struct al { char c; };", tag: "al" )
|
|
527
|
+
c_module = written( [al], [variable( nil, al, text: "ALIGNED(8);" )] )
|
|
528
|
+
|
|
529
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new(
|
|
530
|
+
aggregate_definitions: [type( "struct al { char c; } __attribute__((aligned(8)));", tag: "al" )],
|
|
531
|
+
variable_declarations: [variable( nil, nil, text: "__asm__(\".globl x\");" )]
|
|
532
|
+
) )
|
|
533
|
+
|
|
534
|
+
expect( al.text ).to eq( "struct al { char c; } ALIGNED(8);" )
|
|
535
|
+
expect( c_module.variable_declarations ).to be_empty
|
|
536
|
+
end
|
|
537
|
+
|
|
538
|
+
# `static struct pk { … } __attribute__((packed));` expands to a declaration with no variable name
|
|
539
|
+
it "rejoins a macro whose expanded type a nameless declaration defines" do
|
|
540
|
+
pk = type( "struct pk { char c; int i; };", tag: "pk" )
|
|
541
|
+
c_module = written( [pk], [variable( "PACKED", pk, text: "PACKED;" )] )
|
|
542
|
+
twin_pk = type( "struct pk { char c; int i; };", tag: "pk" )
|
|
543
|
+
|
|
544
|
+
reconcile_with( c_module, CExtractorTypes::CModule.new( aggregate_definitions: [twin_pk], variable_declarations: [variable( nil, twin_pk, text: ";" )] ) )
|
|
545
|
+
|
|
546
|
+
expect( pk.text ).to eq( "struct pk { char c; int i; } PACKED;" )
|
|
547
|
+
end
|
|
548
|
+
|
|
549
|
+
it "lists the macro it gives back to a type" do
|
|
550
|
+
pk = type( "struct pk { char c; int i; };", tag: "pk" )
|
|
551
|
+
|
|
552
|
+
reconcile_with( written( [pk], [variable( "PACKED", pk, text: "PACKED;" )] ), CExtractorTypes::CModule.new( aggregate_definitions: [type( "struct pk { char c; int i; } __attribute__((packed));", tag: "pk" )] ) )
|
|
553
|
+
|
|
554
|
+
expect(@loginator).to have_received(:log_list).with( ["`PACKED` (type attribute of `pk`)"], anything, Verbosity::DEBUG )
|
|
555
|
+
end
|
|
556
|
+
|
|
557
|
+
# Variables after the macro read it as the start of their type. Their twins' types lack it.
|
|
558
|
+
context "and variables follow" do
|
|
559
|
+
def typed(name, type_text, defined_type, text:)
|
|
560
|
+
CExtractorTypes::CVariableDeclaration.new( name: name, type: type_text, text: text, defined_type: defined_type )
|
|
561
|
+
end
|
|
562
|
+
|
|
563
|
+
def expanded_with(*vars, type_text: "struct pk { char c; int i; } __attribute__((packed))", decorators: [])
|
|
564
|
+
twin_pk = type( type_text, tag: "pk" )
|
|
565
|
+
twins = vars.map { |name, rest| typed( name, rest, twin_pk, text: "#{name};" ).tap { |twin| twin.decorators = decorators } }
|
|
566
|
+
return CExtractorTypes::CModule.new( aggregate_definitions: [twin_pk], variable_declarations: twins )
|
|
567
|
+
end
|
|
568
|
+
|
|
569
|
+
it "gives the type the macro once, and takes it from every variable" do
|
|
570
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
571
|
+
vars = [typed( "i1", "PACKED", pk, text: "PACKED i1;" ), typed( "i2", "PACKED", pk, text: "PACKED i2;" )]
|
|
572
|
+
c_module = written( [pk], vars )
|
|
573
|
+
|
|
574
|
+
reconcile_with( c_module, expanded_with( ["i1", ""], ["i2", ""] ) )
|
|
575
|
+
|
|
576
|
+
expect( pk.text ).to eq( "struct pk { char c; int i; } PACKED" )
|
|
577
|
+
expect( vars.map( &:type ) ).to eq( ["", ""] )
|
|
578
|
+
expect( vars.map( &:text ) ).to eq( ["i1;", "i2;"] )
|
|
579
|
+
end
|
|
580
|
+
|
|
581
|
+
it "lists the macro once for a type its variables share" do
|
|
582
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
583
|
+
vars = [typed( "i1", "PACKED", pk, text: "PACKED i1;" ), typed( "i2", "PACKED", pk, text: "PACKED i2;" )]
|
|
584
|
+
|
|
585
|
+
reconcile_with( written( [pk], vars ), expanded_with( ["i1", ""], ["i2", ""] ) )
|
|
586
|
+
|
|
587
|
+
expect(@loginator).to have_received(:log_list).with( ["`PACKED` (type attribute of `pk`)"], anything, Verbosity::DEBUG )
|
|
588
|
+
end
|
|
589
|
+
|
|
590
|
+
it "names a type without a tag by its first variable" do
|
|
591
|
+
anonymous = type( "struct { char c; int i; }", tag: nil )
|
|
592
|
+
twin = type( "struct { char c; int i; } __attribute__((packed))", tag: nil )
|
|
593
|
+
vars = [typed( "a", "PACKED", anonymous, text: "PACKED a;" ), typed( "b", "PACKED", anonymous, text: "PACKED b;" )]
|
|
594
|
+
|
|
595
|
+
reconcile_with( written( [anonymous], vars ), CExtractorTypes::CModule.new(
|
|
596
|
+
aggregate_definitions: [twin], variable_declarations: [typed( "a", "", twin, text: "a;" ), typed( "b", "", twin, text: "b;" )]
|
|
597
|
+
) )
|
|
598
|
+
|
|
599
|
+
expect( anonymous.text ).to eq( "struct { char c; int i; } PACKED" )
|
|
600
|
+
expect(@loginator).to have_received(:log_list).with( ["`PACKED` (type attribute of the type of `a`)"], anything, Verbosity::DEBUG )
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
it "keeps what follows the macro in the variable's type" do
|
|
604
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
605
|
+
gp = typed( "gp", "PACKED *", pk, text: "PACKED *gp;" )
|
|
606
|
+
|
|
607
|
+
reconcile_with( written( [pk], [gp] ), expanded_with( ["gp", "*"] ) )
|
|
608
|
+
|
|
609
|
+
expect( pk.text ).to eq( "struct pk { char c; int i; } PACKED" )
|
|
610
|
+
expect( [gp.type, gp.text] ).to eq( ["*", "*gp;"] )
|
|
611
|
+
end
|
|
612
|
+
|
|
613
|
+
it "ends a type its statement ends before the semicolon" do
|
|
614
|
+
pk = type( "struct pk { char c; int i; };", tag: "pk" )
|
|
615
|
+
|
|
616
|
+
reconcile_with( written( [pk], [typed( "inst", "PACKED", pk, text: "PACKED inst;" )] ), expanded_with( ["inst", ""] ) )
|
|
617
|
+
|
|
618
|
+
expect( pk.text ).to eq( "struct pk { char c; int i; } PACKED;" )
|
|
619
|
+
end
|
|
620
|
+
|
|
621
|
+
# A macro that stands for part of the declarator, as `#define PTR *`, is not the type's
|
|
622
|
+
it "leaves a variable alone whose written type doesn't end in its twin's" do
|
|
623
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
624
|
+
gp = typed( "gp", "PTR", pk, text: "PTR gp;" )
|
|
625
|
+
|
|
626
|
+
reconcile_with( written( [pk], [gp] ), expanded_with( ["gp", "*"] ) )
|
|
627
|
+
|
|
628
|
+
expect( [pk.text, gp.type, gp.text] ).to eq( ["struct pk { char c; int i; }", "PTR", "PTR gp;"] )
|
|
629
|
+
end
|
|
630
|
+
|
|
631
|
+
# A storage class after the brace, as `struct pk { … } PRIVATE inst;`, stays the variable's
|
|
632
|
+
it "leaves a macro alone that gives the variable a decorator" do
|
|
633
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
634
|
+
inst = typed( "inst", "PRIVATE", pk, text: "PRIVATE inst;" )
|
|
635
|
+
|
|
636
|
+
reconcile_with( written( [pk], [inst] ), expanded_with( ["inst", ""], type_text: "struct pk { char c; int i; }", decorators: ['static'] ) )
|
|
637
|
+
|
|
638
|
+
expect( pk.text ).to eq( "struct pk { char c; int i; }" )
|
|
639
|
+
end
|
|
640
|
+
|
|
641
|
+
# A qualifier the compiler reads ahead of an attribute leaves the expanded type as written
|
|
642
|
+
it "leaves a macro alone that adds nothing after the twin's brace" do
|
|
643
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
644
|
+
inst = typed( "inst", "VOLATILE_PACKED", pk, text: "VOLATILE_PACKED inst;" )
|
|
645
|
+
|
|
646
|
+
reconcile_with( written( [pk], [inst] ), expanded_with( ["inst", "__attribute__((packed))"], type_text: "struct pk { char c; int i; }" ) )
|
|
647
|
+
|
|
648
|
+
expect( [pk.text, inst.type] ).to eq( ["struct pk { char c; int i; }", "VOLATILE_PACKED"] )
|
|
649
|
+
end
|
|
650
|
+
|
|
651
|
+
it "leaves a variable alone whose written type matches its twin's" do
|
|
652
|
+
pk = type( "struct pk { char c; int i; }", tag: "pk" )
|
|
653
|
+
gp = typed( "gp", "*", pk, text: "*gp;" )
|
|
654
|
+
|
|
655
|
+
reconcile_with( written( [pk], [gp] ), expanded_with( ["gp", "*"] ) )
|
|
656
|
+
|
|
657
|
+
expect( [pk.text, gp.type] ).to eq( ["struct pk { char c; int i; }", "*"] )
|
|
658
|
+
end
|
|
659
|
+
end
|
|
660
|
+
end
|
|
661
|
+
end
|