ceedling 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/GIT_COMMIT_SHA +1 -1
- data/README.md +11 -9
- data/Rakefile +2 -1
- data/assets/features/ceedling +1 -1
- data/assets/fixtures/test_source_file_duplicate_basenames/test_calc_typo.c +14 -0
- data/assets/fixtures/tests_with_duplicate_test_names/test_foo.c +21 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
- data/bin/actionator.rb +6 -12
- data/bin/app_cfg.rb +14 -1
- data/bin/ceedling +13 -3
- data/bin/cli.rb +25 -6
- data/bin/cli_handler.rb +113 -73
- data/bin/cli_helper.rb +51 -78
- data/bin/installation_selector.rb +81 -0
- data/bin/launchinator.rb +69 -0
- data/bin/mixin_resolvinator.rb +26 -36
- data/bin/objects.yml +13 -0
- data/bin/path_validator.rb +25 -29
- data/bin/versionator.rb +47 -48
- data/ceedling.gemspec +19 -15
- data/docs/BreakingChanges.md +86 -1
- data/docs/Changelog.md +145 -3
- data/docs/KnownIssues.md +179 -6
- data/docs/ReleaseNotes.md +13 -0
- data/examples/wondrous_forest/README.md +29 -1
- data/examples/wondrous_forest/src/ForestUnits.h +23 -0
- data/examples/wondrous_forest/src/RainGauge.c +59 -0
- data/examples/wondrous_forest/src/RainGauge.h +39 -0
- data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
- data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
- data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
- data/lib/ceedling/build_log_writer.rb +33 -0
- data/lib/ceedling/c_extractor/README.md +15 -7
- data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
- data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
- data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
- data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
- data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
- data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
- data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
- data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
- data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
- data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
- data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
- data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
- data/lib/ceedling/c_identifier.rb +21 -0
- data/lib/ceedling/ceedling.h +8 -0
- data/lib/ceedling/config/build_root_policy.rb +70 -0
- data/lib/ceedling/config/configurator.rb +18 -19
- data/lib/ceedling/config/configurator_builder.rb +75 -28
- data/lib/ceedling/config/configurator_paths_validator.rb +179 -0
- data/lib/ceedling/config/configurator_plugins.rb +1 -1
- data/lib/ceedling/config/configurator_setup.rb +44 -33
- data/lib/ceedling/config/configurator_validator.rb +1 -110
- data/lib/ceedling/constants.rb +5 -1
- data/lib/ceedling/defaults.rb +35 -5
- data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
- data/lib/ceedling/dependencies/README.md +18 -16
- data/lib/ceedling/dependencies/dependency_cache_store.rb +43 -21
- data/lib/ceedling/dependencies/dependency_hasher.rb +35 -1
- data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
- data/lib/ceedling/dependencies/dependinator.rb +13 -1
- data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
- data/lib/ceedling/diagnostics/README.md +5 -0
- data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
- data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
- data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
- data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
- data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
- data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
- data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
- data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
- data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
- data/lib/ceedling/filename_extension.rb +7 -1
- data/lib/ceedling/filesystem/FILE_TREE.md +253 -0
- data/lib/ceedling/filesystem/PATH_HANDLING.md +360 -0
- data/lib/ceedling/filesystem/README.md +46 -0
- data/lib/ceedling/filesystem/build_roots.rb +105 -0
- data/lib/ceedling/filesystem/build_subpath.rb +187 -0
- data/lib/ceedling/filesystem/destination_collision.rb +25 -0
- data/lib/ceedling/{file_finder.rb → filesystem/file_finder.rb} +177 -156
- data/lib/ceedling/filesystem/file_finder_helper.rb +154 -0
- data/lib/ceedling/filesystem/file_path_collection_utils.rb +183 -0
- data/lib/ceedling/{file_path_utils.rb → filesystem/file_path_utils.rb} +200 -167
- data/lib/ceedling/{file_system_wrapper.rb → filesystem/file_system_wrapper.rb} +6 -5
- data/lib/ceedling/filesystem/file_tree.rb +241 -0
- data/lib/ceedling/{file_wrapper.rb → filesystem/file_wrapper.rb} +149 -65
- data/lib/ceedling/filesystem/path_exclusions.rb +30 -0
- data/lib/ceedling/{path_matcher.rb → filesystem/path_matcher.rb} +48 -23
- data/lib/ceedling/{path_mirror.rb → filesystem/path_mirror.rb} +19 -18
- data/lib/ceedling/filesystem/path_spellings.rb +55 -0
- data/lib/ceedling/filesystem/project_paths.rb +184 -0
- data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
- data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
- data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
- data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
- data/lib/ceedling/filesystem/working_dir.rb +40 -0
- data/lib/ceedling/generators/generator.rb +32 -70
- data/lib/ceedling/generators/generator_helper.rb +0 -44
- data/lib/ceedling/generators/generator_mocks.rb +5 -0
- data/lib/ceedling/generators/generator_partials.rb +306 -244
- data/lib/ceedling/generators/generator_test_results_backtrace.rb +7 -7
- data/lib/ceedling/generators/generator_test_runner.rb +5 -8
- data/lib/ceedling/generators/partial_header_writer.rb +95 -0
- data/lib/ceedling/generators/partial_source_writer.rb +137 -0
- data/lib/ceedling/handoff.rb +121 -0
- data/lib/ceedling/includes/header_search.rb +225 -0
- data/lib/ceedling/includes/include_factory.rb +9 -12
- data/lib/ceedling/includes/include_pathinator.rb +112 -33
- data/lib/ceedling/includes/includes.rb +150 -38
- data/lib/ceedling/installation.rb +92 -0
- data/lib/ceedling/library_resolver.rb +99 -0
- data/lib/ceedling/objects.yml +112 -6
- data/lib/ceedling/partials/README.md +110 -16
- data/lib/ceedling/partials/carry_plan.rb +71 -0
- data/lib/ceedling/partials/definition_head.rb +74 -0
- data/lib/ceedling/partials/include_groups.rb +37 -0
- data/lib/ceedling/partials/interface_extras.rb +25 -0
- data/lib/ceedling/partials/partializer.rb +603 -124
- data/lib/ceedling/partials/partializer_config.rb +8 -1
- data/lib/ceedling/partials/partializer_helper.rb +851 -145
- data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
- data/lib/ceedling/partials/partializer_utils.rb +89 -109
- data/lib/ceedling/partials/partials.rb +153 -10
- data/lib/ceedling/partials/type_macros.rb +126 -0
- data/lib/ceedling/plugins/report_log_writer_plugin.rb +3 -5
- data/lib/ceedling/preprocess/README.md +43 -33
- data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
- data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
- data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +32 -76
- data/lib/ceedling/preprocess/preprocessinator_includes_handler.rb +1 -1
- data/lib/ceedling/preprocess/preprocessinator_line_marker_includes_extractor.rb +1 -1
- data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
- data/lib/ceedling/rake_app/rakefile_component_resolver.rb +10 -17
- data/lib/ceedling/rakefile.rb +15 -1
- data/lib/ceedling/rakefiles/base/tasks_base.rake +1 -1
- data/lib/ceedling/rakefiles/release/rules_release.rake +4 -7
- data/lib/ceedling/release_invoker/release_build_executor.rb +33 -44
- data/lib/ceedling/release_invoker/release_build_planner.rb +14 -6
- data/lib/ceedling/reportinator.rb +3 -4
- data/lib/ceedling/setupinator.rb +104 -87
- data/lib/ceedling/test_context_extractor.rb +5 -1
- data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
- data/lib/ceedling/test_invoker/PIPELINE.md +62 -19
- data/lib/ceedling/test_invoker/README.md +1 -1
- data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
- data/lib/ceedling/test_invoker/mock_locator.rb +175 -10
- data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
- data/lib/ceedling/test_invoker/partials_manager.rb +271 -302
- data/lib/ceedling/test_invoker/standin_headerinator.rb +19 -17
- data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
- data/lib/ceedling/test_invoker/test_build_executor.rb +358 -234
- data/lib/ceedling/test_invoker/test_build_planner.rb +46 -33
- data/lib/ceedling/test_invoker/test_build_setup.rb +43 -18
- data/lib/ceedling/test_invoker/test_build_validations.rb +35 -47
- data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
- data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +2 -3
- data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
- data/lib/ceedling/test_invoker/test_invoker.rb +6 -1
- data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
- data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +6 -4
- data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
- data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
- data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
- data/lib/ceedling/test_invoker/test_source_file_directive_resolver.rb +40 -20
- data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
- data/lib/ceedling/tools/shell_quoting.rb +45 -0
- data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +9 -3
- data/lib/ceedling/tools/tool_quoting.rb +79 -0
- data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
- data/lib/ceedling/yaml_wrapper.rb +3 -2
- data/lib/version.rb +1 -1
- data/plugins/bullseye/bullseye.rake +1 -3
- data/plugins/bullseye/config/defaults_bullseye.rb +1 -1
- data/plugins/bullseye/lib/bullseye.rb +24 -9
- data/plugins/command_hooks/lib/command_hooks.rb +1 -1
- data/plugins/cppcheck/config/defaults_cppcheck.rb +1 -1
- data/plugins/dependencies/config/defaults.yml +6 -6
- data/plugins/dependencies/dependencies.rake +4 -1
- data/plugins/dependencies/lib/dependencies.rb +18 -8
- data/plugins/dependencies/lib/dependency_spec.rb +17 -5
- data/plugins/fff/lib/fff.rb +79 -46
- data/plugins/fff/lib/fff_mock_generator.rb +12 -9
- data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +262 -0
- data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
- data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
- data/plugins/gcov/config/defaults_gcov.rb +1 -1
- data/plugins/gcov/lib/console_reportinator.rb +28 -36
- data/plugins/gcov/lib/gcov.rb +9 -2
- data/plugins/gcov/lib/gcovr_reportinator.rb +8 -40
- data/plugins/gcov/lib/gcovr_thresholds.rb +74 -0
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +3 -2
- data/plugins/module_generator/lib/module_generator.rb +3 -3
- data/plugins/report_tests_teamcity_stdout/lib/report_tests_teamcity_stdout.rb +53 -80
- data/plugins/sanitize/lib/sanitize_records.rb +3 -6
- data/plugins/valgrind/lib/valgrind.rb +14 -7
- data/site-local/404.html +2 -2
- data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
- data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
- data/site-local/configuration/environment-vars.html +2 -2
- data/site-local/configuration/global-collections.html +3 -3
- data/site-local/configuration/index.html +2 -2
- data/site-local/configuration/loading.html +2 -2
- data/site-local/configuration/mixins.html +2 -2
- data/site-local/configuration/parallel-builds.html +2 -2
- data/site-local/configuration/project-file.html +2 -2
- data/site-local/configuration/reference/cexception.html +2 -2
- data/site-local/configuration/reference/cmock.html +7 -3
- data/site-local/configuration/reference/defines.html +2 -2
- data/site-local/configuration/reference/environment.html +2 -2
- data/site-local/configuration/reference/extension.html +2 -2
- data/site-local/configuration/reference/files.html +65 -12
- data/site-local/configuration/reference/flags.html +2 -2
- data/site-local/configuration/reference/index.html +2 -2
- data/site-local/configuration/reference/libraries.html +23 -5
- data/site-local/configuration/reference/mixins.html +2 -2
- data/site-local/configuration/reference/partials.html +84 -2
- data/site-local/configuration/reference/paths.html +36 -8
- data/site-local/configuration/reference/plugins.html +2 -2
- data/site-local/configuration/reference/project.html +264 -12
- data/site-local/configuration/reference/release-build.html +4 -2
- data/site-local/configuration/reference/test-build.html +2 -2
- data/site-local/configuration/reference/test-runner.html +2 -2
- data/site-local/configuration/reference/tools.html +58 -4
- data/site-local/configuration/reference/unity.html +2 -2
- data/site-local/configuration/which-ceedling.html +379 -19
- data/site-local/development/index.html +2 -2
- data/site-local/development/plugins/configuration.html +2 -2
- data/site-local/development/plugins/index.html +2 -2
- data/site-local/development/plugins/plugin-subclass.html +5 -4
- data/site-local/development/plugins/rake-tasks.html +2 -2
- data/site-local/development/releases.html +7 -3
- data/site-local/development/workflow.html +50 -45
- data/site-local/getting-started/builds.html +4 -2
- data/site-local/getting-started/command-line.html +58 -6
- data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
- data/site-local/getting-started/example-projects/index.html +2 -2
- data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
- data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
- data/site-local/getting-started/index.html +2 -2
- data/site-local/getting-started/installation.html +2 -2
- data/site-local/getting-started/quick-start.html +2 -2
- data/site-local/help.html +2 -2
- data/site-local/index.html +2 -2
- data/site-local/overview/build-system.html +2 -2
- data/site-local/overview/index.html +2 -2
- data/site-local/overview/test-environments.html +2 -2
- data/site-local/overview/tools-and-frameworks.html +2 -2
- data/site-local/plugins/beep.html +2 -2
- data/site-local/plugins/bullseye/index.html +45 -38
- data/site-local/plugins/bullseye/licensing.html +2 -2
- data/site-local/plugins/command-hooks.html +4 -4
- data/site-local/plugins/compile-commands-json-db.html +2 -2
- data/site-local/plugins/cppcheck.html +2 -2
- data/site-local/plugins/dependencies.html +8 -5
- data/site-local/plugins/fff.html +58 -13
- data/site-local/plugins/gcov/examples.html +2 -2
- data/site-local/plugins/gcov/gcovr.html +23 -14
- data/site-local/plugins/gcov/index.html +2 -2
- data/site-local/plugins/gcov/overview.html +2 -2
- data/site-local/plugins/gcov/reportgenerator.html +18 -14
- data/site-local/plugins/gcov/reporting.html +2 -2
- data/site-local/plugins/gcov/setup.html +4 -3
- data/site-local/plugins/gcov/tool-versions.html +2 -2
- data/site-local/plugins/gcov/troubleshooting.html +2 -2
- data/site-local/plugins/index.html +2 -2
- data/site-local/plugins/module-generator.html +2 -2
- data/site-local/plugins/report-build-warnings-log.html +2 -2
- data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
- data/site-local/plugins/report-tests-ide-stdout.html +2 -2
- data/site-local/plugins/report-tests-log-factory.html +2 -2
- data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
- data/site-local/plugins/report-tests-raw-output-log.html +5 -3
- data/site-local/plugins/report-tests-teamcity-stdout.html +8 -5
- data/site-local/plugins/sanitize.html +9 -8
- data/site-local/plugins/valgrind.html +10 -9
- data/site-local/project/index.html +2 -2
- data/site-local/project/release-history.html +2 -2
- data/site-local/project/sbom.html +2 -2
- data/site-local/project/upgrade.html +5 -2
- data/site-local/reference/build-directives.html +2 -2
- data/site-local/reference/command-line.html +11 -4
- data/site-local/reference/environment-vars.html +2 -2
- data/site-local/reference/gcov-plugin.html +2 -2
- data/site-local/reference/global-collections.html +12 -12
- data/site-local/reference/index.html +2 -2
- data/site-local/reference/partials-macros.html +47 -2
- data/site-local/reference/project-configuration.html +2 -2
- data/site-local/sitemap.xml.gz +0 -0
- data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
- data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
- data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
- data/site-local/snapshot/plugins/bullseye/config/defaults_bullseye.rb +1 -1
- data/site-local/snapshot/plugins/gcov/config/defaults_gcov.rb +1 -1
- data/site-local/testing-guide/build-directives.html +2 -2
- data/site-local/testing-guide/conventions.html +113 -15
- data/site-local/testing-guide/frameworks.html +2 -2
- data/site-local/testing-guide/index.html +2 -2
- data/site-local/testing-guide/partials/configuration.html +31 -4
- data/site-local/testing-guide/partials/conventions.html +509 -8
- data/site-local/testing-guide/partials/directives.html +4 -3
- data/site-local/testing-guide/partials/example.html +2 -2
- data/site-local/testing-guide/partials/index.html +2 -2
- data/site-local/testing-guide/partials/overview.html +30 -12
- data/site-local/testing-guide/partials/variables.html +169 -4
- data/site-local/testing-guide/test-cases.html +2 -2
- data/site-local/testing-guide/test-sample.html +2 -2
- data/site-local/testing-guide/test-suite-anatomy.html +2 -2
- data/spec/integration/actionator_file_operations_spec.rb +91 -1
- data/spec/integration/build_step_doctor_spec.rb +270 -0
- data/spec/integration/c_extractor_composition_spec.rb +254 -4
- data/spec/integration/compile_commands_json_db_spec.rb +1 -1
- data/spec/integration/configurator_validation_spec.rb +1 -1
- data/spec/integration/dependencies/dependency_tracker_cache_hardening_spec.rb +26 -0
- data/spec/integration/dependencies/dependency_tracker_core_spec.rb +22 -0
- data/spec/integration/includes_extraction_spec.rb +27 -14
- data/spec/integration/launcher_handoff_spec.rb +297 -0
- data/spec/integration/mixin_loading_spec.rb +1 -1
- data/spec/integration/module_generator_spec.rb +3 -3
- data/spec/integration/nested_test_artifacts_spec.rb +99 -0
- data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
- data/spec/integration/partials_carry_spec.rb +520 -0
- data/spec/integration/partials_declarations_spec.rb +655 -0
- data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
- data/spec/integration/partials_function_pointers_spec.rb +277 -0
- data/spec/integration/partials_header_composition_spec.rb +268 -35
- data/spec/integration/partials_macro_decorators_spec.rb +267 -0
- data/spec/integration/partials_module_resolution_spec.rb +33 -23
- data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
- data/spec/integration/path_intake_scenarios_spec.rb +101 -0
- data/spec/integration/path_length_reporting_spec.rb +64 -0
- data/spec/integration/path_scenarios_spec.rb +399 -0
- data/spec/integration/quote_include_isolator_spec.rb +57 -1
- data/spec/integration/report_build_warnings_log_spec.rb +1 -1
- data/spec/integration/report_tests_log_factory_spec.rb +1 -1
- data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
- data/spec/integration/test_executable_manifest_spec.rb +1 -1
- data/spec/integration/test_includes_extractinator_spec.rb +69 -3
- data/spec/integration/test_naming_spec.rb +201 -0
- data/spec/integration/test_source_file_checks_spec.rb +168 -0
- data/spec/integration/tool_executor_spec.rb +1 -1
- data/spec/integration/tool_validator_spec.rb +3 -3
- data/spec/integration/upgrade_docs_spec.rb +84 -0
- data/spec/integration/vendor_copy_transient_io_retry_spec.rb +74 -5
- data/spec/integration/win_long_paths_probe_spec.rb +46 -0
- data/spec/integration/win_path_limit_spec.rb +53 -0
- data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
- data/spec/support/file_tree_helper.rb +88 -0
- data/spec/support/integration/configurator_integration_helper.rb +14 -9
- data/spec/support/integration/dependency_tracker_integration_helper.rb +1 -1
- data/spec/support/integration/partial_files_harness.rb +181 -0
- data/spec/support/integration/partials_generation_integration_helper.rb +239 -143
- data/spec/support/integration/path_scenario_harness.rb +175 -0
- data/spec/support/integration/spec_integration_helper.rb +9 -4
- data/spec/support/integration/test_includes_harness.rb +69 -37
- data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
- data/spec/support/spec_helper.rb +2 -0
- data/spec/support/system/spec_system_helper.rb +7 -6
- data/spec/support/system/system_context.rb +21 -3
- data/spec/support/working_dir_tracking.rb +49 -0
- data/spec/system/build_output_mirroring_spec.rb +2 -2
- data/spec/system/bullseye_deployment_spec.rb +2 -0
- data/spec/system/conditional_mock_includes_spec.rb +1 -1
- data/spec/system/delta_builds_spec.rb +163 -23
- data/spec/system/encoding_stress_spec.rb +4 -4
- data/spec/system/example_wondrous_forest_spec.rb +2 -2
- data/spec/system/gcov_deployment_spec.rb +3 -0
- data/spec/system/header_include_path_validation_spec.rb +4 -4
- data/spec/system/header_search_paths_spec.rb +1083 -0
- data/spec/system/launcher_handoff_spec.rb +82 -0
- data/spec/system/mock_include_folders_spec.rb +212 -0
- data/spec/system/mockable_header_reassembly_spec.rb +184 -0
- data/spec/system/parent_directory_reference_spec.rb +5 -3
- data/spec/system/partials_carry_spec.rb +581 -0
- data/spec/system/partials_delta_builds_spec.rb +280 -0
- data/spec/system/partials_function_pointers_spec.rb +106 -0
- data/spec/system/partials_macro_decorators_spec.rb +127 -0
- data/spec/system/partials_module_disambiguation_spec.rb +125 -0
- data/spec/system/path_handling_probes_spec.rb +196 -0
- data/spec/system/pinned_thread_count_spec.rb +4 -4
- data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
- data/spec/system/preprocessing_parameterized_tests_spec.rb +1 -1
- data/spec/system/rake_release_task_path_disambiguation_spec.rb +6 -6
- data/spec/system/rake_test_task_path_disambiguation_spec.rb +85 -0
- data/spec/system/short_build_paths_spec.rb +87 -0
- data/spec/system/sibling_header_collision_spec.rb +30 -6
- data/spec/system/special_path_characters_spec.rb +86 -0
- data/spec/system/support/bullseye_common_test_cases.rb +42 -0
- data/spec/system/support/common_test_cases.rb +23 -21
- data/spec/system/support/gcov_common_test_cases.rb +37 -9
- data/spec/system/support/gcov_partials_test_cases.rb +48 -0
- data/spec/system/support/sanitize_common_test_cases.rb +2 -2
- data/spec/system/support/valgrind_common_test_cases.rb +12 -12
- data/spec/system/test_build_layout_spec.rb +209 -0
- data/spec/system/test_pipeline_stop_points_spec.rb +4 -4
- data/spec/system/test_runner_system_include_spec.rb +1 -1
- data/spec/system/test_source_file_directive_spec.rb +64 -5
- data/spec/units/bin/actionator_spec.rb +14 -17
- data/spec/units/bin/app_cfg_spec.rb +37 -0
- data/spec/units/bin/cli_handler_spec.rb +282 -6
- data/spec/units/bin/cli_helper_spec.rb +116 -45
- data/spec/units/bin/installation_selector_spec.rb +114 -0
- data/spec/units/bin/launchinator_spec.rb +171 -0
- data/spec/units/bin/path_validator_spec.rb +10 -0
- data/spec/units/bin/versionator_spec.rb +38 -6
- data/spec/units/build_log_writer_spec.rb +57 -0
- data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
- data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
- data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
- data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
- data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
- data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
- data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
- data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
- data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
- data/spec/units/c_identifier_spec.rb +35 -0
- data/spec/units/config/build_root_policy_spec.rb +61 -0
- data/spec/units/config/configurator_builder_spec.rb +61 -6
- data/spec/units/config/configurator_paths_validator_spec.rb +292 -0
- data/spec/units/config/configurator_setup_spec.rb +80 -68
- data/spec/units/config/configurator_spec.rb +54 -6
- data/spec/units/config/configurator_validator_spec.rb +1 -172
- data/spec/units/dependencies/dependency_cache_store_spec.rb +98 -2
- data/spec/units/dependencies/dependency_debug_tree_spec.rb +1 -1
- data/spec/units/dependencies/dependency_hasher_spec.rb +42 -1
- data/spec/units/dependencies/dependency_path_normalizer_spec.rb +1 -1
- data/spec/units/dependencies/dependency_tracker_spec.rb +28 -1
- data/spec/units/dependencies/dependinator_spec.rb +17 -2
- data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
- data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
- data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
- data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
- data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
- data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
- data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
- data/spec/units/encodinator_spec.rb +3 -4
- data/spec/units/filename_extension_spec.rb +11 -0
- data/spec/units/filesystem/build_roots_spec.rb +131 -0
- data/spec/units/filesystem/build_subpath_spec.rb +235 -0
- data/spec/units/filesystem/destination_collision_spec.rb +30 -0
- data/spec/units/{file_finder_helper_spec.rb → filesystem/file_finder_helper_spec.rb} +126 -1
- data/spec/units/filesystem/file_finder_spec.rb +845 -0
- data/spec/units/{file_path_collection_utils_spec.rb → filesystem/file_path_collection_utils_spec.rb} +181 -1
- data/spec/units/{file_path_utils_spec.rb → filesystem/file_path_utils_spec.rb} +435 -185
- data/spec/units/filesystem/file_system_wrapper_spec.rb +33 -0
- data/spec/units/filesystem/file_tree_spec.rb +511 -0
- data/spec/units/filesystem/file_tree_windows_spec.rb +78 -0
- data/spec/units/{file_wrapper_spec.rb → filesystem/file_wrapper_spec.rb} +286 -18
- data/spec/units/{path_matcher_spec.rb → filesystem/path_matcher_spec.rb} +48 -1
- data/spec/units/{path_mirror_spec.rb → filesystem/path_mirror_spec.rb} +32 -4
- data/spec/units/filesystem/project_paths_spec.rb +147 -0
- data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
- data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
- data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
- data/spec/units/filesystem/working_dir_spec.rb +71 -0
- data/spec/units/generators/generator_helper_spec.rb +0 -60
- data/spec/units/generators/generator_mocks_spec.rb +13 -0
- data/spec/units/generators/generator_partials_spec.rb +656 -55
- data/spec/units/generators/generator_spec.rb +38 -6
- data/spec/units/generators/generator_test_results_backtrace_spec.rb +50 -46
- data/spec/units/generators/generator_test_results_spec.rb +1 -1
- data/spec/units/generators/generator_test_runner_spec.rb +9 -5
- data/spec/units/generators/partial_source_writer_spec.rb +129 -0
- data/spec/units/handoff_spec.rb +205 -0
- data/spec/units/includes/header_search_spec.rb +406 -0
- data/spec/units/includes/include_factory_spec.rb +23 -6
- data/spec/units/includes/include_pathinator_spec.rb +118 -8
- data/spec/units/includes/include_spec.rb +14 -0
- data/spec/units/includes/includes_spec.rb +176 -19
- data/spec/units/installation_spec.rb +228 -0
- data/spec/units/library_resolver_spec.rb +157 -0
- data/spec/units/loginator_spec.rb +31 -0
- data/spec/units/mock_locator_spec.rb +275 -6
- data/spec/units/partials/include_groups_spec.rb +42 -0
- data/spec/units/partials/partializer_config_spec.rb +32 -0
- data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
- data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
- data/spec/units/partials/partializer_helper_spec.rb +529 -277
- data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
- data/spec/units/partials/partializer_spec.rb +1579 -270
- data/spec/units/partials/partializer_utils_spec.rb +269 -232
- data/spec/units/partials/partials_rename_spec.rb +160 -0
- data/spec/units/partials_manager_spec.rb +561 -251
- data/spec/units/plugins/bullseye_spec.rb +49 -2
- data/spec/units/plugins/console_reportinator_spec.rb +73 -26
- data/spec/units/plugins/dependencies_spec.rb +33 -7
- data/spec/units/plugins/dependency_spec_spec.rb +17 -0
- data/spec/units/plugins/gcov_spec.rb +28 -3
- data/spec/units/plugins/gcovr_reportinator_spec.rb +19 -47
- data/spec/units/plugins/gcovr_thresholds_spec.rb +95 -0
- data/spec/units/plugins/module_generator_spec.rb +5 -5
- data/spec/units/plugins/report_build_warnings_log_spec.rb +3 -3
- data/spec/units/plugins/report_log_writer_plugin_spec.rb +10 -1
- data/spec/units/plugins/report_tests_raw_output_log_spec.rb +13 -2
- data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +77 -3
- data/spec/units/plugins/reportgenerator_reportinator_spec.rb +52 -4
- data/spec/units/plugins/sanitize_records_spec.rb +3 -1
- data/spec/units/plugins/sanitize_spec.rb +1 -1
- data/spec/units/plugins/valgrind_spec.rb +23 -8
- data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
- data/spec/units/preprocess/preprocessinator_comment_stripper_spec.rb +1 -1
- data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
- data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
- data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
- data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
- data/spec/units/rake_app/rakefile_component_resolver_spec.rb +21 -0
- data/spec/units/release_build_executor_spec.rb +53 -14
- data/spec/units/release_build_planner_spec.rb +15 -3
- data/spec/units/reportinator_spec.rb +5 -5
- data/spec/units/setupinator_spec.rb +51 -0
- data/spec/units/standin_headerinator_spec.rb +55 -9
- data/spec/units/test_build_executor_spec.rb +842 -166
- data/spec/units/test_build_planner_spec.rb +205 -15
- data/spec/units/test_build_setup_spec.rb +179 -30
- data/spec/units/test_context_extractor_spec.rb +36 -2
- data/spec/units/test_derived_search_paths_spec.rb +259 -0
- data/spec/units/test_file_preprocessinator_spec.rb +17 -1
- data/spec/units/test_includes_extractinator_spec.rb +61 -9
- data/spec/units/test_invoker/objects_wiring_spec.rb +24 -4
- data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
- data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
- data/spec/units/test_invoker_spec.rb +14 -1
- data/spec/units/test_invoker_types_spec.rb +8 -7
- data/spec/units/test_pipeline_manager_spec.rb +54 -13
- data/spec/units/test_runner_generatinator_spec.rb +93 -1
- data/spec/units/test_search_paths_spec.rb +73 -5
- data/spec/units/test_source_file_directive_resolver_spec.rb +38 -7
- data/spec/units/tools/default_tools_quoting_spec.rb +117 -0
- data/spec/units/tools/shell_quoting_spec.rb +76 -0
- data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
- data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +27 -1
- data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
- data/spec/units/windows_registry_query_tool_spec.rb +53 -0
- data/spec/units/yaml_wrapper_spec.rb +11 -0
- metadata +265 -36
- data/lib/ceedling/file_finder_helper.rb +0 -127
- data/lib/ceedling/file_path_collection_utils.rb +0 -164
- data/spec/units/file_finder_spec.rb +0 -495
- /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
require 'tmpdir'
|
|
9
|
+
require 'fileutils'
|
|
10
|
+
|
|
11
|
+
repo_root = File.expand_path( '../../..', __dir__ )
|
|
12
|
+
$LOAD_PATH.unshift( File.join( repo_root, 'lib' ), File.join( repo_root, 'vendor/cmock/lib' ) )
|
|
13
|
+
|
|
14
|
+
require 'fff.rb'
|
|
15
|
+
|
|
16
|
+
# GH #1377: A fake gets the extra includes CMock would give a mock of the same header.
|
|
17
|
+
# Each example runs the wrapper Ceedling swaps in for CMock, with Ceedling's own
|
|
18
|
+
# :includes default, and reads back the files it writes.
|
|
19
|
+
describe FffCMockWrapper do
|
|
20
|
+
|
|
21
|
+
around(:each) do |example|
|
|
22
|
+
Dir.mktmpdir do |root|
|
|
23
|
+
@root = root
|
|
24
|
+
@header = File.join( root, 'src', 'bar.h' )
|
|
25
|
+
FileUtils.mkdir_p( File.dirname( @header ) )
|
|
26
|
+
File.write( @header, "void bar_turn_on(void);\n" )
|
|
27
|
+
example.run
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def fake(options = {})
|
|
32
|
+
mock_path = File.join( @root, 'mocks' )
|
|
33
|
+
config = { :mock_prefix => 'mock_', :mock_path => mock_path, :includes => [], :verbosity => 0 }
|
|
34
|
+
FffCMockWrapper.new( config.merge( options ) ).setup_mocks( @header )
|
|
35
|
+
return {
|
|
36
|
+
:h => File.readlines( File.join( mock_path, 'mock_bar.h' ), chomp: true ),
|
|
37
|
+
:c => File.readlines( File.join( mock_path, 'mock_bar.c' ), chomp: true )
|
|
38
|
+
}
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def position(lines, line)
|
|
42
|
+
index = lines.index( line )
|
|
43
|
+
expect( index ).not_to be_nil, "expected #{line.inspect} in:\n#{lines.join( "\n" )}"
|
|
44
|
+
return index
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def extra_includes(lines)
|
|
48
|
+
standard = ['#include <string.h>', '#include "fff.h"', '#include "fff_unity_helper.h"', '#include "bar.h"', '#include "mock_bar.h"']
|
|
49
|
+
return lines.grep( /\A#include / ) - standard
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# A search path may reach the header only through the folder the fake's own #include names
|
|
53
|
+
it 'includes the original header by the folder its #include names, as CMock does' do
|
|
54
|
+
mock_path = File.join( @root, 'mocks' )
|
|
55
|
+
FffCMockWrapper.new( { :mock_prefix => 'mock_', :mock_path => mock_path, :includes => [], :verbosity => 0 } ).setup_mocks( @header, 'drivers' )
|
|
56
|
+
|
|
57
|
+
expect( File.readlines( File.join( mock_path, 'drivers', 'mock_bar.h' ), chomp: true ) ).to include( '#include "drivers/bar.h"' )
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# Ceedling gives the text a search path listing the header's own directory reaches it by
|
|
61
|
+
it 'includes the original header by the text Ceedling gives in place of its folder' do
|
|
62
|
+
mock_path = File.join( @root, 'mocks' )
|
|
63
|
+
config = { :mock_prefix => 'mock_', :mock_path => mock_path, :includes => [], :verbosity => 0, :orig_header_include => 'bar.h' }
|
|
64
|
+
FffCMockWrapper.new( config ).setup_mocks( @header, 'drivers' )
|
|
65
|
+
|
|
66
|
+
lines = File.readlines( File.join( mock_path, 'drivers', 'mock_bar.h' ), chomp: true )
|
|
67
|
+
expect( lines ).to include( '#include "bar.h"' )
|
|
68
|
+
expect( lines ).not_to include( '#include "drivers/bar.h"' )
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# CMock writes the header's inline-free text beside a mock under :treat_inlines :include, and
|
|
72
|
+
# the mock's #include reaches that copy in place of the header's inline definitions
|
|
73
|
+
context 'with a header holding an inline function' do
|
|
74
|
+
before(:each) do
|
|
75
|
+
File.write( @header, "static inline int bar_peek(void) { return 7; }\nvoid bar_turn_on(void);\n" )
|
|
76
|
+
@mock_path = File.join( @root, 'mocks' )
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def fake_in(folder, options)
|
|
80
|
+
config = { :mock_prefix => 'mock_', :mock_path => @mock_path, :includes => [], :verbosity => 0 }
|
|
81
|
+
FffCMockWrapper.new( config.merge( options ) ).setup_mocks( @header, folder )
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
it 'writes the header without its inline bodies beside the fake under :treat_inlines :include' do
|
|
85
|
+
fake_in( 'drivers', :treat_inlines => :include )
|
|
86
|
+
|
|
87
|
+
copy = File.read( File.join( @mock_path, 'drivers', 'bar.h' ) )
|
|
88
|
+
expect( copy ).to include( 'int bar_peek(void);' )
|
|
89
|
+
expect( copy ).not_to include( 'return 7' )
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'writes no copy of the header under :treat_inlines :exclude' do
|
|
93
|
+
fake_in( 'drivers', :treat_inlines => :exclude )
|
|
94
|
+
|
|
95
|
+
expect( File.exist?( File.join( @mock_path, 'drivers', 'bar.h' ) ) ).to be false
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# CMock names a mock by the header's own extension, as `mock_foox.hpp` and `mock_foox.c`
|
|
100
|
+
def use_hpp_header
|
|
101
|
+
@header = File.join( @root, 'src', 'drivers', 'foox.hpp' )
|
|
102
|
+
@mock_path = File.join( @root, 'mocks' )
|
|
103
|
+
FileUtils.mkdir_p( File.dirname( @header ) )
|
|
104
|
+
File.write( @header, "static inline int foox_peek(void) { return 7; }\nint foox_read(void);\n" )
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def fake_hpp(options = {})
|
|
108
|
+
config = { :mock_prefix => 'mock_', :mock_path => @mock_path, :includes => [], :verbosity => 0 }
|
|
109
|
+
FffCMockWrapper.new( config.merge( options ) ).setup_mocks( @header, 'drivers' )
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def written(name)
|
|
113
|
+
return File.readlines( File.join( @mock_path, 'drivers', name ), chomp: true )
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
context 'with a header whose extension is not .h, the fake\'s files' do
|
|
117
|
+
before(:each) { use_hpp_header }
|
|
118
|
+
|
|
119
|
+
it 'are the mock\'s name with the header\'s extension and with .c' do
|
|
120
|
+
fake_hpp
|
|
121
|
+
|
|
122
|
+
expect( Dir.children( File.join( @mock_path, 'drivers' ) ).sort ).to eq( ['mock_foox.c', 'mock_foox.hpp'] )
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it 'include the fake\'s header from the source by its own name' do
|
|
126
|
+
fake_hpp
|
|
127
|
+
|
|
128
|
+
expect( written( 'mock_foox.c' ) ).to include( '#include "mock_foox.hpp"' )
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it 'include the original header by the folder its #include names and its own name' do
|
|
132
|
+
fake_hpp
|
|
133
|
+
|
|
134
|
+
expect( written( 'mock_foox.hpp' ) ).to include( '#include "drivers/foox.hpp"' )
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it 'include the original header by the text Ceedling gives in place of its folder' do
|
|
138
|
+
fake_hpp( :orig_header_include => 'foox.hpp' )
|
|
139
|
+
|
|
140
|
+
expect( written( 'mock_foox.hpp' ) ).to include( '#include "foox.hpp"' )
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
context 'with a header whose extension is not .h, the fake\'s names and copy' do
|
|
145
|
+
before(:each) { use_hpp_header }
|
|
146
|
+
|
|
147
|
+
it 'name the guard and control functions by the mock\'s name' do
|
|
148
|
+
fake_hpp
|
|
149
|
+
|
|
150
|
+
expect( written( 'mock_foox.hpp' ) ).to include( '#ifndef mock_foox_H', 'void mock_foox_Init(void);' )
|
|
151
|
+
expect( written( 'mock_foox.c' ) ).to include( 'void mock_foox_Init(void)' )
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
it 'name the guard and control functions by the folder under :mock_name_include_folder' do
|
|
155
|
+
fake_hpp( :mock_name_include_folder => true )
|
|
156
|
+
|
|
157
|
+
expect( written( 'mock_foox.hpp' ) ).to include( '#ifndef drivers_mock_foox_H', 'void drivers_mock_foox_Init(void);' )
|
|
158
|
+
expect( written( 'mock_foox.c' ) ).to include( 'void drivers_mock_foox_Init(void)' )
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
it 'write the header\'s copy as drivers/foox.hpp under :treat_inlines :include' do
|
|
162
|
+
fake_hpp( :treat_inlines => :include )
|
|
163
|
+
|
|
164
|
+
copy = File.read( File.join( @mock_path, 'drivers', 'foox.hpp' ) )
|
|
165
|
+
expect( copy ).to include( 'int foox_peek(void);' )
|
|
166
|
+
expect( copy ).not_to include( 'return 7' )
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it 'are named at verbose' do
|
|
170
|
+
path = File.join( @mock_path, 'drivers', 'mock_foox' )
|
|
171
|
+
|
|
172
|
+
expect { fake_hpp( :verbosity => 3 ) }.to output(
|
|
173
|
+
"Creating fake functions for foox...\n" \
|
|
174
|
+
"Creating fake functions: #{path}.hpp and #{path}.c\n"
|
|
175
|
+
).to_stdout
|
|
176
|
+
end
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# A name with dots is sanitized to a C identifier, with or without a folder
|
|
180
|
+
it 'forms a C name for a dotted module name with no folder' do
|
|
181
|
+
wrapper = FffCMockWrapper.new( { :mock_prefix => 'mock_', :mock_path => @root, :includes => [], :verbosity => 0 } )
|
|
182
|
+
|
|
183
|
+
expect( wrapper.c_name_for( 'mock_Sensor.44', nil ) ).to eq( 'mock_Sensor_44' )
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
it 'adds no includes when no setting names any' do
|
|
187
|
+
files = fake
|
|
188
|
+
|
|
189
|
+
expect( extra_includes( files[:h] ) ).to eq( [] )
|
|
190
|
+
expect( extra_includes( files[:c] ) ).to eq( [] )
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
it 'includes :includes_c_pre_header in the source before the fake header' do
|
|
194
|
+
files = fake( :includes_c_pre_header => ['extra_c.h'] )
|
|
195
|
+
|
|
196
|
+
expect( position( files[:c], '#include "extra_c.h"' ) ).to be < position( files[:c], '#include "mock_bar.h"' )
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it 'includes :includes_c_post_header in the source after the fake header' do
|
|
200
|
+
files = fake( :includes_c_post_header => ['extra_c.h'] )
|
|
201
|
+
|
|
202
|
+
expect( position( files[:c], '#include "extra_c.h"' ) ).to be > position( files[:c], '#include "mock_bar.h"' )
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it 'includes :includes_h_pre_orig_header in the header before the original header' do
|
|
206
|
+
files = fake( :includes_h_pre_orig_header => ['extra_h.h'] )
|
|
207
|
+
|
|
208
|
+
expect( position( files[:h], '#include "extra_h.h"' ) ).to be < position( files[:h], '#include "bar.h"' )
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
it 'includes :includes_h_post_orig_header in the header after the original header' do
|
|
212
|
+
files = fake( :includes_h_post_orig_header => ['extra_h.h'] )
|
|
213
|
+
|
|
214
|
+
expect( position( files[:h], '#include "extra_h.h"' ) ).to be > position( files[:h], '#include "bar.h"' )
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
it 'merges :includes with :includes_h_pre_orig_header, :includes first, each once' do
|
|
218
|
+
files = fake( :includes => ['first.h', 'both.h'], :includes_h_pre_orig_header => ['both.h', 'second.h'] )
|
|
219
|
+
|
|
220
|
+
expect( extra_includes( files[:h] ) ).to eq( ['#include "first.h"', '#include "both.h"', '#include "second.h"'] )
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
it 'keeps an angle-bracket include as written and quotes a bare name' do
|
|
224
|
+
files = fake( :includes_c_pre_header => ['<stdint.h>', 'extra_c.h'] )
|
|
225
|
+
|
|
226
|
+
expect( extra_includes( files[:c] ) ).to eq( ['#include <stdint.h>', '#include "extra_c.h"'] )
|
|
227
|
+
end
|
|
228
|
+
|
|
229
|
+
it 'includes a Unity helper in the source after the fake header, by its path from the mock root' do
|
|
230
|
+
helper = File.join( @root, 'support', 'helper.h' )
|
|
231
|
+
FileUtils.mkdir_p( File.dirname( helper ) )
|
|
232
|
+
File.write( helper, "\n" )
|
|
233
|
+
|
|
234
|
+
files = fake( :unity_helper_path => [helper] )
|
|
235
|
+
|
|
236
|
+
expect( position( files[:c], '#include "../support/helper.h"' ) ).to be > position( files[:c], '#include "mock_bar.h"' )
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
# CMock's :verbosity levels: 0 errors only, 1 warnings, 2 normal, 3 verbose
|
|
240
|
+
context 'at CMock\'s verbosity levels' do
|
|
241
|
+
|
|
242
|
+
it 'prints nothing for errors only or warnings' do
|
|
243
|
+
expect { fake( :verbosity => 0 ) }.not_to output.to_stdout
|
|
244
|
+
expect { fake( :verbosity => 1 ) }.not_to output.to_stdout
|
|
245
|
+
end
|
|
246
|
+
|
|
247
|
+
it 'announces each fake at normal verbosity, as CMock announces each mock' do
|
|
248
|
+
expect { fake( :verbosity => 2 ) }.to output( "Creating fake functions for bar...\n" ).to_stdout
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
it 'also names the files written at verbose' do
|
|
252
|
+
path = File.join( @root, 'mocks', 'mock_bar' )
|
|
253
|
+
|
|
254
|
+
expect { fake( :verbosity => 3 ) }.to output(
|
|
255
|
+
"Creating fake functions for bar...\n" \
|
|
256
|
+
"Creating fake functions: #{path}.h and #{path}.c\n"
|
|
257
|
+
).to_stdout
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
end
|
|
261
|
+
|
|
262
|
+
end
|
|
@@ -27,6 +27,15 @@ describe "FffMockGenerator.create_mock_header" do
|
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
context "when given the text it includes the original header by," do
|
|
31
|
+
let(:mock_header) {
|
|
32
|
+
FffMockGenerator.create_mock_header("config", "mock_config", {}, header_include: "drivers/uart/config.h")
|
|
33
|
+
}
|
|
34
|
+
it "then the original header is included by that text" do
|
|
35
|
+
expect(mock_header).to include(%{#include "drivers/uart/config.h"\n})
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
30
39
|
context "when there is nothing to mock," do
|
|
31
40
|
let(:mock_header) {
|
|
32
41
|
parsed_header = {}
|
|
@@ -25,6 +25,26 @@ describe "FffMockGenerator.create_mock_source" do
|
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
# A fake's header takes the original header's extension, which the source includes it by
|
|
29
|
+
context "when given a mock header name," do
|
|
30
|
+
it "then it includes that name in place of the mock's name with .h" do
|
|
31
|
+
mock_source = FffMockGenerator.create_mock_source("mock_foox", {}, mock_header: "mock_foox.hpp")
|
|
32
|
+
|
|
33
|
+
expect(mock_source).to include(%{#include "mock_foox.hpp"\n})
|
|
34
|
+
expect(mock_source).not_to include(%{#include "mock_foox.h"\n})
|
|
35
|
+
end
|
|
36
|
+
it "then the control functions still take the mock's name" do
|
|
37
|
+
mock_source = FffMockGenerator.create_mock_source("mock_foox", {}, mock_header: "mock_foox.hpp")
|
|
38
|
+
|
|
39
|
+
expect(mock_source).to include("void mock_foox_Init(void)\n")
|
|
40
|
+
end
|
|
41
|
+
it "then, when given none, it includes the mock's name with .h" do
|
|
42
|
+
mock_source = FffMockGenerator.create_mock_source("mock_foox", {})
|
|
43
|
+
|
|
44
|
+
expect(mock_source).to include(%{#include "mock_foox.h"\n})
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
28
48
|
context "when there is nothing to mock," do
|
|
29
49
|
let(:mock_source) {
|
|
30
50
|
parsed_header = {}
|
|
@@ -41,7 +41,7 @@ DEFAULT_GCOV_LINKER_TOOL = {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
DEFAULT_GCOV_FIXTURE_TOOL = {
|
|
44
|
-
:executable => '${1}'.freeze,
|
|
44
|
+
:executable => '"${1}"'.freeze, # Test executable, quoted as a path
|
|
45
45
|
:name => 'default_gcov_fixture'.freeze,
|
|
46
46
|
:optional => false.freeze,
|
|
47
47
|
:arguments => [].freeze
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
# =========================================================================
|
|
7
7
|
|
|
8
8
|
require 'ceedling/constants'
|
|
9
|
-
require 'ceedling/path_mirror'
|
|
9
|
+
require 'ceedling/filesystem/path_mirror'
|
|
10
10
|
require 'gcov_reportinator'
|
|
11
11
|
|
|
12
12
|
class ConsoleReportinator < GcovReportinator
|
|
@@ -41,11 +41,12 @@ class ConsoleReportinator < GcovReportinator
|
|
|
41
41
|
# reported under is gcov's own where it could be parsed -- for a Partial that is the
|
|
42
42
|
# original module, which #line directives remap it to -- and the queried source
|
|
43
43
|
# otherwise.
|
|
44
|
-
|
|
44
|
+
replaced = partial_replacements( sources )
|
|
45
|
+
reports = remap_partial_sources( sources ).filter_map do |source|
|
|
45
46
|
results = run_gcov_summary( test, source, opts )
|
|
46
47
|
next if results.nil?
|
|
47
48
|
|
|
48
|
-
gcov_source = extract_gcov_source_path( results, test, source )
|
|
49
|
+
gcov_source = extract_gcov_source_path( results, test, source, original: replaced[source]&.first )
|
|
49
50
|
|
|
50
51
|
{ source: source, results: results, gcov_source: gcov_source }
|
|
51
52
|
end
|
|
@@ -124,26 +125,27 @@ class ConsoleReportinator < GcovReportinator
|
|
|
124
125
|
# drop every same-named module, and one nobody Partialized would lose its coverage
|
|
125
126
|
# report entirely.
|
|
126
127
|
def remap_partial_sources(sources)
|
|
127
|
-
|
|
128
|
-
|
|
128
|
+
return sources - partial_replacements( sources ).values.flatten
|
|
129
|
+
end
|
|
129
130
|
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
# Each Partial among the sources, keyed to the original sources it replaces
|
|
132
|
+
def partial_replacements(sources)
|
|
133
|
+
partials, originals = sources.partition { |s| File.basename(s).match?(PATTERNS::PARTIAL_IMPL_FILENAME) }
|
|
132
134
|
|
|
133
|
-
partials.
|
|
134
|
-
|
|
135
|
+
return partials.to_h { |partial| [partial, replaced_sources( partial, originals )] }
|
|
136
|
+
end
|
|
135
137
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
+
def replaced_sources(partial, originals)
|
|
139
|
+
query = partial_module_segments( partial )
|
|
138
140
|
|
|
139
|
-
|
|
141
|
+
scored = originals.map { |source| [source, common_suffix_length( query, source_segments( source ) )] }
|
|
142
|
+
.reject { |_source, length| length.zero? }
|
|
140
143
|
|
|
141
|
-
|
|
144
|
+
return [] if scored.empty?
|
|
142
145
|
|
|
143
|
-
|
|
144
|
-
end
|
|
146
|
+
best = scored.map { |_source, length| length }.max
|
|
145
147
|
|
|
146
|
-
return
|
|
148
|
+
return scored.select { |_source, length| length == best }.map(&:first)
|
|
147
149
|
end
|
|
148
150
|
|
|
149
151
|
# The module a generated Partial replaces, as path segments. The reversal itself belongs
|
|
@@ -173,22 +175,8 @@ class ConsoleReportinator < GcovReportinator
|
|
|
173
175
|
def run_gcov_summary(test, source, opts)
|
|
174
176
|
filename = File.basename(source)
|
|
175
177
|
|
|
176
|
-
#
|
|
177
|
-
|
|
178
|
-
# compile step already follows -- so the directory gcov is told to search must include that
|
|
179
|
-
# mirrored subdirectory too, not just the flat <build>/gcov/out/<test name> root.
|
|
180
|
-
# A generated Partial sits below its own test's Partials build root rather than a
|
|
181
|
-
# configured source root, so the source roots mirror nothing for it. Its own root is
|
|
182
|
-
# what carries the module's subdirectory.
|
|
183
|
-
roots =
|
|
184
|
-
if File.basename(source).match?(PATTERNS::PARTIAL_IMPL_FILENAME)
|
|
185
|
-
[File.join( @configurator.project_test_partials_path, test )]
|
|
186
|
-
else
|
|
187
|
-
@configurator.paths_source + @configurator.paths_support
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
subdir = PathMirror.relative_subdir( source, roots )
|
|
191
|
-
obj_dir = subdir.empty? ? File.join(GCOV_BUILD_OUTPUT_PATH, test) : File.join(GCOV_BUILD_OUTPUT_PATH, test, subdir)
|
|
178
|
+
# The coverage data sits beside the object, wherever the test's build placed it
|
|
179
|
+
obj_dir = File.dirname( @file_path_utils.form_test_object_filepath( source, name: test, context: GCOV_SYM ) )
|
|
192
180
|
|
|
193
181
|
# Run gcov to extract the coverage summary
|
|
194
182
|
command = @tool_executor.build_command_line(
|
|
@@ -197,7 +185,7 @@ class ConsoleReportinator < GcovReportinator
|
|
|
197
185
|
(opts[:gcov_mcdc] ? ['-g'] : []),
|
|
198
186
|
# Argument replacement
|
|
199
187
|
filename, # .c source file compiled with coverage
|
|
200
|
-
obj_dir # <build>/gcov/out/<test name
|
|
188
|
+
obj_dir # <build>/gcov/out/<test name>/_t_[/source directory] for coverage data files
|
|
201
189
|
)
|
|
202
190
|
|
|
203
191
|
# Do not raise an exception if `gcov` terminates with a non-zero exit code, just note it and move on.
|
|
@@ -231,13 +219,17 @@ class ConsoleReportinator < GcovReportinator
|
|
|
231
219
|
results
|
|
232
220
|
end
|
|
233
221
|
|
|
234
|
-
|
|
235
|
-
|
|
222
|
+
# A Partial's #line directives attribute its coverage to every file its code came from. That
|
|
223
|
+
# includes the module source it replaces and any header whose helpers or inline function
|
|
224
|
+
# bodies it carries. The module source is the one to report, so a Partial matches on the
|
|
225
|
+
# exact filename of the original it replaces.
|
|
226
|
+
def extract_gcov_source_path(results, test, source, original: nil)
|
|
227
|
+
matches = results.match(/File\s+'((?:[^']*[\/\\])?#{Regexp.escape(File.basename(original))})'/) if original
|
|
236
228
|
|
|
237
229
|
# Prefer the File header that specifically matches the queried source filename.
|
|
238
230
|
# gcov may list instrumented system headers (e.g. _stdio.h pulled in via FILE*)
|
|
239
231
|
# before the actual source file, so the first File entry is not always correct.
|
|
240
|
-
matches
|
|
232
|
+
matches ||= results.match(/File\s+'([^']*#{Regexp.escape(File.basename(source, '.*'))}[^']*)'/)
|
|
241
233
|
|
|
242
234
|
# Fall back to the first File header for Partial implementations: their #line
|
|
243
235
|
# directives remap gcov output to the original module name, so the Partial
|
data/plugins/gcov/lib/gcov.rb
CHANGED
|
@@ -12,6 +12,7 @@ require 'gcov_constants'
|
|
|
12
12
|
require 'gcov_types'
|
|
13
13
|
require 'gcov_reportinator'
|
|
14
14
|
require 'console_reportinator'
|
|
15
|
+
require 'gcovr_thresholds'
|
|
15
16
|
require 'gcovr_reportinator'
|
|
16
17
|
require 'reportgenerator_reportinator'
|
|
17
18
|
|
|
@@ -141,7 +142,7 @@ class Gcov < Plugin
|
|
|
141
142
|
|
|
142
143
|
# Full filepaths (not basenames)
|
|
143
144
|
header = "Untested source files not in the coverage report (:untested_sources is :list):"
|
|
144
|
-
@loginator.log_list( untested_sources.sort, header, Verbosity::COMPLAIN
|
|
145
|
+
@loginator.log_list( untested_sources.sort, header, Verbosity::COMPLAIN )
|
|
145
146
|
|
|
146
147
|
when GCOV_UNTESTED_SOURCES_COMPILE
|
|
147
148
|
validate_mcdc_gcc_version!
|
|
@@ -163,7 +164,7 @@ class Gcov < Plugin
|
|
|
163
164
|
untested_sources.each do |filepath|
|
|
164
165
|
filename = File.basename(filepath)
|
|
165
166
|
object = @file_path_utils.form_test_object_filepath( filepath, context:GCOV_SYM )
|
|
166
|
-
dependencies = @file_path_utils.form_test_dependencies_filepath(
|
|
167
|
+
dependencies = @file_path_utils.form_test_dependencies_filepath( object, context:GCOV_SYM )
|
|
167
168
|
search_paths = @configurator.collection_paths_include
|
|
168
169
|
# Defines and flags resolve as a tested source's do, against this source's filepath
|
|
169
170
|
defines = @test_build_setup.context_defines( context:GCOV_SYM, filepath:filepath )
|
|
@@ -196,6 +197,9 @@ class Gcov < Plugin
|
|
|
196
197
|
next
|
|
197
198
|
end
|
|
198
199
|
|
|
200
|
+
@file_wrapper.mkdir( File.dirname( object ) )
|
|
201
|
+
@file_wrapper.mkdir( File.dirname( dependencies ) )
|
|
202
|
+
|
|
199
203
|
begin
|
|
200
204
|
@generator.generate_object_file_c(
|
|
201
205
|
tool: TOOLS_GCOV_COMPILER,
|
|
@@ -382,6 +386,9 @@ class Gcov < Plugin
|
|
|
382
386
|
|
|
383
387
|
begin
|
|
384
388
|
reportinator.generate_reports( @configurator.project_config_hash )
|
|
389
|
+
rescue GcovrThresholdError => ex
|
|
390
|
+
# Each violated threshold is its own build failure
|
|
391
|
+
ex.violations.each { |violation| @ceedling[:plugin_manager].register_build_failure( GCOV_SYM, violation ) }
|
|
385
392
|
rescue => ex
|
|
386
393
|
# Register the exception as a build failure
|
|
387
394
|
@ceedling[:plugin_manager].register_build_failure( GCOV_SYM, ex.message )
|
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
|
|
8
8
|
require 'ceedling/exceptions'
|
|
9
9
|
require 'ceedling/constants'
|
|
10
|
+
require 'ceedling/filename_extension'
|
|
10
11
|
require 'gcov_types'
|
|
11
12
|
require 'gcov_reportinator'
|
|
13
|
+
require 'gcovr_thresholds'
|
|
12
14
|
|
|
13
15
|
class GcovrReportinator < GcovReportinator
|
|
14
16
|
|
|
@@ -507,9 +509,8 @@ class GcovrReportinator < GcovReportinator
|
|
|
507
509
|
data = build_exclusion_data
|
|
508
510
|
patterns = []
|
|
509
511
|
|
|
510
|
-
# A source extension can be configured as more than one string, so
|
|
511
|
-
|
|
512
|
-
src_extension_alternation = data[:src_extension].to_a.map { |ext| Regexp.escape(ext) }.join('|')
|
|
512
|
+
# A source extension can be configured as more than one string, so any one of them matches
|
|
513
|
+
src_extension_alternation = FilenameExtension.new( data[:src_extension] ).pattern
|
|
513
514
|
test_prefix = Regexp.escape(data[:test_prefix].to_s)
|
|
514
515
|
build_root = Regexp.escape(strip_leading_dot_slash(data[:build_root].to_s))
|
|
515
516
|
|
|
@@ -576,23 +577,6 @@ class GcovrReportinator < GcovReportinator
|
|
|
576
577
|
end
|
|
577
578
|
|
|
578
579
|
|
|
579
|
-
# Returns the error message text from gcovr stderr, or nil if none found.
|
|
580
|
-
# Matches lines beginning with "error" or "(ERROR)" and extracts the trailing message.
|
|
581
|
-
def extract_gcovr_error_message(shell_result)
|
|
582
|
-
return nil if shell_result.nil?
|
|
583
|
-
|
|
584
|
-
stderr = shell_result[:stderr]
|
|
585
|
-
return nil if stderr.nil? || stderr.empty?
|
|
586
|
-
|
|
587
|
-
stderr.each_line do |line|
|
|
588
|
-
match = line.match( /^\(?error\S*\s+(.+)/i )
|
|
589
|
-
return match[1].strip.capitalize if match
|
|
590
|
-
end
|
|
591
|
-
|
|
592
|
-
nil
|
|
593
|
-
end
|
|
594
|
-
|
|
595
|
-
|
|
596
580
|
# Extract the last contiguous block of lines containing '%' from gcovr stdout.
|
|
597
581
|
# gcovr --print-summary emits lines like "lines: 69.6% (80 out of 115)" — this
|
|
598
582
|
# locates that block generically without depending on exact line labels.
|
|
@@ -620,33 +604,17 @@ class GcovrReportinator < GcovReportinator
|
|
|
620
604
|
end
|
|
621
605
|
|
|
622
606
|
|
|
623
|
-
#
|
|
624
|
-
#
|
|
625
|
-
# gcovr's composite exit code bit-ORs every violated :fail_under_* threshold together --
|
|
626
|
-
# every violated bit is collected and reported, not just whichever is checked first.
|
|
607
|
+
# Reports every :fail_under_* threshold a gcovr run violated, raising when boom is set and
|
|
608
|
+
# logging otherwise. Returns whether the exit code holds a problem no threshold explains.
|
|
627
609
|
def gcovr_exec_exception?(opts, exitcode, boom, shell_result=nil)
|
|
628
|
-
violations =
|
|
629
|
-
|
|
630
|
-
{
|
|
631
|
-
2 => [:fail_under_line, 'Line'],
|
|
632
|
-
4 => [:fail_under_branch, 'Branch'],
|
|
633
|
-
8 => [:fail_under_decision, 'Decision'],
|
|
634
|
-
16 => [:fail_under_function, 'Function'],
|
|
635
|
-
}.each do |bit, (option, label)|
|
|
636
|
-
next unless ((exitcode & bit) == bit) && !opts[option].nil?
|
|
637
|
-
|
|
638
|
-
fallback = "#{label} coverage is less than the configured minimum of #{opts[option]}%"
|
|
639
|
-
violations << "Gcovr ⏩️ #{extract_gcovr_error_message( shell_result ) || fallback}"
|
|
640
|
-
exitcode &= ~bit
|
|
641
|
-
end
|
|
610
|
+
violations, exitcode = GcovrThresholds.decode( opts: opts, exitcode: exitcode, stderr: shell_result&.dig( :stderr ) )
|
|
642
611
|
|
|
643
612
|
if boom
|
|
644
|
-
raise
|
|
613
|
+
raise GcovrThresholdError.new( violations ) unless violations.empty?
|
|
645
614
|
else
|
|
646
615
|
violations.each { |msg| @loginator.log( msg, Verbosity::COMPLAIN ) }
|
|
647
616
|
end
|
|
648
617
|
|
|
649
|
-
# A non-zero exit code is a problem
|
|
650
618
|
return (exitcode != 0)
|
|
651
619
|
end
|
|
652
620
|
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
require 'ceedling/exceptions'
|
|
9
|
+
|
|
10
|
+
# Coverage thresholds a gcovr run violated, one message each
|
|
11
|
+
class GcovrThresholdError < CeedlingException
|
|
12
|
+
|
|
13
|
+
attr_reader :violations
|
|
14
|
+
|
|
15
|
+
def initialize(violations)
|
|
16
|
+
@violations = violations
|
|
17
|
+
super( violations.join( "\n" ) )
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Decodes gcovr's exit status and stderr into the :fail_under_* thresholds a run violated.
|
|
23
|
+
# Each violated threshold sets a bit of the exit status and writes a line of its own to
|
|
24
|
+
# stderr. Bit 8 covers both condition and decision coverage, which from gcovr 8.7 may
|
|
25
|
+
# each write a line.
|
|
26
|
+
module GcovrThresholds
|
|
27
|
+
|
|
28
|
+
BITS = {
|
|
29
|
+
2 => { option: :fail_under_line, label: 'Line', kinds: ['line'] },
|
|
30
|
+
4 => { option: :fail_under_branch, label: 'Branch', kinds: ['branch'] },
|
|
31
|
+
8 => { option: :fail_under_decision, label: 'Condition or decision', kinds: ['condition', 'decision'] },
|
|
32
|
+
16 => { option: :fail_under_function, label: 'Function', kinds: ['function'] },
|
|
33
|
+
}.freeze
|
|
34
|
+
|
|
35
|
+
MESSAGE_PATTERN = /^\(?error\)?:?\s+(failed minimum (\w+) coverage.*?)\s*$/i
|
|
36
|
+
|
|
37
|
+
# Returns the violation messages, and the exit status bits no configured threshold explains
|
|
38
|
+
def self.decode(opts:, exitcode:, stderr:)
|
|
39
|
+
messages = messages_by_kind( stderr )
|
|
40
|
+
violations = []
|
|
41
|
+
|
|
42
|
+
BITS.each do |bit, threshold|
|
|
43
|
+
next unless (exitcode & bit) == bit && !opts[threshold[:option]].nil?
|
|
44
|
+
|
|
45
|
+
violations.concat( violations_for( threshold, opts, messages ) )
|
|
46
|
+
exitcode &= ~bit
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return violations, exitcode
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# gcovr's own messages, grouped by the coverage kind each names. Older gcovr writes them in
|
|
53
|
+
# lowercase, so the first letter is capitalized, and nothing else is touched.
|
|
54
|
+
def self.messages_by_kind(stderr)
|
|
55
|
+
messages = Hash.new { |hash, kind| hash[kind] = [] }
|
|
56
|
+
|
|
57
|
+
stderr.to_s.each_line do |line|
|
|
58
|
+
match = line.match( MESSAGE_PATTERN )
|
|
59
|
+
messages[match[2].downcase] << match[1].sub( /\A./ ) { |first| first.upcase } if match
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
return messages
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def self.violations_for(threshold, opts, messages)
|
|
66
|
+
found = threshold[:kinds].flat_map { |kind| messages[kind] }
|
|
67
|
+
found = ["#{threshold[:label]} coverage is less than the configured minimum of #{opts[threshold[:option]]}%"] if found.empty?
|
|
68
|
+
|
|
69
|
+
return found.map { |message| "Gcovr ⏩️ #{message}" }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
private_class_method :messages_by_kind, :violations_for
|
|
73
|
+
|
|
74
|
+
end
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
require 'benchmark'
|
|
9
9
|
require 'ceedling/constants'
|
|
10
10
|
require 'ceedling/exceptions'
|
|
11
|
-
require 'ceedling/file_path_utils'
|
|
11
|
+
require 'ceedling/filesystem/file_path_utils'
|
|
12
12
|
require 'gcov_reportinator'
|
|
13
13
|
|
|
14
14
|
class ReportGeneratorReportinator < GcovReportinator
|
|
@@ -276,7 +276,8 @@ class ReportGeneratorReportinator < GcovReportinator
|
|
|
276
276
|
# filter_map drops empty dirs so Batchinator never queues no-op work items.
|
|
277
277
|
work_items = gcno_dirs.filter_map do |gcno_dir|
|
|
278
278
|
files = @file_wrapper.directory_listing(File.join(gcno_dir, "*#{EXTENSION_GCNO}"))
|
|
279
|
-
|
|
279
|
+
# Patterns are written against build paths as they would read with no root shortened
|
|
280
|
+
.reject { |f| gcno_exclude_regex && @ceedling[:file_path_utils].expanded_build_path( f ) =~ gcno_exclude_regex }
|
|
280
281
|
# Sort to process non-partial source files before their partial counterparts.
|
|
281
282
|
# Processing the coverage compiled version of the original source creates .gcov
|
|
282
283
|
# files for more than the partial does (primarily header files),
|