ceedling 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/GIT_COMMIT_SHA +1 -1
- data/README.md +11 -9
- data/Rakefile +2 -1
- data/assets/features/ceedling +1 -1
- data/assets/fixtures/test_source_file_duplicate_basenames/test_calc_typo.c +14 -0
- data/assets/fixtures/tests_with_duplicate_test_names/test_foo.c +21 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
- data/bin/actionator.rb +6 -12
- data/bin/app_cfg.rb +14 -1
- data/bin/ceedling +13 -3
- data/bin/cli.rb +25 -6
- data/bin/cli_handler.rb +113 -73
- data/bin/cli_helper.rb +51 -78
- data/bin/installation_selector.rb +81 -0
- data/bin/launchinator.rb +69 -0
- data/bin/mixin_resolvinator.rb +26 -36
- data/bin/objects.yml +13 -0
- data/bin/path_validator.rb +25 -29
- data/bin/versionator.rb +47 -48
- data/ceedling.gemspec +19 -15
- data/docs/BreakingChanges.md +86 -1
- data/docs/Changelog.md +145 -3
- data/docs/KnownIssues.md +179 -6
- data/docs/ReleaseNotes.md +13 -0
- data/examples/wondrous_forest/README.md +29 -1
- data/examples/wondrous_forest/src/ForestUnits.h +23 -0
- data/examples/wondrous_forest/src/RainGauge.c +59 -0
- data/examples/wondrous_forest/src/RainGauge.h +39 -0
- data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
- data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
- data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
- data/lib/ceedling/build_log_writer.rb +33 -0
- data/lib/ceedling/c_extractor/README.md +15 -7
- data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
- data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
- data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
- data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
- data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
- data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
- data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
- data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
- data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
- data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
- data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
- data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
- data/lib/ceedling/c_identifier.rb +21 -0
- data/lib/ceedling/ceedling.h +8 -0
- data/lib/ceedling/config/build_root_policy.rb +70 -0
- data/lib/ceedling/config/configurator.rb +18 -19
- data/lib/ceedling/config/configurator_builder.rb +75 -28
- data/lib/ceedling/config/configurator_paths_validator.rb +179 -0
- data/lib/ceedling/config/configurator_plugins.rb +1 -1
- data/lib/ceedling/config/configurator_setup.rb +44 -33
- data/lib/ceedling/config/configurator_validator.rb +1 -110
- data/lib/ceedling/constants.rb +5 -1
- data/lib/ceedling/defaults.rb +35 -5
- data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
- data/lib/ceedling/dependencies/README.md +18 -16
- data/lib/ceedling/dependencies/dependency_cache_store.rb +43 -21
- data/lib/ceedling/dependencies/dependency_hasher.rb +35 -1
- data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
- data/lib/ceedling/dependencies/dependinator.rb +13 -1
- data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
- data/lib/ceedling/diagnostics/README.md +5 -0
- data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
- data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
- data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
- data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
- data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
- data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
- data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
- data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
- data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
- data/lib/ceedling/filename_extension.rb +7 -1
- data/lib/ceedling/filesystem/FILE_TREE.md +253 -0
- data/lib/ceedling/filesystem/PATH_HANDLING.md +360 -0
- data/lib/ceedling/filesystem/README.md +46 -0
- data/lib/ceedling/filesystem/build_roots.rb +105 -0
- data/lib/ceedling/filesystem/build_subpath.rb +187 -0
- data/lib/ceedling/filesystem/destination_collision.rb +25 -0
- data/lib/ceedling/{file_finder.rb → filesystem/file_finder.rb} +177 -156
- data/lib/ceedling/filesystem/file_finder_helper.rb +154 -0
- data/lib/ceedling/filesystem/file_path_collection_utils.rb +183 -0
- data/lib/ceedling/{file_path_utils.rb → filesystem/file_path_utils.rb} +200 -167
- data/lib/ceedling/{file_system_wrapper.rb → filesystem/file_system_wrapper.rb} +6 -5
- data/lib/ceedling/filesystem/file_tree.rb +241 -0
- data/lib/ceedling/{file_wrapper.rb → filesystem/file_wrapper.rb} +149 -65
- data/lib/ceedling/filesystem/path_exclusions.rb +30 -0
- data/lib/ceedling/{path_matcher.rb → filesystem/path_matcher.rb} +48 -23
- data/lib/ceedling/{path_mirror.rb → filesystem/path_mirror.rb} +19 -18
- data/lib/ceedling/filesystem/path_spellings.rb +55 -0
- data/lib/ceedling/filesystem/project_paths.rb +184 -0
- data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
- data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
- data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
- data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
- data/lib/ceedling/filesystem/working_dir.rb +40 -0
- data/lib/ceedling/generators/generator.rb +32 -70
- data/lib/ceedling/generators/generator_helper.rb +0 -44
- data/lib/ceedling/generators/generator_mocks.rb +5 -0
- data/lib/ceedling/generators/generator_partials.rb +306 -244
- data/lib/ceedling/generators/generator_test_results_backtrace.rb +7 -7
- data/lib/ceedling/generators/generator_test_runner.rb +5 -8
- data/lib/ceedling/generators/partial_header_writer.rb +95 -0
- data/lib/ceedling/generators/partial_source_writer.rb +137 -0
- data/lib/ceedling/handoff.rb +121 -0
- data/lib/ceedling/includes/header_search.rb +225 -0
- data/lib/ceedling/includes/include_factory.rb +9 -12
- data/lib/ceedling/includes/include_pathinator.rb +112 -33
- data/lib/ceedling/includes/includes.rb +150 -38
- data/lib/ceedling/installation.rb +92 -0
- data/lib/ceedling/library_resolver.rb +99 -0
- data/lib/ceedling/objects.yml +112 -6
- data/lib/ceedling/partials/README.md +110 -16
- data/lib/ceedling/partials/carry_plan.rb +71 -0
- data/lib/ceedling/partials/definition_head.rb +74 -0
- data/lib/ceedling/partials/include_groups.rb +37 -0
- data/lib/ceedling/partials/interface_extras.rb +25 -0
- data/lib/ceedling/partials/partializer.rb +603 -124
- data/lib/ceedling/partials/partializer_config.rb +8 -1
- data/lib/ceedling/partials/partializer_helper.rb +851 -145
- data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
- data/lib/ceedling/partials/partializer_utils.rb +89 -109
- data/lib/ceedling/partials/partials.rb +153 -10
- data/lib/ceedling/partials/type_macros.rb +126 -0
- data/lib/ceedling/plugins/report_log_writer_plugin.rb +3 -5
- data/lib/ceedling/preprocess/README.md +43 -33
- data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
- data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
- data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +32 -76
- data/lib/ceedling/preprocess/preprocessinator_includes_handler.rb +1 -1
- data/lib/ceedling/preprocess/preprocessinator_line_marker_includes_extractor.rb +1 -1
- data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
- data/lib/ceedling/rake_app/rakefile_component_resolver.rb +10 -17
- data/lib/ceedling/rakefile.rb +15 -1
- data/lib/ceedling/rakefiles/base/tasks_base.rake +1 -1
- data/lib/ceedling/rakefiles/release/rules_release.rake +4 -7
- data/lib/ceedling/release_invoker/release_build_executor.rb +33 -44
- data/lib/ceedling/release_invoker/release_build_planner.rb +14 -6
- data/lib/ceedling/reportinator.rb +3 -4
- data/lib/ceedling/setupinator.rb +104 -87
- data/lib/ceedling/test_context_extractor.rb +5 -1
- data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
- data/lib/ceedling/test_invoker/PIPELINE.md +62 -19
- data/lib/ceedling/test_invoker/README.md +1 -1
- data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
- data/lib/ceedling/test_invoker/mock_locator.rb +175 -10
- data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
- data/lib/ceedling/test_invoker/partials_manager.rb +271 -302
- data/lib/ceedling/test_invoker/standin_headerinator.rb +19 -17
- data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
- data/lib/ceedling/test_invoker/test_build_executor.rb +358 -234
- data/lib/ceedling/test_invoker/test_build_planner.rb +46 -33
- data/lib/ceedling/test_invoker/test_build_setup.rb +43 -18
- data/lib/ceedling/test_invoker/test_build_validations.rb +35 -47
- data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
- data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +2 -3
- data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
- data/lib/ceedling/test_invoker/test_invoker.rb +6 -1
- data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
- data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +6 -4
- data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
- data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
- data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
- data/lib/ceedling/test_invoker/test_source_file_directive_resolver.rb +40 -20
- data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
- data/lib/ceedling/tools/shell_quoting.rb +45 -0
- data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +9 -3
- data/lib/ceedling/tools/tool_quoting.rb +79 -0
- data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
- data/lib/ceedling/yaml_wrapper.rb +3 -2
- data/lib/version.rb +1 -1
- data/plugins/bullseye/bullseye.rake +1 -3
- data/plugins/bullseye/config/defaults_bullseye.rb +1 -1
- data/plugins/bullseye/lib/bullseye.rb +24 -9
- data/plugins/command_hooks/lib/command_hooks.rb +1 -1
- data/plugins/cppcheck/config/defaults_cppcheck.rb +1 -1
- data/plugins/dependencies/config/defaults.yml +6 -6
- data/plugins/dependencies/dependencies.rake +4 -1
- data/plugins/dependencies/lib/dependencies.rb +18 -8
- data/plugins/dependencies/lib/dependency_spec.rb +17 -5
- data/plugins/fff/lib/fff.rb +79 -46
- data/plugins/fff/lib/fff_mock_generator.rb +12 -9
- data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +262 -0
- data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
- data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
- data/plugins/gcov/config/defaults_gcov.rb +1 -1
- data/plugins/gcov/lib/console_reportinator.rb +28 -36
- data/plugins/gcov/lib/gcov.rb +9 -2
- data/plugins/gcov/lib/gcovr_reportinator.rb +8 -40
- data/plugins/gcov/lib/gcovr_thresholds.rb +74 -0
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +3 -2
- data/plugins/module_generator/lib/module_generator.rb +3 -3
- data/plugins/report_tests_teamcity_stdout/lib/report_tests_teamcity_stdout.rb +53 -80
- data/plugins/sanitize/lib/sanitize_records.rb +3 -6
- data/plugins/valgrind/lib/valgrind.rb +14 -7
- data/site-local/404.html +2 -2
- data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
- data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
- data/site-local/configuration/environment-vars.html +2 -2
- data/site-local/configuration/global-collections.html +3 -3
- data/site-local/configuration/index.html +2 -2
- data/site-local/configuration/loading.html +2 -2
- data/site-local/configuration/mixins.html +2 -2
- data/site-local/configuration/parallel-builds.html +2 -2
- data/site-local/configuration/project-file.html +2 -2
- data/site-local/configuration/reference/cexception.html +2 -2
- data/site-local/configuration/reference/cmock.html +7 -3
- data/site-local/configuration/reference/defines.html +2 -2
- data/site-local/configuration/reference/environment.html +2 -2
- data/site-local/configuration/reference/extension.html +2 -2
- data/site-local/configuration/reference/files.html +65 -12
- data/site-local/configuration/reference/flags.html +2 -2
- data/site-local/configuration/reference/index.html +2 -2
- data/site-local/configuration/reference/libraries.html +23 -5
- data/site-local/configuration/reference/mixins.html +2 -2
- data/site-local/configuration/reference/partials.html +84 -2
- data/site-local/configuration/reference/paths.html +36 -8
- data/site-local/configuration/reference/plugins.html +2 -2
- data/site-local/configuration/reference/project.html +264 -12
- data/site-local/configuration/reference/release-build.html +4 -2
- data/site-local/configuration/reference/test-build.html +2 -2
- data/site-local/configuration/reference/test-runner.html +2 -2
- data/site-local/configuration/reference/tools.html +58 -4
- data/site-local/configuration/reference/unity.html +2 -2
- data/site-local/configuration/which-ceedling.html +379 -19
- data/site-local/development/index.html +2 -2
- data/site-local/development/plugins/configuration.html +2 -2
- data/site-local/development/plugins/index.html +2 -2
- data/site-local/development/plugins/plugin-subclass.html +5 -4
- data/site-local/development/plugins/rake-tasks.html +2 -2
- data/site-local/development/releases.html +7 -3
- data/site-local/development/workflow.html +50 -45
- data/site-local/getting-started/builds.html +4 -2
- data/site-local/getting-started/command-line.html +58 -6
- data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
- data/site-local/getting-started/example-projects/index.html +2 -2
- data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
- data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
- data/site-local/getting-started/index.html +2 -2
- data/site-local/getting-started/installation.html +2 -2
- data/site-local/getting-started/quick-start.html +2 -2
- data/site-local/help.html +2 -2
- data/site-local/index.html +2 -2
- data/site-local/overview/build-system.html +2 -2
- data/site-local/overview/index.html +2 -2
- data/site-local/overview/test-environments.html +2 -2
- data/site-local/overview/tools-and-frameworks.html +2 -2
- data/site-local/plugins/beep.html +2 -2
- data/site-local/plugins/bullseye/index.html +45 -38
- data/site-local/plugins/bullseye/licensing.html +2 -2
- data/site-local/plugins/command-hooks.html +4 -4
- data/site-local/plugins/compile-commands-json-db.html +2 -2
- data/site-local/plugins/cppcheck.html +2 -2
- data/site-local/plugins/dependencies.html +8 -5
- data/site-local/plugins/fff.html +58 -13
- data/site-local/plugins/gcov/examples.html +2 -2
- data/site-local/plugins/gcov/gcovr.html +23 -14
- data/site-local/plugins/gcov/index.html +2 -2
- data/site-local/plugins/gcov/overview.html +2 -2
- data/site-local/plugins/gcov/reportgenerator.html +18 -14
- data/site-local/plugins/gcov/reporting.html +2 -2
- data/site-local/plugins/gcov/setup.html +4 -3
- data/site-local/plugins/gcov/tool-versions.html +2 -2
- data/site-local/plugins/gcov/troubleshooting.html +2 -2
- data/site-local/plugins/index.html +2 -2
- data/site-local/plugins/module-generator.html +2 -2
- data/site-local/plugins/report-build-warnings-log.html +2 -2
- data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
- data/site-local/plugins/report-tests-ide-stdout.html +2 -2
- data/site-local/plugins/report-tests-log-factory.html +2 -2
- data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
- data/site-local/plugins/report-tests-raw-output-log.html +5 -3
- data/site-local/plugins/report-tests-teamcity-stdout.html +8 -5
- data/site-local/plugins/sanitize.html +9 -8
- data/site-local/plugins/valgrind.html +10 -9
- data/site-local/project/index.html +2 -2
- data/site-local/project/release-history.html +2 -2
- data/site-local/project/sbom.html +2 -2
- data/site-local/project/upgrade.html +5 -2
- data/site-local/reference/build-directives.html +2 -2
- data/site-local/reference/command-line.html +11 -4
- data/site-local/reference/environment-vars.html +2 -2
- data/site-local/reference/gcov-plugin.html +2 -2
- data/site-local/reference/global-collections.html +12 -12
- data/site-local/reference/index.html +2 -2
- data/site-local/reference/partials-macros.html +47 -2
- data/site-local/reference/project-configuration.html +2 -2
- data/site-local/sitemap.xml.gz +0 -0
- data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
- data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
- data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
- data/site-local/snapshot/plugins/bullseye/config/defaults_bullseye.rb +1 -1
- data/site-local/snapshot/plugins/gcov/config/defaults_gcov.rb +1 -1
- data/site-local/testing-guide/build-directives.html +2 -2
- data/site-local/testing-guide/conventions.html +113 -15
- data/site-local/testing-guide/frameworks.html +2 -2
- data/site-local/testing-guide/index.html +2 -2
- data/site-local/testing-guide/partials/configuration.html +31 -4
- data/site-local/testing-guide/partials/conventions.html +509 -8
- data/site-local/testing-guide/partials/directives.html +4 -3
- data/site-local/testing-guide/partials/example.html +2 -2
- data/site-local/testing-guide/partials/index.html +2 -2
- data/site-local/testing-guide/partials/overview.html +30 -12
- data/site-local/testing-guide/partials/variables.html +169 -4
- data/site-local/testing-guide/test-cases.html +2 -2
- data/site-local/testing-guide/test-sample.html +2 -2
- data/site-local/testing-guide/test-suite-anatomy.html +2 -2
- data/spec/integration/actionator_file_operations_spec.rb +91 -1
- data/spec/integration/build_step_doctor_spec.rb +270 -0
- data/spec/integration/c_extractor_composition_spec.rb +254 -4
- data/spec/integration/compile_commands_json_db_spec.rb +1 -1
- data/spec/integration/configurator_validation_spec.rb +1 -1
- data/spec/integration/dependencies/dependency_tracker_cache_hardening_spec.rb +26 -0
- data/spec/integration/dependencies/dependency_tracker_core_spec.rb +22 -0
- data/spec/integration/includes_extraction_spec.rb +27 -14
- data/spec/integration/launcher_handoff_spec.rb +297 -0
- data/spec/integration/mixin_loading_spec.rb +1 -1
- data/spec/integration/module_generator_spec.rb +3 -3
- data/spec/integration/nested_test_artifacts_spec.rb +99 -0
- data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
- data/spec/integration/partials_carry_spec.rb +520 -0
- data/spec/integration/partials_declarations_spec.rb +655 -0
- data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
- data/spec/integration/partials_function_pointers_spec.rb +277 -0
- data/spec/integration/partials_header_composition_spec.rb +268 -35
- data/spec/integration/partials_macro_decorators_spec.rb +267 -0
- data/spec/integration/partials_module_resolution_spec.rb +33 -23
- data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
- data/spec/integration/path_intake_scenarios_spec.rb +101 -0
- data/spec/integration/path_length_reporting_spec.rb +64 -0
- data/spec/integration/path_scenarios_spec.rb +399 -0
- data/spec/integration/quote_include_isolator_spec.rb +57 -1
- data/spec/integration/report_build_warnings_log_spec.rb +1 -1
- data/spec/integration/report_tests_log_factory_spec.rb +1 -1
- data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
- data/spec/integration/test_executable_manifest_spec.rb +1 -1
- data/spec/integration/test_includes_extractinator_spec.rb +69 -3
- data/spec/integration/test_naming_spec.rb +201 -0
- data/spec/integration/test_source_file_checks_spec.rb +168 -0
- data/spec/integration/tool_executor_spec.rb +1 -1
- data/spec/integration/tool_validator_spec.rb +3 -3
- data/spec/integration/upgrade_docs_spec.rb +84 -0
- data/spec/integration/vendor_copy_transient_io_retry_spec.rb +74 -5
- data/spec/integration/win_long_paths_probe_spec.rb +46 -0
- data/spec/integration/win_path_limit_spec.rb +53 -0
- data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
- data/spec/support/file_tree_helper.rb +88 -0
- data/spec/support/integration/configurator_integration_helper.rb +14 -9
- data/spec/support/integration/dependency_tracker_integration_helper.rb +1 -1
- data/spec/support/integration/partial_files_harness.rb +181 -0
- data/spec/support/integration/partials_generation_integration_helper.rb +239 -143
- data/spec/support/integration/path_scenario_harness.rb +175 -0
- data/spec/support/integration/spec_integration_helper.rb +9 -4
- data/spec/support/integration/test_includes_harness.rb +69 -37
- data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
- data/spec/support/spec_helper.rb +2 -0
- data/spec/support/system/spec_system_helper.rb +7 -6
- data/spec/support/system/system_context.rb +21 -3
- data/spec/support/working_dir_tracking.rb +49 -0
- data/spec/system/build_output_mirroring_spec.rb +2 -2
- data/spec/system/bullseye_deployment_spec.rb +2 -0
- data/spec/system/conditional_mock_includes_spec.rb +1 -1
- data/spec/system/delta_builds_spec.rb +163 -23
- data/spec/system/encoding_stress_spec.rb +4 -4
- data/spec/system/example_wondrous_forest_spec.rb +2 -2
- data/spec/system/gcov_deployment_spec.rb +3 -0
- data/spec/system/header_include_path_validation_spec.rb +4 -4
- data/spec/system/header_search_paths_spec.rb +1083 -0
- data/spec/system/launcher_handoff_spec.rb +82 -0
- data/spec/system/mock_include_folders_spec.rb +212 -0
- data/spec/system/mockable_header_reassembly_spec.rb +184 -0
- data/spec/system/parent_directory_reference_spec.rb +5 -3
- data/spec/system/partials_carry_spec.rb +581 -0
- data/spec/system/partials_delta_builds_spec.rb +280 -0
- data/spec/system/partials_function_pointers_spec.rb +106 -0
- data/spec/system/partials_macro_decorators_spec.rb +127 -0
- data/spec/system/partials_module_disambiguation_spec.rb +125 -0
- data/spec/system/path_handling_probes_spec.rb +196 -0
- data/spec/system/pinned_thread_count_spec.rb +4 -4
- data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
- data/spec/system/preprocessing_parameterized_tests_spec.rb +1 -1
- data/spec/system/rake_release_task_path_disambiguation_spec.rb +6 -6
- data/spec/system/rake_test_task_path_disambiguation_spec.rb +85 -0
- data/spec/system/short_build_paths_spec.rb +87 -0
- data/spec/system/sibling_header_collision_spec.rb +30 -6
- data/spec/system/special_path_characters_spec.rb +86 -0
- data/spec/system/support/bullseye_common_test_cases.rb +42 -0
- data/spec/system/support/common_test_cases.rb +23 -21
- data/spec/system/support/gcov_common_test_cases.rb +37 -9
- data/spec/system/support/gcov_partials_test_cases.rb +48 -0
- data/spec/system/support/sanitize_common_test_cases.rb +2 -2
- data/spec/system/support/valgrind_common_test_cases.rb +12 -12
- data/spec/system/test_build_layout_spec.rb +209 -0
- data/spec/system/test_pipeline_stop_points_spec.rb +4 -4
- data/spec/system/test_runner_system_include_spec.rb +1 -1
- data/spec/system/test_source_file_directive_spec.rb +64 -5
- data/spec/units/bin/actionator_spec.rb +14 -17
- data/spec/units/bin/app_cfg_spec.rb +37 -0
- data/spec/units/bin/cli_handler_spec.rb +282 -6
- data/spec/units/bin/cli_helper_spec.rb +116 -45
- data/spec/units/bin/installation_selector_spec.rb +114 -0
- data/spec/units/bin/launchinator_spec.rb +171 -0
- data/spec/units/bin/path_validator_spec.rb +10 -0
- data/spec/units/bin/versionator_spec.rb +38 -6
- data/spec/units/build_log_writer_spec.rb +57 -0
- data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
- data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
- data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
- data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
- data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
- data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
- data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
- data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
- data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
- data/spec/units/c_identifier_spec.rb +35 -0
- data/spec/units/config/build_root_policy_spec.rb +61 -0
- data/spec/units/config/configurator_builder_spec.rb +61 -6
- data/spec/units/config/configurator_paths_validator_spec.rb +292 -0
- data/spec/units/config/configurator_setup_spec.rb +80 -68
- data/spec/units/config/configurator_spec.rb +54 -6
- data/spec/units/config/configurator_validator_spec.rb +1 -172
- data/spec/units/dependencies/dependency_cache_store_spec.rb +98 -2
- data/spec/units/dependencies/dependency_debug_tree_spec.rb +1 -1
- data/spec/units/dependencies/dependency_hasher_spec.rb +42 -1
- data/spec/units/dependencies/dependency_path_normalizer_spec.rb +1 -1
- data/spec/units/dependencies/dependency_tracker_spec.rb +28 -1
- data/spec/units/dependencies/dependinator_spec.rb +17 -2
- data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
- data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
- data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
- data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
- data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
- data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
- data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
- data/spec/units/encodinator_spec.rb +3 -4
- data/spec/units/filename_extension_spec.rb +11 -0
- data/spec/units/filesystem/build_roots_spec.rb +131 -0
- data/spec/units/filesystem/build_subpath_spec.rb +235 -0
- data/spec/units/filesystem/destination_collision_spec.rb +30 -0
- data/spec/units/{file_finder_helper_spec.rb → filesystem/file_finder_helper_spec.rb} +126 -1
- data/spec/units/filesystem/file_finder_spec.rb +845 -0
- data/spec/units/{file_path_collection_utils_spec.rb → filesystem/file_path_collection_utils_spec.rb} +181 -1
- data/spec/units/{file_path_utils_spec.rb → filesystem/file_path_utils_spec.rb} +435 -185
- data/spec/units/filesystem/file_system_wrapper_spec.rb +33 -0
- data/spec/units/filesystem/file_tree_spec.rb +511 -0
- data/spec/units/filesystem/file_tree_windows_spec.rb +78 -0
- data/spec/units/{file_wrapper_spec.rb → filesystem/file_wrapper_spec.rb} +286 -18
- data/spec/units/{path_matcher_spec.rb → filesystem/path_matcher_spec.rb} +48 -1
- data/spec/units/{path_mirror_spec.rb → filesystem/path_mirror_spec.rb} +32 -4
- data/spec/units/filesystem/project_paths_spec.rb +147 -0
- data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
- data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
- data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
- data/spec/units/filesystem/working_dir_spec.rb +71 -0
- data/spec/units/generators/generator_helper_spec.rb +0 -60
- data/spec/units/generators/generator_mocks_spec.rb +13 -0
- data/spec/units/generators/generator_partials_spec.rb +656 -55
- data/spec/units/generators/generator_spec.rb +38 -6
- data/spec/units/generators/generator_test_results_backtrace_spec.rb +50 -46
- data/spec/units/generators/generator_test_results_spec.rb +1 -1
- data/spec/units/generators/generator_test_runner_spec.rb +9 -5
- data/spec/units/generators/partial_source_writer_spec.rb +129 -0
- data/spec/units/handoff_spec.rb +205 -0
- data/spec/units/includes/header_search_spec.rb +406 -0
- data/spec/units/includes/include_factory_spec.rb +23 -6
- data/spec/units/includes/include_pathinator_spec.rb +118 -8
- data/spec/units/includes/include_spec.rb +14 -0
- data/spec/units/includes/includes_spec.rb +176 -19
- data/spec/units/installation_spec.rb +228 -0
- data/spec/units/library_resolver_spec.rb +157 -0
- data/spec/units/loginator_spec.rb +31 -0
- data/spec/units/mock_locator_spec.rb +275 -6
- data/spec/units/partials/include_groups_spec.rb +42 -0
- data/spec/units/partials/partializer_config_spec.rb +32 -0
- data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
- data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
- data/spec/units/partials/partializer_helper_spec.rb +529 -277
- data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
- data/spec/units/partials/partializer_spec.rb +1579 -270
- data/spec/units/partials/partializer_utils_spec.rb +269 -232
- data/spec/units/partials/partials_rename_spec.rb +160 -0
- data/spec/units/partials_manager_spec.rb +561 -251
- data/spec/units/plugins/bullseye_spec.rb +49 -2
- data/spec/units/plugins/console_reportinator_spec.rb +73 -26
- data/spec/units/plugins/dependencies_spec.rb +33 -7
- data/spec/units/plugins/dependency_spec_spec.rb +17 -0
- data/spec/units/plugins/gcov_spec.rb +28 -3
- data/spec/units/plugins/gcovr_reportinator_spec.rb +19 -47
- data/spec/units/plugins/gcovr_thresholds_spec.rb +95 -0
- data/spec/units/plugins/module_generator_spec.rb +5 -5
- data/spec/units/plugins/report_build_warnings_log_spec.rb +3 -3
- data/spec/units/plugins/report_log_writer_plugin_spec.rb +10 -1
- data/spec/units/plugins/report_tests_raw_output_log_spec.rb +13 -2
- data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +77 -3
- data/spec/units/plugins/reportgenerator_reportinator_spec.rb +52 -4
- data/spec/units/plugins/sanitize_records_spec.rb +3 -1
- data/spec/units/plugins/sanitize_spec.rb +1 -1
- data/spec/units/plugins/valgrind_spec.rb +23 -8
- data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
- data/spec/units/preprocess/preprocessinator_comment_stripper_spec.rb +1 -1
- data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
- data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
- data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
- data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
- data/spec/units/rake_app/rakefile_component_resolver_spec.rb +21 -0
- data/spec/units/release_build_executor_spec.rb +53 -14
- data/spec/units/release_build_planner_spec.rb +15 -3
- data/spec/units/reportinator_spec.rb +5 -5
- data/spec/units/setupinator_spec.rb +51 -0
- data/spec/units/standin_headerinator_spec.rb +55 -9
- data/spec/units/test_build_executor_spec.rb +842 -166
- data/spec/units/test_build_planner_spec.rb +205 -15
- data/spec/units/test_build_setup_spec.rb +179 -30
- data/spec/units/test_context_extractor_spec.rb +36 -2
- data/spec/units/test_derived_search_paths_spec.rb +259 -0
- data/spec/units/test_file_preprocessinator_spec.rb +17 -1
- data/spec/units/test_includes_extractinator_spec.rb +61 -9
- data/spec/units/test_invoker/objects_wiring_spec.rb +24 -4
- data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
- data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
- data/spec/units/test_invoker_spec.rb +14 -1
- data/spec/units/test_invoker_types_spec.rb +8 -7
- data/spec/units/test_pipeline_manager_spec.rb +54 -13
- data/spec/units/test_runner_generatinator_spec.rb +93 -1
- data/spec/units/test_search_paths_spec.rb +73 -5
- data/spec/units/test_source_file_directive_resolver_spec.rb +38 -7
- data/spec/units/tools/default_tools_quoting_spec.rb +117 -0
- data/spec/units/tools/shell_quoting_spec.rb +76 -0
- data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
- data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +27 -1
- data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
- data/spec/units/windows_registry_query_tool_spec.rb +53 -0
- data/spec/units/yaml_wrapper_spec.rb +11 -0
- metadata +265 -36
- data/lib/ceedling/file_finder_helper.rb +0 -127
- data/lib/ceedling/file_path_collection_utils.rb +0 -164
- data/spec/units/file_finder_spec.rb +0 -495
- /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
|
@@ -316,11 +316,59 @@ describe CExtractorFunctions do
|
|
|
316
316
|
it "rejects pointer to array declaration" do
|
|
317
317
|
content = "int (*ptr)[10];"
|
|
318
318
|
signature, pos, rest = extract_signature.call(content, :declaration)
|
|
319
|
-
|
|
319
|
+
|
|
320
320
|
expect(signature).to be_nil
|
|
321
321
|
expect(pos).to eq(0)
|
|
322
322
|
expect(rest).to eq("int (*ptr)[10];")
|
|
323
323
|
end
|
|
324
|
+
|
|
325
|
+
# A label's ')' ends the declaration, but it closes no parameter list. A basic asm statement
|
|
326
|
+
# at file scope is a label alone.
|
|
327
|
+
it "rejects a variable declaration with an asm label, and a basic asm statement" do
|
|
328
|
+
['int g asm("g_sym");', 'int g __asm ("g_sym");', 'int g[2] __asm__("g_sym");', 'int (*fp)(int) asm("fp_sym");', 'asm(".globl top_sym");'].each do |content|
|
|
329
|
+
signature, pos, _rest = extract_signature.call(content, :declaration)
|
|
330
|
+
|
|
331
|
+
expect(signature).to be_nil, content
|
|
332
|
+
expect(pos).to eq(0)
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
|
|
336
|
+
it "accepts a function declaration with an asm label" do
|
|
337
|
+
signature, pos, rest = extract_signature.call('int f(void) asm("f_sym"); int g;', :declaration)
|
|
338
|
+
|
|
339
|
+
expect(signature).to eq('int f(void) asm("f_sym");')
|
|
340
|
+
expect(pos).to eq(25)
|
|
341
|
+
expect(rest).to eq(' int g;')
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
# Unexpanded macros may sit around the label. A function's text holds a parameter list, which
|
|
345
|
+
# is empty or opens with a word, an ellipsis or a C23 attribute. A macro's argument such as
|
|
346
|
+
# `(4)` and a specifier's argument are no parameter list.
|
|
347
|
+
it "accepts a function declaration with a macro ahead of its asm label" do
|
|
348
|
+
['int f(void) MY_API asm("f_sym");', 'int h(int) DEPRECATED __asm("h_sym");', 'int k(void) MY_API __asm__("k_sym");',
|
|
349
|
+
'int f(int a, char *b) API asm("f_sym");', 'int f(...) API asm("f_sym");', 'int f() API asm("f_sym");',
|
|
350
|
+
'int f(typeof(int) *p) API asm("f_sym");', 'int f([[maybe_unused]] int x) API asm("f_sym");',
|
|
351
|
+
'int f(void) MY_DEPRECATED("use g") API asm("f_sym");', 'int f(void) asm("f_sym") MY_TRAIL;'].each do |content|
|
|
352
|
+
signature, _pos, _rest = extract_signature.call(content, :declaration)
|
|
353
|
+
|
|
354
|
+
expect(signature).to eq(content)
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
# A line splice, or a directive fallback preprocessing leaves in place, may open the list
|
|
358
|
+
["int f(\\\n int x) __asm__(\"f_sym\");", "int f(\n#if WIDE\n long x\n#else\n int x\n#endif\n) asm(\"f_sym\");"].each do |content|
|
|
359
|
+
signature, _pos, _rest = extract_signature.call(content, :declaration)
|
|
360
|
+
|
|
361
|
+
expect(signature).to start_with('int f('), content
|
|
362
|
+
end
|
|
363
|
+
|
|
364
|
+
['typeof(int) g MY asm("g_sym");', '_Alignas(8) int g asm("g_sym");', 'int MY_ALIGN(4) g __asm__("g_sym");',
|
|
365
|
+
'int SECTION(".data") g __asm__("g_sym");', 'int __attribute((aligned(4))) g asm("g_sym");', 'int g asm("g"), *h asm("h");',
|
|
366
|
+
'int g MY_SECTION(".x") asm("g_sym");'].each do |content|
|
|
367
|
+
signature, _pos, _rest = extract_signature.call(content, :declaration)
|
|
368
|
+
|
|
369
|
+
expect(signature).to be_nil, content
|
|
370
|
+
end
|
|
371
|
+
end
|
|
324
372
|
end
|
|
325
373
|
|
|
326
374
|
context "function signatures with whitespace variations" do
|
|
@@ -1084,9 +1132,27 @@ describe CExtractorFunctions do
|
|
|
1084
1132
|
it "extracts name from function with array of function pointers" do
|
|
1085
1133
|
signature = "void dispatch(void (*handlers[])(int))"
|
|
1086
1134
|
name = parse_name.call(signature)
|
|
1087
|
-
|
|
1135
|
+
|
|
1088
1136
|
expect(name).to eq("dispatch")
|
|
1089
1137
|
end
|
|
1138
|
+
|
|
1139
|
+
# Qualifiers, calling conventions and attributes may sit among the stars ahead of the name
|
|
1140
|
+
it "extracts name from function returning a function pointer through decorated stars" do
|
|
1141
|
+
expect(parse_name.call("int (* const getConst(void))(int)")).to eq("getConst")
|
|
1142
|
+
expect(parse_name.call("int (__cdecl *getCdecl(void))(int)")).to eq("getCdecl")
|
|
1143
|
+
expect(parse_name.call("int (* __attribute__((unused)) getUnused(void))(int)")).to eq("getUnused")
|
|
1144
|
+
end
|
|
1145
|
+
|
|
1146
|
+
it "extracts name from function returning a function pointer with its name in parentheses" do
|
|
1147
|
+
expect(parse_name.call("int (*(getWrapped)(void))(int)")).to eq("getWrapped")
|
|
1148
|
+
end
|
|
1149
|
+
|
|
1150
|
+
it "extracts name from function returning a pointer to an array" do
|
|
1151
|
+
signature = "int (*getRow(void))[4]"
|
|
1152
|
+
name = parse_name.call(signature)
|
|
1153
|
+
|
|
1154
|
+
expect(name).to eq("getRow")
|
|
1155
|
+
end
|
|
1090
1156
|
end
|
|
1091
1157
|
|
|
1092
1158
|
context "function names with underscores and naming conventions" do
|
|
@@ -1827,6 +1893,23 @@ describe CExtractorFunctions do
|
|
|
1827
1893
|
end
|
|
1828
1894
|
end
|
|
1829
1895
|
|
|
1896
|
+
# A C23 attribute may lead a definition, ahead of its storage class. The signature keeps it
|
|
1897
|
+
# in place, and the storage class is a decorator.
|
|
1898
|
+
context "C23 attributes" do
|
|
1899
|
+
[
|
|
1900
|
+
['[[nodiscard]] static int f(void) { return 0; }', ['static'], '[[nodiscard]] int f(void)'],
|
|
1901
|
+
['[[deprecated("a]]b")]] int f(void) { return 0; }', [], '[[deprecated("a]]b")]] int f(void)'],
|
|
1902
|
+
['[[maybe_unused]] [[nodiscard]] static int f(int x[2]) { return x[0]; }', ['static'], '[[maybe_unused]] [[nodiscard]] int f(int x[2])']
|
|
1903
|
+
].each do |content, decorators, signature_stripped|
|
|
1904
|
+
it "extracts `#{content}`" do
|
|
1905
|
+
success, func, _pos, rest = try_extract.call( content )
|
|
1906
|
+
|
|
1907
|
+
expect( success ).to be true
|
|
1908
|
+
expect( [func.name, func.decorators, func.signature_stripped, rest] ).to eq ['f', decorators, signature_stripped, '']
|
|
1909
|
+
end
|
|
1910
|
+
end
|
|
1911
|
+
end
|
|
1912
|
+
|
|
1830
1913
|
context "function extraction with various body styles" do
|
|
1831
1914
|
it "extracts function with empty body" do
|
|
1832
1915
|
content = "void empty(void) {}"
|
|
@@ -2553,6 +2636,67 @@ describe CExtractorFunctions do
|
|
|
2553
2636
|
end
|
|
2554
2637
|
end
|
|
2555
2638
|
|
|
2639
|
+
# A declaration is a function's when a parameter list follows its name. A pointer to a
|
|
2640
|
+
# function inside the parameters declares a parameter.
|
|
2641
|
+
context "declarations involving function pointers" do
|
|
2642
|
+
[
|
|
2643
|
+
['void ticker_register(int (*cb)(int));', 'ticker_register'],
|
|
2644
|
+
['void ticker_register_any(int (*)(int));', 'ticker_register_any'],
|
|
2645
|
+
['int board_apply(int (*fn)(int), int n);', 'board_apply'],
|
|
2646
|
+
['int (*ticker_get(void))(int);', 'ticker_get'],
|
|
2647
|
+
['int (* const ticker_const(void))(int);', 'ticker_const'],
|
|
2648
|
+
['int (__cdecl *ticker_cdecl(void))(int);', 'ticker_cdecl'],
|
|
2649
|
+
['int (*ticker_row(void))[4];', 'ticker_row'],
|
|
2650
|
+
['int (*f(int (*g)(int)))(int);', 'f'],
|
|
2651
|
+
['void (*signal(int sig, void (*func)(int)))(int);', 'signal'],
|
|
2652
|
+
['void (* _Nullable sigset(int, void (* _Nullable)(int)))(int);', 'sigset'],
|
|
2653
|
+
['int (*(ticker_paren(void)))(int);', 'ticker_paren'],
|
|
2654
|
+
['int (*(ticker_wrap)(void))(int);', 'ticker_wrap'],
|
|
2655
|
+
['DECLARE_THING(*p, b);', 'DECLARE_THING']
|
|
2656
|
+
].each do |content, name|
|
|
2657
|
+
it "reads `#{content}` as a declaration of #{name}()" do
|
|
2658
|
+
success, decl, pos, _ = try_extract_decl.call(content)
|
|
2659
|
+
|
|
2660
|
+
expect(success).to be true
|
|
2661
|
+
expect(decl.name).to eq(name)
|
|
2662
|
+
expect(decl.signature).to eq(content)
|
|
2663
|
+
expect(pos).to eq(content.length)
|
|
2664
|
+
end
|
|
2665
|
+
end
|
|
2666
|
+
|
|
2667
|
+
[
|
|
2668
|
+
'int (*g_hook)(int);',
|
|
2669
|
+
'int (*const k_hook)(int);',
|
|
2670
|
+
'int (* volatile v_hook)(int);',
|
|
2671
|
+
'int (__cdecl *on_tick)(int);',
|
|
2672
|
+
'int (* __attribute__((unused)) u_hook)(int);',
|
|
2673
|
+
'int (* _Nullable n_hook)(int);',
|
|
2674
|
+
'int (*(r_hook))(int);',
|
|
2675
|
+
'char (*(r_row))[4];',
|
|
2676
|
+
'int (*hook$x)(int);',
|
|
2677
|
+
'void (__attribute__((stdcall)) *s_hook)(int);',
|
|
2678
|
+
'handler_t (*table[4])(void);',
|
|
2679
|
+
'int (*g_row)[4];'
|
|
2680
|
+
].each do |content|
|
|
2681
|
+
it "leaves the variable `#{content}` to the declaration extractors" do
|
|
2682
|
+
success, decl, pos, _ = try_extract_decl.call(content)
|
|
2683
|
+
|
|
2684
|
+
expect(success).to be false
|
|
2685
|
+
expect(decl).to be_nil
|
|
2686
|
+
expect(pos).to eq(0)
|
|
2687
|
+
end
|
|
2688
|
+
end
|
|
2689
|
+
|
|
2690
|
+
it "separates the decorators of a declaration taking a function pointer" do
|
|
2691
|
+
success, decl, _, _ = try_extract_decl.call('extern void ticker_on(void (*cb)(void));')
|
|
2692
|
+
|
|
2693
|
+
expect(success).to be true
|
|
2694
|
+
expect(decl.name).to eq('ticker_on')
|
|
2695
|
+
expect(decl.decorators).to eq(['extern'])
|
|
2696
|
+
expect(decl.signature_stripped).to eq('void ticker_on(void (*cb)(void));')
|
|
2697
|
+
end
|
|
2698
|
+
end
|
|
2699
|
+
|
|
2556
2700
|
context "successful extraction returns CFunctionDeclaration struct" do
|
|
2557
2701
|
it "extracts simple function declaration" do
|
|
2558
2702
|
content = "int foo(void);"
|
|
@@ -2608,6 +2752,15 @@ describe CExtractorFunctions do
|
|
|
2608
2752
|
expect(decl.decorators).to eq(["extern"])
|
|
2609
2753
|
expect(decl.signature_stripped).to eq("void bar(int x);")
|
|
2610
2754
|
end
|
|
2755
|
+
|
|
2756
|
+
it "keeps an unsigned long return type in a declaration" do
|
|
2757
|
+
content = "unsigned long big(void);"
|
|
2758
|
+
success, decl, _, _ = try_extract_decl.call(content)
|
|
2759
|
+
|
|
2760
|
+
expect(success).to be true
|
|
2761
|
+
expect(decl.decorators).to eq([])
|
|
2762
|
+
expect(decl.signature_stripped).to eq("unsigned long big(void);")
|
|
2763
|
+
end
|
|
2611
2764
|
end
|
|
2612
2765
|
|
|
2613
2766
|
context "failed extraction" do
|
|
@@ -2676,34 +2829,115 @@ describe CExtractorFunctions do
|
|
|
2676
2829
|
expect(stripped).to eq("int foo(void)")
|
|
2677
2830
|
end
|
|
2678
2831
|
|
|
2679
|
-
|
|
2832
|
+
# A qualifier before the return type belongs to that type, so stripping it would change it
|
|
2833
|
+
it "keeps a const qualifier as part of the return type" do
|
|
2680
2834
|
decorators, stripped = functions.send(:parse_decorators_and_strip, "const int* foo(void)", "foo")
|
|
2681
|
-
expect(decorators).to eq([
|
|
2682
|
-
expect(stripped).to eq("int* foo(void)")
|
|
2835
|
+
expect(decorators).to eq([])
|
|
2836
|
+
expect(stripped).to eq("const int* foo(void)")
|
|
2683
2837
|
end
|
|
2684
2838
|
|
|
2685
|
-
it "
|
|
2686
|
-
# The algorithm treats leading TYPE_KEYWORDS as the split point; "unsigned" becomes a decorator
|
|
2687
|
-
# and "int" becomes the start of the return type
|
|
2839
|
+
it "keeps every keyword of an unsigned int return type" do
|
|
2688
2840
|
decorators, stripped = functions.send(:parse_decorators_and_strip, "unsigned int foo(void)", "foo")
|
|
2689
|
-
expect(decorators).to eq([
|
|
2690
|
-
expect(stripped).to eq("int foo(void)")
|
|
2841
|
+
expect(decorators).to eq([])
|
|
2842
|
+
expect(stripped).to eq("unsigned int foo(void)")
|
|
2691
2843
|
end
|
|
2692
2844
|
|
|
2693
|
-
it "
|
|
2694
|
-
# Similarly, "struct" is a TYPE_KEYWORD and becomes the split point
|
|
2845
|
+
it "keeps a struct return type whole" do
|
|
2695
2846
|
decorators, stripped = functions.send(:parse_decorators_and_strip, "struct Point* foo(void)", "foo")
|
|
2696
|
-
expect(decorators).to eq([
|
|
2697
|
-
expect(stripped).to eq("Point* foo(void)")
|
|
2847
|
+
expect(decorators).to eq([])
|
|
2848
|
+
expect(stripped).to eq("struct Point* foo(void)")
|
|
2698
2849
|
end
|
|
2699
2850
|
|
|
2700
|
-
it "
|
|
2701
|
-
# Similarly, "long" is a TYPE_KEYWORD and becomes the split point
|
|
2851
|
+
it "keeps every keyword of a long int return type" do
|
|
2702
2852
|
decorators, stripped = functions.send(:parse_decorators_and_strip, "long int foo(void)", "foo")
|
|
2703
|
-
expect(decorators).to eq([
|
|
2853
|
+
expect(decorators).to eq([])
|
|
2854
|
+
expect(stripped).to eq("long int foo(void)")
|
|
2855
|
+
end
|
|
2856
|
+
|
|
2857
|
+
it "keeps a typedef name before a spaced pointer" do
|
|
2858
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "uint8_t *get_buf(void)", "get_buf")
|
|
2859
|
+
expect(decorators).to eq([])
|
|
2860
|
+
expect(stripped).to eq("uint8_t *get_buf(void)")
|
|
2861
|
+
end
|
|
2862
|
+
|
|
2863
|
+
it "keeps an enum return type whole" do
|
|
2864
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "enum mode get_mode(void)", "get_mode")
|
|
2865
|
+
expect(decorators).to eq([])
|
|
2866
|
+
expect(stripped).to eq("enum mode get_mode(void)")
|
|
2867
|
+
end
|
|
2868
|
+
|
|
2869
|
+
it "keeps both words of a long long return type" do
|
|
2870
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "long long foo(void)", "foo")
|
|
2871
|
+
expect(decorators).to eq([])
|
|
2872
|
+
expect(stripped).to eq("long long foo(void)")
|
|
2873
|
+
end
|
|
2874
|
+
|
|
2875
|
+
it "keeps a calling convention between the return type and the name" do
|
|
2876
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "int __cdecl foo(void)", "foo")
|
|
2877
|
+
expect(decorators).to eq([])
|
|
2878
|
+
expect(stripped).to eq("int __cdecl foo(void)")
|
|
2879
|
+
end
|
|
2880
|
+
|
|
2881
|
+
# Macros are resolved by reconciling with the fully expanded copy, not by guessing here
|
|
2882
|
+
it "keeps an unexpanded macro before the return type" do
|
|
2883
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "PRIVATE int foo(void)", "foo")
|
|
2884
|
+
expect(decorators).to eq([])
|
|
2885
|
+
expect(stripped).to eq("PRIVATE int foo(void)")
|
|
2886
|
+
end
|
|
2887
|
+
|
|
2888
|
+
it "strips a storage class written after a qualifier and keeps the qualifier" do
|
|
2889
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "const static int *t(void)", "t")
|
|
2890
|
+
expect(decorators).to eq(["static"])
|
|
2891
|
+
expect(stripped).to eq("const int *t(void)")
|
|
2892
|
+
end
|
|
2893
|
+
|
|
2894
|
+
it "strips a storage class written after the return type" do
|
|
2895
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "int static foo(void)", "foo")
|
|
2896
|
+
expect(decorators).to eq(["static"])
|
|
2704
2897
|
expect(stripped).to eq("int foo(void)")
|
|
2705
2898
|
end
|
|
2706
2899
|
|
|
2900
|
+
# The name must be found as a whole word, not inside a return type such as "float"
|
|
2901
|
+
it "finds a short name that also appears inside the return type" do
|
|
2902
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "static float f(void)", "f")
|
|
2903
|
+
expect(decorators).to eq(["static"])
|
|
2904
|
+
expect(stripped).to eq("float f(void)")
|
|
2905
|
+
end
|
|
2906
|
+
|
|
2907
|
+
# A selected function needs it, or a caller's missing return reads as a warning
|
|
2908
|
+
it "keeps the _Noreturn function specifier" do
|
|
2909
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "_Noreturn void die(void)", "die")
|
|
2910
|
+
expect(decorators).to eq([])
|
|
2911
|
+
expect(stripped).to eq("_Noreturn void die(void)")
|
|
2912
|
+
end
|
|
2913
|
+
|
|
2914
|
+
it "strips static and keeps _Noreturn" do
|
|
2915
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "static _Noreturn void fatal(void)", "fatal")
|
|
2916
|
+
expect(decorators).to eq(["static"])
|
|
2917
|
+
expect(stripped).to eq("_Noreturn void fatal(void)")
|
|
2918
|
+
end
|
|
2919
|
+
|
|
2920
|
+
# Only whole words separated by whitespace are decorators, never text inside an attribute
|
|
2921
|
+
it "leaves a decorator word inside an attribute string alone" do
|
|
2922
|
+
signature = 'static int __attribute__((section(".text.static"))) g(void)'
|
|
2923
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, signature, "g")
|
|
2924
|
+
expect(decorators).to eq(["static"])
|
|
2925
|
+
expect(stripped).to eq('int __attribute__((section(".text.static"))) g(void)')
|
|
2926
|
+
end
|
|
2927
|
+
|
|
2928
|
+
it "strips the decorator itself when an attribute string ahead of it holds the same word" do
|
|
2929
|
+
signature = '__attribute__((section(".text.static"))) static int g(void)'
|
|
2930
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, signature, "g")
|
|
2931
|
+
expect(decorators).to eq(["static"])
|
|
2932
|
+
expect(stripped).to eq('__attribute__((section(".text.static"))) int g(void)')
|
|
2933
|
+
end
|
|
2934
|
+
|
|
2935
|
+
it "strips extern inline from a prototype and keeps its semicolon" do
|
|
2936
|
+
decorators, stripped = functions.send(:parse_decorators_and_strip, "extern inline int twice(void);", "twice")
|
|
2937
|
+
expect(decorators).to eq(["extern", "inline"])
|
|
2938
|
+
expect(stripped).to eq("int twice(void);")
|
|
2939
|
+
end
|
|
2940
|
+
|
|
2707
2941
|
it "returns empty decorators and original signature when name is nil" do
|
|
2708
2942
|
decorators, stripped = functions.send(:parse_decorators_and_strip, "int foo(void)", nil)
|
|
2709
2943
|
expect(decorators).to eq([])
|
|
@@ -2734,11 +2968,10 @@ describe CExtractorFunctions do
|
|
|
2734
2968
|
expect(stripped).to eq("char* foo(void)")
|
|
2735
2969
|
end
|
|
2736
2970
|
|
|
2737
|
-
it "
|
|
2738
|
-
# const is in MODIFIER_KEYWORDS, so algorithm treats it as decorator alongside static
|
|
2971
|
+
it "strips static from a const pointer return and keeps const" do
|
|
2739
2972
|
decorators, stripped = functions.send(:parse_decorators_and_strip, "static const char* foo(void)", "foo")
|
|
2740
|
-
expect(decorators).to eq(["static"
|
|
2741
|
-
expect(stripped).to eq("char* foo(void)")
|
|
2973
|
+
expect(decorators).to eq(["static"])
|
|
2974
|
+
expect(stripped).to eq("const char* foo(void)")
|
|
2742
2975
|
end
|
|
2743
2976
|
|
|
2744
2977
|
it "handles function with parameters that include type keywords" do
|
|
@@ -2801,6 +3034,214 @@ describe CExtractorFunctions do
|
|
|
2801
3034
|
expect(func.decorators).to eq(["static", "inline"])
|
|
2802
3035
|
expect(func.signature_stripped).to eq("int bar(int x)")
|
|
2803
3036
|
end
|
|
3037
|
+
|
|
3038
|
+
it "keeps a struct pointer return type when stripping static" do
|
|
3039
|
+
success, func = try_extract.call("static struct point *origin(void) { return 0; }")
|
|
3040
|
+
expect(success).to be true
|
|
3041
|
+
expect(func.decorators).to eq(["static"])
|
|
3042
|
+
expect(func.signature_stripped).to eq("struct point *origin(void)")
|
|
3043
|
+
end
|
|
3044
|
+
|
|
3045
|
+
it "keeps a const return type on a function with no decorators" do
|
|
3046
|
+
success, func = try_extract.call("const char *name(void) { return \"n\"; }")
|
|
3047
|
+
expect(success).to be true
|
|
3048
|
+
expect(func.decorators).to eq([])
|
|
3049
|
+
expect(func.signature_stripped).to eq("const char *name(void)")
|
|
3050
|
+
end
|
|
3051
|
+
end
|
|
3052
|
+
|
|
3053
|
+
describe ".remove_tokens" do
|
|
3054
|
+
def remove(text, tokens)
|
|
3055
|
+
described_class.remove_tokens( text, tokens )
|
|
3056
|
+
end
|
|
3057
|
+
|
|
3058
|
+
it "removes a token with the spaces after it" do
|
|
3059
|
+
expect( remove( "static int f(void)", ['static'] ) ).to eq( "int f(void)" )
|
|
3060
|
+
end
|
|
3061
|
+
|
|
3062
|
+
it "removes a token with the tab after it" do
|
|
3063
|
+
expect( remove( "static\tint f(void)", ['static'] ) ).to eq( "int f(void)" )
|
|
3064
|
+
end
|
|
3065
|
+
|
|
3066
|
+
# A caller counts the lines a decorator occupied, so a newline after it stays
|
|
3067
|
+
it "keeps a newline after a token" do
|
|
3068
|
+
expect( remove( "static\nint f(void)", ['static'] ) ).to eq( "\nint f(void)" )
|
|
3069
|
+
end
|
|
3070
|
+
|
|
3071
|
+
it "keeps whitespace after a token when it holds a newline" do
|
|
3072
|
+
expect( remove( "static \nint f(void)", ['static'] ) ).to eq( " \nint f(void)" )
|
|
3073
|
+
end
|
|
3074
|
+
|
|
3075
|
+
it "removes each listed token once" do
|
|
3076
|
+
expect( remove( "static static int f(void)", ['static'] ) ).to eq( "static int f(void)" )
|
|
3077
|
+
expect( remove( "static static int f(void)", ['static', 'static'] ) ).to eq( "int f(void)" )
|
|
3078
|
+
end
|
|
3079
|
+
|
|
3080
|
+
it "leaves a token that is only part of a longer word" do
|
|
3081
|
+
expect( remove( "int is_static(void)", ['static'] ) ).to eq( "int is_static(void)" )
|
|
3082
|
+
end
|
|
3083
|
+
|
|
3084
|
+
it "leaves the text alone when a token is absent" do
|
|
3085
|
+
expect( remove( "int f(void)", ['inline'] ) ).to eq( "int f(void)" )
|
|
3086
|
+
end
|
|
3087
|
+
end
|
|
3088
|
+
|
|
3089
|
+
describe ".name_position" do
|
|
3090
|
+
it "finds the name ahead of its parameter list" do
|
|
3091
|
+
expect( described_class.name_position( "static int f(void)", 'f' ) ).to eq( 11 )
|
|
3092
|
+
end
|
|
3093
|
+
|
|
3094
|
+
it "finds the name with space before its parameter list" do
|
|
3095
|
+
expect( described_class.name_position( "int f (void)", 'f' ) ).to eq( 4 )
|
|
3096
|
+
end
|
|
3097
|
+
|
|
3098
|
+
it "does not find a name inside a longer one" do
|
|
3099
|
+
expect( described_class.name_position( "int buf(void)", 'f' ) ).to be_nil
|
|
3100
|
+
end
|
|
3101
|
+
|
|
3102
|
+
it "does not find a name without a parameter list after it" do
|
|
3103
|
+
expect( described_class.name_position( "int f;", 'f' ) ).to be_nil
|
|
3104
|
+
end
|
|
3105
|
+
|
|
3106
|
+
it "finds a name at the very start of the text" do
|
|
3107
|
+
expect( described_class.name_position( "f(void)", 'f' ) ).to eq( 0 )
|
|
3108
|
+
end
|
|
3109
|
+
|
|
3110
|
+
it "does not find a name at the start of a longer one" do
|
|
3111
|
+
expect( described_class.name_position( "int fx(void)", 'f' ) ).to be_nil
|
|
3112
|
+
end
|
|
3113
|
+
|
|
3114
|
+
it "finds the name with a newline and a tab before its parameter list" do
|
|
3115
|
+
expect( described_class.name_position( "int f\n\t(void)", 'f' ) ).to eq( 4 )
|
|
3116
|
+
end
|
|
3117
|
+
|
|
3118
|
+
it "finds the name right after a pointer star" do
|
|
3119
|
+
expect( described_class.name_position( "int *f(void)", 'f' ) ).to eq( 5 )
|
|
3120
|
+
end
|
|
3121
|
+
|
|
3122
|
+
# A struct tag may share the function's name
|
|
3123
|
+
it "passes over an earlier occurrence with no parameter list after it" do
|
|
3124
|
+
expect( described_class.name_position( "struct f f(void)", 'f' ) ).to eq( 9 )
|
|
3125
|
+
end
|
|
3126
|
+
|
|
3127
|
+
it "passes over the name inside a longer word to find it whole later" do
|
|
3128
|
+
expect( described_class.name_position( "int buf; int f(void)", 'f' ) ).to eq( 13 )
|
|
3129
|
+
end
|
|
3130
|
+
|
|
3131
|
+
it "does not find a name that only overlaps a longer run of its letters" do
|
|
3132
|
+
expect( described_class.name_position( "int fff(void)", 'ff' ) ).to be_nil
|
|
3133
|
+
end
|
|
3134
|
+
|
|
3135
|
+
it "counts the position in characters" do
|
|
3136
|
+
expect( described_class.name_position( "/* é */ int f(void)", 'f' ) ).to eq( 12 )
|
|
3137
|
+
end
|
|
3138
|
+
end
|
|
3139
|
+
|
|
3140
|
+
# GCC and Clang accept '$' in an identifier
|
|
3141
|
+
describe "names holding '$'" do
|
|
3142
|
+
let(:functions) { CExtractorFunctions.new({ c_extractor_code_text: CExtractorCodeText.new() }).tap(&:setup) }
|
|
3143
|
+
|
|
3144
|
+
it "does not find a name inside a longer one that holds a '$'" do
|
|
3145
|
+
expect( described_class.name_position( "int x$f(void); int f(void)", 'f' ) ).to eq( 19 )
|
|
3146
|
+
end
|
|
3147
|
+
|
|
3148
|
+
[
|
|
3149
|
+
['int f$1(void);', 'f$1'],
|
|
3150
|
+
['int $g(int $a);', '$g'],
|
|
3151
|
+
['static int h$(void);', 'h$'],
|
|
3152
|
+
['int f$__inline(void);', 'f$__inline']
|
|
3153
|
+
].each do |signature, name|
|
|
3154
|
+
it "reads the declaration `#{signature}` as `#{name}`" do
|
|
3155
|
+
success, declaration = functions.try_extract_function_declaration( StringScanner.new( signature ) )
|
|
3156
|
+
|
|
3157
|
+
expect( success ).to be true
|
|
3158
|
+
expect( declaration.name ).to eq( name )
|
|
3159
|
+
end
|
|
3160
|
+
end
|
|
3161
|
+
|
|
3162
|
+
it "reads a definition's name holding '$'" do
|
|
3163
|
+
success, definition = functions.try_extract_function_definition( StringScanner.new( "int f$1(void) { return 1; }" ), nil )
|
|
3164
|
+
|
|
3165
|
+
expect( success ).to be true
|
|
3166
|
+
expect( [definition.name, definition.signature_stripped] ).to eq ['f$1', 'int f$1(void)']
|
|
3167
|
+
end
|
|
3168
|
+
end
|
|
3169
|
+
|
|
3170
|
+
|
|
3171
|
+
# A return type a specifier spells keeps its parentheses, which hold no name
|
|
3172
|
+
describe "return types a specifier spells" do
|
|
3173
|
+
let(:functions) { CExtractorFunctions.new({ c_extractor_code_text: CExtractorCodeText.new() }).tap(&:setup) }
|
|
3174
|
+
|
|
3175
|
+
[
|
|
3176
|
+
['typeof(int) tf(void);', 'tf', 'typeof(int) tf(void);'],
|
|
3177
|
+
['_Atomic(int) af(void);', 'af', '_Atomic(int) af(void);'],
|
|
3178
|
+
['typeof(*p) pf(int n);', 'pf', 'typeof(*p) pf(int n);'],
|
|
3179
|
+
['__typeof__( helper(1) ) tq(void);', 'tq', '__typeof__( helper(1) ) tq(void);'],
|
|
3180
|
+
['typeof(unsigned int (*)(void)) getfp(void);', 'getfp', 'typeof(unsigned int (*)(void)) getfp(void);']
|
|
3181
|
+
].each do |signature, name, stripped|
|
|
3182
|
+
it "reads the declaration `#{signature}` as `#{name}`" do
|
|
3183
|
+
success, declaration = functions.try_extract_function_declaration( StringScanner.new( signature ) )
|
|
3184
|
+
|
|
3185
|
+
expect( success ).to be true
|
|
3186
|
+
expect( [declaration.name, declaration.signature_stripped] ).to eq [name, stripped]
|
|
3187
|
+
end
|
|
3188
|
+
end
|
|
3189
|
+
|
|
3190
|
+
it "reads a definition whose return type `__typeof__` spells" do
|
|
3191
|
+
success, definition = functions.try_extract_function_definition( StringScanner.new( "__typeof__(int) uf(void) { return 0; }" ), nil )
|
|
3192
|
+
|
|
3193
|
+
expect( success ).to be true
|
|
3194
|
+
expect( definition.name ).to eq( 'uf' )
|
|
3195
|
+
end
|
|
3196
|
+
end
|
|
3197
|
+
|
|
3198
|
+
describe ".body_start" do
|
|
3199
|
+
it "gives the byte of the brace that opens the body" do
|
|
3200
|
+
expect( described_class.body_start( "int f(void) { return 0; }" ) ).to eq( 12 )
|
|
3201
|
+
end
|
|
3202
|
+
|
|
3203
|
+
# An attribute string or a comment in the head may hold a brace
|
|
3204
|
+
it "passes over braces in a literal or a comment" do
|
|
3205
|
+
code = "__attribute__((section(\"{s}\"))) int f(void) /* { */ { return 0; }"
|
|
3206
|
+
expect( code.byteslice( described_class.body_start( code ), 1 ) ).to eq( "{" )
|
|
3207
|
+
expect( code.byteslice( described_class.body_start( code ) - 8, 8 ) ).to eq( "/* { */ " )
|
|
3208
|
+
end
|
|
3209
|
+
end
|
|
3210
|
+
|
|
3211
|
+
describe ".signature_end" do
|
|
3212
|
+
def tail(code)
|
|
3213
|
+
code.byteslice( described_class.signature_end( code )..)
|
|
3214
|
+
end
|
|
3215
|
+
|
|
3216
|
+
it "gives the byte just past the parameter list" do
|
|
3217
|
+
expect( tail( "int f(int a, int b) { return a; }" ) ).to eq( " { return a; }" )
|
|
3218
|
+
end
|
|
3219
|
+
|
|
3220
|
+
it "passes over parentheses nested in the parameter list" do
|
|
3221
|
+
expect( tail( "int f(int (*cb)(int)) { return cb( 1 ); }" ) ).to eq( " { return cb( 1 ); }" )
|
|
3222
|
+
end
|
|
3223
|
+
|
|
3224
|
+
# A C23 attribute or a comment after the list belongs to what follows it
|
|
3225
|
+
it "ends before a comment after the list" do
|
|
3226
|
+
expect( tail( "int f(void) /* x( */ { return 0; }" ) ).to eq( " /* x( */ { return 0; }" )
|
|
3227
|
+
end
|
|
3228
|
+
|
|
3229
|
+
# A GNU attribute after the list closes at the top level too, so the declarator ends after it
|
|
3230
|
+
it "ends after a GNU attribute that follows the list" do
|
|
3231
|
+
expect( tail( "int f(void) __attribute__((cold)) { return 0; }" ) ).to eq( " { return 0; }" )
|
|
3232
|
+
end
|
|
3233
|
+
|
|
3234
|
+
it "ends after the declarator of a function returning a function pointer" do
|
|
3235
|
+
expect( tail( "int (*get(int a))(int) { return 0; }" ) ).to eq( " { return 0; }" )
|
|
3236
|
+
end
|
|
3237
|
+
|
|
3238
|
+
it "reads a parenthesis in a literal or a comment as text" do
|
|
3239
|
+
expect( tail( "int f(const char *s /* ) */) { return s[0] == ')'; }" ) ).to eq( " { return s[0] == ')'; }" )
|
|
3240
|
+
end
|
|
3241
|
+
|
|
3242
|
+
it "gives nil for a head with no parameter list" do
|
|
3243
|
+
expect( described_class.signature_end( "{ return 0; }" ) ).to be_nil
|
|
3244
|
+
end
|
|
2804
3245
|
end
|
|
2805
3246
|
|
|
2806
3247
|
end
|
|
@@ -708,6 +708,25 @@ describe CExtractorPreprocessing do
|
|
|
708
708
|
[result, scanner.pos]
|
|
709
709
|
end
|
|
710
710
|
|
|
711
|
+
# A type specifier that takes parentheses has an invocation's shape, but a declaration follows
|
|
712
|
+
[
|
|
713
|
+
'typeof(int) g_t;',
|
|
714
|
+
'typeof(*g_pp) g_q;',
|
|
715
|
+
'typeof_unqual(const int) g_u;',
|
|
716
|
+
'__typeof(int) g_v;',
|
|
717
|
+
'__typeof_unqual(const int) g_w;',
|
|
718
|
+
'_Atomic(int) g_a;',
|
|
719
|
+
'_Alignas(8) int g_al;',
|
|
720
|
+
'alignas(8) int g_al2;',
|
|
721
|
+
'_BitInt(8) g_b;'
|
|
722
|
+
].each do |text|
|
|
723
|
+
it "declines a type specifier taking parentheses: #{text}" do
|
|
724
|
+
result, pos = try_bare_invocation(text)
|
|
725
|
+
expect(result).to eq [false, nil]
|
|
726
|
+
expect(pos).to eq 0
|
|
727
|
+
end
|
|
728
|
+
end
|
|
729
|
+
|
|
711
730
|
# --- Success cases ---
|
|
712
731
|
|
|
713
732
|
it "extracts a simple invocation followed by unrelated trailing content" do
|
|
@@ -800,6 +819,26 @@ describe CExtractorPreprocessing do
|
|
|
800
819
|
expect(pos).to eq 0
|
|
801
820
|
end
|
|
802
821
|
|
|
822
|
+
# A declarator in parentheses goes on past its group, which no bare invocation does
|
|
823
|
+
[
|
|
824
|
+
['a parameter list', 'int (*g_hook)(int) = 0;'],
|
|
825
|
+
['an array suffix', 'int (*g_row)[4];'],
|
|
826
|
+
['an initializer', 'int (*p) = 0;'],
|
|
827
|
+
['another declarator', 'int (*a), (*b);']
|
|
828
|
+
].each do |continuation, text|
|
|
829
|
+
it "leaves a parenthesized declarator followed by #{continuation} to the declaration extractors" do
|
|
830
|
+
result, pos = try_bare_invocation(text)
|
|
831
|
+
expect(result).to eq [false, nil]
|
|
832
|
+
expect(pos).to eq 0
|
|
833
|
+
end
|
|
834
|
+
end
|
|
835
|
+
|
|
836
|
+
it "leaves a function returning a function pointer to the function extractors" do
|
|
837
|
+
result, pos = try_bare_invocation('int (*ticker_get(void))(int);')
|
|
838
|
+
expect(result).to eq [false, nil]
|
|
839
|
+
expect(pos).to eq 0
|
|
840
|
+
end
|
|
841
|
+
|
|
803
842
|
it "defers to the function-definition path when followed by '{'" do
|
|
804
843
|
result, pos = try_bare_invocation('FOO(0){}')
|
|
805
844
|
expect(result).to eq [false, nil]
|
|
@@ -140,8 +140,8 @@ describe CExtractor do
|
|
|
140
140
|
result = extract_feature.call(io, 1000, extractor)
|
|
141
141
|
|
|
142
142
|
expect(result).to eq("HELLO")
|
|
143
|
-
#
|
|
144
|
-
expect(io.pos).to eq(
|
|
143
|
+
# The chunk ends inside the comment, so the comment is left for the next read whole
|
|
144
|
+
expect(io.pos).to eq(5)
|
|
145
145
|
end
|
|
146
146
|
|
|
147
147
|
it "returns nil when pattern is not found before EOF" do
|
|
@@ -333,8 +333,8 @@ describe CExtractor do
|
|
|
333
333
|
result = extract_feature.call(io, 1000, extractor)
|
|
334
334
|
|
|
335
335
|
expect(result).to eq("PATTERN")
|
|
336
|
-
#
|
|
337
|
-
expect(io.pos).to eq(
|
|
336
|
+
# The chunk ends inside the comment, so the comment is left for the next read whole
|
|
337
|
+
expect(io.pos).to eq(7)
|
|
338
338
|
end
|
|
339
339
|
|
|
340
340
|
it "allows extraction when pattern exactly matches chunk size" do
|