ceedling 0.25.0 → 0.27.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.
Files changed (434) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/assets/project_as_gem.yml +13 -0
  4. data/assets/project_with_guts.yml +13 -0
  5. data/bin/ceedling +91 -67
  6. data/docs/CeedlingPacket.md +61 -23
  7. data/docs/CeedlingPacket.odt +0 -0
  8. data/docs/CeedlingPacket.pdf +0 -0
  9. data/docs/ThrowTheSwitchCodingStandard.md +207 -0
  10. data/examples/temp_sensor/test/TestTemperatureCalculator.c +4 -1
  11. data/lib/ceedling/configurator.rb +14 -1
  12. data/lib/ceedling/configurator_builder.rb +2 -1
  13. data/lib/ceedling/configurator_validator.rb +12 -3
  14. data/lib/ceedling/constants.rb +3 -1
  15. data/lib/ceedling/defaults.rb +12 -1
  16. data/lib/ceedling/file_finder.rb +3 -0
  17. data/lib/ceedling/file_path_utils.rb +1 -1
  18. data/lib/ceedling/file_wrapper.rb +4 -4
  19. data/lib/ceedling/generator.rb +12 -3
  20. data/lib/ceedling/preprocessinator_helper.rb +5 -5
  21. data/lib/ceedling/preprocessinator_includes_handler.rb +10 -1
  22. data/lib/ceedling/project_config_manager.rb +1 -2
  23. data/lib/ceedling/project_file_loader.rb +27 -9
  24. data/lib/ceedling/rakefile.rb +6 -6
  25. data/lib/ceedling/release_invoker.rb +21 -6
  26. data/lib/ceedling/rules_release.rake +9 -5
  27. data/lib/ceedling/rules_tests.rake +6 -1
  28. data/lib/ceedling/setupinator.rb +1 -0
  29. data/lib/ceedling/tasks_base.rake +3 -0
  30. data/lib/ceedling/tasks_filesystem.rake +10 -7
  31. data/lib/ceedling/tasks_release.rake +3 -1
  32. data/lib/ceedling/test_includes_extractor.rb +16 -12
  33. data/lib/ceedling/test_invoker.rb +40 -0
  34. data/lib/ceedling/version.rb +3 -3
  35. data/lib/ceedling/version.rb.erb +1 -1
  36. data/plugins/command_hooks/lib/command_hooks.rb +1 -1
  37. data/plugins/fake_function_framework/examples/fff_example/src/bar.h +1 -0
  38. data/plugins/fake_function_framework/examples/fff_example/src/event_processor.c +1 -0
  39. data/plugins/fake_function_framework/lib/fff_mock_generator.rb +4 -0
  40. data/plugins/fake_function_framework/spec/{fff_mock_generator_spec.rb → fff_mock_header_generator_spec.rb} +34 -194
  41. data/plugins/fake_function_framework/spec/fff_mock_source_generator_spec.rb +149 -0
  42. data/plugins/fake_function_framework/spec/header_generator.rb +51 -0
  43. data/plugins/junit_tests_report/lib/junit_tests_report.rb +115 -0
  44. data/plugins/subprojects/README.md +63 -0
  45. data/plugins/subprojects/config/defaults.yml +33 -0
  46. data/plugins/subprojects/lib/subprojects.rb +92 -0
  47. data/plugins/subprojects/subprojects.rake +78 -0
  48. data/spec/preprocessinator_includes_handler_spec.rb +15 -5
  49. data/spec/spec_helper.rb +2 -2
  50. data/spec/spec_system_helper.rb +49 -1
  51. data/spec/system/deployment_spec.rb +29 -0
  52. data/vendor/c_exception/README.md +8 -2
  53. data/vendor/c_exception/docs/{readme.txt → CException.md} +133 -102
  54. data/vendor/c_exception/docs/ThrowTheSwitchCodingStandard.md +207 -0
  55. data/vendor/c_exception/vendor/unity/README.md +19 -10
  56. data/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +67 -64
  57. data/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +20 -20
  58. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +149 -142
  59. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +234 -232
  60. data/vendor/c_exception/vendor/unity/auto/parse_output.rb +220 -0
  61. data/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +108 -120
  62. data/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +11 -9
  63. data/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +1 -3
  64. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +6 -2
  65. data/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +45 -57
  66. data/vendor/c_exception/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -0
  67. data/vendor/c_exception/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
  68. data/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.md +716 -0
  69. data/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.md +398 -0
  70. data/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.md +191 -0
  71. data/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -0
  72. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +22 -17
  73. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +1 -1
  74. data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +1 -1
  75. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +16 -17
  76. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +15 -15
  77. data/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +93 -100
  78. data/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +4 -10
  79. data/vendor/c_exception/vendor/unity/examples/unity_config.h +14 -26
  80. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +12 -12
  81. data/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +87 -88
  82. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +15 -8
  83. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +6 -1
  84. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +3 -0
  85. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +1 -0
  86. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +1 -1
  87. data/vendor/c_exception/vendor/unity/src/unity.c +396 -330
  88. data/vendor/c_exception/vendor/unity/src/unity.h +50 -4
  89. data/vendor/c_exception/vendor/unity/src/unity_internals.h +119 -84
  90. data/vendor/c_exception/vendor/unity/test/Makefile +17 -17
  91. data/vendor/c_exception/vendor/unity/test/rakefile +63 -3
  92. data/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +108 -105
  93. data/vendor/c_exception/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -0
  94. data/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +0 -6
  95. data/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +1 -9
  96. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +2 -0
  97. data/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +2 -2
  98. data/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +5 -5
  99. data/vendor/c_exception/vendor/unity/test/tests/testunity.c +1338 -151
  100. data/vendor/cmock/README.md +10 -1
  101. data/vendor/cmock/config/test_environment.rb +7 -7
  102. data/vendor/cmock/docs/CMock_Summary.md +325 -128
  103. data/vendor/cmock/docs/ThrowTheSwitchCodingStandard.md +207 -0
  104. data/vendor/cmock/examples/make_example/Makefile +2 -2
  105. data/vendor/cmock/examples/temp_sensor/gcc.yml +5 -4
  106. data/vendor/cmock/examples/temp_sensor/iar_v4.yml +5 -4
  107. data/vendor/cmock/examples/temp_sensor/iar_v5.yml +5 -4
  108. data/vendor/cmock/examples/temp_sensor/rakefile.rb +11 -1
  109. data/vendor/cmock/examples/temp_sensor/rakefile_helper.rb +12 -10
  110. data/vendor/cmock/lib/cmock.rb +0 -3
  111. data/vendor/cmock/lib/cmock_generator_plugin_callback.rb +6 -2
  112. data/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +2 -1
  113. data/vendor/cmock/lib/cmock_header_parser.rb +5 -6
  114. data/vendor/cmock/release/version.info +1 -1
  115. data/vendor/cmock/scripts/create_makefile.rb +4 -2
  116. data/vendor/cmock/scripts/test_summary.rb +17 -9
  117. data/vendor/cmock/src/cmock.c +1 -0
  118. data/vendor/cmock/src/cmock.h +1 -1
  119. data/vendor/cmock/src/cmock_internals.h +14 -1
  120. data/vendor/cmock/test/c/TestCMockC.yml +4 -4
  121. data/vendor/cmock/test/c/TestCMockCDynamic.yml +4 -4
  122. data/vendor/cmock/{iar → test/iar}/iar_v4/Resource/SAM7_FLASH.mac +0 -0
  123. data/vendor/cmock/{iar → test/iar}/iar_v4/Resource/SAM7_RAM.mac +0 -0
  124. data/vendor/cmock/{iar → test/iar}/iar_v4/Resource/SAM7_SIM.mac +0 -0
  125. data/vendor/cmock/{iar → test/iar}/iar_v4/Resource/at91SAM7X256_FLASH.xcl +0 -0
  126. data/vendor/cmock/{iar → test/iar}/iar_v4/Resource/at91SAM7X256_RAM.xcl +0 -0
  127. data/vendor/cmock/{iar → test/iar}/iar_v4/Resource/ioat91sam7x256.ddf +0 -0
  128. data/vendor/cmock/{iar → test/iar}/iar_v4/cmock_demo.dep +0 -0
  129. data/vendor/cmock/{iar → test/iar}/iar_v4/cmock_demo.ewd +0 -0
  130. data/vendor/cmock/{iar → test/iar}/iar_v4/cmock_demo.ewp +0 -0
  131. data/vendor/cmock/{iar → test/iar}/iar_v4/cmock_demo.eww +0 -0
  132. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/AT91SAM7X-EK.h +0 -0
  133. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/AT91SAM7X256.inc +0 -0
  134. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/AT91SAM7X256.rdf +0 -0
  135. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/AT91SAM7X256.tcl +0 -0
  136. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/AT91SAM7X256_inc.h +0 -0
  137. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/ioat91sam7x256.h +0 -0
  138. data/vendor/cmock/{iar → test/iar}/iar_v4/incIAR/lib_AT91SAM7X256.h +0 -0
  139. data/vendor/cmock/{iar → test/iar}/iar_v4/settings/cmock_demo.cspy.bat +0 -0
  140. data/vendor/cmock/{iar → test/iar}/iar_v4/settings/cmock_demo.dbgdt +0 -0
  141. data/vendor/cmock/{iar → test/iar}/iar_v4/settings/cmock_demo.dni +0 -0
  142. data/vendor/cmock/{iar → test/iar}/iar_v4/settings/cmock_demo.wsdt +0 -0
  143. data/vendor/cmock/{iar → test/iar}/iar_v4/srcIAR/Cstartup.s79 +0 -0
  144. data/vendor/cmock/{iar → test/iar}/iar_v4/srcIAR/Cstartup_SAM7.c +0 -0
  145. data/vendor/cmock/{iar → test/iar}/iar_v5/Resource/SAM7_FLASH.mac +0 -0
  146. data/vendor/cmock/{iar → test/iar}/iar_v5/Resource/SAM7_RAM.mac +0 -0
  147. data/vendor/cmock/{iar → test/iar}/iar_v5/Resource/SAM7_SIM.mac +0 -0
  148. data/vendor/cmock/{iar → test/iar}/iar_v5/Resource/at91SAM7X256_FLASH.icf +0 -0
  149. data/vendor/cmock/{iar → test/iar}/iar_v5/Resource/at91SAM7X256_RAM.icf +0 -0
  150. data/vendor/cmock/{iar → test/iar}/iar_v5/cmock_demo.dep +0 -0
  151. data/vendor/cmock/{iar → test/iar}/iar_v5/cmock_demo.ewd +0 -0
  152. data/vendor/cmock/{iar → test/iar}/iar_v5/cmock_demo.ewp +0 -0
  153. data/vendor/cmock/{iar → test/iar}/iar_v5/cmock_demo.eww +0 -0
  154. data/vendor/cmock/{iar → test/iar}/iar_v5/incIAR/AT91SAM7X-EK.h +0 -0
  155. data/vendor/cmock/{iar → test/iar}/iar_v5/incIAR/AT91SAM7X256_inc.h +0 -0
  156. data/vendor/cmock/{iar → test/iar}/iar_v5/incIAR/lib_AT91SAM7X256.h +0 -0
  157. data/vendor/cmock/{iar → test/iar}/iar_v5/incIAR/project.h +0 -0
  158. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +0 -0
  159. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/BasicInterrupt_SAM7X.dbgdt +0 -0
  160. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/BasicInterrupt_SAM7X.dni +0 -0
  161. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/BasicInterrupt_SAM7X.wsdt +0 -0
  162. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +0 -0
  163. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo.cspy.bat +0 -0
  164. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo.dbgdt +0 -0
  165. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo.dni +0 -0
  166. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo.wsdt +0 -0
  167. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo_Binary.jlink +0 -0
  168. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +0 -0
  169. data/vendor/cmock/{iar → test/iar}/iar_v5/settings/cmock_demo_RAM_Debug.jlink +0 -0
  170. data/vendor/cmock/{iar → test/iar}/iar_v5/srcIAR/Cstartup.s +0 -0
  171. data/vendor/cmock/{iar → test/iar}/iar_v5/srcIAR/Cstartup_SAM7.c +0 -0
  172. data/vendor/cmock/{Rakefile → test/rakefile} +9 -9
  173. data/vendor/cmock/{rakefile_helper.rb → test/rakefile_helper.rb} +13 -13
  174. data/vendor/cmock/test/system/test_compilation/config.yml +4 -4
  175. data/vendor/cmock/test/system/test_interactions/parsing_challenges.yml +2 -0
  176. data/vendor/cmock/{targets → test/targets}/clang_strict.yml +11 -11
  177. data/vendor/cmock/{targets → test/targets}/gcc.yml +9 -9
  178. data/vendor/cmock/{targets → test/targets}/gcc_64.yml +9 -9
  179. data/vendor/cmock/{targets → test/targets}/gcc_tiny.yml +9 -9
  180. data/vendor/cmock/{targets → test/targets}/iar_arm_v4.yml +9 -9
  181. data/vendor/cmock/{targets → test/targets}/iar_arm_v5.yml +10 -10
  182. data/vendor/cmock/test/test_helper.rb +4 -8
  183. data/vendor/cmock/test/unit/cmock_config_test.rb +1 -1
  184. data/vendor/cmock/test/unit/cmock_file_writer_test.rb +1 -1
  185. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +1 -1
  186. data/vendor/cmock/test/unit/cmock_generator_plugin_array_test.rb +1 -1
  187. data/vendor/cmock/test/unit/cmock_generator_plugin_callback_test.rb +3 -1
  188. data/vendor/cmock/test/unit/cmock_generator_plugin_cexception_test.rb +1 -1
  189. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_a_test.rb +1 -1
  190. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_any_args_test.rb +1 -1
  191. data/vendor/cmock/test/unit/cmock_generator_plugin_expect_b_test.rb +1 -1
  192. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_arg_test.rb +1 -1
  193. data/vendor/cmock/test/unit/cmock_generator_plugin_ignore_test.rb +1 -1
  194. data/vendor/cmock/test/unit/cmock_generator_plugin_return_thru_ptr_test.rb +1 -1
  195. data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +1 -1
  196. data/vendor/cmock/test/unit/cmock_header_parser_test.rb +15 -2
  197. data/vendor/cmock/test/unit/cmock_plugin_manager_test.rb +6 -10
  198. data/vendor/cmock/test/unit/cmock_unityhelper_parser_test.rb +1 -1
  199. data/vendor/cmock/vendor/c_exception/README.md +8 -2
  200. data/vendor/cmock/vendor/c_exception/docs/{readme.txt → CException.md} +133 -102
  201. data/vendor/cmock/vendor/c_exception/docs/ThrowTheSwitchCodingStandard.md +207 -0
  202. data/vendor/cmock/vendor/c_exception/vendor/unity/README.md +19 -10
  203. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +67 -64
  204. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +20 -20
  205. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +149 -142
  206. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +234 -232
  207. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/parse_output.rb +220 -0
  208. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +108 -120
  209. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/test_file_filter.rb +11 -9
  210. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +1 -3
  211. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +6 -2
  212. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +45 -57
  213. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -0
  214. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
  215. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.md +716 -0
  216. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.md +398 -0
  217. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.md +191 -0
  218. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -0
  219. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +22 -17
  220. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +1 -1
  221. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +1 -1
  222. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +16 -17
  223. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +15 -15
  224. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile_helper.rb +93 -100
  225. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/readme.txt +4 -10
  226. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/unity_config.h +14 -26
  227. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +12 -12
  228. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +87 -88
  229. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +15 -8
  230. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +6 -1
  231. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +3 -0
  232. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +1 -0
  233. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +1 -1
  234. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +396 -330
  235. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +50 -4
  236. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +119 -84
  237. data/vendor/cmock/vendor/c_exception/vendor/unity/test/Makefile +17 -17
  238. data/vendor/cmock/vendor/c_exception/vendor/unity/test/rakefile +63 -3
  239. data/vendor/cmock/vendor/c_exception/vendor/unity/test/rakefile_helper.rb +108 -105
  240. data/vendor/cmock/vendor/c_exception/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -0
  241. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +0 -6
  242. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_strict.yml +1 -9
  243. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +2 -0
  244. data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +2 -2
  245. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/test_generate_test_runner.rb +5 -5
  246. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +1338 -151
  247. data/vendor/cmock/vendor/unity/README.md +19 -10
  248. data/vendor/cmock/vendor/unity/auto/colour_prompt.rb +67 -64
  249. data/vendor/cmock/vendor/unity/auto/colour_reporter.rb +20 -20
  250. data/vendor/cmock/vendor/unity/auto/generate_module.rb +149 -142
  251. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +234 -232
  252. data/vendor/cmock/vendor/unity/auto/parse_output.rb +220 -0
  253. data/vendor/cmock/vendor/unity/auto/stylize_as_junit.rb +108 -120
  254. data/vendor/cmock/vendor/unity/auto/test_file_filter.rb +11 -9
  255. data/vendor/cmock/vendor/unity/auto/type_sanitizer.rb +1 -3
  256. data/vendor/cmock/vendor/unity/auto/unity_test_summary.py +6 -2
  257. data/vendor/cmock/vendor/unity/auto/unity_test_summary.rb +45 -57
  258. data/vendor/cmock/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -0
  259. data/vendor/cmock/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
  260. data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.md +716 -0
  261. data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.md +398 -0
  262. data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.md +191 -0
  263. data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -0
  264. data/vendor/cmock/vendor/unity/examples/example_1/makefile +22 -17
  265. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +1 -1
  266. data/vendor/cmock/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +1 -1
  267. data/vendor/cmock/vendor/unity/examples/example_2/makefile +16 -17
  268. data/vendor/cmock/vendor/unity/examples/example_3/rakefile.rb +15 -15
  269. data/vendor/cmock/vendor/unity/examples/example_3/rakefile_helper.rb +93 -100
  270. data/vendor/cmock/vendor/unity/examples/example_3/readme.txt +4 -10
  271. data/vendor/cmock/vendor/unity/examples/unity_config.h +14 -26
  272. data/vendor/cmock/vendor/unity/extras/fixture/rakefile.rb +12 -12
  273. data/vendor/cmock/vendor/unity/extras/fixture/rakefile_helper.rb +87 -88
  274. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +15 -8
  275. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +6 -1
  276. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +3 -0
  277. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +1 -0
  278. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +1 -1
  279. data/vendor/cmock/vendor/unity/release/version.info +1 -1
  280. data/vendor/cmock/vendor/unity/src/unity.c +396 -330
  281. data/vendor/cmock/vendor/unity/src/unity.h +50 -4
  282. data/vendor/cmock/vendor/unity/src/unity_internals.h +119 -84
  283. data/vendor/cmock/vendor/unity/test/Makefile +17 -17
  284. data/vendor/cmock/vendor/unity/test/rakefile +63 -3
  285. data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +108 -105
  286. data/vendor/cmock/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -0
  287. data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +0 -6
  288. data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +1 -9
  289. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +2 -0
  290. data/vendor/cmock/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +2 -2
  291. data/vendor/cmock/vendor/unity/test/tests/test_generate_test_runner.rb +5 -5
  292. data/vendor/cmock/vendor/unity/test/tests/testunity.c +1338 -151
  293. data/vendor/deep_merge/Rakefile +1 -1
  294. data/vendor/unity/README.md +19 -10
  295. data/vendor/unity/auto/colour_prompt.rb +67 -64
  296. data/vendor/unity/auto/colour_reporter.rb +20 -20
  297. data/vendor/unity/auto/generate_module.rb +149 -142
  298. data/vendor/unity/auto/generate_test_runner.rb +234 -232
  299. data/vendor/unity/auto/parse_output.rb +220 -0
  300. data/vendor/unity/auto/stylize_as_junit.rb +108 -120
  301. data/vendor/unity/auto/test_file_filter.rb +11 -9
  302. data/vendor/unity/auto/type_sanitizer.rb +1 -3
  303. data/vendor/unity/auto/unity_test_summary.py +6 -2
  304. data/vendor/unity/auto/unity_test_summary.rb +45 -57
  305. data/vendor/unity/docs/ThrowTheSwitchCodingStandard.md +207 -0
  306. data/vendor/unity/docs/UnityAssertionsCheatSheetSuitableforPrintingandPossiblyFraming.pdf +0 -0
  307. data/vendor/unity/docs/UnityAssertionsReference.md +716 -0
  308. data/vendor/unity/docs/UnityConfigurationGuide.md +398 -0
  309. data/vendor/unity/docs/UnityGettingStartedGuide.md +191 -0
  310. data/vendor/unity/docs/UnityHelperScriptsGuide.md +242 -0
  311. data/vendor/unity/examples/example_1/makefile +22 -17
  312. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +1 -1
  313. data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +1 -1
  314. data/vendor/unity/examples/example_2/makefile +16 -17
  315. data/vendor/unity/examples/example_3/rakefile.rb +15 -15
  316. data/vendor/unity/examples/example_3/rakefile_helper.rb +93 -100
  317. data/vendor/unity/examples/example_3/readme.txt +4 -10
  318. data/vendor/unity/examples/unity_config.h +14 -26
  319. data/vendor/unity/extras/fixture/rakefile.rb +12 -12
  320. data/vendor/unity/extras/fixture/rakefile_helper.rb +87 -88
  321. data/vendor/unity/extras/fixture/src/unity_fixture.c +15 -8
  322. data/vendor/unity/extras/fixture/src/unity_fixture.h +6 -1
  323. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +3 -0
  324. data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +1 -0
  325. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +1 -1
  326. data/vendor/unity/release/version.info +1 -1
  327. data/vendor/unity/src/unity.c +396 -330
  328. data/vendor/unity/src/unity.h +50 -4
  329. data/vendor/unity/src/unity_internals.h +119 -84
  330. data/vendor/unity/test/Makefile +17 -17
  331. data/vendor/unity/test/rakefile +63 -3
  332. data/vendor/unity/test/rakefile_helper.rb +108 -105
  333. data/vendor/unity/test/spec/generate_module_existing_file_spec.rb +158 -0
  334. data/vendor/unity/test/targets/clang_file.yml +0 -6
  335. data/vendor/unity/test/targets/clang_strict.yml +1 -9
  336. data/vendor/unity/test/testdata/testRunnerGeneratorSmall.c +2 -0
  337. data/vendor/unity/test/testdata/testRunnerGeneratorWithMocks.c +2 -2
  338. data/vendor/unity/test/tests/test_generate_test_runner.rb +5 -5
  339. data/vendor/unity/test/tests/testunity.c +1338 -151
  340. metadata +102 -157
  341. data/test_graveyard/integration/paths.yml +0 -17
  342. data/test_graveyard/integration/paths_test.rb +0 -80
  343. data/test_graveyard/integration/rake_rules_aux_dependencies_test.rb +0 -75
  344. data/test_graveyard/integration/rake_rules_cmock_test.rb +0 -74
  345. data/test_graveyard/integration/rake_rules_preprocess_test.rb +0 -178
  346. data/test_graveyard/integration/rake_rules_test.rb +0 -268
  347. data/test_graveyard/integration/rake_tasks_test.rb +0 -103
  348. data/test_graveyard/integration_test_helper.rb +0 -34
  349. data/test_graveyard/rakefile_rules.rb +0 -10
  350. data/test_graveyard/rakefile_rules_aux_dependencies.rb +0 -10
  351. data/test_graveyard/rakefile_rules_cmock.rb +0 -10
  352. data/test_graveyard/rakefile_rules_preprocess.rb +0 -10
  353. data/test_graveyard/rakefile_tasks.rb +0 -10
  354. data/test_graveyard/system/file_system_dependencies.yml +0 -20
  355. data/test_graveyard/system/file_system_kitchen_sink.yml +0 -20
  356. data/test_graveyard/system/file_system_mocks.yml +0 -20
  357. data/test_graveyard/system/file_system_preprocess.yml +0 -20
  358. data/test_graveyard/system/file_system_simple.yml +0 -20
  359. data/test_graveyard/system/file_system_test.rb +0 -78
  360. data/test_graveyard/system/mocks/include/a_file.h +0 -2
  361. data/test_graveyard/system/mocks/include/other_stuff.h +0 -2
  362. data/test_graveyard/system/mocks/include/stuff.h +0 -3
  363. data/test_graveyard/system/mocks/source/a_file.c +0 -9
  364. data/test_graveyard/system/mocks/test/test_a_file.c +0 -41
  365. data/test_graveyard/system/mocks/test/test_no_file.c +0 -14
  366. data/test_graveyard/system/project_mocks.yml +0 -43
  367. data/test_graveyard/system/project_mocks_test.rb +0 -38
  368. data/test_graveyard/system/project_simple.yml +0 -36
  369. data/test_graveyard/system/project_simple_test.rb +0 -39
  370. data/test_graveyard/system/rule_mocks_test.rb +0 -44
  371. data/test_graveyard/system/rule_runners_test.rb +0 -44
  372. data/test_graveyard/system/simple/include/other_stuff.h +0 -2
  373. data/test_graveyard/system/simple/include/stuff.h +0 -3
  374. data/test_graveyard/system/simple/source/other_stuff.c +0 -6
  375. data/test_graveyard/system/simple/source/stuff.c +0 -7
  376. data/test_graveyard/system/simple/test/test_other_stuff.c +0 -30
  377. data/test_graveyard/system/simple/test/test_stuff.c +0 -51
  378. data/test_graveyard/system_test_helper.rb +0 -73
  379. data/test_graveyard/test_helper.rb +0 -93
  380. data/test_graveyard/unit/busted/configurator_builder_test.rb +0 -569
  381. data/test_graveyard/unit/busted/configurator_helper_test.rb +0 -234
  382. data/test_graveyard/unit/busted/configurator_test.rb +0 -232
  383. data/test_graveyard/unit/busted/configurator_validator_test.rb +0 -169
  384. data/test_graveyard/unit/busted/deep_merge_fix_test.rb +0 -55
  385. data/test_graveyard/unit/busted/dependinator_test.rb +0 -129
  386. data/test_graveyard/unit/busted/file_finder_helper_test.rb +0 -45
  387. data/test_graveyard/unit/busted/file_finder_test.rb +0 -114
  388. data/test_graveyard/unit/busted/file_path_utils_test.rb +0 -97
  389. data/test_graveyard/unit/busted/file_system_utils_test.rb +0 -21
  390. data/test_graveyard/unit/busted/generator_test.rb +0 -187
  391. data/test_graveyard/unit/busted/generator_test_results_test.rb +0 -129
  392. data/test_graveyard/unit/busted/generator_test_runner_test.rb +0 -475
  393. data/test_graveyard/unit/busted/preprocessinator_file_handler_test.rb +0 -39
  394. data/test_graveyard/unit/busted/preprocessinator_helper_test.rb +0 -156
  395. data/test_graveyard/unit/busted/preprocessinator_includes_handler_test.rb +0 -93
  396. data/test_graveyard/unit/busted/preprocessinator_test.rb +0 -57
  397. data/test_graveyard/unit/busted/project_file_loader_test.rb +0 -142
  398. data/test_graveyard/unit/busted/setupinator_test.rb +0 -45
  399. data/test_graveyard/unit/busted/streaminator_test.rb +0 -49
  400. data/test_graveyard/unit/busted/task_invoker_test.rb +0 -69
  401. data/test_graveyard/unit/busted/test_includes_extractor_test.rb +0 -111
  402. data/test_graveyard/unit/busted/test_invoker_helper_test.rb +0 -62
  403. data/test_graveyard/unit/busted/test_invoker_test.rb +0 -47
  404. data/test_graveyard/unit/busted/tool_executor_helper_test.rb +0 -100
  405. data/test_graveyard/unit/busted/tool_executor_test.rb +0 -351
  406. data/test_graveyard/unit/busted/verbosinator_test.rb +0 -65
  407. data/test_graveyard/unit/preprocessinator_extractor_test.rb +0 -731
  408. data/test_graveyard/unit_test_helper.rb +0 -16
  409. data/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
  410. data/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
  411. data/vendor/c_exception/vendor/unity/auto/parseOutput.rb +0 -191
  412. data/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
  413. data/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
  414. data/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
  415. data/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
  416. data/vendor/cmock/docs/CMock Summary.odt +0 -0
  417. data/vendor/cmock/docs/CMock Summary.pdf +0 -0
  418. data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
  419. data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
  420. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/parseOutput.rb +0 -191
  421. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
  422. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
  423. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
  424. data/vendor/cmock/vendor/c_exception/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
  425. data/vendor/cmock/vendor/unity/auto/parseOutput.rb +0 -191
  426. data/vendor/cmock/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
  427. data/vendor/cmock/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
  428. data/vendor/cmock/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
  429. data/vendor/cmock/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
  430. data/vendor/unity/auto/parseOutput.rb +0 -191
  431. data/vendor/unity/docs/UnityAssertionsReference.pdf +0 -0
  432. data/vendor/unity/docs/UnityConfigurationGuide.pdf +0 -0
  433. data/vendor/unity/docs/UnityGettingStartedGuide.pdf +0 -0
  434. data/vendor/unity/docs/UnityHelperScriptsGuide.pdf +0 -0
