ceedling 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/GIT_COMMIT_SHA +1 -1
- data/README.md +1 -1
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.c +7 -0
- data/assets/fixtures/tests_with_partials_coverage/src/private_macro.h +5 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.c +13 -0
- data/assets/fixtures/tests_with_partials_coverage/src/tally.h +4 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_private_macro.c +10 -0
- data/assets/fixtures/tests_with_partials_coverage/test/test_tally.c +9 -0
- data/docs/BreakingChanges.md +16 -0
- data/docs/Changelog.md +71 -0
- data/docs/KnownIssues.md +91 -4
- data/examples/wondrous_forest/README.md +29 -1
- data/examples/wondrous_forest/src/ForestUnits.h +23 -0
- data/examples/wondrous_forest/src/RainGauge.c +59 -0
- data/examples/wondrous_forest/src/RainGauge.h +39 -0
- data/examples/wondrous_forest/src/RainTipIsr.c +17 -0
- data/examples/wondrous_forest/src/RainTipIsr.h +14 -0
- data/examples/wondrous_forest/test/TestRainGauge.c +126 -0
- data/lib/ceedling/c_extractor/README.md +15 -7
- data/lib/ceedling/c_extractor/c_extractor.rb +25 -14
- data/lib/ceedling/c_extractor/c_extractor_code_text.rb +84 -54
- data/lib/ceedling/c_extractor/c_extractor_constants.rb +18 -7
- data/lib/ceedling/c_extractor/c_extractor_declarations.rb +319 -283
- data/lib/ceedling/c_extractor/c_extractor_declarator.rb +285 -0
- data/lib/ceedling/c_extractor/c_extractor_defined_type.rb +111 -0
- data/lib/ceedling/c_extractor/c_extractor_definitions.rb +174 -121
- data/lib/ceedling/c_extractor/c_extractor_functions.rb +191 -162
- data/lib/ceedling/c_extractor/c_extractor_preprocessing.rb +46 -55
- data/lib/ceedling/c_extractor/c_extractor_statement.rb +30 -0
- data/lib/ceedling/c_extractor/c_extractor_types.rb +63 -41
- data/lib/ceedling/c_extractor/c_module_edits.rb +48 -0
- data/lib/ceedling/c_identifier.rb +21 -0
- data/lib/ceedling/ceedling.h +8 -0
- data/lib/ceedling/config/configurator.rb +4 -3
- data/lib/ceedling/config/configurator_builder.rb +17 -0
- data/lib/ceedling/config/configurator_setup.rb +29 -5
- data/lib/ceedling/constants.rb +5 -1
- data/lib/ceedling/defaults.rb +31 -1
- data/lib/ceedling/dependencies/CACHE_SCHEMA.md +118 -0
- data/lib/ceedling/dependencies/README.md +1 -1
- data/lib/ceedling/dependencies/dependency_cache_store.rb +30 -25
- data/lib/ceedling/dependencies/dependency_tracker.rb +9 -3
- data/lib/ceedling/dependencies/dependinator.rb +13 -1
- data/lib/ceedling/diagnostics/DOCTOR.md +142 -0
- data/lib/ceedling/diagnostics/README.md +5 -0
- data/lib/ceedling/diagnostics/build_step_doctor.rb +110 -0
- data/lib/ceedling/diagnostics/duplicate_symbol_specialist.rb +108 -0
- data/lib/ceedling/diagnostics/guidance_phrases.rb +30 -0
- data/lib/ceedling/diagnostics/header_collision_guidance.rb +56 -0
- data/lib/ceedling/diagnostics/header_collision_specialist.rb +152 -0
- data/lib/ceedling/diagnostics/include_depth_specialist.rb +132 -0
- data/lib/ceedling/diagnostics/missing_symbol_specialist.rb +111 -0
- data/lib/ceedling/diagnostics/partial_name_specialist.rb +134 -0
- data/lib/ceedling/diagnostics/toolchain_output.rb +44 -0
- data/lib/ceedling/filesystem/PATH_HANDLING.md +83 -27
- data/lib/ceedling/filesystem/README.md +6 -1
- data/lib/ceedling/filesystem/build_roots.rb +105 -0
- data/lib/ceedling/filesystem/build_subpath.rb +110 -25
- data/lib/ceedling/filesystem/file_finder.rb +76 -110
- data/lib/ceedling/filesystem/file_finder_helper.rb +33 -11
- data/lib/ceedling/filesystem/file_path_utils.rb +113 -91
- data/lib/ceedling/filesystem/file_wrapper.rb +105 -28
- data/lib/ceedling/filesystem/path_matcher.rb +21 -0
- data/lib/ceedling/filesystem/test_build_layout.rb +114 -0
- data/lib/ceedling/filesystem/win_long_paths.rb +153 -0
- data/lib/ceedling/filesystem/win_path_limit.rb +83 -0
- data/lib/ceedling/filesystem/win_path_prober.rb +52 -0
- data/lib/ceedling/generators/generator.rb +27 -64
- data/lib/ceedling/generators/generator_helper.rb +0 -44
- data/lib/ceedling/generators/generator_mocks.rb +5 -0
- data/lib/ceedling/generators/generator_partials.rb +305 -243
- data/lib/ceedling/generators/generator_test_runner.rb +5 -8
- data/lib/ceedling/generators/partial_header_writer.rb +95 -0
- data/lib/ceedling/generators/partial_source_writer.rb +137 -0
- data/lib/ceedling/includes/header_search.rb +225 -0
- data/lib/ceedling/includes/include_factory.rb +9 -12
- data/lib/ceedling/includes/include_pathinator.rb +53 -31
- data/lib/ceedling/includes/includes.rb +149 -37
- data/lib/ceedling/objects.yml +89 -4
- data/lib/ceedling/partials/README.md +110 -16
- data/lib/ceedling/partials/carry_plan.rb +71 -0
- data/lib/ceedling/partials/definition_head.rb +74 -0
- data/lib/ceedling/partials/include_groups.rb +37 -0
- data/lib/ceedling/partials/interface_extras.rb +25 -0
- data/lib/ceedling/partials/partializer.rb +599 -120
- data/lib/ceedling/partials/partializer_config.rb +5 -0
- data/lib/ceedling/partials/partializer_helper.rb +851 -145
- data/lib/ceedling/partials/partializer_reconciler.rb +174 -0
- data/lib/ceedling/partials/partializer_utils.rb +89 -109
- data/lib/ceedling/partials/partials.rb +153 -10
- data/lib/ceedling/partials/type_macros.rb +126 -0
- data/lib/ceedling/preprocess/README.md +43 -33
- data/lib/ceedling/preprocess/preprocessinator.rb +100 -186
- data/lib/ceedling/preprocess/preprocessinator_code_finder.rb +65 -72
- data/lib/ceedling/preprocess/preprocessinator_file_assembler.rb +31 -75
- data/lib/ceedling/preprocess/preprocessinator_reconstructor.rb +51 -14
- data/lib/ceedling/setupinator.rb +16 -3
- data/lib/ceedling/test_invoker/HEADER_COLLISIONS.md +21 -7
- data/lib/ceedling/test_invoker/PIPELINE.md +57 -16
- data/lib/ceedling/test_invoker/README.md +1 -1
- data/lib/ceedling/test_invoker/derived_search_path_notices.rb +45 -0
- data/lib/ceedling/test_invoker/mock_locator.rb +116 -9
- data/lib/ceedling/test_invoker/partial_files_preprocessinator.rb +181 -0
- data/lib/ceedling/test_invoker/partials_manager.rb +265 -308
- data/lib/ceedling/test_invoker/standin_headerinator.rb +8 -15
- data/lib/ceedling/test_invoker/test_bare_includes_extractinator.rb +26 -3
- data/lib/ceedling/test_invoker/test_build_executor.rb +338 -198
- data/lib/ceedling/test_invoker/test_build_planner.rb +13 -19
- data/lib/ceedling/test_invoker/test_build_setup.rb +26 -6
- data/lib/ceedling/test_invoker/test_build_validations.rb +23 -20
- data/lib/ceedling/test_invoker/test_derived_search_paths.rb +189 -0
- data/lib/ceedling/test_invoker/test_file_preprocessinator.rb +1 -2
- data/lib/ceedling/test_invoker/test_includes_reconcilinator.rb +1 -1
- data/lib/ceedling/test_invoker/test_invoker_types.rb +28 -20
- data/lib/ceedling/test_invoker/test_pipeline_helpers.rb +5 -3
- data/lib/ceedling/test_invoker/test_pipeline_manager.rb +25 -8
- data/lib/ceedling/test_invoker/test_runner_generatinator.rb +31 -3
- data/lib/ceedling/test_invoker/test_search_paths.rb +30 -8
- data/lib/ceedling/test_invoker/test_substitutions.rb +72 -0
- data/lib/ceedling/tools/shell_quoting.rb +45 -0
- data/lib/ceedling/tools/tool_quoting.rb +79 -0
- data/lib/ceedling/{tool_validator.rb → tools/tool_validator.rb} +18 -7
- data/lib/version.rb +1 -1
- data/plugins/bullseye/bullseye.rake +1 -3
- data/plugins/bullseye/lib/bullseye.rb +15 -2
- data/plugins/command_hooks/lib/command_hooks.rb +1 -1
- data/plugins/fff/lib/fff.rb +42 -15
- data/plugins/fff/lib/fff_mock_generator.rb +12 -9
- data/plugins/fff/spec/fff_cmock_wrapper_spec.rb +134 -0
- data/plugins/fff/spec/fff_mock_header_generator_spec.rb +9 -0
- data/plugins/fff/spec/fff_mock_source_generator_spec.rb +20 -0
- data/plugins/gcov/lib/console_reportinator.rb +25 -19
- data/plugins/gcov/lib/reportgenerator_reportinator.rb +2 -1
- data/site-local/404.html +2 -2
- data/site-local/assets/javascripts/{bundle.c21346df.min.js → bundle.a5f9d56c.min.js} +1 -1
- data/site-local/assets/javascripts/{bundle.c21346df.min.js.map → bundle.a5f9d56c.min.js.map} +2 -2
- data/site-local/configuration/environment-vars.html +2 -2
- data/site-local/configuration/global-collections.html +3 -3
- data/site-local/configuration/index.html +2 -2
- data/site-local/configuration/loading.html +2 -2
- data/site-local/configuration/mixins.html +2 -2
- data/site-local/configuration/parallel-builds.html +2 -2
- data/site-local/configuration/project-file.html +2 -2
- data/site-local/configuration/reference/cexception.html +2 -2
- data/site-local/configuration/reference/cmock.html +5 -2
- data/site-local/configuration/reference/defines.html +2 -2
- data/site-local/configuration/reference/environment.html +2 -2
- data/site-local/configuration/reference/extension.html +2 -2
- data/site-local/configuration/reference/files.html +56 -9
- data/site-local/configuration/reference/flags.html +2 -2
- data/site-local/configuration/reference/index.html +2 -2
- data/site-local/configuration/reference/libraries.html +2 -2
- data/site-local/configuration/reference/mixins.html +2 -2
- data/site-local/configuration/reference/partials.html +84 -2
- data/site-local/configuration/reference/paths.html +7 -2
- data/site-local/configuration/reference/plugins.html +2 -2
- data/site-local/configuration/reference/project.html +247 -5
- data/site-local/configuration/reference/release-build.html +2 -2
- data/site-local/configuration/reference/test-build.html +2 -2
- data/site-local/configuration/reference/test-runner.html +2 -2
- data/site-local/configuration/reference/tools.html +49 -4
- data/site-local/configuration/reference/unity.html +2 -2
- data/site-local/configuration/which-ceedling.html +2 -2
- data/site-local/development/index.html +2 -2
- data/site-local/development/plugins/configuration.html +2 -2
- data/site-local/development/plugins/index.html +2 -2
- data/site-local/development/plugins/plugin-subclass.html +5 -4
- data/site-local/development/plugins/rake-tasks.html +2 -2
- data/site-local/development/releases.html +2 -2
- data/site-local/development/workflow.html +2 -2
- data/site-local/getting-started/builds.html +2 -2
- data/site-local/getting-started/command-line.html +2 -2
- data/site-local/getting-started/example-projects/cipher-quest.html +2 -2
- data/site-local/getting-started/example-projects/index.html +2 -2
- data/site-local/getting-started/example-projects/temp-sensor.html +2 -2
- data/site-local/getting-started/example-projects/wondrous-forest.html +10 -2
- data/site-local/getting-started/index.html +2 -2
- data/site-local/getting-started/installation.html +2 -2
- data/site-local/getting-started/quick-start.html +2 -2
- data/site-local/help.html +2 -2
- data/site-local/index.html +2 -2
- data/site-local/overview/build-system.html +2 -2
- data/site-local/overview/index.html +2 -2
- data/site-local/overview/test-environments.html +2 -2
- data/site-local/overview/tools-and-frameworks.html +2 -2
- data/site-local/plugins/beep.html +2 -2
- data/site-local/plugins/bullseye/index.html +45 -38
- data/site-local/plugins/bullseye/licensing.html +2 -2
- data/site-local/plugins/command-hooks.html +4 -4
- data/site-local/plugins/compile-commands-json-db.html +2 -2
- data/site-local/plugins/cppcheck.html +2 -2
- data/site-local/plugins/dependencies.html +2 -2
- data/site-local/plugins/fff.html +16 -2
- data/site-local/plugins/gcov/examples.html +2 -2
- data/site-local/plugins/gcov/gcovr.html +8 -2
- data/site-local/plugins/gcov/index.html +2 -2
- data/site-local/plugins/gcov/overview.html +2 -2
- data/site-local/plugins/gcov/reportgenerator.html +18 -14
- data/site-local/plugins/gcov/reporting.html +2 -2
- data/site-local/plugins/gcov/setup.html +2 -2
- data/site-local/plugins/gcov/tool-versions.html +2 -2
- data/site-local/plugins/gcov/troubleshooting.html +2 -2
- data/site-local/plugins/index.html +2 -2
- data/site-local/plugins/module-generator.html +2 -2
- data/site-local/plugins/report-build-warnings-log.html +2 -2
- data/site-local/plugins/report-tests-gtestlike-stdout.html +2 -2
- data/site-local/plugins/report-tests-ide-stdout.html +2 -2
- data/site-local/plugins/report-tests-log-factory.html +2 -2
- data/site-local/plugins/report-tests-pretty-stdout.html +2 -2
- data/site-local/plugins/report-tests-raw-output-log.html +2 -2
- data/site-local/plugins/report-tests-teamcity-stdout.html +2 -2
- data/site-local/plugins/sanitize.html +2 -2
- data/site-local/plugins/valgrind.html +2 -2
- data/site-local/project/index.html +2 -2
- data/site-local/project/release-history.html +2 -2
- data/site-local/project/sbom.html +2 -2
- data/site-local/project/upgrade.html +2 -2
- data/site-local/reference/build-directives.html +2 -2
- data/site-local/reference/command-line.html +2 -2
- data/site-local/reference/environment-vars.html +2 -2
- data/site-local/reference/gcov-plugin.html +2 -2
- data/site-local/reference/global-collections.html +12 -12
- data/site-local/reference/index.html +2 -2
- data/site-local/reference/partials-macros.html +47 -2
- data/site-local/reference/project-configuration.html +2 -2
- data/site-local/sitemap.xml.gz +0 -0
- data/site-local/snapshot/examples/cipher_quest/index.html +2 -2
- data/site-local/snapshot/examples/temp_sensor/index.html +2 -2
- data/site-local/snapshot/examples/wondrous_forest/index.html +72 -15
- data/site-local/testing-guide/build-directives.html +2 -2
- data/site-local/testing-guide/conventions.html +67 -22
- data/site-local/testing-guide/frameworks.html +2 -2
- data/site-local/testing-guide/index.html +2 -2
- data/site-local/testing-guide/partials/configuration.html +31 -4
- data/site-local/testing-guide/partials/conventions.html +509 -8
- data/site-local/testing-guide/partials/directives.html +4 -3
- data/site-local/testing-guide/partials/example.html +2 -2
- data/site-local/testing-guide/partials/index.html +2 -2
- data/site-local/testing-guide/partials/overview.html +30 -12
- data/site-local/testing-guide/partials/variables.html +169 -4
- data/site-local/testing-guide/test-cases.html +2 -2
- data/site-local/testing-guide/test-sample.html +2 -2
- data/site-local/testing-guide/test-suite-anatomy.html +2 -2
- data/spec/integration/build_step_doctor_spec.rb +270 -0
- data/spec/integration/c_extractor_composition_spec.rb +254 -4
- data/spec/integration/includes_extraction_spec.rb +27 -14
- data/spec/integration/nested_test_artifacts_spec.rb +1 -1
- data/spec/integration/partial_files_preprocessing_spec.rb +128 -0
- data/spec/integration/partials_carry_spec.rb +520 -0
- data/spec/integration/partials_declarations_spec.rb +655 -0
- data/spec/integration/partials_fallback_preprocessing_spec.rb +65 -0
- data/spec/integration/partials_function_pointers_spec.rb +277 -0
- data/spec/integration/partials_header_composition_spec.rb +268 -35
- data/spec/integration/partials_macro_decorators_spec.rb +267 -0
- data/spec/integration/partials_module_resolution_spec.rb +26 -19
- data/spec/integration/partials_symbol_linkage_spec.rb +13 -0
- data/spec/integration/path_length_reporting_spec.rb +64 -0
- data/spec/integration/path_scenarios_spec.rb +80 -3
- data/spec/integration/quote_include_isolator_spec.rb +56 -0
- data/spec/integration/test_build_parallel_barrier_spec.rb +1 -1
- data/spec/integration/test_includes_extractinator_spec.rb +70 -5
- data/spec/integration/test_naming_spec.rb +6 -3
- data/spec/integration/test_source_file_checks_spec.rb +5 -3
- data/spec/integration/tool_executor_spec.rb +1 -1
- data/spec/integration/tool_validator_spec.rb +2 -2
- data/spec/integration/win_long_paths_probe_spec.rb +46 -0
- data/spec/integration/win_path_limit_spec.rb +53 -0
- data/spec/integration/windows_registry_query_tool_spec.rb +41 -0
- data/spec/support/integration/configurator_integration_helper.rb +8 -3
- data/spec/support/integration/partial_files_harness.rb +181 -0
- data/spec/support/integration/partials_generation_integration_helper.rb +237 -141
- data/spec/support/integration/path_scenario_harness.rb +4 -2
- data/spec/support/integration/spec_integration_helper.rb +8 -3
- data/spec/support/integration/test_includes_harness.rb +56 -35
- data/spec/support/integration/tool_executor_integration_helper.rb +14 -2
- data/spec/system/bullseye_deployment_spec.rb +2 -0
- data/spec/system/delta_builds_spec.rb +26 -12
- data/spec/system/encoding_stress_spec.rb +4 -4
- data/spec/system/example_wondrous_forest_spec.rb +2 -2
- data/spec/system/gcov_deployment_spec.rb +2 -0
- data/spec/system/header_include_path_validation_spec.rb +4 -4
- data/spec/system/header_search_paths_spec.rb +1083 -0
- data/spec/system/mock_include_folders_spec.rb +121 -0
- data/spec/system/mockable_header_reassembly_spec.rb +184 -0
- data/spec/system/partials_carry_spec.rb +581 -0
- data/spec/system/partials_delta_builds_spec.rb +280 -0
- data/spec/system/partials_function_pointers_spec.rb +106 -0
- data/spec/system/partials_macro_decorators_spec.rb +127 -0
- data/spec/system/partials_module_disambiguation_spec.rb +125 -0
- data/spec/system/path_handling_probes_spec.rb +16 -12
- data/spec/system/pinned_thread_count_spec.rb +4 -4
- data/spec/system/preprocessing_fallback_conditionals_spec.rb +1 -1
- data/spec/system/short_build_paths_spec.rb +87 -0
- data/spec/system/sibling_header_collision_spec.rb +30 -6
- data/spec/system/support/bullseye_common_test_cases.rb +42 -0
- data/spec/system/support/common_test_cases.rb +2 -2
- data/spec/system/support/gcov_partials_test_cases.rb +48 -0
- data/spec/system/test_build_layout_spec.rb +209 -0
- data/spec/system/test_source_file_directive_spec.rb +35 -5
- data/spec/units/c_extractor/c_extractor_code_text_spec.rb +67 -10
- data/spec/units/c_extractor/c_extractor_declarations_spec.rb +501 -4
- data/spec/units/c_extractor/c_extractor_declarator_spec.rb +245 -0
- data/spec/units/c_extractor/c_extractor_defined_type_spec.rb +45 -0
- data/spec/units/c_extractor/c_extractor_definitions_spec.rb +163 -3
- data/spec/units/c_extractor/c_extractor_functions_spec.rb +462 -21
- data/spec/units/c_extractor/c_extractor_preprocessing_spec.rb +39 -0
- data/spec/units/c_extractor/c_extractor_spec.rb +4 -4
- data/spec/units/c_extractor/c_extractor_types_spec.rb +163 -0
- data/spec/units/c_identifier_spec.rb +35 -0
- data/spec/units/config/configurator_builder_spec.rb +24 -0
- data/spec/units/config/configurator_setup_spec.rb +72 -4
- data/spec/units/config/configurator_spec.rb +27 -1
- data/spec/units/dependencies/dependency_cache_store_spec.rb +68 -3
- data/spec/units/dependencies/dependency_tracker_spec.rb +25 -0
- data/spec/units/dependencies/dependinator_spec.rb +17 -2
- data/spec/units/diagnostics/build_step_doctor_spec.rb +170 -0
- data/spec/units/diagnostics/duplicate_symbol_specialist_spec.rb +117 -0
- data/spec/units/diagnostics/header_collision_specialist_spec.rb +267 -0
- data/spec/units/diagnostics/include_depth_specialist_spec.rb +137 -0
- data/spec/units/diagnostics/missing_symbol_specialist_spec.rb +154 -0
- data/spec/units/diagnostics/partial_name_specialist_spec.rb +129 -0
- data/spec/units/diagnostics/toolchain_output_spec.rb +86 -0
- data/spec/units/encodinator_spec.rb +3 -4
- data/spec/units/filesystem/build_roots_spec.rb +131 -0
- data/spec/units/filesystem/build_subpath_spec.rb +113 -0
- data/spec/units/filesystem/file_finder_helper_spec.rb +80 -0
- data/spec/units/filesystem/file_finder_spec.rb +242 -58
- data/spec/units/filesystem/file_path_utils_spec.rb +251 -118
- data/spec/units/filesystem/file_wrapper_spec.rb +191 -6
- data/spec/units/filesystem/path_matcher_spec.rb +36 -0
- data/spec/units/filesystem/test_build_layout_spec.rb +216 -0
- data/spec/units/filesystem/win_long_paths_spec.rb +204 -0
- data/spec/units/filesystem/win_path_prober_spec.rb +158 -0
- data/spec/units/generators/generator_helper_spec.rb +0 -60
- data/spec/units/generators/generator_mocks_spec.rb +13 -0
- data/spec/units/generators/generator_partials_spec.rb +656 -55
- data/spec/units/generators/generator_spec.rb +26 -0
- data/spec/units/generators/generator_test_runner_spec.rb +9 -5
- data/spec/units/generators/partial_source_writer_spec.rb +129 -0
- data/spec/units/includes/header_search_spec.rb +406 -0
- data/spec/units/includes/include_factory_spec.rb +22 -5
- data/spec/units/includes/include_pathinator_spec.rb +77 -13
- data/spec/units/includes/include_spec.rb +14 -0
- data/spec/units/includes/includes_spec.rb +176 -19
- data/spec/units/loginator_spec.rb +31 -0
- data/spec/units/mock_locator_spec.rb +199 -5
- data/spec/units/partials/include_groups_spec.rb +42 -0
- data/spec/units/partials/partializer_config_spec.rb +25 -0
- data/spec/units/partials/partializer_helper_carry_spec.rb +661 -0
- data/spec/units/partials/partializer_helper_interface_extras_spec.rb +396 -0
- data/spec/units/partials/partializer_helper_spec.rb +529 -277
- data/spec/units/partials/partializer_reconciler_spec.rb +661 -0
- data/spec/units/partials/partializer_spec.rb +1578 -270
- data/spec/units/partials/partializer_utils_spec.rb +269 -232
- data/spec/units/partials/partials_rename_spec.rb +160 -0
- data/spec/units/partials_manager_spec.rb +554 -261
- data/spec/units/plugins/bullseye_spec.rb +34 -0
- data/spec/units/plugins/console_reportinator_spec.rb +58 -9
- data/spec/units/plugins/report_tests_teamcity_stdout_spec.rb +1 -1
- data/spec/units/plugins/reportgenerator_reportinator_spec.rb +51 -3
- data/spec/units/preprocess/preprocessinator_code_finder_spec.rb +73 -10
- data/spec/units/preprocess/preprocessinator_file_assembler_spec.rb +125 -37
- data/spec/units/preprocess/preprocessinator_includes_handler_spec.rb +15 -0
- data/spec/units/preprocess/preprocessinator_reconstructor_spec.rb +197 -0
- data/spec/units/preprocess/preprocessinator_spec.rb +153 -95
- data/spec/units/setupinator_spec.rb +51 -0
- data/spec/units/standin_headerinator_spec.rb +27 -11
- data/spec/units/test_build_executor_spec.rb +780 -166
- data/spec/units/test_build_planner_spec.rb +116 -28
- data/spec/units/test_build_setup_spec.rb +83 -18
- data/spec/units/test_context_extractor_spec.rb +11 -2
- data/spec/units/test_derived_search_paths_spec.rb +259 -0
- data/spec/units/test_includes_extractinator_spec.rb +56 -8
- data/spec/units/test_invoker/objects_wiring_spec.rb +20 -3
- data/spec/units/test_invoker/partial_files_preprocessinator_spec.rb +264 -0
- data/spec/units/test_invoker/test_substitutions_spec.rb +122 -0
- data/spec/units/test_invoker_types_spec.rb +8 -7
- data/spec/units/test_pipeline_manager_spec.rb +54 -13
- data/spec/units/test_runner_generatinator_spec.rb +93 -1
- data/spec/units/test_search_paths_spec.rb +73 -5
- data/spec/units/{default_tools_quoting_spec.rb → tools/default_tools_quoting_spec.rb} +39 -5
- data/spec/units/tools/shell_quoting_spec.rb +76 -0
- data/spec/units/{tool_executor_helper_spec.rb → tools/tool_executor_helper_spec.rb} +1 -1
- data/spec/units/{tool_executor_spec.rb → tools/tool_executor_spec.rb} +1 -1
- data/spec/units/{tool_validator_spec.rb → tools/tool_validator_spec.rb} +110 -1
- data/spec/units/windows_registry_query_tool_spec.rb +53 -0
- metadata +161 -16
- /data/lib/ceedling/{tool_executor.rb → tools/tool_executor.rb} +0 -0
- /data/lib/ceedling/{tool_executor_helper.rb → tools/tool_executor_helper.rb} +0 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
require 'spec_system_helper'
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
## Partial Regeneration Through Real Builds
|
|
12
|
+
## ========================================
|
|
13
|
+
##
|
|
14
|
+
## A Partial is regenerated when anything its generation reads changes: the test's selection
|
|
15
|
+
## of functions, or the preprocessed copies of the module, which forced fallback preprocessing
|
|
16
|
+
## rewrites without touching the originals. Nothing is regenerated when nothing changed. A
|
|
17
|
+
## mocked Partial's header is never preprocessed for mocking, since CMock reads it as generated.
|
|
18
|
+
##
|
|
19
|
+
|
|
20
|
+
PARTIALS_DELTA_ENGINE_HEADER = <<~C
|
|
21
|
+
#ifndef ENGINE_H
|
|
22
|
+
#define ENGINE_H
|
|
23
|
+
int engine_get(void);
|
|
24
|
+
#endif
|
|
25
|
+
C
|
|
26
|
+
|
|
27
|
+
PARTIALS_DELTA_ENGINE_SOURCE = <<~C
|
|
28
|
+
#include "engine.h"
|
|
29
|
+
|
|
30
|
+
static int helper(void)
|
|
31
|
+
{
|
|
32
|
+
return 41;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
int engine_get(void)
|
|
36
|
+
{
|
|
37
|
+
return 42;
|
|
38
|
+
}
|
|
39
|
+
C
|
|
40
|
+
|
|
41
|
+
# A typedef gives the Partial a shared types header, which its implementation includes
|
|
42
|
+
PARTIALS_DELTA_TYPED_HEADER = <<~C
|
|
43
|
+
#ifndef ENGINE_H
|
|
44
|
+
#define ENGINE_H
|
|
45
|
+
typedef int engine_count_t;
|
|
46
|
+
engine_count_t engine_get(void);
|
|
47
|
+
#endif
|
|
48
|
+
C
|
|
49
|
+
|
|
50
|
+
PARTIALS_DELTA_TYPED_SOURCE = <<~C
|
|
51
|
+
#include "engine.h"
|
|
52
|
+
|
|
53
|
+
engine_count_t engine_get(void)
|
|
54
|
+
{
|
|
55
|
+
return 42;
|
|
56
|
+
}
|
|
57
|
+
C
|
|
58
|
+
|
|
59
|
+
PARTIALS_DELTA_PREAMBLE = "#include \"unity.h\"\n#include \"ceedling.h\"\n"
|
|
60
|
+
|
|
61
|
+
# A storage class from a macro in a header the module includes, which decides whether a
|
|
62
|
+
# public selection holds helper()
|
|
63
|
+
PARTIALS_DELTA_CONFIG_HEADER = "#ifndef CONFIG_H\n#define CONFIG_H\n#define PRIVATE static\n#endif\n"
|
|
64
|
+
|
|
65
|
+
PARTIALS_DELTA_CONFIGURED_HEADER = <<~C
|
|
66
|
+
#ifndef ENGINE_H
|
|
67
|
+
#define ENGINE_H
|
|
68
|
+
#include "config.h"
|
|
69
|
+
int engine_get(void);
|
|
70
|
+
#endif
|
|
71
|
+
C
|
|
72
|
+
|
|
73
|
+
PARTIALS_DELTA_CONFIGURED_SOURCE = <<~C
|
|
74
|
+
#include "engine.h"
|
|
75
|
+
|
|
76
|
+
PRIVATE int helper(void)
|
|
77
|
+
{
|
|
78
|
+
return 41;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
int engine_get(void)
|
|
82
|
+
{
|
|
83
|
+
return 42;
|
|
84
|
+
}
|
|
85
|
+
C
|
|
86
|
+
|
|
87
|
+
# Variables declared together with their types, at file scope and inside a function
|
|
88
|
+
PARTIALS_DELTA_STATEFUL_SOURCE = <<~C
|
|
89
|
+
#include "engine.h"
|
|
90
|
+
|
|
91
|
+
static struct { int count; } s_ctx;
|
|
92
|
+
static enum { IDLE, RUN } s_state;
|
|
93
|
+
|
|
94
|
+
int engine_get(void)
|
|
95
|
+
{
|
|
96
|
+
static struct step { int n; } last;
|
|
97
|
+
struct step *at = &last;
|
|
98
|
+
at->n++;
|
|
99
|
+
s_ctx.count++;
|
|
100
|
+
s_state = RUN;
|
|
101
|
+
return last.n;
|
|
102
|
+
}
|
|
103
|
+
C
|
|
104
|
+
|
|
105
|
+
# Each type is reached through the variable, its members and values, and the name ceedling.h gives it
|
|
106
|
+
PARTIALS_DELTA_STATEFUL_TEST = PARTIALS_DELTA_PREAMBLE + <<~C
|
|
107
|
+
#include TEST_PARTIAL_PUBLIC_MODULE(engine)
|
|
108
|
+
void setUp(void) { s_ctx.count = 0; s_state = IDLE; }
|
|
109
|
+
void tearDown(void) {}
|
|
110
|
+
void test_get(void)
|
|
111
|
+
{
|
|
112
|
+
PARTIAL_TYPE(engine, s_ctx) saved;
|
|
113
|
+
PARTIAL_LOCAL_TYPE(engine, engine_get, last) step;
|
|
114
|
+
|
|
115
|
+
TEST_ASSERT_EQUAL_INT(1, engine_get());
|
|
116
|
+
saved = s_ctx;
|
|
117
|
+
step = PARTIAL_LOCAL_VAR(engine_get, last);
|
|
118
|
+
TEST_ASSERT_EQUAL_INT(1, saved.count);
|
|
119
|
+
TEST_ASSERT_EQUAL_INT(1, step.n);
|
|
120
|
+
TEST_ASSERT_EQUAL_INT(RUN, s_state);
|
|
121
|
+
}
|
|
122
|
+
C
|
|
123
|
+
|
|
124
|
+
# Only engine_get(), which the public selection holds
|
|
125
|
+
PARTIALS_DELTA_PUBLIC_TEST = PARTIALS_DELTA_PREAMBLE + <<~C
|
|
126
|
+
#include TEST_PARTIAL_PUBLIC_MODULE(engine)
|
|
127
|
+
void setUp(void) {}
|
|
128
|
+
void tearDown(void) {}
|
|
129
|
+
void test_get(void) { TEST_ASSERT_EQUAL_INT(42, engine_get()); }
|
|
130
|
+
C
|
|
131
|
+
|
|
132
|
+
# helper() too, which only the whole module's selection holds
|
|
133
|
+
PARTIALS_DELTA_ALL_TEST = PARTIALS_DELTA_PREAMBLE + <<~C
|
|
134
|
+
#include TEST_PARTIAL_ALL_MODULE(engine)
|
|
135
|
+
void setUp(void) {}
|
|
136
|
+
void tearDown(void) {}
|
|
137
|
+
void test_get(void) { TEST_ASSERT_EQUAL_INT(42, engine_get()); }
|
|
138
|
+
void test_helper(void) { TEST_ASSERT_EQUAL_INT(41, helper()); }
|
|
139
|
+
C
|
|
140
|
+
|
|
141
|
+
# A plain header mocked beside a Partial, so mock preprocessing has one header to work on
|
|
142
|
+
PARTIALS_DELTA_CLOCK_HEADER = "#ifndef CLOCK_H\n#define CLOCK_H\nint clock_now(void);\n#endif\n"
|
|
143
|
+
|
|
144
|
+
PARTIALS_DELTA_MOCKED_TEST = PARTIALS_DELTA_PREAMBLE + <<~C
|
|
145
|
+
#include "mock_clock.h"
|
|
146
|
+
#include MOCK_PARTIAL_PUBLIC_MODULE(engine)
|
|
147
|
+
void setUp(void) {}
|
|
148
|
+
void tearDown(void) {}
|
|
149
|
+
void test_get(void) { engine_get_ExpectAndReturn(42); clock_now_ExpectAndReturn(7); TEST_ASSERT_EQUAL_INT(49, engine_get() + clock_now()); }
|
|
150
|
+
C
|
|
151
|
+
|
|
152
|
+
ceedling_system_tests do
|
|
153
|
+
include_context "a fresh ceedling gem project", "partials_delta"
|
|
154
|
+
|
|
155
|
+
before do
|
|
156
|
+
in_project do
|
|
157
|
+
File.write( 'src/engine.h', PARTIALS_DELTA_ENGINE_HEADER )
|
|
158
|
+
File.write( 'src/engine.c', PARTIALS_DELTA_ENGINE_SOURCE )
|
|
159
|
+
File.write( 'test/test_engine.c', PARTIALS_DELTA_PUBLIC_TEST )
|
|
160
|
+
|
|
161
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true } } )
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
def build_passing(tests)
|
|
166
|
+
output = @c.ceedling_build_exec( "test:all" )
|
|
167
|
+
expect(@c.last_exit_status).to eq(0), output
|
|
168
|
+
expect(output).to match(/PASSED:\s+#{tests}/)
|
|
169
|
+
|
|
170
|
+
return output
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
it "regenerates a Partial when the test's selection changes, without a clobber" do
|
|
174
|
+
in_project do
|
|
175
|
+
build_passing( 1 )
|
|
176
|
+
|
|
177
|
+
File.write( 'test/test_engine.c', PARTIALS_DELTA_ALL_TEST )
|
|
178
|
+
output = build_passing( 2 )
|
|
179
|
+
expect(output).to match(/Generating Partial implementation for .*engine/)
|
|
180
|
+
|
|
181
|
+
File.write( 'test/test_engine.c', PARTIALS_DELTA_PUBLIC_TEST )
|
|
182
|
+
output = build_passing( 1 )
|
|
183
|
+
expect(output).to match(/Generating Partial implementation for .*engine/)
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# The implementation and interface vouch for the types header they include, so even a build
|
|
188
|
+
# that finds every other file fresh restores it
|
|
189
|
+
it "restores a Partial's shared types header when it goes missing" do
|
|
190
|
+
in_project do
|
|
191
|
+
File.write( 'src/engine.h', PARTIALS_DELTA_TYPED_HEADER )
|
|
192
|
+
File.write( 'src/engine.c', PARTIALS_DELTA_TYPED_SOURCE )
|
|
193
|
+
build_passing( 1 )
|
|
194
|
+
|
|
195
|
+
types = Dir.glob( 'build/test/partials/**/ceedling_partial_engine_types.h' )
|
|
196
|
+
expect(types).to_not be_empty
|
|
197
|
+
File.delete( *types )
|
|
198
|
+
|
|
199
|
+
output = build_passing( 1 )
|
|
200
|
+
expect(output).to match(/Generating shared Partial types for .*engine/)
|
|
201
|
+
expect(types).to all( satisfy { |path| File.exist?( path ) } )
|
|
202
|
+
end
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
it "tests a module whose variables define their types, and regenerates nothing on an unchanged rebuild" do
|
|
206
|
+
in_project do
|
|
207
|
+
File.write( 'src/engine.c', PARTIALS_DELTA_STATEFUL_SOURCE )
|
|
208
|
+
File.write( 'test/test_engine.c', PARTIALS_DELTA_STATEFUL_TEST )
|
|
209
|
+
build_passing( 1 )
|
|
210
|
+
|
|
211
|
+
output = build_passing( 1 )
|
|
212
|
+
expect(output).to_not match(/Generating (?:Partial implementation|shared Partial types) for/)
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
it "skips generating a Partial when nothing changed" do
|
|
217
|
+
in_project do
|
|
218
|
+
build_passing( 1 )
|
|
219
|
+
|
|
220
|
+
output = build_passing( 1 )
|
|
221
|
+
expect(output).to_not match(/Generating Partial implementation for/)
|
|
222
|
+
expect(output).to match(/Skipping Partial implementation generation/)
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# The module itself is unchanged. Only its preprocessing sees the header's new macro.
|
|
227
|
+
it "regenerates a Partial when a header its module includes changes a macro" do
|
|
228
|
+
in_project do
|
|
229
|
+
File.write( 'src/config.h', PARTIALS_DELTA_CONFIG_HEADER )
|
|
230
|
+
File.write( 'src/engine.h', PARTIALS_DELTA_CONFIGURED_HEADER )
|
|
231
|
+
File.write( 'src/engine.c', PARTIALS_DELTA_CONFIGURED_SOURCE )
|
|
232
|
+
build_passing( 1 )
|
|
233
|
+
|
|
234
|
+
implementation = Dir.glob( 'build/test/partials/**/ceedling_partial_engine_impl.h' )
|
|
235
|
+
expect(implementation).to_not be_empty
|
|
236
|
+
expect(File.read( implementation.first )).to_not include( 'helper(' )
|
|
237
|
+
|
|
238
|
+
File.write( 'src/config.h', PARTIALS_DELTA_CONFIG_HEADER.sub( '#define PRIVATE static', '#define PRIVATE' ) )
|
|
239
|
+
output = build_passing( 1 )
|
|
240
|
+
expect(output).to match(/Generating Partial implementation for .*engine/)
|
|
241
|
+
expect(File.read( implementation.first )).to match(/^int helper\(void\);/)
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
# Stage 8 stays fresh when preprocessing writes identical copies, so only the log shows a rerun
|
|
246
|
+
it "skips preprocessing a Partial's files when nothing changed" do
|
|
247
|
+
in_project do
|
|
248
|
+
File.write( 'src/config.h', PARTIALS_DELTA_CONFIG_HEADER )
|
|
249
|
+
File.write( 'src/engine.h', PARTIALS_DELTA_CONFIGURED_HEADER )
|
|
250
|
+
File.write( 'src/engine.c', PARTIALS_DELTA_CONFIGURED_SOURCE )
|
|
251
|
+
progress = /Preprocessing (?:header|source) file for follow-on Partials handling/
|
|
252
|
+
expect(build_passing( 1 )).to match(progress)
|
|
253
|
+
|
|
254
|
+
output = build_passing( 1 )
|
|
255
|
+
expect(output).to_not match(progress)
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
it "regenerates a Partial when forced fallback preprocessing rewrites its preprocessed copies" do
|
|
260
|
+
in_project do
|
|
261
|
+
build_passing( 1 )
|
|
262
|
+
|
|
263
|
+
@c.merge_project_yml_for_test( { :test_build => { :preprocess_force_fallback => true } } )
|
|
264
|
+
output = build_passing( 1 )
|
|
265
|
+
expect(output).to match(/Generating Partial implementation for .*engine/)
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
it "preprocesses a plain header for mocking but never a mocked Partial's header" do
|
|
270
|
+
in_project do
|
|
271
|
+
File.write( 'src/clock.h', PARTIALS_DELTA_CLOCK_HEADER )
|
|
272
|
+
File.write( 'test/test_engine.c', PARTIALS_DELTA_MOCKED_TEST )
|
|
273
|
+
@c.merge_project_yml_for_test( { :project => { :use_mocks => true, :use_test_preprocessor => :all } } )
|
|
274
|
+
|
|
275
|
+
output = build_passing( 1 )
|
|
276
|
+
expect(output).to match(/Preprocessing header file for follow-on mock handling \S*clock\.h/)
|
|
277
|
+
expect(output).to_not match(/Preprocessing header file for follow-on mock handling \S*_interface\.h/)
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
require 'spec_system_helper'
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
## Function Pointers in Partials Through Real Builds
|
|
12
|
+
## =================================================
|
|
13
|
+
##
|
|
14
|
+
## A module may take, return and hold function pointers without a typedef for their type.
|
|
15
|
+
## A Partial of such a module has to read each declaration whole and declare each function
|
|
16
|
+
## pointer with its whole type. A mocked Partial hands such a prototype to CMock.
|
|
17
|
+
##
|
|
18
|
+
|
|
19
|
+
PARTIALS_FP_PREAMBLE = "#include \"unity.h\"\n#include \"ceedling.h\"\n"
|
|
20
|
+
|
|
21
|
+
PARTIALS_FP_HEADER = <<~C
|
|
22
|
+
#ifndef TICKER_H
|
|
23
|
+
#define TICKER_H
|
|
24
|
+
void ticker_register(int (*cb)(int));
|
|
25
|
+
int ticker_count(void);
|
|
26
|
+
int ticker_fire(int n);
|
|
27
|
+
#endif
|
|
28
|
+
C
|
|
29
|
+
|
|
30
|
+
PARTIALS_FP_SOURCE = <<~C
|
|
31
|
+
#include "ticker.h"
|
|
32
|
+
|
|
33
|
+
static int calls;
|
|
34
|
+
static int (*s_hook)(int);
|
|
35
|
+
|
|
36
|
+
void ticker_register(int (*cb)(int))
|
|
37
|
+
{
|
|
38
|
+
s_hook = cb;
|
|
39
|
+
calls = cb(calls);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
int ticker_count(void)
|
|
43
|
+
{
|
|
44
|
+
return calls;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
int ticker_fire(int n)
|
|
48
|
+
{
|
|
49
|
+
return s_hook ? s_hook(n) : -1;
|
|
50
|
+
}
|
|
51
|
+
C
|
|
52
|
+
|
|
53
|
+
PARTIALS_FP_TEST = PARTIALS_FP_PREAMBLE + <<~C
|
|
54
|
+
#include TEST_PARTIAL_PUBLIC_MODULE(ticker)
|
|
55
|
+
static int bump(int n) { return n + 1; }
|
|
56
|
+
void setUp(void) {}
|
|
57
|
+
void tearDown(void) {}
|
|
58
|
+
void test_register_calls_back(void) { ticker_register(bump); TEST_ASSERT_EQUAL_INT(1, ticker_count()); }
|
|
59
|
+
void test_fire_uses_the_hook(void) { ticker_register(bump); TEST_ASSERT_EQUAL_INT(3, ticker_fire(2)); }
|
|
60
|
+
void test_hook_is_visible(void) { s_hook = bump; TEST_ASSERT_EQUAL_INT(5, ticker_fire(4)); }
|
|
61
|
+
C
|
|
62
|
+
|
|
63
|
+
PARTIALS_FP_MOCK_TEST = PARTIALS_FP_PREAMBLE + <<~C
|
|
64
|
+
#include MOCK_PARTIAL_PUBLIC_MODULE(ticker)
|
|
65
|
+
static int bump(int n) { return n + 1; }
|
|
66
|
+
void setUp(void) {}
|
|
67
|
+
void tearDown(void) {}
|
|
68
|
+
void test_register_is_expected(void) { ticker_register_Expect(bump); ticker_register(bump); }
|
|
69
|
+
C
|
|
70
|
+
|
|
71
|
+
ceedling_system_tests do
|
|
72
|
+
include_context "a fresh ceedling gem project", "partials_function_pointers"
|
|
73
|
+
|
|
74
|
+
before do
|
|
75
|
+
in_project do
|
|
76
|
+
File.write( 'src/ticker.h', PARTIALS_FP_HEADER )
|
|
77
|
+
File.write( 'src/ticker.c', PARTIALS_FP_SOURCE )
|
|
78
|
+
|
|
79
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true } } )
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def build_passing(tests)
|
|
84
|
+
output = @c.ceedling_build_exec( "test:all" )
|
|
85
|
+
expect(@c.last_exit_status).to eq(0), output
|
|
86
|
+
expect(output).to match(/PASSED:\s+#{tests}/)
|
|
87
|
+
|
|
88
|
+
return output
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "tests a module whose function takes a function pointer and that holds one" do
|
|
92
|
+
in_project do
|
|
93
|
+
File.write( 'test/test_ticker.c', PARTIALS_FP_TEST )
|
|
94
|
+
|
|
95
|
+
build_passing( 3 )
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "mocks a module whose function takes a function pointer" do
|
|
100
|
+
in_project do
|
|
101
|
+
File.write( 'test/test_ticker.c', PARTIALS_FP_MOCK_TEST )
|
|
102
|
+
|
|
103
|
+
build_passing( 1 )
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# =========================================================================
|
|
2
|
+
# Ceedling - Test-Centered Build System for C
|
|
3
|
+
# ThrowTheSwitch.org
|
|
4
|
+
# Copyright (c) 2010-26 Mike Karlesky, Mark VanderVoord, & Greg Williams
|
|
5
|
+
# SPDX-License-Identifier: MIT
|
|
6
|
+
# =========================================================================
|
|
7
|
+
|
|
8
|
+
require 'spec_system_helper'
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
## Macro-Supplied Decorators in Partials Through Real Builds
|
|
12
|
+
## =========================================================
|
|
13
|
+
##
|
|
14
|
+
## A module may spell `static`, `static inline` or a type attribute through macros of its own.
|
|
15
|
+
## A Partial tests and mocks each function a macro makes static, and exposes each such variable.
|
|
16
|
+
## A type keeps an attribute a macro writes after its closing brace, with or without a variable
|
|
17
|
+
## after it. Forced fallback preprocessing builds the same tests.
|
|
18
|
+
##
|
|
19
|
+
|
|
20
|
+
PARTIALS_MACROS_CONFIG_HEADER = <<~C
|
|
21
|
+
#ifndef CONFIG_H
|
|
22
|
+
#define CONFIG_H
|
|
23
|
+
#define PRIVATE static
|
|
24
|
+
#define STATICINLINE static inline
|
|
25
|
+
#define PACKED __attribute__((packed))
|
|
26
|
+
#endif
|
|
27
|
+
C
|
|
28
|
+
|
|
29
|
+
PARTIALS_MACROS_WIDGET_HEADER = <<~C
|
|
30
|
+
#ifndef WIDGET_H
|
|
31
|
+
#define WIDGET_H
|
|
32
|
+
#include "config.h"
|
|
33
|
+
struct pk { char c; int i; } PACKED;
|
|
34
|
+
int widget_get(void);
|
|
35
|
+
#endif
|
|
36
|
+
C
|
|
37
|
+
|
|
38
|
+
PARTIALS_MACROS_WIDGET_SOURCE = <<~C
|
|
39
|
+
#include "widget.h"
|
|
40
|
+
|
|
41
|
+
PRIVATE int counter;
|
|
42
|
+
struct frame { char c; int i; } PACKED g_frame;
|
|
43
|
+
|
|
44
|
+
// The name on its own line moves the rewritten head's line marker
|
|
45
|
+
PRIVATE int
|
|
46
|
+
helper(void)
|
|
47
|
+
{
|
|
48
|
+
return 20;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
STATICINLINE int twice(int v)
|
|
52
|
+
{
|
|
53
|
+
return v * 2;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
int widget_get(void)
|
|
57
|
+
{
|
|
58
|
+
counter++;
|
|
59
|
+
return twice( helper() ) + 2;
|
|
60
|
+
}
|
|
61
|
+
C
|
|
62
|
+
|
|
63
|
+
PARTIALS_MACROS_PREAMBLE = "#include \"unity.h\"\n#include \"ceedling.h\"\n"
|
|
64
|
+
|
|
65
|
+
# Every function and variable a macro made static, and the type a macro packed
|
|
66
|
+
PARTIALS_MACROS_ALL_TEST = PARTIALS_MACROS_PREAMBLE + <<~C
|
|
67
|
+
#include TEST_PARTIAL_ALL_MODULE(widget)
|
|
68
|
+
void setUp(void) { counter = 0; }
|
|
69
|
+
void tearDown(void) {}
|
|
70
|
+
void test_helper(void) { TEST_ASSERT_EQUAL_INT(20, helper()); }
|
|
71
|
+
void test_twice(void) { TEST_ASSERT_EQUAL_INT(42, twice(21)); }
|
|
72
|
+
void test_get_counts(void) { TEST_ASSERT_EQUAL_INT(42, widget_get()); TEST_ASSERT_EQUAL_INT(1, counter); }
|
|
73
|
+
void test_packed(void) { TEST_ASSERT_EQUAL_size_t(sizeof(char) + sizeof(int), sizeof(struct pk)); }
|
|
74
|
+
void test_packed_variable(void) { TEST_ASSERT_EQUAL_size_t(sizeof(char) + sizeof(int), sizeof(g_frame)); }
|
|
75
|
+
C
|
|
76
|
+
|
|
77
|
+
# The public function under test calls its private neighbors through their mocks
|
|
78
|
+
PARTIALS_MACROS_MOCKED_TEST = PARTIALS_MACROS_PREAMBLE + <<~C
|
|
79
|
+
#include TEST_PARTIAL_PUBLIC_MODULE(widget)
|
|
80
|
+
#include MOCK_PARTIAL_PRIVATE_MODULE(widget)
|
|
81
|
+
void setUp(void) {}
|
|
82
|
+
void tearDown(void) {}
|
|
83
|
+
void test_get_through_mocks(void)
|
|
84
|
+
{
|
|
85
|
+
helper_ExpectAndReturn(5);
|
|
86
|
+
twice_ExpectAndReturn(5, 7);
|
|
87
|
+
TEST_ASSERT_EQUAL_INT(9, widget_get());
|
|
88
|
+
}
|
|
89
|
+
C
|
|
90
|
+
|
|
91
|
+
ceedling_system_tests do
|
|
92
|
+
include_context "a fresh ceedling gem project", "partials_macro_decorators"
|
|
93
|
+
|
|
94
|
+
before do
|
|
95
|
+
in_project do
|
|
96
|
+
File.write( 'src/config.h', PARTIALS_MACROS_CONFIG_HEADER )
|
|
97
|
+
File.write( 'src/widget.h', PARTIALS_MACROS_WIDGET_HEADER )
|
|
98
|
+
File.write( 'src/widget.c', PARTIALS_MACROS_WIDGET_SOURCE )
|
|
99
|
+
File.write( 'test/test_widget_all.c', PARTIALS_MACROS_ALL_TEST )
|
|
100
|
+
File.write( 'test/test_widget_mocked.c', PARTIALS_MACROS_MOCKED_TEST )
|
|
101
|
+
|
|
102
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true } } )
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def build_passing(tests)
|
|
107
|
+
output = @c.ceedling_build_exec( "test:all" )
|
|
108
|
+
expect(@c.last_exit_status).to eq(0), output
|
|
109
|
+
expect(output).to match(/PASSED:\s+#{tests}/)
|
|
110
|
+
|
|
111
|
+
return output
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "tests and mocks the functions macros make static, and exposes the variable" do
|
|
115
|
+
in_project do
|
|
116
|
+
build_passing( 6 )
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it "tests and mocks the functions macros make static with forced fallback preprocessing" do
|
|
121
|
+
in_project do
|
|
122
|
+
@c.merge_project_yml_for_test( { :test_build => { :preprocess_force_fallback => true } } )
|
|
123
|
+
|
|
124
|
+
expect(build_passing( 6 )).to match(/Forcing best-effort fallback preprocessing/)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -20,6 +20,8 @@ require 'spec_system_helper'
|
|
|
20
20
|
## Assets: assets/fixtures/same_named_modules/
|
|
21
21
|
##
|
|
22
22
|
|
|
23
|
+
PARTIALS_DISAMBIG_PREAMBLE = "#include \"unity.h\"\n#include \"ceedling.h\"\n"
|
|
24
|
+
|
|
23
25
|
ceedling_system_tests do
|
|
24
26
|
include_context "a fresh ceedling gem project", "partial_disambig"
|
|
25
27
|
|
|
@@ -139,5 +141,128 @@ ceedling_system_tests do
|
|
|
139
141
|
end
|
|
140
142
|
end
|
|
141
143
|
|
|
144
|
+
# A module named by directory claims only its own header. Another header sharing its
|
|
145
|
+
# basename, partialized or not, keeps its place in every generated file.
|
|
146
|
+
context "with a module named by directory beside a same-named header" do
|
|
147
|
+
def include_paths(paths)
|
|
148
|
+
@c.remove_project_yml_option_for_test( :paths, :include )
|
|
149
|
+
@c.merge_project_yml_for_test( { :paths => { :include => paths } } )
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def write(path, text)
|
|
153
|
+
FileUtils.mkdir_p( File.dirname( path ) )
|
|
154
|
+
File.write( path, text )
|
|
155
|
+
end
|
|
156
|
+
|
|
157
|
+
def build_passing
|
|
158
|
+
output = @c.ceedling_build_exec( "test:all" )
|
|
159
|
+
expect(@c.last_exit_status).to eq(0), output
|
|
160
|
+
expect(output).to match(/PASSED:\s+1/)
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# The mocked module's real inline body fails any test it runs in
|
|
164
|
+
def same_named_configs
|
|
165
|
+
write( 'include/drivers/uart/config.h', "#ifndef UART_CONFIG_H\n#define UART_CONFIG_H\nint uart_config_baud(void);\n#endif\n" )
|
|
166
|
+
write( 'include/drivers/spi/config.h',
|
|
167
|
+
"#ifndef SPI_CONFIG_H\n#define SPI_CONFIG_H\ntypedef struct spi_cfg { int div; } spi_cfg_t;\n" \
|
|
168
|
+
"static inline int spi_read(void) { return -1000; }\nint spi_config_clock_div(void);\n#endif\n" )
|
|
169
|
+
write( 'src/drivers/uart/config.c',
|
|
170
|
+
"#include \"drivers/uart/config.h\"\n#include \"drivers/spi/config.h\"\n" \
|
|
171
|
+
"int uart_config_baud(void) { spi_cfg_t c = { spi_read() }; return c.div + 1; }\n" )
|
|
172
|
+
write( 'src/drivers/spi/config.c', "#include \"drivers/spi/config.h\"\nint spi_config_clock_div(void) { return 8; }\n" )
|
|
173
|
+
write( 'test/test_uart.c', PARTIALS_DISAMBIG_PREAMBLE +
|
|
174
|
+
"#include TEST_PARTIAL_PUBLIC_MODULE_AT(drivers/uart, config)\n#include MOCK_PARTIAL_PRIVATE_MODULE_AT(drivers/spi, config)\n" \
|
|
175
|
+
"void setUp(void) {}\nvoid tearDown(void) {}\n" \
|
|
176
|
+
"void test_baud(void) { spi_read_ExpectAndReturn(41); TEST_ASSERT_EQUAL_INT(42, uart_config_baud()); }\n" )
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# An application header sharing the Partial's basename, which a tested module's header uses
|
|
180
|
+
def app_config_beside(partial_macro, body)
|
|
181
|
+
write( 'src/config.h', "#ifndef APP_CONFIG_H\n#define APP_CONFIG_H\n#define GAIN 3\n#endif\n" )
|
|
182
|
+
write( 'include/drivers/uart/config.h', "#ifndef UART_CONFIG_H\n#define UART_CONFIG_H\nint uart_config_baud(void);\n#endif\n" )
|
|
183
|
+
write( 'src/drivers/uart/config.c', "#include \"drivers/uart/config.h\"\nint uart_config_baud(void) { return 9600; }\n" )
|
|
184
|
+
write( 'src/motor.h', "#ifndef MOTOR_H\n#define MOTOR_H\n#include \"config.h\"\ntypedef struct motor { int v[GAIN]; } motor_t;\nint motor_run(void);\n#endif\n" )
|
|
185
|
+
write( 'src/motor.c', "#include \"motor.h\"\nint motor_run(void) { motor_t m = {{0}}; (void)m; return GAIN; }\n" )
|
|
186
|
+
write( 'test/test_motor.c', PARTIALS_DISAMBIG_PREAMBLE +
|
|
187
|
+
"#include TEST_PARTIAL_PUBLIC_MODULE(motor)\n#include #{partial_macro}\n" \
|
|
188
|
+
"void setUp(void) {}\nvoid tearDown(void) {}\nvoid test_run(void) { TEST_ASSERT_EQUAL_INT(3, motor_run()); #{body} }\n" )
|
|
189
|
+
end
|
|
190
|
+
|
|
191
|
+
# Fallback reads an #include as written, which the compiler looks for beside the file
|
|
192
|
+
# holding it before any search path
|
|
193
|
+
[false, true].each do |fallback|
|
|
194
|
+
it "takes a module's own header from beside its source#{' under fallback preprocessing' if fallback}" do
|
|
195
|
+
in_project do
|
|
196
|
+
include_paths( ['src/**'] )
|
|
197
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true }, :test_build => { :preprocess_force_fallback => fallback } } )
|
|
198
|
+
write( 'src/config.h', "#ifndef APP_CONFIG_H\n#define APP_CONFIG_H\n#define GAIN 3\n#endif\n" )
|
|
199
|
+
write( 'src/drivers/uart/config.h', "#ifndef UART_CONFIG_H\n#define UART_CONFIG_H\n" \
|
|
200
|
+
"typedef struct uart_cfg { int baud; } uart_cfg_t;\nint uart_config_baud(void);\n#endif\n" )
|
|
201
|
+
write( 'src/drivers/uart/uses.h', "#ifndef UART_USES_H\n#define UART_USES_H\nint uart_use(uart_cfg_t *c);\n#endif\n" )
|
|
202
|
+
write( 'src/drivers/uart/config.c', "#include \"config.h\"\n#include \"uses.h\"\nint uart_use(uart_cfg_t *c) { return c->baud; }\n" \
|
|
203
|
+
"int uart_config_baud(void) { uart_cfg_t c = { 11 }; return uart_use(&c); }\n" )
|
|
204
|
+
write( 'test/test_uart.c', PARTIALS_DISAMBIG_PREAMBLE + "#include TEST_PARTIAL_PUBLIC_MODULE_AT(drivers/uart, config)\n" \
|
|
205
|
+
"void setUp(void) {}\nvoid tearDown(void) {}\nvoid test_baud(void) { TEST_ASSERT_EQUAL_INT(11, uart_config_baud()); }\n" )
|
|
206
|
+
|
|
207
|
+
build_passing
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
|
|
212
|
+
[false, true].each do |fallback|
|
|
213
|
+
it "mocks a same-named module a tested Partial includes by its path#{' under fallback preprocessing' if fallback}" do
|
|
214
|
+
in_project do
|
|
215
|
+
include_paths( ['src/**', 'include/**'] )
|
|
216
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true }, :test_build => { :preprocess_force_fallback => fallback } } )
|
|
217
|
+
same_named_configs
|
|
218
|
+
|
|
219
|
+
build_passing
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
end
|
|
223
|
+
|
|
224
|
+
# A bare #include under fallback names the header the test's search paths reach first
|
|
225
|
+
[false, true].each do |fallback|
|
|
226
|
+
mode = fallback ? ' under fallback preprocessing' : ''
|
|
227
|
+
|
|
228
|
+
it "keeps an application header sharing the basename of a mocked Partial#{mode}" do
|
|
229
|
+
in_project do
|
|
230
|
+
include_paths( ['src/**', 'include/**'] )
|
|
231
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true }, :test_build => { :preprocess_force_fallback => fallback } } )
|
|
232
|
+
app_config_beside( 'MOCK_PARTIAL_PUBLIC_MODULE_AT(drivers/uart, config)',
|
|
233
|
+
'uart_config_baud_ExpectAndReturn(2); TEST_ASSERT_EQUAL_INT(2, uart_config_baud());' )
|
|
234
|
+
|
|
235
|
+
build_passing
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
239
|
+
it "keeps an application header sharing the basename of a tested Partial#{mode}" do
|
|
240
|
+
in_project do
|
|
241
|
+
include_paths( ['src/**', 'include/**'] )
|
|
242
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true }, :test_build => { :preprocess_force_fallback => fallback } } )
|
|
243
|
+
app_config_beside( 'TEST_PARTIAL_PUBLIC_MODULE_AT(drivers/uart, config)', 'TEST_ASSERT_EQUAL_INT(9600, uart_config_baud());' )
|
|
244
|
+
|
|
245
|
+
build_passing
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
# Fallback anchors a `..` #include to its file's own directory, which may name no file at
|
|
251
|
+
# all when the compiler finds the header through a search path
|
|
252
|
+
it "takes a `..` #include fallback can't anchor for a module's own header" do
|
|
253
|
+
in_project do
|
|
254
|
+
include_paths( ['include/**'] )
|
|
255
|
+
@c.merge_project_yml_for_test( { :project => { :use_partials => true }, :test_build => { :preprocess_force_fallback => true } } )
|
|
256
|
+
write( 'include/hw/port.h', "#ifndef PORT_H\n#define PORT_H\ntypedef struct port_cfg { int pin; } port_cfg_t;\nint port_open(void);\n#endif\n" )
|
|
257
|
+
write( 'include/hw/sub/placeholder.h', "#ifndef PLACEHOLDER_H\n#define PLACEHOLDER_H\n#endif\n" )
|
|
258
|
+
write( 'src/hw/port.c', "#include \"../port.h\"\nint port_open(void) { port_cfg_t c = { 7 }; return c.pin; }\n" )
|
|
259
|
+
write( 'test/test_port.c', PARTIALS_DISAMBIG_PREAMBLE + "#include TEST_PARTIAL_PUBLIC_MODULE_AT(hw, port)\n" \
|
|
260
|
+
"void setUp(void) {}\nvoid tearDown(void) {}\nvoid test_open(void) { TEST_ASSERT_EQUAL_INT(7, port_open()); }\n" )
|
|
261
|
+
|
|
262
|
+
build_passing
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
end
|
|
266
|
+
|
|
142
267
|
end
|
|
143
268
|
end
|
|
@@ -83,20 +83,24 @@ ceedling_system_tests do
|
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
# The mock search path for the header's mirrored directory reaches the #include as written
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
# The mock search path for the header's mirrored directory reaches the #include as written.
|
|
87
|
+
# Test preprocessing finds and places the mock by the #include anchored to the test file's
|
|
88
|
+
# directory, as the text scan does.
|
|
89
|
+
[:none, :tests, :all].each do |preprocessor|
|
|
90
|
+
it "G14: builds a mock #include that climbs with `..`, keeping the mock below its test's mocks directory, under :use_test_preprocessor #{preprocessor}" do
|
|
91
|
+
in_app do
|
|
92
|
+
write( 'inc/x/foo.h', "int foo_read(void);\n" )
|
|
93
|
+
write( 'test/test_c.c', PROBE_TEST_PREAMBLE + "#include \"../x/mock_foo.h\"\nvoid test_reads(void) { foo_read_ExpectAndReturn(5); TEST_ASSERT_EQUAL_INT(5, foo_read()); }\n" )
|
|
94
|
+
@c.merge_project_yml_for_test( { :project => { :use_test_preprocessor => preprocessor }, :paths => { :include => ['inc/**'] } } )
|
|
92
95
|
|
|
93
|
-
|
|
96
|
+
output = @c.ceedling_build_exec( "test:all" )
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
expect(@c.last_exit_status).to eq(0), output
|
|
99
|
+
expect(output).to match(/PASSED:\s+1/)
|
|
100
|
+
expect(Dir.glob( 'build/test/mocks/test/test_c/**/mock_foo.h' )).to_not be_empty
|
|
101
|
+
expect(Dir.children( 'build/test/mocks' )).to eq( ['test'] )
|
|
102
|
+
expect(Dir.children( 'build/test/mocks/test' )).to eq( ['test_c'] )
|
|
103
|
+
end
|
|
100
104
|
end
|
|
101
105
|
end
|
|
102
106
|
|