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
|
@@ -138,11 +138,22 @@ describe PartializerUtils do
|
|
|
138
138
|
source_filepath: 'src/code/myfile.c',
|
|
139
139
|
line_num: 34,
|
|
140
140
|
decorators: ['__pragma__', 'static'],
|
|
141
|
+
hidden_decorators: [],
|
|
141
142
|
code_block: "__pragma__ static void testFunc(int x) {\n return x * 2;\n}"
|
|
142
143
|
)
|
|
143
144
|
end
|
|
144
145
|
|
|
145
146
|
context "when output_type is :impl" do
|
|
147
|
+
# A selected function's callers rely on it never returning
|
|
148
|
+
it "keeps _Noreturn on a testable function" do
|
|
149
|
+
func = double('function', name: 'die', decorators: ['static'], hidden_decorators: [], source_filepath: 'src/m.c', line_num: 3,
|
|
150
|
+
code_block: "static _Noreturn void die(void) { for (;;) {} }")
|
|
151
|
+
|
|
152
|
+
result = @utils.transform_function(func, '_Noreturn void die(void)', :impl)
|
|
153
|
+
|
|
154
|
+
expect(result.code_block).to eq("_Noreturn void die(void) { for (;;) {} }")
|
|
155
|
+
end
|
|
156
|
+
|
|
146
157
|
it "returns a FunctionDefinition with source filepath, line number, signature, and code block" do
|
|
147
158
|
signature = 'void testFunc(int x)'
|
|
148
159
|
|
|
@@ -167,6 +178,27 @@ describe PartializerUtils do
|
|
|
167
178
|
expect(result).not_to respond_to(:code_block)
|
|
168
179
|
end
|
|
169
180
|
|
|
181
|
+
# A mock always returns, so a mock declared never to return would contradict itself
|
|
182
|
+
it "drops _Noreturn from a mockable signature" do
|
|
183
|
+
result = @utils.transform_function(mock_func, '_Noreturn void testFunc(int x);', :interface)
|
|
184
|
+
|
|
185
|
+
expect(result.signature).to eq('void testFunc(int x)')
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
it "drops the GNU and C23 noreturn attributes from a mockable signature" do
|
|
189
|
+
gnu = @utils.transform_function(mock_func, '__attribute__((noreturn)) void testFunc(int x);', :interface)
|
|
190
|
+
c23 = @utils.transform_function(mock_func, '[[noreturn]] void testFunc(int x);', :interface)
|
|
191
|
+
|
|
192
|
+
expect(gnu.signature).to eq('void testFunc(int x)')
|
|
193
|
+
expect(c23.signature).to eq('void testFunc(int x)')
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
it "keeps an attribute that says something else" do
|
|
197
|
+
result = @utils.transform_function(mock_func, '__attribute__((warn_unused_result)) int testFunc(int x);', :interface)
|
|
198
|
+
|
|
199
|
+
expect(result.signature).to eq('__attribute__((warn_unused_result)) int testFunc(int x)')
|
|
200
|
+
end
|
|
201
|
+
|
|
170
202
|
it "strips a trailing semicolon from a declaration-sourced signature" do
|
|
171
203
|
# CFunctionDeclaration#signature_stripped always carries its own trailing
|
|
172
204
|
# semicolon (it's a bare prototype); CFunctionDefinition#signature_stripped never
|
|
@@ -190,268 +222,269 @@ describe PartializerUtils do
|
|
|
190
222
|
end
|
|
191
223
|
end
|
|
192
224
|
|
|
193
|
-
#
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
225
|
+
# A macro the module's header defines, such as `#define PRIVATE static`, hides a decorator the
|
|
226
|
+
# written head can't be stripped of. The implementation header declares the expanded,
|
|
227
|
+
# stripped signature, so the definition takes the same one.
|
|
228
|
+
context "#transform_function with decorators a macro hides" do
|
|
229
|
+
def definition(code_block, hidden:, line_num: 10, name: 'helper', decorators: hidden)
|
|
230
|
+
CExtractorTypes::CFunctionDefinition.new(
|
|
231
|
+
name: name, code_block: code_block, line_num: line_num, decorators: decorators, hidden_decorators: hidden
|
|
232
|
+
)
|
|
233
|
+
end
|
|
198
234
|
|
|
199
|
-
|
|
200
|
-
|
|
235
|
+
def transform(func, signature)
|
|
236
|
+
@utils.transform_function( func, signature, :impl )
|
|
201
237
|
end
|
|
202
238
|
|
|
203
|
-
it "
|
|
204
|
-
|
|
205
|
-
result, newlines = @utils.send(:extract_code_block, code_block, ['__pragma__', 'static'])
|
|
239
|
+
it "writes the head from the signature and keeps the body as written" do
|
|
240
|
+
result = transform( definition( "PRIVATE int helper(void) {\n return 41;\n}", hidden: ['static'] ), 'int helper(void)' )
|
|
206
241
|
|
|
207
|
-
expect(result).to eq("
|
|
208
|
-
expect(
|
|
242
|
+
expect( result.code_block ).to eq( "int helper(void) {\n return 41;\n}" )
|
|
243
|
+
expect( result.line_num ).to eq( 10 )
|
|
209
244
|
end
|
|
210
245
|
|
|
211
|
-
it "
|
|
212
|
-
|
|
213
|
-
result, newlines = @utils.send(:extract_code_block, code_block, [])
|
|
246
|
+
it "rewrites a head a macro makes static and inline" do
|
|
247
|
+
result = transform( definition( "STATICINLINE int twice(int v) { return v * 2; }", hidden: ['static', 'inline'], name: 'twice' ), 'int twice(int v)' )
|
|
214
248
|
|
|
215
|
-
expect(result).to eq(
|
|
216
|
-
expect(newlines).to eq(0)
|
|
249
|
+
expect( result.code_block ).to eq( "int twice(int v) { return v * 2; }" )
|
|
217
250
|
end
|
|
218
251
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
252
|
+
# A macro that respells a keyword the head already names, as `#define inline __inline` does
|
|
253
|
+
it "rewrites a head whose written decorator a macro turns into another" do
|
|
254
|
+
func = definition( "inline int tick(void) { return 1; }", hidden: ['__inline'], decorators: ['inline'], name: 'tick' )
|
|
255
|
+
result = transform( func, 'int tick(void)' )
|
|
222
256
|
|
|
223
|
-
expect(result).to eq("int
|
|
224
|
-
expect(newlines).to eq(1)
|
|
257
|
+
expect( result.code_block ).to eq( "int tick(void) { return 1; }" )
|
|
225
258
|
end
|
|
226
259
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
260
|
+
# Coverage tools place a function at its name's line, and every body line keeps its own
|
|
261
|
+
it "keeps the name's line and every body line of a head spread over several lines" do
|
|
262
|
+
func = definition( "PRIVATE int\nhelper(int a,\n int b)\n{\n return a + b;\n}", hidden: ['static'] )
|
|
263
|
+
result = transform( func, "int helper(int a,\n int b)" )
|
|
230
264
|
|
|
231
|
-
expect(result).to eq("int
|
|
232
|
-
expect(
|
|
265
|
+
expect( result.code_block ).to eq( "int helper(int a, int b)\n\n{\n return a + b;\n}" )
|
|
266
|
+
expect( result.line_num ).to eq( 11 )
|
|
233
267
|
end
|
|
234
268
|
|
|
235
|
-
it "
|
|
236
|
-
|
|
237
|
-
result, _ = @utils.send(:extract_code_block, code_block, ['static'])
|
|
269
|
+
it "keeps what follows the parameter list as written" do
|
|
270
|
+
result = transform( definition( "PRIVATE int helper(void) /* note */ { return 1; }", hidden: ['static'] ), 'int helper(void)' )
|
|
238
271
|
|
|
239
|
-
expect(result).to
|
|
240
|
-
expect(result.count("\n")).to eq(3)
|
|
272
|
+
expect( result.code_block ).to eq( "int helper(void) /* note */ { return 1; }" )
|
|
241
273
|
end
|
|
242
274
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
result
|
|
275
|
+
# Fallback keeps comments, so a ';' in one after the list says nothing of K&R
|
|
276
|
+
it "rewrites a head whose comment after the list holds a ';'" do
|
|
277
|
+
result = transform( definition( "PRIVATE int helper(void) /* adds; */ { return 1; }", hidden: ['static'] ), 'int helper(void)' )
|
|
246
278
|
|
|
247
|
-
expect(result).to eq("int
|
|
248
|
-
expect(result).not_to include("static")
|
|
249
|
-
expect(newlines).to eq(0)
|
|
279
|
+
expect( result.code_block ).to eq( "int helper(void) /* adds; */ { return 1; }" )
|
|
250
280
|
end
|
|
251
281
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
282
|
+
# Fallback keeps comments, so the name can sit apart from its list. The body's recursive
|
|
283
|
+
# call must not pass for the name.
|
|
284
|
+
it "finds the name in the head alone, past a comment ahead of the list" do
|
|
285
|
+
code = "PRIVATE int helper /* c */ (int a) { return a ? helper( a - 1 ) : 0; }"
|
|
286
|
+
result = transform( definition( code, hidden: ['static'] ), 'int helper (int a)' )
|
|
255
287
|
|
|
256
|
-
expect(result).to eq(
|
|
257
|
-
expect(newlines).to eq(0)
|
|
288
|
+
expect( result.code_block ).to eq( "int helper (int a) { return a ? helper( a - 1 ) : 0; }" )
|
|
258
289
|
end
|
|
259
290
|
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
result
|
|
291
|
+
# A multibyte character ahead of the name counts as one character but several bytes
|
|
292
|
+
it "keeps the body intact behind a multibyte character ahead of the name" do
|
|
293
|
+
code = "__attribute__((section(\"région\"))) PRIVATE int\nhelper(void)\n{ return 1; }"
|
|
294
|
+
result = transform( definition( code, hidden: ['static'] ), '__attribute__((section("région"))) int helper(void)' )
|
|
264
295
|
|
|
265
|
-
expect(result).to
|
|
266
|
-
expect(result).to
|
|
296
|
+
expect( result.code_block ).to eq( "__attribute__((section(\"région\"))) int helper(void)\n{ return 1; }" )
|
|
297
|
+
expect( result.line_num ).to eq( 11 )
|
|
267
298
|
end
|
|
268
299
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
300
|
+
# A K&R definition declares its parameters between the list and the body
|
|
301
|
+
it "strips as written when a ';' follows the parameter list" do
|
|
302
|
+
code = "PRIVATE int helper(a)\n int a;\n{ return a; }"
|
|
303
|
+
result = transform( definition( code, hidden: ['static'] ), 'int helper(a)' )
|
|
272
304
|
|
|
273
|
-
expect(result).to eq(
|
|
274
|
-
expect(newlines).to eq(1)
|
|
305
|
+
expect( result.code_block ).to eq( code )
|
|
275
306
|
end
|
|
276
|
-
end
|
|
277
307
|
|
|
278
|
-
|
|
279
|
-
it "
|
|
280
|
-
|
|
308
|
+
# A compound literal's brace inside the list hides where the body opens
|
|
309
|
+
it "strips as written when a brace sits inside the parameter list" do
|
|
310
|
+
code = "PRIVATE int helper(int n, int a[(int){3}]) { return n; }"
|
|
311
|
+
result = transform( definition( code, hidden: ['static'] ), 'int helper(int n, int a[(int){3}])' )
|
|
312
|
+
|
|
313
|
+
expect( result.code_block ).to eq( code )
|
|
281
314
|
end
|
|
282
315
|
|
|
283
|
-
|
|
284
|
-
|
|
316
|
+
# A `_Pragma` in the head expands to a directive, which can't share a line with the head
|
|
317
|
+
it "strips as written when the signature holds a directive" do
|
|
318
|
+
code = "PRIVATE NOUNUSED int helper(int a) { return 1; }"
|
|
319
|
+
signature = "\n#pragma GCC diagnostic ignored \"-Wunused-parameter\"\n int helper(int a)"
|
|
320
|
+
result = transform( definition( code, hidden: ['static'] ), signature )
|
|
321
|
+
|
|
322
|
+
expect( result.code_block ).to eq( code )
|
|
285
323
|
end
|
|
286
324
|
|
|
287
|
-
it "
|
|
288
|
-
|
|
325
|
+
it "strips as written when nothing is hidden" do
|
|
326
|
+
result = transform( definition( "static int helper(void) { return 1; }", hidden: [], decorators: ['static'] ), 'int helper(void)' )
|
|
327
|
+
|
|
328
|
+
expect( result.code_block ).to eq( "int helper(void) { return 1; }" )
|
|
289
329
|
end
|
|
290
330
|
|
|
291
|
-
it "
|
|
292
|
-
|
|
331
|
+
it "keeps line breaks the head's CRLF endings hold" do
|
|
332
|
+
result = transform( definition( "PRIVATE int\r\nhelper(void)\r\n{\r\n return 1;\r\n}", hidden: ['static'] ), 'int helper(void)' )
|
|
333
|
+
|
|
334
|
+
expect( result.code_block ).to eq( "int helper(void)\r\n{\r\n return 1;\r\n}" )
|
|
335
|
+
expect( result.line_num ).to eq( 11 )
|
|
293
336
|
end
|
|
294
337
|
end
|
|
295
338
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
339
|
+
# Test private method for code block manipulation used by `transform_function()`
|
|
340
|
+
context "#extract_code_block" do
|
|
341
|
+
it "strips a decorator on the signature's own line and counts no newlines" do
|
|
342
|
+
code_block = "static void foo(void) {\n return;\n}"
|
|
343
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static'], 'foo')
|
|
300
344
|
|
|
301
|
-
expect(result).to
|
|
302
|
-
expect(
|
|
303
|
-
expect(result).not_to start_with(" static int count;")
|
|
345
|
+
expect(result).to eq("void foo(void) {\n return;\n}")
|
|
346
|
+
expect(newlines).to eq(0)
|
|
304
347
|
end
|
|
305
348
|
|
|
306
|
-
it "
|
|
307
|
-
|
|
308
|
-
result = @utils.
|
|
349
|
+
it "strips several decorators on the signature's own line and counts no newlines" do
|
|
350
|
+
code_block = "static inline void foo(void) { return; }"
|
|
351
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static', 'inline'], 'foo')
|
|
309
352
|
|
|
310
|
-
expect(result.
|
|
311
|
-
|
|
312
|
-
expect(result).to include("static int x")
|
|
353
|
+
expect(result).to eq("void foo(void) { return; }")
|
|
354
|
+
expect(newlines).to eq(0)
|
|
313
355
|
end
|
|
314
356
|
|
|
315
|
-
it "
|
|
316
|
-
|
|
317
|
-
result = @utils.
|
|
357
|
+
it "handles empty decorators array — no stripping, 0 leading newlines" do
|
|
358
|
+
code_block = "void foo(void) { return; }"
|
|
359
|
+
result, newlines = @utils.send(:extract_code_block, code_block, [], 'foo')
|
|
318
360
|
|
|
319
|
-
expect(result).to
|
|
320
|
-
expect(
|
|
361
|
+
expect(result).to eq(code_block)
|
|
362
|
+
expect(newlines).to eq(0)
|
|
321
363
|
end
|
|
322
364
|
|
|
323
|
-
it "
|
|
324
|
-
|
|
325
|
-
result = @utils.
|
|
365
|
+
it "counts 1 leading newline when decorator occupies its own line" do
|
|
366
|
+
code_block = "static\nint foo(void) { return 0; }"
|
|
367
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static'], 'foo')
|
|
326
368
|
|
|
327
|
-
expect(result).to eq(
|
|
369
|
+
expect(result).to eq("int foo(void) { return 0; }")
|
|
370
|
+
expect(newlines).to eq(1)
|
|
328
371
|
end
|
|
329
372
|
|
|
330
|
-
it "
|
|
331
|
-
|
|
332
|
-
result = @utils.
|
|
373
|
+
it "counts 2 leading newlines when two decorators each occupy their own line" do
|
|
374
|
+
code_block = "static\ninline\nint foo(void) { return 0; }"
|
|
375
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static', 'inline'], 'foo')
|
|
333
376
|
|
|
334
|
-
expect(result).to
|
|
377
|
+
expect(result).to eq("int foo(void) { return 0; }")
|
|
378
|
+
expect(newlines).to eq(2)
|
|
335
379
|
end
|
|
336
|
-
end
|
|
337
380
|
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
result = @utils.replace_compound_declaration_with_noops(text, "static int count", "PH_COUNT", 1)
|
|
381
|
+
it "preserves body indentation and internal newlines" do
|
|
382
|
+
code_block = "static void indented(void) {\n int x = 1;\n return x;\n}"
|
|
383
|
+
result, _ = @utils.send(:extract_code_block, code_block, ['static'], 'indented')
|
|
342
384
|
|
|
343
|
-
expect(result
|
|
344
|
-
expect(result).to
|
|
385
|
+
expect(result).to include(" int x = 1;")
|
|
386
|
+
expect(result.count("\n")).to eq(3)
|
|
345
387
|
end
|
|
346
388
|
|
|
347
|
-
it "
|
|
348
|
-
|
|
349
|
-
result = @utils.
|
|
389
|
+
it "handles multi-line parameter list without relying on signature substring match" do
|
|
390
|
+
code_block = "static int multiline(\n int a,\n int b) {\n return a + b;\n}"
|
|
391
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static'], 'multiline')
|
|
350
392
|
|
|
351
|
-
expect(result.
|
|
352
|
-
expect(result).
|
|
353
|
-
|
|
354
|
-
expect(result.scan("/*").length).to eq(1)
|
|
393
|
+
expect(result).to eq("int multiline(\n int a,\n int b) {\n return a + b;\n}")
|
|
394
|
+
expect(result).not_to include("static")
|
|
395
|
+
expect(newlines).to eq(0)
|
|
355
396
|
end
|
|
356
397
|
|
|
357
|
-
it "
|
|
358
|
-
|
|
359
|
-
result = @utils.
|
|
398
|
+
it "is a no-op when decorator is not present in code_block" do
|
|
399
|
+
code_block = "void foo(void) { }"
|
|
400
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['extern'], 'foo')
|
|
360
401
|
|
|
361
|
-
expect(result
|
|
362
|
-
expect(
|
|
363
|
-
expect(result.scan("/*").length).to eq(1)
|
|
402
|
+
expect(result).to eq(code_block)
|
|
403
|
+
expect(newlines).to eq(0)
|
|
364
404
|
end
|
|
365
405
|
|
|
366
|
-
it "
|
|
367
|
-
|
|
368
|
-
|
|
406
|
+
it "leaves a decorator word in the body alone" do
|
|
407
|
+
# 'static' in the body (e.g., a local static var) must not be touched
|
|
408
|
+
code_block = "static int foo(void) {\n static int x = 0;\n return x;\n}"
|
|
409
|
+
result, _ = @utils.send(:extract_code_block, code_block, ['static'], 'foo')
|
|
369
410
|
|
|
370
|
-
expect(result.
|
|
371
|
-
expect(result).to include("static int
|
|
411
|
+
expect(result).to start_with("int foo(void)")
|
|
412
|
+
expect(result).to include("static int x = 0;")
|
|
372
413
|
end
|
|
373
414
|
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
415
|
+
# Only the text before the name is searched, so a body's own static stays when a macro
|
|
416
|
+
# hides the signature's
|
|
417
|
+
it "leaves a body's decorator word alone when the signature spells its decorator as a macro" do
|
|
418
|
+
code_block = "PRIVATE int hidden(void) { static int n; return n; }"
|
|
419
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static'], 'hidden')
|
|
377
420
|
|
|
378
|
-
expect(result).to eq(
|
|
421
|
+
expect(result).to eq(code_block)
|
|
422
|
+
expect(newlines).to eq(0)
|
|
379
423
|
end
|
|
380
424
|
|
|
381
|
-
it "
|
|
382
|
-
|
|
383
|
-
result = @utils.
|
|
425
|
+
it "strips multiple decorators and counts newlines for inline+multiline mix" do
|
|
426
|
+
code_block = "extern\nstatic int bar(int x) { return x; }"
|
|
427
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['extern', 'static'], 'bar')
|
|
384
428
|
|
|
385
|
-
expect(result).to
|
|
386
|
-
expect(
|
|
429
|
+
expect(result).to eq("int bar(int x) { return x; }")
|
|
430
|
+
expect(newlines).to eq(1)
|
|
387
431
|
end
|
|
388
|
-
end
|
|
389
432
|
|
|
390
|
-
|
|
391
|
-
it "
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
end
|
|
433
|
+
# Only storage-class and inline keywords are stripped. A qualifier belongs to the return type.
|
|
434
|
+
it "keeps a const return type when stripping static" do
|
|
435
|
+
code_block = "static const char *name(void) { return \"n\"; }"
|
|
436
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static'], 'name')
|
|
395
437
|
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
expect(result).to eq("partial_foo_count = partial_foo_count + 1;")
|
|
438
|
+
expect(result).to eq("const char *name(void) { return \"n\"; }")
|
|
439
|
+
expect(newlines).to eq(0)
|
|
399
440
|
end
|
|
400
441
|
|
|
401
|
-
it "
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
end
|
|
442
|
+
it "strips a storage class written after a qualifier" do
|
|
443
|
+
code_block = "const static int *table(void) { return 0; }"
|
|
444
|
+
result, _ = @utils.send(:extract_code_block, code_block, ['static'], 'table')
|
|
405
445
|
|
|
406
|
-
|
|
407
|
-
result = @utils.rename_c_identifier("count_down = 0;", "count", "partial_foo_count")
|
|
408
|
-
expect(result).to eq("count_down = 0;")
|
|
446
|
+
expect(result).to eq("const int *table(void) { return 0; }")
|
|
409
447
|
end
|
|
410
448
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
449
|
+
# A decorator word inside the name or body is not a decorator
|
|
450
|
+
it "leaves a decorator word that appears inside the function name" do
|
|
451
|
+
code_block = "PRIVATE int is_static(void) { return 1; }"
|
|
452
|
+
result, _ = @utils.send(:extract_code_block, code_block, ['static'], 'is_static')
|
|
415
453
|
|
|
416
|
-
|
|
417
|
-
result = @utils.rename_c_identifier("foo(count)", "count", "partial_foo_count")
|
|
418
|
-
expect(result).to eq("foo(partial_foo_count)")
|
|
454
|
+
expect(result).to eq(code_block)
|
|
419
455
|
end
|
|
420
456
|
|
|
421
|
-
it "
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
end
|
|
457
|
+
it "strips the decorator itself when an attribute string ahead of it holds the same word" do
|
|
458
|
+
code_block = '__attribute__((section(".text.static"))) static int g(void) { return 0; }'
|
|
459
|
+
result, _ = @utils.send(:extract_code_block, code_block, ['static'], 'g')
|
|
425
460
|
|
|
426
|
-
|
|
427
|
-
result = @utils.rename_c_identifier("count[0]", "count", "partial_foo_count")
|
|
428
|
-
expect(result).to eq("partial_foo_count[0]")
|
|
461
|
+
expect(result).to eq('__attribute__((section(".text.static"))) int g(void) { return 0; }')
|
|
429
462
|
end
|
|
430
463
|
|
|
431
|
-
it "
|
|
432
|
-
|
|
433
|
-
|
|
464
|
+
it "leaves the text alone when a decorator from the expanded copy is absent" do
|
|
465
|
+
code_block = "PRIVATE int hidden(void) { return 0; }"
|
|
466
|
+
result, newlines = @utils.send(:extract_code_block, code_block, ['static'], 'hidden')
|
|
467
|
+
|
|
468
|
+
expect(result).to eq(code_block)
|
|
469
|
+
expect(newlines).to eq(0)
|
|
434
470
|
end
|
|
471
|
+
end
|
|
435
472
|
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
expect(
|
|
473
|
+
context "#adjust_line_num" do
|
|
474
|
+
it "returns nil when line_num is nil" do
|
|
475
|
+
expect(@utils.send(:adjust_line_num, nil, 3)).to be_nil
|
|
439
476
|
end
|
|
440
477
|
|
|
441
|
-
it "
|
|
442
|
-
|
|
443
|
-
expect(result).to eq("&partial_foo_count")
|
|
478
|
+
it "returns line_num unchanged when stripped_newlines is 0" do
|
|
479
|
+
expect(@utils.send(:adjust_line_num, 10, 0)).to eq(10)
|
|
444
480
|
end
|
|
445
481
|
|
|
446
|
-
it "
|
|
447
|
-
|
|
448
|
-
expect(result).to eq("")
|
|
482
|
+
it "adds stripped_newlines to line_num" do
|
|
483
|
+
expect(@utils.send(:adjust_line_num, 5, 2)).to eq(7)
|
|
449
484
|
end
|
|
450
485
|
|
|
451
|
-
it "
|
|
452
|
-
|
|
453
|
-
result = @utils.rename_c_identifier(text, "count", "partial_foo_count")
|
|
454
|
-
expect(result).to eq(text)
|
|
486
|
+
it "handles a single stripped newline" do
|
|
487
|
+
expect(@utils.send(:adjust_line_num, 1, 1)).to eq(2)
|
|
455
488
|
end
|
|
456
489
|
end
|
|
457
490
|
|
|
@@ -479,88 +512,92 @@ describe PartializerUtils do
|
|
|
479
512
|
end
|
|
480
513
|
end
|
|
481
514
|
|
|
482
|
-
context "#
|
|
483
|
-
it "returns
|
|
484
|
-
expect(@code_finder).to receive(:
|
|
485
|
-
.with('/path/to/file.c', 'void foo(void) {}')
|
|
486
|
-
.and_return(42)
|
|
515
|
+
context "#locate_functions_in_source" do
|
|
516
|
+
it "returns each function's line from one search of the source" do
|
|
517
|
+
expect(@code_finder).to receive(:find_all_in_c_file)
|
|
518
|
+
.with('/path/to/file.c', ['void foo(void) {}', 'void missing(void) {}']).once
|
|
519
|
+
.and_return([42, nil])
|
|
520
|
+
|
|
521
|
+
result = @utils.locate_functions_in_source(code_blocks: ['void foo(void) {}', 'void missing(void) {}'], filepath: '/path/to/file.c')
|
|
522
|
+
expect(result).to eq([42, nil])
|
|
523
|
+
end
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
context "#locate_declarations_in_text" do
|
|
527
|
+
it "returns the line where each declaration appears in the text, in order" do
|
|
528
|
+
text = "int a;\nint tick(void);\nint tock(void);\n"
|
|
529
|
+
expect(@code_finder).to receive(:find_in_c_string).with(text, 'int tock(void);').and_return(3)
|
|
530
|
+
expect(@code_finder).to receive(:find_in_c_string).with(text, 'int tick(void);').and_return(2)
|
|
531
|
+
|
|
532
|
+
expect(@utils.locate_declarations_in_text(signatures: ['int tock(void);', 'int tick(void);'], text: text)).to eq([3, 2])
|
|
533
|
+
end
|
|
534
|
+
|
|
535
|
+
it "returns nil for a declaration not in the text" do
|
|
536
|
+
allow(@code_finder).to receive(:find_in_c_string).and_return(nil)
|
|
537
|
+
|
|
538
|
+
expect(@utils.locate_declarations_in_text(signatures: ['int tick(void);'], text: '')).to eq([nil])
|
|
539
|
+
end
|
|
540
|
+
|
|
541
|
+
# Blanking costs a pass over the whole file, so one blanked copy serves every declaration
|
|
542
|
+
it "searches every declaration in one blanked copy of the text" do
|
|
543
|
+
searched = []
|
|
544
|
+
allow(@code_finder).to receive(:find_in_c_string) { |text, _signature| searched << text; nil }
|
|
545
|
+
|
|
546
|
+
@utils.locate_declarations_in_text(signatures: ['int tick(void);', 'int tock(void);'], text: "/* c */\nint tick(void);\n")
|
|
487
547
|
|
|
488
|
-
|
|
489
|
-
expect(
|
|
548
|
+
expect(searched.size).to eq(2)
|
|
549
|
+
expect(searched.map(&:object_id).uniq.size).to eq(1)
|
|
490
550
|
end
|
|
491
551
|
|
|
492
|
-
|
|
493
|
-
|
|
552
|
+
# A commented-out copy of the declaration would otherwise be found first
|
|
553
|
+
it "searches the text with its comments blanked and its lines kept" do
|
|
554
|
+
line_comment = '// int tick(void);'
|
|
555
|
+
block_comment = '/* int tick(void); */'
|
|
556
|
+
expect(@code_finder).to receive(:find_in_c_string)
|
|
557
|
+
.with("#{' ' * line_comment.length}\n#{' ' * block_comment.length}\nint tick(void);\n", 'int tick(void);')
|
|
558
|
+
.and_return(3)
|
|
494
559
|
|
|
495
|
-
|
|
496
|
-
expect(result).to be_nil
|
|
560
|
+
@utils.locate_declarations_in_text(signatures: ['int tick(void);'], text: "#{line_comment}\n#{block_comment}\nint tick(void);\n")
|
|
497
561
|
end
|
|
498
562
|
|
|
499
|
-
it "
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
.and_return(nil)
|
|
563
|
+
it "keeps a comment marker inside a string literal" do
|
|
564
|
+
text = "int open(const char *url) __attribute__((deprecated(\"see http://x\")));\n"
|
|
565
|
+
expect(@code_finder).to receive(:find_in_c_string).with(text, 'int open(void);').and_return(nil)
|
|
503
566
|
|
|
504
|
-
@utils.
|
|
567
|
+
@utils.locate_declarations_in_text(signatures: ['int open(void);'], text: text)
|
|
505
568
|
end
|
|
506
569
|
end
|
|
507
570
|
|
|
508
|
-
context "#
|
|
571
|
+
context "#locate_functions_via_preprocessed" do
|
|
509
572
|
let(:filepath) { '/path/to/source.c' }
|
|
510
573
|
let(:preprocessed_filepath) { '/build/preproc/source.i' }
|
|
511
|
-
let(:
|
|
512
|
-
|
|
513
|
-
it "returns line number from preprocessed file when found there" do
|
|
514
|
-
expect(@code_finder).to receive(:find_in_preprocessed_file)
|
|
515
|
-
.with(preprocessed_filepath, code_block)
|
|
516
|
-
.and_return(10)
|
|
517
|
-
expect(@code_finder).not_to receive(:find_in_c_file)
|
|
518
|
-
|
|
519
|
-
result = @utils.locate_function_via_preprocessed(
|
|
520
|
-
code_block: code_block,
|
|
521
|
-
filepath: filepath,
|
|
522
|
-
preprocessed_filepath: preprocessed_filepath
|
|
523
|
-
)
|
|
524
|
-
expect(result).to eq(10)
|
|
525
|
-
end
|
|
574
|
+
let(:blocks) { ['void foo(void) {}', 'void bar(void) {}', 'void baz(void) {}'] }
|
|
526
575
|
|
|
527
|
-
it "
|
|
528
|
-
|
|
529
|
-
expect(@code_finder).
|
|
576
|
+
it "returns each function's line from the preprocessed file when found there" do
|
|
577
|
+
expect(@code_finder).to receive(:find_all_in_preprocessed_file).with(preprocessed_filepath, blocks).once.and_return([10, 20, 30])
|
|
578
|
+
expect(@code_finder).not_to receive(:find_all_in_c_file)
|
|
530
579
|
|
|
531
|
-
result = @utils.
|
|
532
|
-
|
|
533
|
-
filepath: filepath,
|
|
534
|
-
preprocessed_filepath: preprocessed_filepath
|
|
535
|
-
)
|
|
536
|
-
expect(result).to eq(25)
|
|
580
|
+
result = @utils.locate_functions_via_preprocessed(code_blocks: blocks, filepath: filepath, preprocessed_filepath: preprocessed_filepath)
|
|
581
|
+
expect(result).to eq([10, 20, 30])
|
|
537
582
|
end
|
|
538
583
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
allow(@code_finder).to receive(:
|
|
584
|
+
# The source is searched once, and only for what the preprocessed file lacks
|
|
585
|
+
it "falls back to the C source for just the functions the preprocessed file lacks" do
|
|
586
|
+
allow(@code_finder).to receive(:find_all_in_preprocessed_file).and_return([nil, 20, nil])
|
|
587
|
+
expect(@code_finder).to receive(:find_all_in_c_file).with(filepath, [blocks[0], blocks[2]]).once.and_return([25, nil])
|
|
542
588
|
|
|
543
|
-
result = @utils.
|
|
544
|
-
|
|
545
|
-
filepath: filepath,
|
|
546
|
-
preprocessed_filepath: preprocessed_filepath
|
|
547
|
-
)
|
|
548
|
-
expect(result).to be_nil
|
|
589
|
+
result = @utils.locate_functions_via_preprocessed(code_blocks: blocks, filepath: filepath, preprocessed_filepath: preprocessed_filepath)
|
|
590
|
+
expect(result).to eq([25, 20, nil])
|
|
549
591
|
end
|
|
550
592
|
|
|
551
|
-
it "
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
.and_return(nil)
|
|
555
|
-
expect(@code_finder).to receive(:find_in_c_file)
|
|
556
|
-
.with('/exact/source.c', 'exact block')
|
|
557
|
-
.and_return(nil)
|
|
593
|
+
it "logs the fallback search once for each function that needs it" do
|
|
594
|
+
allow(@code_finder).to receive(:find_all_in_preprocessed_file).and_return([10, nil, nil])
|
|
595
|
+
allow(@code_finder).to receive(:find_all_in_c_file).and_return([25, nil])
|
|
558
596
|
|
|
559
|
-
@
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
)
|
|
597
|
+
expect(@loginator).to receive(:log)
|
|
598
|
+
.with("Using fallback C function location search for #{filepath}", Verbosity::OBNOXIOUS, LogLabels::WARNING).twice
|
|
599
|
+
|
|
600
|
+
@utils.locate_functions_via_preprocessed(code_blocks: blocks, filepath: filepath, preprocessed_filepath: preprocessed_filepath)
|
|
564
601
|
end
|
|
565
602
|
end
|
|
566
603
|
|