@@ -12,8 +12,8 @@ require 'rubygems'
12
12
  require 'fileutils'
13
13
  require 'pathname'
14
14
 
15
- #TEMPLATE_TST
16
- TEMPLATE_TST ||= %q[#include "unity.h"
15
+ # TEMPLATE_TST
16
+ TEMPLATE_TST ||= '#include "unity.h"
17
17
  %2$s#include "%1$s.h"
18
18
 
19
19
  void setUp(void)
@@ -28,115 +28,118 @@ void test_%1$s_NeedToImplement(void)
28
28
  {
29
29
  TEST_IGNORE_MESSAGE("Need to Implement %1$s");
30
30
  }
31
- ]
31
+ '.freeze
32
32
 
33
- #TEMPLATE_SRC
34
- TEMPLATE_SRC ||= %q[%2$s#include "%1$s.h"
35
- ]
33
+ # TEMPLATE_SRC
34
+ TEMPLATE_SRC ||= '%2$s#include "%1$s.h"
35
+ '.freeze
36
36
 
37
- #TEMPLATE_INC
38
- TEMPLATE_INC ||= %q[#ifndef _%3$s_H
37
+ # TEMPLATE_INC
38
+ TEMPLATE_INC ||= '#ifndef _%3$s_H
39
39
  #define _%3$s_H
40
40
  %2$s
41
41
 
42
42
  #endif // _%3$s_H
43
- ]
43
+ '.freeze
44
44
 
