ceedling 0.20.3 → 0.21.0
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/Gemfile +3 -0
- data/Gemfile.lock +1 -0
- data/Rakefile +1 -0
- data/bin/ceedling +79 -26
- data/lib/ceedling/configurator_plugins.rb +0 -18
- data/lib/ceedling/rules_cmock.rake +1 -1
- data/lib/ceedling/tasks_base.rake +5 -1
- data/lib/ceedling/tasks_tests.rake +12 -9
- data/lib/ceedling/version.rb +1 -1
- data/lib/ceedling/version.rb.erb +1 -1
- data/plugins/fake_function_framework/README.md +250 -0
- data/plugins/fake_function_framework/Rakefile +19 -0
- data/plugins/fake_function_framework/examples/fff_example/project.yml +71 -0
- data/plugins/fake_function_framework/examples/fff_example/rakefile.rb +7 -0
- data/plugins/fake_function_framework/examples/fff_example/src/bar.c +1 -0
- data/plugins/fake_function_framework/examples/fff_example/src/bar.h +13 -0
- data/plugins/fake_function_framework/examples/fff_example/src/custom_types.h +6 -0
- data/plugins/fake_function_framework/examples/fff_example/src/display.c +7 -0
- data/plugins/fake_function_framework/examples/fff_example/src/display.h +16 -0
- data/plugins/fake_function_framework/examples/fff_example/src/event_processor.c +92 -0
- data/plugins/fake_function_framework/examples/fff_example/src/event_processor.h +11 -0
- data/plugins/fake_function_framework/examples/fff_example/src/foo.c +16 -0
- data/plugins/fake_function_framework/examples/fff_example/src/foo.h +8 -0
- data/plugins/fake_function_framework/examples/fff_example/src/subfolder/zzz.c +1 -0
- data/plugins/fake_function_framework/examples/fff_example/src/subfolder/zzz.h +6 -0
- data/plugins/fake_function_framework/examples/fff_example/test/test_event_processor.c +155 -0
- data/plugins/fake_function_framework/examples/fff_example/test/test_foo.c +47 -0
- data/plugins/fake_function_framework/lib/fake_function_framework.rb +87 -0
- data/plugins/fake_function_framework/lib/fff_mock_generator.rb +159 -0
- data/plugins/fake_function_framework/spec/fff_mock_generator_spec.rb +464 -0
- data/plugins/fake_function_framework/spec/spec_helper.rb +96 -0
- data/plugins/fake_function_framework/src/fff_unity_helper.h +33 -0
- data/plugins/fake_function_framework/vendor/fff/LICENSE +25 -0
- data/plugins/fake_function_framework/vendor/fff/Makefile +10 -0
- data/plugins/fake_function_framework/vendor/fff/README.md +454 -0
- data/plugins/fake_function_framework/vendor/fff/buildandtest +15 -0
- data/plugins/fake_function_framework/vendor/fff/examples/Makefile +7 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/Makefile +64 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.c +24 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.h +11 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.cpp +50 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/driver.test.fff.cpp +62 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/hardware_abstraction.h +15 -0
- data/plugins/fake_function_framework/vendor/fff/examples/driver_testing/registers.h +13 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/DISPLAY.h +17 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/Kata.txt +25 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/Makefile +67 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/SYSTEM.h +21 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/UI.c +48 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/UI.h +12 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/UI_test_ansic.c +183 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/UI_test_cpp.cpp +136 -0
- data/plugins/fake_function_framework/vendor/fff/examples/embedded_ui/test_suite_template.c +34 -0
- data/plugins/fake_function_framework/vendor/fff/fakegen.rb +420 -0
- data/plugins/fake_function_framework/vendor/fff/fff.h +5112 -0
- data/plugins/fake_function_framework/vendor/fff/gtest/Makefile +22 -0
- data/plugins/fake_function_framework/vendor/fff/gtest/gtest-all.cc +9118 -0
- data/plugins/fake_function_framework/vendor/fff/gtest/gtest-main.cc +6 -0
- data/plugins/fake_function_framework/vendor/fff/gtest/gtest.h +19537 -0
- data/plugins/fake_function_framework/vendor/fff/test/Makefile +81 -0
- data/plugins/fake_function_framework/vendor/fff/test/c_test_framework.h +15 -0
- data/plugins/fake_function_framework/vendor/fff/test/fff_test_c.c +108 -0
- data/plugins/fake_function_framework/vendor/fff/test/fff_test_cpp.cpp +45 -0
- data/plugins/fake_function_framework/vendor/fff/test/fff_test_global_c.c +76 -0
- data/plugins/fake_function_framework/vendor/fff/test/fff_test_global_cpp.cpp +23 -0
- data/plugins/fake_function_framework/vendor/fff/test/global_fakes.c +13 -0
- data/plugins/fake_function_framework/vendor/fff/test/global_fakes.h +37 -0
- data/plugins/fake_function_framework/vendor/fff/test/test_cases.include +276 -0
- data/plugins/gcov/README.md +9 -0
- data/plugins/gcov/{template.erb → assets/template.erb} +1 -1
- data/plugins/gcov/{defaults.yml → config/defaults.yml} +10 -1
- data/plugins/gcov/gcov.rake +20 -8
- data/plugins/gcov/{gcov.rb → lib/gcov.rb} +13 -24
- data/plugins/module_generator/module_generator.rake +3 -3
- data/plugins/warnings_report/lib/warnings_report.rb +69 -0
- data/plugins/xml_tests_report/lib/xml_tests_report.rb +108 -0
- data/spec/spec_system_helper.rb +1 -1
- data/vendor/c_exception/lib/CException.h +1 -1
- data/vendor/c_exception/vendor/unity/auto/generate_module.rb +16 -16
- data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +61 -21
- data/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +5 -1
- data/vendor/c_exception/vendor/unity/auto/unity_to_junit.py +146 -0
- data/vendor/c_exception/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
- data/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
- data/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
- data/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
- data/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
- data/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +7 -7
- data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -2
- data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +14 -14
- data/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +2 -2
- data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +5 -5
- data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +5 -5
- data/vendor/c_exception/vendor/unity/examples/unity_config.h +257 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +9 -8
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +1 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +28 -8
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +57 -17
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +3 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +2 -3
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +1 -1
- data/vendor/c_exception/vendor/unity/release/version.info +1 -1
- data/vendor/c_exception/vendor/unity/src/unity.c +336 -191
- data/vendor/c_exception/vendor/unity/src/unity.h +73 -69
- data/vendor/c_exception/vendor/unity/src/unity_internals.h +119 -90
- data/vendor/c_exception/vendor/unity/test/Makefile +51 -0
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +5 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +5 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +5 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +6 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +6 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +6 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +8 -8
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +6 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +8 -8
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -7
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +5 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +7 -7
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +5 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +5 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +7 -7
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +6 -6
- data/vendor/c_exception/vendor/unity/test/rakefile +5 -0
- data/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +9 -7
- data/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +3 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_limits.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v4.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5_3.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_cortexm3_v5.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_msp430.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/targets/iar_sh2a_v6.yml +1 -0
- data/vendor/c_exception/vendor/unity/test/testdata/CException.h +11 -0
- data/vendor/c_exception/vendor/unity/test/testdata/Defs.h +8 -0
- data/vendor/c_exception/vendor/unity/test/testdata/cmock.h +14 -0
- data/vendor/c_exception/vendor/unity/test/testdata/mockMock.h +13 -0
- data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGenerator.c +183 -0
- data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +65 -0
- data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -0
- data/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +1221 -71
- data/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +1 -1
- data/vendor/c_exception/vendor/unity/test/tests/testunity.c +127 -5
- data/vendor/cmock/docs/CMock_Summary.md +1 -1
- data/vendor/cmock/lib/cmock_generator.rb +7 -2
- data/vendor/cmock/lib/cmock_header_parser.rb +29 -9
- data/vendor/cmock/scripts/create_mock.rb +1 -1
- data/vendor/cmock/test/system/test_compilation/const.h +15 -0
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +4 -4
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +136 -73
- data/vendor/cmock/vendor/c_exception/lib/CException.h +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +16 -16
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +61 -21
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +5 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_to_junit.py +146 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode.c +7 -7
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -2
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode.c +14 -14
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/TestProductionCode2.c +2 -2
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/unity_config.h +257 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +9 -8
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +28 -8
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +57 -17
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +3 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +2 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +336 -191
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +73 -69
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +119 -90
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/Makefile +51 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +8 -8
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +8 -8
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -7
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +7 -7
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +5 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +7 -7
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +6 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/rakefile +5 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +9 -7
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +3 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_limits.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_arm_v4.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_arm_v5_3.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_cortexm3_v5.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_msp430.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/iar_sh2a_v6.yml +1 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/CException.h +11 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/Defs.h +8 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/cmock.h +14 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/mockMock.h +13 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGenerator.c +183 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +65 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +1221 -71
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +127 -5
- data/vendor/cmock/vendor/unity/auto/generate_module.rb +16 -16
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +61 -21
- data/vendor/cmock/vendor/unity/auto/stylize_as_junit.rb +5 -1
- data/vendor/cmock/vendor/unity/auto/unity_to_junit.py +146 -0
- data/vendor/cmock/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
- data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
- data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
- data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
- data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
- data/vendor/cmock/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode.c +7 -7
- data/vendor/cmock/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -2
- data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode.c +14 -14
- data/vendor/cmock/vendor/unity/examples/example_1/test/TestProductionCode2.c +2 -2
- data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +5 -5
- data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +5 -5
- data/vendor/cmock/vendor/unity/examples/unity_config.h +257 -0
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +3 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +5 -2
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +1 -2
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.h +1 -1
- data/vendor/cmock/vendor/unity/src/unity.c +329 -186
- data/vendor/cmock/vendor/unity/src/unity.h +73 -69
- data/vendor/cmock/vendor/unity/src/unity_internals.h +119 -94
- data/vendor/cmock/vendor/unity/test/Makefile +4 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +5 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +5 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.c +5 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_cmd.c +6 -6
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_def.c +6 -6
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.c +6 -6
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -6
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_new2.c +8 -8
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_param.c +6 -6
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -6
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_run2.c +8 -8
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -7
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +5 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +7 -7
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +5 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +5 -5
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +7 -7
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +6 -6
- data/vendor/cmock/vendor/unity/test/rakefile +5 -0
- data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +9 -7
- data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +3 -0
- data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_limits.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_stdint.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/gcc_manual_math.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_arm_v4.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_arm_v5_3.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_cortexm3_v5.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_msp430.yml +1 -0
- data/vendor/cmock/vendor/unity/test/targets/iar_sh2a_v6.yml +1 -0
- data/vendor/cmock/vendor/unity/test/testdata/CException.h +11 -0
- data/vendor/cmock/vendor/unity/test/testdata/Defs.h +8 -0
- data/vendor/cmock/vendor/unity/test/testdata/cmock.h +14 -0
- data/vendor/cmock/vendor/unity/test/testdata/mockMock.h +13 -0
- data/vendor/cmock/vendor/unity/test/testdata/testRunnerGenerator.c +183 -0
- data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +65 -0
- data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -0
- data/vendor/cmock/vendor/unity/test/tests/test_generate_test_runner.rb +1221 -71
- data/vendor/cmock/vendor/unity/test/tests/testparameterized.c +1 -1
- data/vendor/cmock/vendor/unity/test/tests/testunity.c +104 -7
- data/vendor/deep_merge/README +94 -94
- data/vendor/deep_merge/Rakefile +28 -28
- data/vendor/deep_merge/lib/deep_merge.rb +211 -211
- data/vendor/deep_merge/test/test_deep_merge.rb +553 -553
- data/vendor/unity/auto/generate_module.rb +16 -16
- data/vendor/unity/auto/generate_test_runner.rb +61 -21
- data/vendor/unity/auto/stylize_as_junit.rb +5 -1
- data/vendor/unity/auto/unity_to_junit.py +146 -0
- data/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
- data/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
- data/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
- data/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
- data/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
- data/vendor/unity/examples/example_1/makefile +1 -1
- data/vendor/unity/examples/example_1/src/ProductionCode.c +7 -7
- data/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -2
- data/vendor/unity/examples/example_1/test/TestProductionCode.c +14 -14
- data/vendor/unity/examples/example_1/test/TestProductionCode2.c +2 -2
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +5 -5
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +5 -5
- data/vendor/unity/examples/unity_config.h +257 -0
- data/vendor/unity/extras/fixture/src/unity_fixture.c +3 -0
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +5 -2
- data/vendor/unity/extras/fixture/test/unity_output_Spy.c +1 -2
- data/vendor/unity/extras/fixture/test/unity_output_Spy.h +1 -1
- data/vendor/unity/src/unity.c +329 -186
- data/vendor/unity/src/unity.h +73 -69
- data/vendor/unity/src/unity_internals.h +119 -94
- data/vendor/unity/test/Makefile +4 -5
- data/vendor/unity/test/expectdata/testsample_cmd.c +5 -5
- data/vendor/unity/test/expectdata/testsample_def.c +5 -5
- data/vendor/unity/test/expectdata/testsample_head1.c +5 -5
- data/vendor/unity/test/expectdata/testsample_mock_cmd.c +6 -6
- data/vendor/unity/test/expectdata/testsample_mock_def.c +6 -6
- data/vendor/unity/test/expectdata/testsample_mock_head1.c +6 -6
- data/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -6
- data/vendor/unity/test/expectdata/testsample_mock_new2.c +8 -8
- data/vendor/unity/test/expectdata/testsample_mock_param.c +6 -6
- data/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -6
- data/vendor/unity/test/expectdata/testsample_mock_run2.c +8 -8
- data/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -7
- data/vendor/unity/test/expectdata/testsample_new1.c +5 -5
- data/vendor/unity/test/expectdata/testsample_new2.c +7 -7
- data/vendor/unity/test/expectdata/testsample_param.c +5 -5
- data/vendor/unity/test/expectdata/testsample_run1.c +5 -5
- data/vendor/unity/test/expectdata/testsample_run2.c +7 -7
- data/vendor/unity/test/expectdata/testsample_yaml.c +6 -6
- data/vendor/unity/test/rakefile +5 -0
- data/vendor/unity/test/rakefile_helper.rb +9 -7
- data/vendor/unity/test/targets/clang_file.yml +1 -0
- data/vendor/unity/test/targets/clang_strict.yml +3 -0
- data/vendor/unity/test/targets/gcc_32.yml +1 -0
- data/vendor/unity/test/targets/gcc_64.yml +1 -0
- data/vendor/unity/test/targets/gcc_auto_limits.yml +1 -0
- data/vendor/unity/test/targets/gcc_auto_sizeof.yml +1 -0
- data/vendor/unity/test/targets/gcc_auto_stdint.yml +1 -0
- data/vendor/unity/test/targets/gcc_manual_math.yml +1 -0
- data/vendor/unity/test/targets/iar_arm_v4.yml +1 -0
- data/vendor/unity/test/targets/iar_arm_v5.yml +1 -0
- data/vendor/unity/test/targets/iar_arm_v5_3.yml +1 -0
- data/vendor/unity/test/targets/iar_armcortex_LM3S9B92_v5_4.yml +1 -0
- data/vendor/unity/test/targets/iar_cortexm3_v5.yml +1 -0
- data/vendor/unity/test/targets/iar_msp430.yml +1 -0
- data/vendor/unity/test/targets/iar_sh2a_v6.yml +1 -0
- data/vendor/unity/test/testdata/CException.h +11 -0
- data/vendor/unity/test/testdata/Defs.h +8 -0
- data/vendor/unity/test/testdata/cmock.h +14 -0
- data/vendor/unity/test/testdata/mockMock.h +13 -0
- data/vendor/unity/test/testdata/testRunnerGenerator.c +183 -0
- data/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +65 -0
- data/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +192 -0
- data/vendor/unity/test/tests/test_generate_test_runner.rb +1221 -71
- data/vendor/unity/test/tests/testparameterized.c +1 -1
- data/vendor/unity/test/tests/testunity.c +104 -7
- metadata +124 -32
- data/plugins/gcov/readme.txt +0 -0
- data/plugins/warnings_report/warnings_report.rb +0 -71
- data/plugins/xml_tests_report/xml_tests_report.rb +0 -110
- data/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +0 -224
- data/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +0 -51
- data/vendor/c_exception/vendor/unity/test/testdata/sample.yml +0 -9
- data/vendor/c_exception/vendor/unity/test/testdata/testsample.c +0 -68
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +0 -224
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +0 -51
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/sample.yml +0 -9
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testsample.c +0 -68
- data/vendor/cmock/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/cmock/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/cmock/vendor/unity/docs/Unity Summary.txt +0 -224
- data/vendor/cmock/vendor/unity/test/testdata/mocksample.c +0 -51
- data/vendor/cmock/vendor/unity/test/testdata/sample.yml +0 -9
- data/vendor/cmock/vendor/unity/test/testdata/testsample.c +0 -68
- data/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/unity/docs/Unity Summary.txt +0 -224
- data/vendor/unity/test/testdata/mocksample.c +0 -51
- data/vendor/unity/test/testdata/sample.yml +0 -9
- data/vendor/unity/test/testdata/testsample.c +0 -68
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#include "unity.h"
|
|
2
|
+
#include "foo.h"
|
|
3
|
+
#include "mock_bar.h"
|
|
4
|
+
#include "mock_zzz.h"
|
|
5
|
+
|
|
6
|
+
void setUp(void)
|
|
7
|
+
{
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
void tearDown(void)
|
|
11
|
+
{
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
void test_foo(void)
|
|
15
|
+
{
|
|
16
|
+
//When
|
|
17
|
+
foo_turn_on();
|
|
18
|
+
|
|
19
|
+
//Then
|
|
20
|
+
TEST_ASSERT_EQUAL(1, bar_turn_on_fake.call_count);
|
|
21
|
+
TEST_ASSERT_EQUAL(1, zzz_sleep_fake.call_count);
|
|
22
|
+
TEST_ASSERT_EQUAL_STRING("sleepy", zzz_sleep_fake.arg1_val);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void test_foo_again(void)
|
|
26
|
+
{
|
|
27
|
+
//When
|
|
28
|
+
foo_turn_on();
|
|
29
|
+
|
|
30
|
+
//Then
|
|
31
|
+
TEST_ASSERT_EQUAL(1, bar_turn_on_fake.call_count);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
void test_foo_mock_with_const(void)
|
|
35
|
+
{
|
|
36
|
+
foo_print_message("123");
|
|
37
|
+
|
|
38
|
+
TEST_ASSERT_EQUAL(1, bar_print_message_fake.call_count);
|
|
39
|
+
TEST_ASSERT_EQUAL_STRING("123", bar_print_message_fake.arg0_val);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
void test_foo_mock_with_variable_args(void)
|
|
43
|
+
{
|
|
44
|
+
foo_print_special_message();
|
|
45
|
+
TEST_ASSERT_EQUAL(1, bar_print_message_formatted_fake.call_count);
|
|
46
|
+
TEST_ASSERT_EQUAL_STRING("The numbers are %d, %d and %d", bar_print_message_formatted_fake.arg0_val);
|
|
47
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
require 'ceedling/plugin'
|
|
2
|
+
require 'fff_mock_generator'
|
|
3
|
+
|
|
4
|
+
class FakeFunctionFramework < Plugin
|
|
5
|
+
|
|
6
|
+
# Set up Ceedling to use this plugin.
|
|
7
|
+
def setup
|
|
8
|
+
# Get the location of this plugin.
|
|
9
|
+
@plugin_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
10
|
+
puts "Using fake function framework (fff)..."
|
|
11
|
+
|
|
12
|
+
# Switch out the cmock_builder with our own.
|
|
13
|
+
@ceedling[:cmock_builder].cmock = FffMockGeneratorForCMock.new(@ceedling[:setupinator].config_hash[:cmock])
|
|
14
|
+
|
|
15
|
+
# Add the path to fff.h to the include paths.
|
|
16
|
+
COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR << "#{@plugin_root}/vendor/fff"
|
|
17
|
+
COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR << "#{@plugin_root}/src"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def post_runner_generate(arg_hash)
|
|
21
|
+
# After the test runner file has been created, append the FFF globals
|
|
22
|
+
# definition to the end of the test runner. These globals will be shared by
|
|
23
|
+
# all mocks linked into the test.
|
|
24
|
+
File.open(arg_hash[:runner_file], 'a') do |f|
|
|
25
|
+
f.puts
|
|
26
|
+
f.puts "//=======Defintions of FFF variables====="
|
|
27
|
+
f.puts %{#include "fff.h"}
|
|
28
|
+
f.puts "DEFINE_FFF_GLOBALS;"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end # class FakeFunctionFramework
|
|
33
|
+
|
|
34
|
+
class FffMockGeneratorForCMock
|
|
35
|
+
|
|
36
|
+
def initialize(options=nil)
|
|
37
|
+
@cm_config = CMockConfig.new(options)
|
|
38
|
+
@cm_parser = CMockHeaderParser.new(@cm_config)
|
|
39
|
+
@silent = (@cm_config.verbosity < 2)
|
|
40
|
+
|
|
41
|
+
# These are the additional files to include in the mock files.
|
|
42
|
+
@includes_h_pre_orig_header = (@cm_config.includes || @cm_config.includes_h_pre_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
|
43
|
+
@includes_h_post_orig_header = (@cm_config.includes_h_post_orig_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
|
44
|
+
@includes_c_pre_header = (@cm_config.includes_c_pre_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
|
45
|
+
@includes_c_post_header = (@cm_config.includes_c_post_header || []).map{|h| h =~ /</ ? h : "\"#{h}\""}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def setup_mocks(files)
|
|
49
|
+
[files].flatten.each do |src|
|
|
50
|
+
generate_mock (src)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def generate_mock (header_file_to_mock)
|
|
55
|
+
module_name = File.basename(header_file_to_mock, '.h')
|
|
56
|
+
puts "Creating mock for #{module_name}..." unless @silent
|
|
57
|
+
mock_name = @cm_config.mock_prefix + module_name + @cm_config.mock_suffix
|
|
58
|
+
mock_path = @cm_config.mock_path
|
|
59
|
+
if @cm_config.subdir
|
|
60
|
+
# If a subdirectory has been configured, append it to the mock path.
|
|
61
|
+
mock_path = "#{mock_path}/#{@cm_config.subdir}"
|
|
62
|
+
end
|
|
63
|
+
full_path_for_mock = "#{mock_path}/#{mock_name}"
|
|
64
|
+
|
|
65
|
+
# Parse the header file so we know what to mock.
|
|
66
|
+
parsed_header = @cm_parser.parse(module_name, File.read(header_file_to_mock))
|
|
67
|
+
|
|
68
|
+
# Create the directory if it doesn't exist.
|
|
69
|
+
mkdir_p full_path_for_mock.pathmap("%d")
|
|
70
|
+
|
|
71
|
+
# Generate the mock header file.
|
|
72
|
+
puts "Creating mock: #{full_path_for_mock}.h"
|
|
73
|
+
|
|
74
|
+
# Create the mock header.
|
|
75
|
+
File.open("#{full_path_for_mock}.h", 'w') do |f|
|
|
76
|
+
f.write(FffMockGenerator.create_mock_header(module_name, mock_name, parsed_header,
|
|
77
|
+
@includes_h_pre_orig_header, @includes_h_post_orig_header))
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Create the mock source file.
|
|
81
|
+
File.open("#{full_path_for_mock}.c", 'w') do |f|
|
|
82
|
+
f.write(FffMockGenerator.create_mock_source(mock_name, parsed_header,
|
|
83
|
+
@includes_c_pre_orig_header, @includes_c_post_orig_header))
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
end
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# Creates mock files from parsed header files that can be linked into applications.
|
|
2
|
+
# The mocks created are compatible with CMock for use with Ceedling.
|
|
3
|
+
|
|
4
|
+
class FffMockGenerator
|
|
5
|
+
|
|
6
|
+
def self.create_mock_header(module_name, mock_name, parsed_header, pre_includes=nil,
|
|
7
|
+
post_includes=nil)
|
|
8
|
+
output = StringIO.new
|
|
9
|
+
write_opening_include_guard(mock_name, output)
|
|
10
|
+
output.puts
|
|
11
|
+
write_extra_includes(pre_includes, output)
|
|
12
|
+
write_header_includes(module_name, output)
|
|
13
|
+
write_extra_includes(post_includes, output)
|
|
14
|
+
output.puts
|
|
15
|
+
write_typedefs(parsed_header, output)
|
|
16
|
+
output.puts
|
|
17
|
+
write_function_declarations(parsed_header, output)
|
|
18
|
+
output.puts
|
|
19
|
+
write_control_function_prototypes(mock_name, output)
|
|
20
|
+
output.puts
|
|
21
|
+
write_closing_include_guard(mock_name, output)
|
|
22
|
+
output.string
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def self.create_mock_source (mock_name, parsed_header, pre_includes=nil,
|
|
26
|
+
post_includes=nil)
|
|
27
|
+
output = StringIO.new
|
|
28
|
+
write_extra_includes(pre_includes, output)
|
|
29
|
+
write_source_includes(mock_name, output)
|
|
30
|
+
write_extra_includes(post_includes, output)
|
|
31
|
+
output.puts
|
|
32
|
+
write_function_definitions(parsed_header, output)
|
|
33
|
+
output.puts
|
|
34
|
+
write_control_function_definitions(mock_name, parsed_header, output)
|
|
35
|
+
output.string
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
private
|
|
39
|
+
|
|
40
|
+
# Header file generation functions.
|
|
41
|
+
|
|
42
|
+
def self.write_opening_include_guard(mock_name, output)
|
|
43
|
+
output.puts "#ifndef #{mock_name}_H"
|
|
44
|
+
output.puts "#define #{mock_name}_H"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.write_header_includes(module_name, output)
|
|
48
|
+
output.puts %{#include "fff.h"}
|
|
49
|
+
output.puts %{#include "fff_unity_helper.h"}
|
|
50
|
+
output.puts %{#include "#{module_name}.h"}
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def self.write_typedefs(parsed_header, output)
|
|
54
|
+
return unless parsed_header.key?(:typedefs)
|
|
55
|
+
parsed_header[:typedefs].each do |typedef|
|
|
56
|
+
output.puts typedef
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.write_function_declarations(parsed_header, output)
|
|
61
|
+
write_function_macros("DECLARE", parsed_header, output)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def self.write_control_function_prototypes(mock_name, output)
|
|
66
|
+
output.puts "void #{mock_name}_Init(void);"
|
|
67
|
+
output.puts "void #{mock_name}_Verify(void);"
|
|
68
|
+
output.puts "void #{mock_name}_Destroy(void);"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def self.write_closing_include_guard(mock_name, output)
|
|
72
|
+
output.puts "#endif // #{mock_name}_H"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Source file generation functions.
|
|
76
|
+
|
|
77
|
+
def self.write_source_includes (mock_name, output)
|
|
78
|
+
output.puts "#include <string.h>"
|
|
79
|
+
output.puts %{#include "fff.h"}
|
|
80
|
+
output.puts %{#include "#{mock_name}.h"}
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def self.write_function_definitions(parsed_header, output)
|
|
84
|
+
write_function_macros("DEFINE", parsed_header, output)
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.write_control_function_definitions(mock_name, parsed_header, output)
|
|
88
|
+
output.puts "void #{mock_name}_Init(void)"
|
|
89
|
+
output.puts "{"
|
|
90
|
+
# In the init function, reset the FFF globals. These are used for things
|
|
91
|
+
# like the call history.
|
|
92
|
+
output.puts " FFF_RESET_HISTORY();"
|
|
93
|
+
|
|
94
|
+
# Also, reset all of the fakes.
|
|
95
|
+
if parsed_header[:functions]
|
|
96
|
+
parsed_header[:functions].each do |function|
|
|
97
|
+
output.puts " RESET_FAKE(#{function[:name]})"
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
output.puts "}"
|
|
101
|
+
output.puts "void #{mock_name}_Verify(void)"
|
|
102
|
+
output.puts "{"
|
|
103
|
+
output.puts "}"
|
|
104
|
+
output.puts "void #{mock_name}_Destroy(void)"
|
|
105
|
+
output.puts "{"
|
|
106
|
+
output.puts "}"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Shared functions.
|
|
110
|
+
|
|
111
|
+
def self.write_extra_includes(includes, output)
|
|
112
|
+
if includes
|
|
113
|
+
includes.each {|inc| output.puts "#include #{inc}\n"}
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def self.write_function_macros(macro_type, parsed_header, output)
|
|
118
|
+
return unless parsed_header.key?(:functions)
|
|
119
|
+
parsed_header[:functions].each do |function|
|
|
120
|
+
name = function[:name]
|
|
121
|
+
return_type = function[:return][:type]
|
|
122
|
+
arg_count = function[:args].size
|
|
123
|
+
|
|
124
|
+
# Check for variable arguments.
|
|
125
|
+
var_arg_suffix = ""
|
|
126
|
+
if function[:var_arg]
|
|
127
|
+
# If there are are variable arguments, then we need to add this argument
|
|
128
|
+
# to the count, update the suffix that will get added to the macro.
|
|
129
|
+
arg_count += 1
|
|
130
|
+
var_arg_suffix = "_VARARG"
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Generate the correct macro.
|
|
134
|
+
if return_type == 'void'
|
|
135
|
+
output.print "#{macro_type}_FAKE_VOID_FUNC#{arg_count}#{var_arg_suffix}(#{name}"
|
|
136
|
+
else
|
|
137
|
+
output.print "#{macro_type}_FAKE_VALUE_FUNC#{arg_count}#{var_arg_suffix}(#{return_type}, #{name}"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
# Append each argument type.
|
|
141
|
+
function[:args].each do |arg|
|
|
142
|
+
output.print ", "
|
|
143
|
+
if arg[:const?]
|
|
144
|
+
output.print "const "
|
|
145
|
+
end
|
|
146
|
+
output.print "#{arg[:type]}"
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# If this argument list ends with a variable argument, add it here at the end.
|
|
150
|
+
if function[:var_arg]
|
|
151
|
+
output.print ", ..."
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# Close the declaration.
|
|
155
|
+
output.puts ");"
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
end
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
require 'stringio'
|
|
2
|
+
require 'fff_mock_generator.rb'
|
|
3
|
+
|
|
4
|
+
describe "FffMockGenerator.create_mock_header" do
|
|
5
|
+
|
|
6
|
+
context "when there is nothing to mock," do
|
|
7
|
+
let(:mock_header) {
|
|
8
|
+
parsed_header = {}
|
|
9
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
10
|
+
}
|
|
11
|
+
it "then the generated header file starts with an opening include guard" do
|
|
12
|
+
expect(mock_header).to start_with(
|
|
13
|
+
"#ifndef mock_display_H\n" +
|
|
14
|
+
"#define mock_display_H")
|
|
15
|
+
end
|
|
16
|
+
it "then the generated file ends with a closing include guard" do
|
|
17
|
+
expect(mock_header).to end_with(
|
|
18
|
+
"#endif // mock_display_H\n")
|
|
19
|
+
end
|
|
20
|
+
it "then the generated file includes the fff header" do
|
|
21
|
+
expect(mock_header).to include(
|
|
22
|
+
%{#include "fff.h"\n})
|
|
23
|
+
end
|
|
24
|
+
it "then the generated file has a prototype for the init function" do
|
|
25
|
+
expect(mock_header).to include(
|
|
26
|
+
"void mock_display_Init(void);")
|
|
27
|
+
end
|
|
28
|
+
it "then the generated file has a prototype for the verify function" do
|
|
29
|
+
expect(mock_header).to include(
|
|
30
|
+
"void mock_display_Verify(void);")
|
|
31
|
+
end
|
|
32
|
+
it "then the generated file has a prototype for the destroy function" do
|
|
33
|
+
expect(mock_header).to include(
|
|
34
|
+
"void mock_display_Destroy(void);")
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context "when there is a function with no args and a void return," do
|
|
39
|
+
let(:mock_header) {
|
|
40
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
41
|
+
[{:name => 'display_turnOffStatusLed', :return_type => 'void'}])
|
|
42
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
43
|
+
}
|
|
44
|
+
it "then the generated header file starts with an opening include guard" do
|
|
45
|
+
expect(mock_header).to start_with(
|
|
46
|
+
"#ifndef mock_display_H\n" +
|
|
47
|
+
"#define mock_display_H")
|
|
48
|
+
end
|
|
49
|
+
it "then the generated header file contains a fake function declaration" do
|
|
50
|
+
expect(mock_header).to include(
|
|
51
|
+
"DECLARE_FAKE_VOID_FUNC0(display_turnOffStatusLed);"
|
|
52
|
+
)
|
|
53
|
+
end
|
|
54
|
+
it "then the generated file ends with a closing include guard" do
|
|
55
|
+
expect(mock_header).to end_with(
|
|
56
|
+
"#endif // mock_display_H\n")
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
context "when there is a function with no args and a bool return," do
|
|
61
|
+
let(:mock_header) {
|
|
62
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
63
|
+
[{:name => 'display_isError', :return_type => 'bool'}])
|
|
64
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
65
|
+
}
|
|
66
|
+
it "then the generated file contains the fake function declaration" do
|
|
67
|
+
expect(mock_header).to include(
|
|
68
|
+
"DECLARE_FAKE_VALUE_FUNC0(bool, display_isError);"
|
|
69
|
+
)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
context "when there is a function with no args and an int return," do
|
|
74
|
+
let(:mock_header) {
|
|
75
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
76
|
+
[{:name => 'display_isError', :return_type => 'int'}])
|
|
77
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
78
|
+
}
|
|
79
|
+
it "then the generated file contains the fake function declaration" do
|
|
80
|
+
expect(mock_header).to include(
|
|
81
|
+
"DECLARE_FAKE_VALUE_FUNC0(int, display_isError);"
|
|
82
|
+
)
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
context "when there is a function with args and a void return," do
|
|
87
|
+
let(:mock_header) {
|
|
88
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
89
|
+
[{:name => 'display_setVolume', :return_type => 'void', :args => ['int']}])
|
|
90
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
91
|
+
}
|
|
92
|
+
it "then the generated file contains the fake function declaration" do
|
|
93
|
+
expect(mock_header).to include(
|
|
94
|
+
"DECLARE_FAKE_VOID_FUNC1(display_setVolume, int);"
|
|
95
|
+
)
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
context "when there is a function with args and a value return," do
|
|
100
|
+
let(:mock_header) {
|
|
101
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
102
|
+
[{:name => 'a_function', :return_type => 'int', :args => ['char *']}])
|
|
103
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
104
|
+
}
|
|
105
|
+
it "then the generated file contains the fake function declaration" do
|
|
106
|
+
expect(mock_header).to include(
|
|
107
|
+
"FAKE_VALUE_FUNC1(int, a_function, char *);"
|
|
108
|
+
)
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
context "when there is a function with many args and a void return," do
|
|
113
|
+
let(:mock_header) {
|
|
114
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
115
|
+
[{:name => 'a_function', :return_type => 'void',
|
|
116
|
+
:args => ['int', 'char *', 'int', 'int', 'bool', 'applesauce']}])
|
|
117
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
118
|
+
}
|
|
119
|
+
it "then the generated file contains the fake function declaration" do
|
|
120
|
+
expect(mock_header).to include(
|
|
121
|
+
"DECLARE_FAKE_VOID_FUNC6(a_function, int, char *, int, int, bool, applesauce);"
|
|
122
|
+
)
|
|
123
|
+
end
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
context "when there are multiple functions," do
|
|
127
|
+
let(:mock_header) {
|
|
128
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
129
|
+
[ {:name => 'a_function', :return_type => 'int', :args => ['char *']},
|
|
130
|
+
{:name => 'another_function', :return_type => 'void'},
|
|
131
|
+
{:name => 'three', :return_type => 'bool', :args => ['float', 'int']}
|
|
132
|
+
])
|
|
133
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
134
|
+
}
|
|
135
|
+
it "then the generated file contains the first fake function declaration" do
|
|
136
|
+
expect(mock_header).to include(
|
|
137
|
+
"DECLARE_FAKE_VALUE_FUNC1(int, a_function, char *);"
|
|
138
|
+
)
|
|
139
|
+
end
|
|
140
|
+
it "then the generated file contains the second fake function declaration" do
|
|
141
|
+
expect(mock_header).to include(
|
|
142
|
+
"DECLARE_FAKE_VOID_FUNC0(another_function);"
|
|
143
|
+
)
|
|
144
|
+
end
|
|
145
|
+
it "then the generated file contains the third fake function declaration" do
|
|
146
|
+
expect(mock_header).to include(
|
|
147
|
+
"DECLARE_FAKE_VALUE_FUNC2(bool, three, float, int);"
|
|
148
|
+
)
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
context "when there is a typedef," do
|
|
153
|
+
let(:mock_header) {
|
|
154
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
155
|
+
nil, ["typedef void (*displayCompleteCallback) (void);"])
|
|
156
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
157
|
+
}
|
|
158
|
+
it "then the generated file contains the typedef" do
|
|
159
|
+
expect(mock_header).to include(
|
|
160
|
+
"typedef void (*displayCompleteCallback) (void);"
|
|
161
|
+
)
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
context "when there is a void function with variable arguments" do
|
|
166
|
+
let(:mock_header){
|
|
167
|
+
parsed_header = {}
|
|
168
|
+
parsed_header[:functions] = [{
|
|
169
|
+
:name => "function_with_var_args",
|
|
170
|
+
:return => {:type => "void"},
|
|
171
|
+
:var_arg => "...",
|
|
172
|
+
:args => [{:type => 'char *'}]
|
|
173
|
+
}]
|
|
174
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
175
|
+
}
|
|
176
|
+
it "then the generated file contains the vararg declaration" do
|
|
177
|
+
expect(mock_header).to include(
|
|
178
|
+
"DECLARE_FAKE_VOID_FUNC2_VARARG(function_with_var_args, char *, ...)"
|
|
179
|
+
)
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
context "when there is a function with a return value and variable arguments" do
|
|
184
|
+
let(:mock_header){
|
|
185
|
+
parsed_header = {}
|
|
186
|
+
parsed_header[:functions] = [{
|
|
187
|
+
:name => "function_with_var_args",
|
|
188
|
+
:return => {:type => "int"},
|
|
189
|
+
:var_arg => "...",
|
|
190
|
+
:args => [{:type => 'char *'}]
|
|
191
|
+
}]
|
|
192
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
193
|
+
}
|
|
194
|
+
it "then the generated file contains the vararg declaration" do
|
|
195
|
+
expect(mock_header).to include(
|
|
196
|
+
"DECLARE_FAKE_VALUE_FUNC2_VARARG(int, function_with_var_args, char *, ...)"
|
|
197
|
+
)
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
context "when there is a void function with variable arguments and " +
|
|
202
|
+
"additional arguments" do
|
|
203
|
+
let(:mock_header){
|
|
204
|
+
parsed_header = {}
|
|
205
|
+
parsed_header[:functions] = [{
|
|
206
|
+
:name => "function_with_var_args",
|
|
207
|
+
:return => {:type => "void"},
|
|
208
|
+
:var_arg => "...",
|
|
209
|
+
:args => [{:type => 'char *'}, {:type => 'int'}]
|
|
210
|
+
}]
|
|
211
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
212
|
+
}
|
|
213
|
+
it "then the generated file contains the vararg declaration" do
|
|
214
|
+
expect(mock_header).to include(
|
|
215
|
+
"DECLARE_FAKE_VOID_FUNC3_VARARG(function_with_var_args, char *, int, ...)"
|
|
216
|
+
)
|
|
217
|
+
end
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
context "when there is a function with a pointer to a const value" do
|
|
221
|
+
let(:mock_header){
|
|
222
|
+
parsed_header = {}
|
|
223
|
+
parsed_header[:functions] = [{
|
|
224
|
+
:name => "const_test_function",
|
|
225
|
+
:return => {:type => "void"},
|
|
226
|
+
:args => [{:type => "char *", :name => "a", :ptr? => false, :const? => true},
|
|
227
|
+
{:type => "char *", :name => "b", :ptr? => false, :const? => false}]
|
|
228
|
+
}]
|
|
229
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header)
|
|
230
|
+
}
|
|
231
|
+
it "then the generated file contains the correct const argument in the declaration" do
|
|
232
|
+
expect(mock_header).to include(
|
|
233
|
+
"DECLARE_FAKE_VOID_FUNC2(const_test_function, const char *, char *)"
|
|
234
|
+
)
|
|
235
|
+
end
|
|
236
|
+
end
|
|
237
|
+
|
|
238
|
+
context "when there are pre-includes" do
|
|
239
|
+
let(:mock_header) {
|
|
240
|
+
parsed_header = {}
|
|
241
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header,
|
|
242
|
+
[%{"another_header.h"}])
|
|
243
|
+
}
|
|
244
|
+
it "then they are included before the other files" do
|
|
245
|
+
expect(mock_header).to include(
|
|
246
|
+
%{#include "another_header.h"\n} +
|
|
247
|
+
%{#include "fff.h"}
|
|
248
|
+
)
|
|
249
|
+
end
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
context "when there are post-includes" do
|
|
253
|
+
let(:mock_header) {
|
|
254
|
+
parsed_header = {}
|
|
255
|
+
FffMockGenerator.create_mock_header("display", "mock_display", parsed_header,
|
|
256
|
+
nil, [%{"another_header.h"}])
|
|
257
|
+
}
|
|
258
|
+
it "then they are included after the other files" do
|
|
259
|
+
expect(mock_header).to include(
|
|
260
|
+
%{#include "display.h"\n} +
|
|
261
|
+
%{#include "another_header.h"\n}
|
|
262
|
+
)
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
describe "FffMockGenerator.create_mock_source" do
|
|
269
|
+
|
|
270
|
+
context "when there is nothing to mock," do
|
|
271
|
+
let(:mock_source) {
|
|
272
|
+
parsed_header = {}
|
|
273
|
+
FffMockGenerator.create_mock_source("mock_my_module", parsed_header)
|
|
274
|
+
}
|
|
275
|
+
it "then the generated file includes the fff header" do
|
|
276
|
+
expect(mock_source).to include(
|
|
277
|
+
# fff.h also requires including string.h
|
|
278
|
+
%{#include <string.h>\n} +
|
|
279
|
+
%{#include "fff.h"}
|
|
280
|
+
)
|
|
281
|
+
end
|
|
282
|
+
it "then the generated file includes the mock header" do
|
|
283
|
+
expect(mock_source).to include(
|
|
284
|
+
%{#include "mock_my_module.h"\n}
|
|
285
|
+
)
|
|
286
|
+
end
|
|
287
|
+
it "then the generated file defines the init function" do
|
|
288
|
+
expect(mock_source).to include(
|
|
289
|
+
"void mock_my_module_Init(void)\n" +
|
|
290
|
+
"{\n" +
|
|
291
|
+
" FFF_RESET_HISTORY();\n" +
|
|
292
|
+
"}"
|
|
293
|
+
)
|
|
294
|
+
end
|
|
295
|
+
it "then the generated file defines the verify function" do
|
|
296
|
+
expect(mock_source).to include(
|
|
297
|
+
"void mock_my_module_Verify(void)\n" +
|
|
298
|
+
"{\n" +
|
|
299
|
+
"}"
|
|
300
|
+
)
|
|
301
|
+
end
|
|
302
|
+
it "then the generated file defines the destroy function" do
|
|
303
|
+
expect(mock_source).to include(
|
|
304
|
+
"void mock_my_module_Destroy(void)\n" +
|
|
305
|
+
"{\n" +
|
|
306
|
+
"}"
|
|
307
|
+
)
|
|
308
|
+
end
|
|
309
|
+
end
|
|
310
|
+
|
|
311
|
+
context "when there are multiple functions," do
|
|
312
|
+
let(:mock_source) {
|
|
313
|
+
parsed_header = create_cmock_style_parsed_header(
|
|
314
|
+
[ {:name => 'a_function', :return_type => 'int', :args => ['char *']},
|
|
315
|
+
{:name => 'another_function', :return_type => 'void'},
|
|
316
|
+
{:name => 'three', :return_type => 'bool', :args => ['float', 'int']}
|
|
317
|
+
])
|
|
318
|
+
FffMockGenerator.create_mock_source("mock_display", parsed_header)
|
|
319
|
+
}
|
|
320
|
+
it "then the generated file contains the first fake function definition" do
|
|
321
|
+
expect(mock_source).to include(
|
|
322
|
+
"DEFINE_FAKE_VALUE_FUNC1(int, a_function, char *);"
|
|
323
|
+
)
|
|
324
|
+
end
|
|
325
|
+
it "then the generated file contains the second fake function definition" do
|
|
326
|
+
expect(mock_source).to include(
|
|
327
|
+
"DEFINE_FAKE_VOID_FUNC0(another_function);"
|
|
328
|
+
)
|
|
329
|
+
end
|
|
330
|
+
it "then the generated file contains the third fake function definition" do
|
|
331
|
+
expect(mock_source).to include(
|
|
332
|
+
"DEFINE_FAKE_VALUE_FUNC2(bool, three, float, int);"
|
|
333
|
+
)
|
|
334
|
+
end
|
|
335
|
+
it "then the init function resets all of the fakes" do
|
|
336
|
+
expect(mock_source).to include(
|
|
337
|
+
"void mock_display_Init(void)\n" +
|
|
338
|
+
"{\n" +
|
|
339
|
+
" FFF_RESET_HISTORY();\n" +
|
|
340
|
+
" RESET_FAKE(a_function)\n" +
|
|
341
|
+
" RESET_FAKE(another_function)\n" +
|
|
342
|
+
" RESET_FAKE(three)\n" +
|
|
343
|
+
"}"
|
|
344
|
+
)
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
context "when there is a void function with variable arguments and " +
|
|
349
|
+
"additional arguments" do
|
|
350
|
+
let(:mock_source){
|
|
351
|
+
parsed_header = {}
|
|
352
|
+
parsed_header[:functions] = [{
|
|
353
|
+
:name => "function_with_var_args",
|
|
354
|
+
:return => {:type => "void"},
|
|
355
|
+
:var_arg => "...",
|
|
356
|
+
:args => [{:type => 'char *'}, {:type => 'int'}]
|
|
357
|
+
}]
|
|
358
|
+
FffMockGenerator.create_mock_source("mock_display", parsed_header)
|
|
359
|
+
}
|
|
360
|
+
it "then the generated file contains the vararg definition" do
|
|
361
|
+
expect(mock_source).to include(
|
|
362
|
+
"DEFINE_FAKE_VOID_FUNC3_VARARG(function_with_var_args, char *, int, ...)"
|
|
363
|
+
)
|
|
364
|
+
end
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
context "when there is a function with a pointer to a const value" do
|
|
368
|
+
let(:mock_source){
|
|
369
|
+
parsed_header = {}
|
|
370
|
+
parsed_header[:functions] = [{
|
|
371
|
+
:name => "const_test_function",
|
|
372
|
+
:return => {:type => "void"},
|
|
373
|
+
:args => [{:type => "char *", :name => "a", :ptr? => false, :const? => true},
|
|
374
|
+
{:type => "char *", :name => "b", :ptr? => false, :const? => false}]
|
|
375
|
+
}]
|
|
376
|
+
FffMockGenerator.create_mock_source("mock_display", parsed_header)
|
|
377
|
+
}
|
|
378
|
+
it "then the generated file contains the correct const argument in the declaration" do
|
|
379
|
+
expect(mock_source).to include(
|
|
380
|
+
"DEFINE_FAKE_VOID_FUNC2(const_test_function, const char *, char *)"
|
|
381
|
+
)
|
|
382
|
+
end
|
|
383
|
+
end
|
|
384
|
+
|
|
385
|
+
context "when there are pre-includes" do
|
|
386
|
+
let(:mock_source) {
|
|
387
|
+
parsed_source = {}
|
|
388
|
+
FffMockGenerator.create_mock_source("mock_display", parsed_source,
|
|
389
|
+
[%{"another_header.h"}])
|
|
390
|
+
}
|
|
391
|
+
it "then they are included before the other files" do
|
|
392
|
+
expect(mock_source).to include(
|
|
393
|
+
%{#include "another_header.h"\n} +
|
|
394
|
+
%{#include <string.h>}
|
|
395
|
+
)
|
|
396
|
+
end
|
|
397
|
+
end
|
|
398
|
+
|
|
399
|
+
context "when there are post-includes" do
|
|
400
|
+
let(:mock_source) {
|
|
401
|
+
parsed_source = {}
|
|
402
|
+
FffMockGenerator.create_mock_source("mock_display", parsed_source,
|
|
403
|
+
nil, [%{"another_header.h"}])
|
|
404
|
+
}
|
|
405
|
+
it "then they are included before the other files" do
|
|
406
|
+
expect(mock_source).to include(
|
|
407
|
+
%{#include "mock_display.h"\n} +
|
|
408
|
+
%{#include "another_header.h"\n}
|
|
409
|
+
)
|
|
410
|
+
end
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
# Create a CMock-style parsed header hash. This the type of hash created by
|
|
415
|
+
# CMock when parsing header files for automock generation. It contains all of
|
|
416
|
+
# includes, typedefs and functions (with return types and arguments) parsed from
|
|
417
|
+
# the header file.
|
|
418
|
+
def create_cmock_style_parsed_header(functions, typedefs = nil)
|
|
419
|
+
parsed_header = {
|
|
420
|
+
:includes => nil,
|
|
421
|
+
:functions => [],
|
|
422
|
+
:typedefs => []
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
# Add the typedefs.
|
|
426
|
+
if typedefs
|
|
427
|
+
typedefs.each do |typedef|
|
|
428
|
+
parsed_header[:typedefs] << typedef
|
|
429
|
+
end
|
|
430
|
+
end
|
|
431
|
+
|
|
432
|
+
# Add the functions.
|
|
433
|
+
if functions
|
|
434
|
+
functions.each do |function|
|
|
435
|
+
# Build the array of arguments.
|
|
436
|
+
args = []
|
|
437
|
+
if function.key?(:args)
|
|
438
|
+
function[:args].each do |arg|
|
|
439
|
+
args << {
|
|
440
|
+
:type => arg
|
|
441
|
+
}
|
|
442
|
+
end
|
|
443
|
+
end
|
|
444
|
+
parsed_header[:functions] << {
|
|
445
|
+
:name => function[:name],
|
|
446
|
+
:modifier => "",
|
|
447
|
+
:return => {
|
|
448
|
+
:type => function[:return_type],
|
|
449
|
+
:name => "cmock_to_return",
|
|
450
|
+
:ptr? => false,
|
|
451
|
+
:const? => false,
|
|
452
|
+
:str => "void cmock_to_return",
|
|
453
|
+
:void? => true
|
|
454
|
+
},
|
|
455
|
+
:var_arg => nil,
|
|
456
|
+
:args_string => "void",
|
|
457
|
+
:args => args,
|
|
458
|
+
:args_call => "",
|
|
459
|
+
:contains_ptr? => false
|
|
460
|
+
}
|
|
461
|
+
end
|
|
462
|
+
end
|
|
463
|
+
parsed_header
|
|
464
|
+
end
|