45
45
  class UnityModuleGenerator
46
-
47
46
  ############################
48
- def initialize(options=nil)
49
-
47
+ def initialize(options = nil)
50
48
  here = File.expand_path(File.dirname(__FILE__)) + '/'
51
49
 
52
50
  @options = UnityModuleGenerator.default_options
53
- case(options)
54
- when NilClass then @options
55
- when String then @options.merge!(UnityModuleGenerator.grab_config(options))
56
- when Hash then @options.merge!(options)
57
- else raise "If you specify arguments, it should be a filename or a hash of options"
51
+ case options
52
+ when NilClass then @options
53
+ when String then @options.merge!(UnityModuleGenerator.grab_config(options))
54
+ when Hash then @options.merge!(options)
55
+ else raise 'If you specify arguments, it should be a filename or a hash of options'
58
56
  end
59
57
 
60
58
  # Create default file paths if none were provided
61
- @options[:path_src] = here + "../src/" if @options[:path_src].nil?
59
+ @options[:path_src] = here + '../src/' if @options[:path_src].nil?
62
60
  @options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
63
- @options[:path_tst] = here + "../test/" if @options[:path_tst].nil?
64
- @options[:path_src] += '/' unless (@options[:path_src][-1] == 47)
65
- @options[:path_inc] += '/' unless (@options[:path_inc][-1] == 47)
66
- @options[:path_tst] += '/' unless (@options[:path_tst][-1] == 47)
67
-
68
- #Built in patterns
69
- @patterns = { 'src' => {'' => { :inc => [] } },
70
- 'test'=> {'' => { :inc => [] } },
71
- 'dh' => {'Driver' => { :inc => [create_filename('%1$s','Hardware.h')] },
72
- 'Hardware' => { :inc => [] }
73
- },
74
- 'dih' => {'Driver' => { :inc => [create_filename('%1$s','Hardware.h'), create_filename('%1$s','Interrupt.h')] },
75
- 'Interrupt'=> { :inc => [create_filename('%1$s','Hardware.h')] },
76
- 'Hardware' => { :inc => [] }
77
- },
78
- 'mch' => {'Model' => { :inc => [] },
79
- 'Conductor'=> { :inc => [create_filename('%1$s','Model.h'), create_filename('%1$s','Hardware.h')] },
80
- 'Hardware' => { :inc => [] }
81
- },
82
- 'mvp' => {'Model' => { :inc => [] },
83
- 'Presenter'=> { :inc => [create_filename('%1$s','Model.h'), create_filename('%1$s','View.h')] },
84
- 'View' => { :inc => [] }
85
- }
86
- }
61
+ @options[:path_tst] = here + '../test/' if @options[:path_tst].nil?
62
+ @options[:path_src] += '/' unless @options[:path_src][-1] == 47
63
+ @options[:path_inc] += '/' unless @options[:path_inc][-1] == 47
64
+ @options[:path_tst] += '/' unless @options[:path_tst][-1] == 47
65
+
66
+ # Built in patterns
67
+ @patterns = {
68
+ 'src' => {
69
+ '' => { inc: [] }
70
+ },
71
+ 'test' => {
72
+ '' => { inc: [] }
73
+ },
74
+ 'dh' => {
75
+ 'Driver' => { inc: [create_filename('%1$s', 'Hardware.h')] },
76
+ 'Hardware' => { inc: [] }
77
+ },
78
+ 'dih' => {
79
+ 'Driver' => { inc: [create_filename('%1$s', 'Hardware.h'), create_filename('%1$s', 'Interrupt.h')] },
80
+ 'Interrupt' => { inc: [create_filename('%1$s', 'Hardware.h')] },
81
+ 'Hardware' => { inc: [] }
82
+ },
83
+ 'mch' => {
84
+ 'Model' => { inc: [] },
85
+ 'Conductor' => { inc: [create_filename('%1$s', 'Model.h'), create_filename('%1$s', 'Hardware.h')] },
86
+ 'Hardware' => { inc: [] }
87
+ },
88
+ 'mvp' => {
89
+ 'Model' => { inc: [] },
90
+ 'Presenter' => { inc: [create_filename('%1$s', 'Model.h'), create_filename('%1$s', 'View.h')] },
91
+ 'View' => { inc: [] }
92
+ }
93
+ }
87
94
  end
88
95
 
89
96
  ############################
90
97
  def self.default_options
91
98
  {
92
- :pattern => "src",
93
- :includes =>
94
- {
95
- :src => [],
96
- :inc => [],
97
- :tst => [],
99
+ pattern: 'src',
100
+ includes: {
101
+ src: [],
102
+ inc: [],
103
+ tst: []
98
104
  },
99
- :update_svn => false,
100
- :boilerplates => {},
101
- :test_prefix => 'Test',
102
- :mock_prefix => 'Mock',
105
+ update_svn: false,
106
+ boilerplates: {},
107
+ test_prefix: 'Test',
108
+ mock_prefix: 'Mock'
103
109
  }
104
110
  end
105
111
 
106
112
  ############################
107
113
  def self.grab_config(config_file)
108
- options = self.default_options
109
- unless (config_file.nil? or config_file.empty?)
114
+ options = default_options
115
+ unless config_file.nil? || config_file.empty?
110
116
  require 'yaml'
111
117
  yaml_guts = YAML.load_file(config_file)
112
118
  options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
113
119
  raise "No :unity or :cmock section found in #{config_file}" unless options
114
120
  end
115
- return(options)
121
+ options
116
122
  end
117
123
 
118
124
  ############################
119
- def files_to_operate_on(module_name, pattern=nil)
120
- #strip any leading path information from the module name and save for later
125
+ def files_to_operate_on(module_name, pattern = nil)
126
+ # strip any leading path information from the module name and save for later
121
127
  subfolder = File.dirname(module_name)
122
128
  module_name = File.basename(module_name)
123
129
 
124
- #create triad definition
130
+ # create triad definition
125
131
  prefix = @options[:test_prefix] || 'Test'
126
- triad = [ { :ext => '.c', :path => @options[:path_src], :prefix => "", :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @options[:boilerplates][:src] },
127
- { :ext => '.h', :path => @options[:path_inc], :prefix => "", :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @options[:boilerplates][:inc] },
128
- { :ext => '.c', :path => @options[:path_tst], :prefix => prefix, :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @options[:boilerplates][:tst] },
129
- ]
132
+ triad = [{ ext: '.c', path: @options[:path_src], prefix: '', template: TEMPLATE_SRC, inc: :src, boilerplate: @options[:boilerplates][:src] },
133
+ { ext: '.h', path: @options[:path_inc], prefix: '', template: TEMPLATE_INC, inc: :inc, boilerplate: @options[:boilerplates][:inc] },
134
+ { ext: '.c', path: @options[:path_tst], prefix: prefix, template: TEMPLATE_TST, inc: :tst, boilerplate: @options[:boilerplates][:tst] }]
130
135
 
131
- #prepare the pattern for use
136
+ # prepare the pattern for use
132
137
  pattern = (pattern || @options[:pattern] || 'src').downcase
133
138
  patterns = @patterns[pattern]
134
139
  raise "ERROR: The design pattern '#{pattern}' specified isn't one that I recognize!" if patterns.nil?
135
140
 
136
- #single file patterns (currently just 'test') can reject the other parts of the triad
137
- if (pattern == 'test')
138
- triad.reject!{|v| v[:inc] != :tst }
139
- end
141
+ # single file patterns (currently just 'test') can reject the other parts of the triad
142
+ triad.select! { |v| v[:inc] == :tst } if pattern == 'test'
140
143
 
141
144
  # Assemble the path/names of the files we need to work with.
142
145
  files = []
@@ -145,26 +148,26 @@ class UnityModuleGenerator
145
148
  submodule_name = create_filename(module_name, pattern_file)
146
149
  filename = cfg[:prefix] + submodule_name + cfg[:ext]
147
150
  files << {
148
- :path => (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath,
149
- :name => submodule_name,
150
- :template => cfg[:template],
151
- :boilerplate => cfg[:boilerplate],
152
- :includes => case(cfg[:inc])
153
- when :src then (@options[:includes][:src] || []) | pattern_traits[:inc].map{|f| f % [module_name]}
154
- when :inc then (@options[:includes][:inc] || [])
155
- when :tst then (@options[:includes][:tst] || []) | pattern_traits[:inc].map{|f| "#{@options[:mock_prefix]}#{f}" % [module_name]}
156
- end
151
+ path: (Pathname.new("#{cfg[:path]}#{subfolder}") + filename).cleanpath,
152
+ name: submodule_name,
153
+ template: cfg[:template],
154
+ boilerplate: cfg[:boilerplate],
155
+ includes: case (cfg[:inc])
156
+ when :src then (@options[:includes][:src] || []) | (pattern_traits[:inc].map { |f| format(f, module_name) })
157
+ when :inc then (@options[:includes][:inc] || [])
158
+ when :tst then (@options[:includes][:tst] || []) | (pattern_traits[:inc].map { |f| format("#{@options[:mock_prefix]}#{f}", module_name) })
159
+ end
157
160
  }
158
161
  end
159
162
  end
160
163
 
161
- return files
164
+ files
162
165
  end
163
166
 
164
167
  ############################
165
- def create_filename(part1, part2="")
168
+ def create_filename(part1, part2 = '')
166
169
  if part2.empty?
167
- case(@options[:naming])
170
+ case (@options[:naming])
168
171
  when 'bumpy' then part1
169
172
  when 'camel' then part1
170
173
  when 'snake' then part1.downcase
@@ -172,39 +175,45 @@ class UnityModuleGenerator
172
175
  else part1.downcase
173
176
  end
174
177
  else
175
- case(@options[:naming])
178
+ case (@options[:naming])
176
179
  when 'bumpy' then part1 + part2
177
180
  when 'camel' then part1 + part2
178
- when 'snake' then part1.downcase + "_" + part2.downcase
179
- when 'caps' then part1.upcase + "_" + part2.upcase
180
- else part1.downcase + "_" + part2.downcase
181
+ when 'snake' then part1.downcase + '_' + part2.downcase
182
+ when 'caps' then part1.upcase + '_' + part2.upcase
183
+ else part1.downcase + '_' + part2.downcase
181
184
  end
182
185
  end
183
186
  end
184
187
 
185
188
  ############################
186
- def generate(module_name, pattern=nil)
187
-
189
+ def generate(module_name, pattern = nil)
188
190
  files = files_to_operate_on(module_name, pattern)
189
191
 
190
- #Abort if any module already exists
192
+ # Abort if all of the module files already exist
193
+ all_files_exist = true
191
194
  files.each do |file|
192
- raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
195
+ all_files_exist = false unless File.exist?(file[:path])
193
196
  end
197
+ raise "ERROR: File #{files[0][:name]} already exists. Exiting." if all_files_exist
194
198
 
195
199
  # Create Source Modules
196
- files.each_with_index do |file, i|
197
- FileUtils.mkdir_p(File.dirname(file[:path]), :verbose => false) # Create the path first if necessary.
200
+ files.each_with_index do |file, _i|
201
+ # If this file already exists, don't overwrite it.
202
+ if File.exist?(file[:path])
203
+ puts "File #{file[:path]} already exists!"
204
+ next
205
+ end
206
+ # Create the path first if necessary.
207
+ FileUtils.mkdir_p(File.dirname(file[:path]), verbose: false)
198
208
  File.open(file[:path], 'w') do |f|
199
209
  f.write("#{file[:boilerplate]}\n" % [file[:name]]) unless file[:boilerplate].nil?
200
- f.write(file[:template] % [ file[:name],
201
- file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
202
- file[:name].upcase ]
203
- )
210
+ f.write(file[:template] % [file[:name],
211
+ file[:includes].map { |ff| "#include \"#{ff}\"\n" }.join,
212
+ file[:name].upcase])
204
213
  end
205
- if (@options[:update_svn])
214
+ if @options[:update_svn]
206
215
  `svn add \"#{file[:path]}\"`
207
- if $?.exitstatus == 0
216
+ if $!.exitstatus.zero?
208
217
  puts "File #{file[:path]} created and added to source control"
209
218
  else
210
219
  puts "File #{file[:path]} created but FAILED adding to source control!"
@@ -217,8 +226,7 @@ class UnityModuleGenerator
217
226
  end
218
227
 
219
228
  ############################
220
- def destroy(module_name, pattern=nil)
221
-
229
+ def destroy(module_name, pattern = nil)
222
230
  files_to_operate_on(module_name, pattern).each do |filespec|
223
231
  file = filespec[:path]
224
232
  if File.exist?(file)
@@ -233,66 +241,65 @@ class UnityModuleGenerator
233
241
  puts "File #{file} does not exist so cannot be removed."
234
242
  end
235
243
  end
236
- puts "Destroy Complete"
244
+ puts 'Destroy Complete'
237
245
  end
238
-
239
246
  end
240
247
 
241
248
  ############################
242
- #Handle As Command Line If Called That Way
243
- if ($0 == __FILE__)
249
+ # Handle As Command Line If Called That Way
250
+ if $0 == __FILE__
244
251
  destroy = false
245
- options = { }
252
+ options = {}
246
253
  module_name = nil
247
254
 
248
255
  # Parse the command line parameters.
249
256
  ARGV.each do |arg|
250
- case(arg)
251
- when /^-d/ then destroy = true
252
- when /^-u/ then options[:update_svn] = true
253
- when /^-p\"?(\w+)\"?/ then options[:pattern] = $1
254
- when /^-s\"?(.+)\"?/ then options[:path_src] = $1
255
- when /^-i\"?(.+)\"?/ then options[:path_inc] = $1
256
- when /^-t\"?(.+)\"?/ then options[:path_tst] = $1
257
- when /^-n\"?(.+)\"?/ then options[:naming] = $1
258
- when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config($1)
259
- when /^(\w+)/
260
- raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
261
- module_name = arg
262
- when /^-(h|-help)/
263
- ARGV = []
264
- else
265
- raise "ERROR: Unknown option specified '#{arg}'"
257
+ case arg
258
+ when /^-d/ then destroy = true
259
+ when /^-u/ then options[:update_svn] = true
260
+ when /^-p\"?(\w+)\"?/ then options[:pattern] = Regexp.last_match(1)
261
+ when /^-s\"?(.+)\"?/ then options[:path_src] = Regexp.last_match(1)
262
+ when /^-i\"?(.+)\"?/ then options[:path_inc] = Regexp.last_match(1)
263
+ when /^-t\"?(.+)\"?/ then options[:path_tst] = Regexp.last_match(1)
264
+ when /^-n\"?(.+)\"?/ then options[:naming] = Regexp.last_match(1)
265
+ when /^-y\"?(.+)\"?/ then options = UnityModuleGenerator.grab_config(Regexp.last_match(1))
266
+ when /^(\w+)/
267
+ raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
268
+ module_name = arg
269
+ when /^-(h|-help)/
270
+ ARGV = [].freeze
271
+ else
272
+ raise "ERROR: Unknown option specified '#{arg}'"
266
273
  end
267
274
  end
268
275
 
269
- if (!ARGV[0])
270
- puts [ "\nGENERATE MODULE\n-------- ------",
271
- "\nUsage: ruby generate_module [options] module_name",
272
- " -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
273
- " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
274
- " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
275
- " -p\"MCH\" sets the output pattern to MCH.",
276
- " dh - driver hardware.",
277
- " dih - driver interrupt hardware.",
278
- " mch - model conductor hardware.",
279
- " mvp - model view presenter.",
280
- " src - just a source module, header and test. (DEFAULT)",
281
- " test - just a test file.",
282
- " -d destroy module instead of creating it.",
283
- " -n\"camel\" sets the file naming convention.",
284
- " bumpy - BumpyCaseFilenames.",
285
- " camel - camelCaseFilenames.",
286
- " snake - snake_case_filenames. (DEFAULT)",
287
- " caps - CAPS_CASE_FILENAMES.",
288
- " -u update subversion too (requires subversion command line)",
289
- " -y\"my.yml\" selects a different yaml config file for module generation",
290
- "" ].join("\n")
276
+ unless ARGV[0]
277
+ puts ["\nGENERATE MODULE\n-------- ------",
278
+ "\nUsage: ruby generate_module [options] module_name",
279
+ " -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
280
+ " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
281
+ " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
282
+ ' -p"MCH" sets the output pattern to MCH.',
283
+ ' dh - driver hardware.',
284
+ ' dih - driver interrupt hardware.',
285
+ ' mch - model conductor hardware.',
286
+ ' mvp - model view presenter.',
287
+ ' src - just a source module, header and test. (DEFAULT)',
288
+ ' test - just a test file.',
289
+ ' -d destroy module instead of creating it.',
290
+ ' -n"camel" sets the file naming convention.',
291
+ ' bumpy - BumpyCaseFilenames.',
292
+ ' camel - camelCaseFilenames.',
293
+ ' snake - snake_case_filenames. (DEFAULT)',
294
+ ' caps - CAPS_CASE_FILENAMES.',
295
+ ' -u update subversion too (requires subversion command line)',
296
+ ' -y"my.yml" selects a different yaml config file for module generation',
297
+ ''].join("\n")
291
298
  exit
292
299
  end
293
300
 
294
- raise "ERROR: You must have a Module name specified! (use option -h for help)" if module_name.nil?
295
- if (destroy)
301
+ raise 'ERROR: You must have a Module name specified! (use option -h for help)' if module_name.nil?
302
+ if destroy
296
303
  UnityModuleGenerator.new(options).destroy(module_name)
297
304
  else
298
305
  UnityModuleGenerator.new(options).generate(module_name)
@@ -4,75 +4,70 @@
4
4
  # [Released under MIT License. Please refer to license.txt for details]
5
5
  # ==========================================
6
6
 
7
- $QUICK_RUBY_VERSION = RUBY_VERSION.split('.').inject(0){|vv,v| vv * 100 + v.to_i }
8
- File.expand_path(File.join(File.dirname(__FILE__),'colour_prompt'))
7
+ File.expand_path(File.join(File.dirname(__FILE__), 'colour_prompt'))
9
8
 
10
9
  class UnityTestRunnerGenerator
11
-
12
10
  def initialize(options = nil)
13
11
  @options = UnityTestRunnerGenerator.default_options
14
- case(options)
15
- when NilClass then @options
16
- when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
17
- when Hash then @options.merge!(options)
18
- else raise "If you specify arguments, it should be a filename or a hash of options"
12
+ case options
13
+ when NilClass then @options
14
+ when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
15
+ when Hash then @options.merge!(options)
16
+ else raise 'If you specify arguments, it should be a filename or a hash of options'
19
17
  end
20
18
  require "#{File.expand_path(File.dirname(__FILE__))}/type_sanitizer"
21
19
  end
22
20
 
23
21
  def self.default_options
24
22
  {
25
- :includes => [],
26
- :defines => [],
27
- :plugins => [],
28
- :framework => :unity,
29
- :test_prefix => "test|spec|should",
30
- :setup_name => "setUp",
31
- :teardown_name => "tearDown",
32
- :main_name => "main", #set to :auto to automatically generate each time
33
- :main_export_decl => "",
34
- :cmdline_args => false,
35
- :use_param_tests => false,
23
+ includes: [],
24
+ defines: [],
25
+ plugins: [],
26
+ framework: :unity,
27
+ test_prefix: 'test|spec|should',
28
+ mock_prefix: 'Mock',
29
+ setup_name: 'setUp',
30
+ teardown_name: 'tearDown',
31
+ main_name: 'main', # set to :auto to automatically generate each time
32
+ main_export_decl: '',
33
+ cmdline_args: false,
34
+ use_param_tests: false
36
35
  }
37
36
  end
38
37
 
39
38
  def self.grab_config(config_file)
40
- options = self.default_options
41
- unless (config_file.nil? or config_file.empty?)
39
+ options = default_options
40
+ unless config_file.nil? || config_file.empty?
42
41
  require 'yaml'
43
42
  yaml_guts = YAML.load_file(config_file)
44
43
  options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
45
44
  raise "No :unity or :cmock section found in #{config_file}" unless options
46
45
  end
47
- return(options)
46
+ options
48
47
  end
49
48
 
50
- def run(input_file, output_file, options=nil)
51
- tests = []
52
- testfile_includes = []
53
- used_mocks = []
54
-
49
+ def run(input_file, output_file, options = nil)
55
50
  @options.merge!(options) unless options.nil?
56
- module_name = File.basename(input_file)
57
51
 
58
- #pull required data from source file
52
+ # pull required data from source file
59
53
  source = File.read(input_file)
60
- source = source.force_encoding("ISO-8859-1").encode("utf-8", :replace => nil) if ($QUICK_RUBY_VERSION > 10900)
54
+ source = source.force_encoding('ISO-8859-1').encode('utf-8', replace: nil)
61
55
  tests = find_tests(source)
62
56
  headers = find_includes(source)
63
57
  testfile_includes = (headers[:local] + headers[:system])
64
58
  used_mocks = find_mocks(testfile_includes)
65
59
  testfile_includes = (testfile_includes - used_mocks)
66
- testfile_includes.delete_if{|inc| inc =~ /(unity|cmock)/}
60
+ testfile_includes.delete_if { |inc| inc =~ /(unity|cmock)/ }
67
61
 
68
- #build runner file
62
+ # build runner file
69
63
  generate(input_file, output_file, tests, used_mocks, testfile_includes)
70
64
 
71
- #determine which files were used to return them
65
+ # determine which files were used to return them
72
66
  all_files_used = [input_file, output_file]
73
- all_files_used += testfile_includes.map {|filename| filename + '.c'} unless testfile_includes.empty?
67
+ all_files_used += testfile_includes.map { |filename| filename + '.c' } unless testfile_includes.empty?
74
68
  all_files_used += @options[:includes] unless @options[:includes].empty?
75
- return all_files_used.uniq
69
+ all_files_used += headers[:linkonly] unless headers[:linkonly].empty?
70
+ all_files_used.uniq
76
71
  end
77
72
 
78
73
  def generate(input_file, output_file, tests, used_mocks, testfile_includes)
@@ -80,15 +75,16 @@ class UnityTestRunnerGenerator
80
75
  create_header(output, used_mocks, testfile_includes)
81
76
  create_externs(output, tests, used_mocks)
82
77
  create_mock_management(output, used_mocks)
83
- create_suite_setup_and_teardown(output)
78
+ create_suite_setup(output)
79
+ create_suite_teardown(output)
84
80
  create_reset(output, used_mocks)
85
81
  create_main(output, input_file, tests, used_mocks)
86
82
  end
87
83
 
88
- if (@options[:header_file] && !@options[:header_file].empty?)
89
- File.open(@options[:header_file], 'w') do |output|
90
- create_h_file(output, @options[:header_file], tests, testfile_includes, used_mocks)
91
- end
84
+ return unless @options[:header_file] && !@options[:header_file].empty?
85
+
86
+ File.open(@options[:header_file], 'w') do |output|
87
+ create_h_file(output, @options[:header_file], tests, testfile_includes, used_mocks)
92
88
  end
93
89
  end
94
90
 
@@ -96,103 +92,102 @@ class UnityTestRunnerGenerator
96
92
  tests_and_line_numbers = []
97
93
 
98
94
  source_scrubbed = source.clone
99
- source_scrubbed = source_scrubbed.gsub(/"[^"\n]*"/, '') # remove things in strings
95
+ source_scrubbed = source_scrubbed.gsub(/"[^"\n]*"/, '') # remove things in strings
100
96
  source_scrubbed = source_scrubbed.gsub(/\/\/.*$/, '') # remove line comments
101
97
  source_scrubbed = source_scrubbed.gsub(/\/\*.*?\*\//m, '') # remove block comments
102
98
  lines = source_scrubbed.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
103
99
  | (;|\{|\}) /x) # Match ;, {, and } as end of lines
104
100
 
105
- lines.each_with_index do |line, index|
106
- #find tests
107
- if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/
108
- arguments = $1
109
- name = $2
110
- call = $3
111
- params = $4
112
- args = nil
113
- if (@options[:use_param_tests] and !arguments.empty?)
114
- args = []
115
- arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) {|a| args << a[0]}
116
- end
117
- tests_and_line_numbers << { :test => name, :args => args, :call => call, :params => params, :line_number => 0 }
101
+ lines.each_with_index do |line, _index|
102
+ # find tests
103
+ next unless line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/
104
+ arguments = Regexp.last_match(1)
105
+ name = Regexp.last_match(2)
106
+ call = Regexp.last_match(3)
107
+ params = Regexp.last_match(4)
108
+ args = nil
109
+ if @options[:use_param_tests] && !arguments.empty?
110
+ args = []
111
+ arguments.scan(/\s*TEST_CASE\s*\((.*)\)\s*$/) { |a| args << a[0] }
118
112
  end
113
+ tests_and_line_numbers << { test: name, args: args, call: call, params: params, line_number: 0 }
119
114
  end
120
- tests_and_line_numbers.uniq! {|v| v[:test] }
115
+ tests_and_line_numbers.uniq! { |v| v[:test] }
121
116
 
122
- #determine line numbers and create tests to run
117
+ # determine line numbers and create tests to run
123
118
  source_lines = source.split("\n")
124
- source_index = 0;
119
+ source_index = 0
125
120
  tests_and_line_numbers.size.times do |i|
126
121
  source_lines[source_index..-1].each_with_index do |line, index|
127
- if (line =~ /#{tests_and_line_numbers[i][:test]}/)
128
- source_index += index
129
- tests_and_line_numbers[i][:line_number] = source_index + 1
130
- break
131
- end
122
+ next unless line =~ /#{tests_and_line_numbers[i][:test]}/
123
+ source_index += index
124
+ tests_and_line_numbers[i][:line_number] = source_index + 1
125
+ break
132
126
  end
133
127
  end
134
128
 
135
- return tests_and_line_numbers
129
+ tests_and_line_numbers
136
130
  end
137
131
 
138
132
  def find_includes(source)
139
-
140
- #remove comments (block and line, in three steps to ensure correct precedence)
133
+ # remove comments (block and line, in three steps to ensure correct precedence)
141
134
  source.gsub!(/\/\/(?:.+\/\*|\*(?:$|[^\/])).*$/, '') # remove line comments that comment out the start of blocks
142
135
  source.gsub!(/\/\*.*?\*\//m, '') # remove block comments
143
136
  source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain)
144
137
 
145
- #parse out includes
138
+ # parse out includes
146
139
  includes = {
147
- :local => source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten,
148
- :system => source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" }
140
+ local: source.scan(/^\s*#include\s+\"\s*(.+)\.[hH]\s*\"/).flatten,
141
+ system: source.scan(/^\s*#include\s+<\s*(.+)\s*>/).flatten.map { |inc| "<#{inc}>" },
142
+ linkonly: source.scan(/^TEST_FILE\(\s*\"\s*(.+)\.[cC]\w*\s*\"/).flatten
149
143
  }
150
- return includes
144
+ includes
151
145
  end
152
146
 
153
147
  def find_mocks(includes)
154
148
  mock_headers = []
155
149
  includes.each do |include_path|
156
150
  include_file = File.basename(include_path)
157
- mock_headers << include_path if (include_file =~ /^mock/i)
151
+ mock_headers << include_path if include_file =~ /^#{@options[:mock_prefix]}/i
158
152
  end
159
- return mock_headers
153
+ mock_headers
160
154
  end
161
155
 
162
- def create_header(output, mocks, testfile_includes=[])
156
+ def create_header(output, mocks, testfile_includes = [])
163
157
  output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
164
158
  create_runtest(output, mocks)
165
159
  output.puts("\n/*=======Automagically Detected Files To Include=====*/")
166
- output.puts("#include \"#{@options[:framework].to_s}.h\"")
167
- output.puts('#include "cmock.h"') unless (mocks.empty?)
160
+ output.puts("#include \"#{@options[:framework]}.h\"")
161
+ output.puts('#include "cmock.h"') unless mocks.empty?
168
162
  output.puts('#include <setjmp.h>')
169
163
  output.puts('#include <stdio.h>')
170
- output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
171
- if (@options[:defines] && !@options[:defines].empty?)
172
- @options[:defines].each {|d| output.puts("#define #{d}")}
164
+ if @options[:defines] && !@options[:defines].empty?
165
+ @options[:defines].each { |d| output.puts("#define #{d}") }
173
166
  end
174
- if (@options[:header_file] && !@options[:header_file].empty?)
167
+ if @options[:header_file] && !@options[:header_file].empty?
175
168
  output.puts("#include \"#{File.basename(@options[:header_file])}\"")
176
169
  else
177
170
  @options[:includes].flatten.uniq.compact.each do |inc|
178
- output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
171
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
179
172
  end
180
173
  testfile_includes.each do |inc|
181
- output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
174
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
182
175
  end
183
176
  end
184
177
  mocks.each do |mock|
185
- output.puts("#include \"#{mock.gsub('.h','')}.h\"")
186
- end
187
- if @options[:enforce_strict_ordering]
188
- output.puts('')
189
- output.puts('int GlobalExpectCount;')
190
- output.puts('int GlobalVerifyOrder;')
191
- output.puts('char* GlobalOrderError;')
178
+ output.puts("#include \"#{mock.gsub('.h', '')}.h\"")
192
179
  end
180
+ output.puts('#include "CException.h"') if @options[:plugins].include?(:cexception)
181
+
182
+ return unless @options[:enforce_strict_ordering]
183
+
184
+ output.puts('')
185
+ output.puts('int GlobalExpectCount;')
186
+ output.puts('int GlobalVerifyOrder;')
187
+ output.puts('char* GlobalOrderError;')
193
188
  end
194
189
 
195
- def create_externs(output, tests, mocks)
190
+ def create_externs(output, tests, _mocks)
196
191
  output.puts("\n/*=======External Functions This Runner Calls=====*/")
197
192
  output.puts("extern void #{@options[:setup_name]}(void);")
198
193
  output.puts("extern void #{@options[:teardown_name]}(void);")
@@ -203,55 +198,60 @@ class UnityTestRunnerGenerator
203
198
  end
204
199
 
205
200
  def create_mock_management(output, mock_headers)
206
- unless (mock_headers.empty?)
207
- output.puts("\n/*=======Mock Management=====*/")
208
- output.puts("static void CMock_Init(void)")
209
- output.puts("{")
210
- if @options[:enforce_strict_ordering]
211
- output.puts(" GlobalExpectCount = 0;")
212
- output.puts(" GlobalVerifyOrder = 0;")
213
- output.puts(" GlobalOrderError = NULL;")
214
- end
215
- mocks = mock_headers.map {|mock| File.basename(mock)}
216
- mocks.each do |mock|
217
- mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
218
- output.puts(" #{mock_clean}_Init();")
219
- end
220
- output.puts("}\n")
201
+ return if mock_headers.empty?
221
202
 
222
- output.puts("static void CMock_Verify(void)")
223
- output.puts("{")
224
- mocks.each do |mock|
225
- mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
226
- output.puts(" #{mock_clean}_Verify();")
227
- end
228
- output.puts("}\n")
203
+ output.puts("\n/*=======Mock Management=====*/")
204
+ output.puts('static void CMock_Init(void)')
205
+ output.puts('{')
229
206
 
230
- output.puts("static void CMock_Destroy(void)")
231
- output.puts("{")
232
- mocks.each do |mock|
233
- mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
234
- output.puts(" #{mock_clean}_Destroy();")
235
- end
236
- output.puts("}\n")
207
+ if @options[:enforce_strict_ordering]
208
+ output.puts(' GlobalExpectCount = 0;')
209
+ output.puts(' GlobalVerifyOrder = 0;')
210
+ output.puts(' GlobalOrderError = NULL;')
237
211
  end
238
- end
239
212
 
240
- def create_suite_setup_and_teardown(output)
241
- unless (@options[:suite_setup].nil?)
242
- output.puts("\n/*=======Suite Setup=====*/")
243
- output.puts("static void suite_setup(void)")
244
- output.puts("{")
245
- output.puts(@options[:suite_setup])
246
- output.puts("}")
213
+ mocks = mock_headers.map { |mock| File.basename(mock) }
214
+ mocks.each do |mock|
215
+ mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
216
+ output.puts(" #{mock_clean}_Init();")
247
217
  end
248
- unless (@options[:suite_teardown].nil?)
249
- output.puts("\n/*=======Suite Teardown=====*/")
250
- output.puts("static int suite_teardown(int num_failures)")
251
- output.puts("{")
252
- output.puts(@options[:suite_teardown])
253
- output.puts("}")
218
+ output.puts("}\n")
219
+
220
+ output.puts('static void CMock_Verify(void)')
221
+ output.puts('{')
222
+ mocks.each do |mock|
223
+ mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
224
+ output.puts(" #{mock_clean}_Verify();")
225
+ end
226
+ output.puts("}\n")
227
+
228
+ output.puts('static void CMock_Destroy(void)')
229
+ output.puts('{')
230
+ mocks.each do |mock|
231
+ mock_clean = TypeSanitizer.sanitize_c_identifier(mock)
232
+ output.puts(" #{mock_clean}_Destroy();")
254
233
  end
234
+ output.puts("}\n")
235
+ end
236
+
237
+ def create_suite_setup(output)
238
+ return if @options[:suite_setup].nil?
239
+
240
+ output.puts("\n/*=======Suite Setup=====*/")
241
+ output.puts('static void suite_setup(void)')
242
+ output.puts('{')
243
+ output.puts(@options[:suite_setup])
244
+ output.puts('}')
245
+ end
246
+
247
+ def create_suite_teardown(output)
248
+ return if @options[:suite_teardown].nil?
249
+
250
+ output.puts("\n/*=======Suite Teardown=====*/")
251
+ output.puts('static int suite_teardown(int num_failures)')
252
+ output.puts('{')
253
+ output.puts(@options[:suite_teardown])
254
+ output.puts('}')
255
255
  end
256
256
 
257
257
  def create_runtest(output, used_mocks)
@@ -259,124 +259,124 @@ class UnityTestRunnerGenerator
259
259
  va_args1 = @options[:use_param_tests] ? ', ...' : ''
260
260
  va_args2 = @options[:use_param_tests] ? '__VA_ARGS__' : ''
261
261
  output.puts("\n/*=======Test Runner Used To Run Each Test Below=====*/")
262
- output.puts("#define RUN_TEST_NO_ARGS") if @options[:use_param_tests]
262
+ output.puts('#define RUN_TEST_NO_ARGS') if @options[:use_param_tests]
263
263
  output.puts("#define RUN_TEST(TestFunc, TestLineNum#{va_args1}) \\")
264
- output.puts("{ \\")
264
+ output.puts('{ \\')
265
265
  output.puts(" Unity.CurrentTestName = #TestFunc#{va_args2.empty? ? '' : " \"(\" ##{va_args2} \")\""}; \\")
266
- output.puts(" Unity.CurrentTestLineNumber = TestLineNum; \\")
267
- output.puts(" if (UnityTestMatches()) { \\") if (@options[:cmdline_args])
268
- output.puts(" Unity.NumberOfTests++; \\")
269
- output.puts(" CMock_Init(); \\") unless (used_mocks.empty?)
270
- output.puts(" UNITY_CLR_DETAILS(); \\") unless (used_mocks.empty?)
271
- output.puts(" if (TEST_PROTECT()) \\")
272
- output.puts(" { \\")
273
- output.puts(" CEXCEPTION_T e; \\") if cexception
274
- output.puts(" Try { \\") if cexception
266
+ output.puts(' Unity.CurrentTestLineNumber = TestLineNum; \\')
267
+ output.puts(' if (UnityTestMatches()) { \\') if @options[:cmdline_args]
268
+ output.puts(' Unity.NumberOfTests++; \\')
269
+ output.puts(' CMock_Init(); \\') unless used_mocks.empty?
270
+ output.puts(' UNITY_CLR_DETAILS(); \\') unless used_mocks.empty?
271
+ output.puts(' if (TEST_PROTECT()) \\')
272
+ output.puts(' { \\')
273
+ output.puts(' CEXCEPTION_T e; \\') if cexception
274
+ output.puts(' Try { \\') if cexception
275
275
  output.puts(" #{@options[:setup_name]}(); \\")
276
276
  output.puts(" TestFunc(#{va_args2}); \\")
277
- output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
278
- output.puts(" } \\")
279
- output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
280
- output.puts(" { \\")
277
+ output.puts(' } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, "Unhandled Exception!"); } \\') if cexception
278
+ output.puts(' } \\')
279
+ output.puts(' if (TEST_PROTECT()) \\')
280
+ output.puts(' { \\')
281
281
  output.puts(" #{@options[:teardown_name]}(); \\")
282
- output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
283
- output.puts(" } \\")
284
- output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
285
- output.puts(" UnityConcludeTest(); \\")
286
- output.puts(" } \\") if (@options[:cmdline_args])
282
+ output.puts(' CMock_Verify(); \\') unless used_mocks.empty?
283
+ output.puts(' } \\')
284
+ output.puts(' CMock_Destroy(); \\') unless used_mocks.empty?
285
+ output.puts(' UnityConcludeTest(); \\')
286
+ output.puts(' } \\') if @options[:cmdline_args]
287
287
  output.puts("}\n")
288
288
  end
289
289
 
290
290
  def create_reset(output, used_mocks)
291
291
  output.puts("\n/*=======Test Reset Option=====*/")
292
- output.puts("void resetTest(void);")
293
- output.puts("void resetTest(void)")
294
- output.puts("{")
295
- output.puts(" CMock_Verify();") unless (used_mocks.empty?)
296
- output.puts(" CMock_Destroy();") unless (used_mocks.empty?)
292
+ output.puts('void resetTest(void);')
293
+ output.puts('void resetTest(void)')
294
+ output.puts('{')
295
+ output.puts(' CMock_Verify();') unless used_mocks.empty?
296
+ output.puts(' CMock_Destroy();') unless used_mocks.empty?
297
297
  output.puts(" #{@options[:teardown_name]}();")
298
- output.puts(" CMock_Init();") unless (used_mocks.empty?)
298
+ output.puts(' CMock_Init();') unless used_mocks.empty?
299
299
  output.puts(" #{@options[:setup_name]}();")
300
- output.puts("}")
300
+ output.puts('}')
301
301
  end
302
302
 
303
303
  def create_main(output, filename, tests, used_mocks)
304
304
  output.puts("\n\n/*=======MAIN=====*/")
305
- main_name = (@options[:main_name].to_sym == :auto) ? "main_#{filename.gsub('.c','')}" : "#{@options[:main_name]}"
306
- if (@options[:cmdline_args])
307
- if (main_name != "main")
305
+ main_name = @options[:main_name].to_sym == :auto ? "main_#{filename.gsub('.c', '')}" : (@options[:main_name]).to_s
306
+ if @options[:cmdline_args]
307
+ if main_name != 'main'
308
308
  output.puts("#{@options[:main_export_decl]} int #{main_name}(int argc, char** argv);")
309
309
  end
310
310
  output.puts("#{@options[:main_export_decl]} int #{main_name}(int argc, char** argv)")
311
- output.puts("{")
312
- output.puts(" int parse_status = UnityParseOptions(argc, argv);")
313
- output.puts(" if (parse_status != 0)")
314
- output.puts(" {")
315
- output.puts(" if (parse_status < 0)")
316
- output.puts(" {")
317
- output.puts(" UnityPrint(\"#{filename.gsub('.c','')}.\");")
318
- output.puts(" UNITY_PRINT_EOL();")
319
- if (@options[:use_param_tests])
311
+ output.puts('{')
312
+ output.puts(' int parse_status = UnityParseOptions(argc, argv);')
313
+ output.puts(' if (parse_status != 0)')
314
+ output.puts(' {')
315
+ output.puts(' if (parse_status < 0)')
316
+ output.puts(' {')
317
+ output.puts(" UnityPrint(\"#{filename.gsub('.c', '')}.\");")
318
+ output.puts(' UNITY_PRINT_EOL();')
319
+ if @options[:use_param_tests]
320
320
  tests.each do |test|
321
- if ((test[:args].nil?) or (test[:args].empty?))
321
+ if test[:args].nil? || test[:args].empty?
322
322
  output.puts(" UnityPrint(\" #{test[:test]}(RUN_TEST_NO_ARGS)\");")
323
- output.puts(" UNITY_PRINT_EOL();")
323
+ output.puts(' UNITY_PRINT_EOL();')
324
324
  else
325
325
  test[:args].each do |args|
326
326
  output.puts(" UnityPrint(\" #{test[:test]}(#{args})\");")
327
- output.puts(" UNITY_PRINT_EOL();")
327
+ output.puts(' UNITY_PRINT_EOL();')
328
328
  end
329
329
  end
330
330
  end
331
331
  else
332
- tests.each { |test| output.puts(" UnityPrint(\" #{test[:test]}\");\n UNITY_PRINT_EOL();")}
332
+ tests.each { |test| output.puts(" UnityPrint(\" #{test[:test]}\");\n UNITY_PRINT_EOL();") }
333
333
  end
334
- output.puts(" return 0;")
335
- output.puts(" }")
336
- output.puts(" return parse_status;")
337
- output.puts(" }")
334
+ output.puts(' return 0;')
335
+ output.puts(' }')
336
+ output.puts(' return parse_status;')
337
+ output.puts(' }')
338
338
  else
339
- if (main_name != "main")
339
+ if main_name != 'main'
340
340
  output.puts("#{@options[:main_export_decl]} int #{main_name}(void);")
341
341
  end
342
342
  output.puts("int #{main_name}(void)")
343
- output.puts("{")
343
+ output.puts('{')
344
344
  end
345
- output.puts(" suite_setup();") unless @options[:suite_setup].nil?
346
- output.puts(" UnityBegin(\"#{filename.gsub(/\\/,'\\\\\\')}\");")
347
- if (@options[:use_param_tests])
345
+ output.puts(' suite_setup();') unless @options[:suite_setup].nil?
346
+ output.puts(" UnityBegin(\"#{filename.gsub(/\\/, '\\\\\\')}\");")
347
+ if @options[:use_param_tests]
348
348
  tests.each do |test|
349
- if ((test[:args].nil?) or (test[:args].empty?))
349
+ if test[:args].nil? || test[:args].empty?
350
350
  output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, RUN_TEST_NO_ARGS);")
351
351
  else
352
- test[:args].each {|args| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, #{args});")}
352
+ test[:args].each { |args| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]}, #{args});") }
353
353
  end
354
354
  end
355
355
  else
356
- tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") }
356
+ tests.each { |test| output.puts(" RUN_TEST(#{test[:test]}, #{test[:line_number]});") }
357
357
  end
358
- output.puts()
359
- output.puts(" CMock_Guts_MemFreeFinal();") unless used_mocks.empty?
360
- output.puts(" return #{@options[:suite_teardown].nil? ? "" : "suite_teardown"}(UnityEnd());")
361
- output.puts("}")
358
+ output.puts
359
+ output.puts(' CMock_Guts_MemFreeFinal();') unless used_mocks.empty?
360
+ output.puts(" return #{@options[:suite_teardown].nil? ? '' : 'suite_teardown'}(UnityEnd());")
361
+ output.puts('}')
362
362
  end
363
363
 
364
364
  def create_h_file(output, filename, tests, testfile_includes, used_mocks)
365
- filename = File.basename(filename).gsub(/[-\/\\\.\,\s]/, "_").upcase
366
- output.puts("/* AUTOGENERATED FILE. DO NOT EDIT. */")
365
+ filename = File.basename(filename).gsub(/[-\/\\\.\,\s]/, '_').upcase
366
+ output.puts('/* AUTOGENERATED FILE. DO NOT EDIT. */')
367
367
  output.puts("#ifndef _#{filename}")
368
368
  output.puts("#define _#{filename}\n\n")
369
- output.puts("#include \"#{@options[:framework].to_s}.h\"")
370
- output.puts('#include "cmock.h"') unless (used_mocks.empty?)
369
+ output.puts("#include \"#{@options[:framework]}.h\"")
370
+ output.puts('#include "cmock.h"') unless used_mocks.empty?
371
371
  @options[:includes].flatten.uniq.compact.each do |inc|
372
- output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
372
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
373
373
  end
374
374
  testfile_includes.each do |inc|
375
- output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h','')}.h\""}")
375
+ output.puts("#include #{inc.include?('<') ? inc : "\"#{inc.gsub('.h', '')}.h\""}")
376
376
  end
377
377
  output.puts "\n"
378
378
  tests.each do |test|
379
- if ((test[:params].nil?) or (test[:params].empty?))
379
+ if test[:params].nil? || test[:params].empty?
380
380
  output.puts("void #{test[:test]}(void);")
381
381
  else
382
382
  output.puts("void #{test[:test]}(#{test[:params]});")
@@ -386,50 +386,52 @@ class UnityTestRunnerGenerator
386
386
  end
387
387
  end
388
388
 
389
- if ($0 == __FILE__)
390
- options = { :includes => [] }
391
- yaml_file = nil
389
+ if $0 == __FILE__
390
+ options = { includes: [] }
392
391
 
393
- #parse out all the options first (these will all be removed as we go)
392
+ # parse out all the options first (these will all be removed as we go)
394
393
  ARGV.reject! do |arg|
395
- case(arg)
396
- when '-cexception'
397
- options[:plugins] = [:cexception]; true
398
- when /\.*\.ya?ml/
399
- options = UnityTestRunnerGenerator.grab_config(arg); true
400
- when /--(\w+)=\"?(.*)\"?/
401
- options[$1.to_sym] = $2; true
402
- when /\.*\.h/
403
- options[:includes] << arg; true
404
- else false
394
+ case arg
395
+ when '-cexception'
396
+ options[:plugins] = [:cexception]
397
+ true
398
+ when /\.*\.ya?ml/
399
+ options = UnityTestRunnerGenerator.grab_config(arg)
400
+ true
401
+ when /--(\w+)=\"?(.*)\"?/
402
+ options[Regexp.last_match(1).to_sym] = Regexp.last_match(2)
403
+ true
404
+ when /\.*\.h/
405
+ options[:includes] << arg
406
+ true
407
+ else false
405
408
  end
406
409
  end
407
410
 
408
- #make sure there is at least one parameter left (the input file)
409
- if !ARGV[0]
411
+ # make sure there is at least one parameter left (the input file)
412
+ unless ARGV[0]
410
413
  puts ["\nusage: ruby #{__FILE__} (files) (options) input_test_file (output)",
411
- "\n input_test_file - this is the C file you want to create a runner for",
412
- " output - this is the name of the runner file to generate",
413
- " defaults to (input_test_file)_Runner",
414
- " files:",
415
- " *.yml / *.yaml - loads configuration from here in :unity or :cmock",
416
- " *.h - header files are added as #includes in runner",
417
- " options:",
418
- " -cexception - include cexception support",
419
- " --setup_name=\"\" - redefine setUp func name to something else",
420
- " --teardown_name=\"\" - redefine tearDown func name to something else",
421
- " --main_name=\"\" - redefine main func name to something else",
422
- " --test_prefix=\"\" - redefine test prefix from default test|spec|should",
423
- " --suite_setup=\"\" - code to execute for setup of entire suite",
424
- " --suite_teardown=\"\" - code to execute for teardown of entire suite",
425
- " --use_param_tests=1 - enable parameterized tests (disabled by default)",
426
- " --header_file=\"\" - path/name of test header file to generate too"
427
- ].join("\n")
414
+ "\n input_test_file - this is the C file you want to create a runner for",
415
+ ' output - this is the name of the runner file to generate',
416
+ ' defaults to (input_test_file)_Runner',
417
+ ' files:',
418
+ ' *.yml / *.yaml - loads configuration from here in :unity or :cmock',
419
+ ' *.h - header files are added as #includes in runner',
420
+ ' options:',
421
+ ' -cexception - include cexception support',
422
+ ' --setup_name="" - redefine setUp func name to something else',
423
+ ' --teardown_name="" - redefine tearDown func name to something else',
424
+ ' --main_name="" - redefine main func name to something else',
425
+ ' --test_prefix="" - redefine test prefix from default test|spec|should',
426
+ ' --suite_setup="" - code to execute for setup of entire suite',
427
+ ' --suite_teardown="" - code to execute for teardown of entire suite',
428
+ ' --use_param_tests=1 - enable parameterized tests (disabled by default)',
429
+ ' --header_file="" - path/name of test header file to generate too'].join("\n")
428
430
  exit 1
429
431
  end
430
432
 
431
- #create the default test runner name if not specified
432
- ARGV[1] = ARGV[0].gsub(".c","_Runner.c") if (!ARGV[1])
433
+ # create the default test runner name if not specified
434
+ ARGV[1] = ARGV[0].gsub('.c', '_Runner.c') unless ARGV[1]
433
435
 
434
436
  UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1])
435
437
  end