ceedling 0.21.0 → 0.22.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 (132) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/bin/ceedling +3 -5
  4. data/ceedling-0.21.0.gem +0 -0
  5. data/ceedling.gemspec +1 -0
  6. data/lib/ceedling/configurator.rb +7 -1
  7. data/lib/ceedling/configurator_plugins.rb +21 -21
  8. data/lib/ceedling/generator_test_runner.rb +3 -46
  9. data/lib/ceedling/setupinator.rb +1 -0
  10. data/lib/ceedling/version.rb +4 -4
  11. data/plugins/module_generator/lib/module_generator.rb +14 -127
  12. data/plugins/module_generator/module_generator.rake +15 -3
  13. data/spec/spec_system_helper.rb +1 -1
  14. data/vendor/c_exception/release/build.info +1 -1
  15. data/vendor/c_exception/release/version.info +1 -1
  16. data/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -146
  17. data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +1 -1
  18. data/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
  19. data/vendor/c_exception/vendor/unity/examples/example_2/makefile +1 -1
  20. data/vendor/c_exception/vendor/unity/examples/unity_config.h +11 -19
  21. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  22. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  23. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  24. data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  25. data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +7 -13
  26. data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  27. data/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  28. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  29. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  30. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  31. data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  32. data/vendor/c_exception/vendor/unity/release/build.info +1 -1
  33. data/vendor/c_exception/vendor/unity/release/version.info +1 -1
  34. data/vendor/c_exception/vendor/unity/src/unity.c +45 -72
  35. data/vendor/c_exception/vendor/unity/src/unity.h +3 -4
  36. data/vendor/c_exception/vendor/unity/src/unity_internals.h +71 -109
  37. data/vendor/c_exception/vendor/unity/test/Makefile +25 -13
  38. data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +0 -1
  39. data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +0 -1
  40. data/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +11 -5
  41. data/vendor/c_exception/vendor/unity/test/tests/testunity.c +32 -29
  42. data/vendor/cmock/docs/CMock_Summary.md +4 -0
  43. data/vendor/cmock/lib/cmock_config.rb +7 -2
  44. data/vendor/cmock/lib/cmock_generator.rb +9 -1
  45. data/vendor/cmock/release/build.info +1 -1
  46. data/vendor/cmock/release/version.info +1 -1
  47. data/vendor/cmock/test/unit/cmock_generator_main_test.rb +7 -0
  48. data/vendor/cmock/vendor/c_exception/release/build.info +1 -1
  49. data/vendor/cmock/vendor/c_exception/release/version.info +1 -1
  50. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -146
  51. data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +1 -1
  52. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +1 -1
  53. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +1 -1
  54. data/vendor/cmock/vendor/c_exception/vendor/unity/examples/unity_config.h +11 -19
  55. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  56. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  57. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  58. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  59. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +7 -13
  60. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  61. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  62. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  63. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  64. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  65. data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  66. data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +1 -1
  67. data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +1 -1
  68. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +45 -72
  69. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +3 -4
  70. data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +71 -109
  71. data/vendor/cmock/vendor/c_exception/vendor/unity/test/Makefile +25 -13
  72. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +0 -1
  73. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +0 -1
  74. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testparameterized.c +11 -5
  75. data/vendor/cmock/vendor/c_exception/vendor/unity/test/tests/testunity.c +32 -29
  76. data/vendor/cmock/vendor/unity/auto/generate_module.rb +202 -146
  77. data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +1 -1
  78. data/vendor/cmock/vendor/unity/examples/example_1/makefile +1 -1
  79. data/vendor/cmock/vendor/unity/examples/example_2/makefile +1 -1
  80. data/vendor/cmock/vendor/unity/examples/unity_config.h +11 -19
  81. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  82. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  83. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  84. data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  85. data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +7 -13
  86. data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  87. data/vendor/cmock/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  88. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  89. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  90. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  91. data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  92. data/vendor/cmock/vendor/unity/release/build.info +1 -1
  93. data/vendor/cmock/vendor/unity/release/version.info +1 -1
  94. data/vendor/cmock/vendor/unity/src/unity.c +45 -72
  95. data/vendor/cmock/vendor/unity/src/unity.h +3 -4
  96. data/vendor/cmock/vendor/unity/src/unity_internals.h +71 -109
  97. data/vendor/cmock/vendor/unity/test/Makefile +25 -13
  98. data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +0 -1
  99. data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +0 -1
  100. data/vendor/cmock/vendor/unity/test/tests/testparameterized.c +11 -5
  101. data/vendor/cmock/vendor/unity/test/tests/testunity.c +32 -29
  102. data/vendor/unity/auto/generate_module.rb +202 -146
  103. data/vendor/unity/auto/generate_test_runner.rb +1 -1
  104. data/vendor/unity/examples/example_1/makefile +1 -1
  105. data/vendor/unity/examples/example_2/makefile +1 -1
  106. data/vendor/unity/examples/unity_config.h +11 -19
  107. data/vendor/unity/extras/fixture/src/unity_fixture.c +22 -26
  108. data/vendor/unity/extras/fixture/src/unity_fixture.h +9 -9
  109. data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +15 -6
  110. data/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +15 -15
  111. data/vendor/unity/extras/fixture/test/Makefile +7 -13
  112. data/vendor/unity/extras/fixture/test/main/AllTests.c +6 -6
  113. data/vendor/unity/extras/fixture/test/template_fixture_tests.c +6 -6
  114. data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +36 -29
  115. data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -6
  116. data/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -6
  117. data/vendor/unity/extras/fixture/test/unity_output_Spy.h +6 -6
  118. data/vendor/unity/release/build.info +1 -1
  119. data/vendor/unity/release/version.info +1 -1
  120. data/vendor/unity/src/unity.c +45 -72
  121. data/vendor/unity/src/unity.h +3 -4
  122. data/vendor/unity/src/unity_internals.h +71 -109
  123. data/vendor/unity/test/Makefile +25 -13
  124. data/vendor/unity/test/targets/gcc_32.yml +0 -1
  125. data/vendor/unity/test/targets/gcc_64.yml +0 -1
  126. data/vendor/unity/test/tests/testparameterized.c +11 -5
  127. data/vendor/unity/test/tests/testunity.c +32 -29
  128. metadata +17 -6
  129. data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
  130. data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
  131. data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
  132. data/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -48
@@ -1,9 +1,15 @@
1
- CC ?= gcc
1
+ CC = gcc
2
2
  ifeq ($(shell uname -s), Darwin)
3
- CC ?= clang
3
+ CC = clang
4
+ CFLAGS += -std=c99 -pedantic -Wall -Weverything -Werror
5
+ CFLAGS += -Wno-unknown-warning-option -Wno-switch-enum
6
+ CFLAGS += -Wno-padded -Wno-double-promotion -Wno-missing-noreturn
7
+ CFLAGS += -Wno-missing-prototypes
8
+ endif
9
+ ifeq ($(shell uname -s), Linux)
10
+ CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
4
11
  endif
5
12
  #DEBUG = -O0 -g
6
- CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror -Wredundant-decls
7
13
  CFLAGS += $(DEBUG)
8
14
  DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy
9
15
  DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE -D UNITY_NO_WEAK
@@ -14,10 +20,9 @@ BUILD_DIR = build
14
20
  TARGET = build/testunity-cov.exe
15
21
 
16
22
  # To generate coverage, call 'make -s', the default target runs.
17
- # To see missing coverage, follow up with 'make uncovered'.
18
23
  # For verbose output of all the tests, run 'make test'.
19
24
  default: coverage
20
- .PHONY: default coverage uncovered test clean
25
+ .PHONY: default coverage test clean
21
26
  coverage: $(BUILD_DIR)/testunityRunner.c
22
27
  cd $(BUILD_DIR) && \
23
28
  $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET)
@@ -28,21 +33,28 @@ coverage: $(BUILD_DIR)/testunityRunner.c
28
33
  grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true
29
34
 
30
35
  test: CFLAGS += -Wbad-function-cast -Wcast-qual -Wconversion -Wformat=2 -Wold-style-definition \
31
- -Wpointer-arith -Wshadow -Wstrict-overflow=5 -Wstrict-prototypes -Wswitch-default -Wundef \
32
- -Wunreachable-code -Wunused -fstrict-aliasing
36
+ -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-overflow=5 -Wstrict-prototypes \
37
+ -Wswitch-default -Wundef -Wunreachable-code -Wunused -fstrict-aliasing
33
38
  test: $(BUILD_DIR)/testunityRunner.c
34
39
  $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC) -o $(TARGET)
35
40
  ./$(TARGET)
36
41
 
42
+ # Compile only, for testing that preprocessor detection works
43
+ UNITY_C_ONLY =-c ../src/unity.c -o $(BUILD_DIR)/unity.o
44
+ intDetection:
45
+ $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_STDINT_H
46
+ $(CC) $(CFLAGS) $(INC_DIR) $(UNITY_C_ONLY) -D UNITY_EXCLUDE_LIMITS_H
47
+
37
48
  $(BUILD_DIR)/testunityRunner.c: tests/testunity.c | $(BUILD_DIR)
38
49
  awk $(AWK_SCRIPT) tests/testunity.c > $@
39
50
 
40
- AWK_SCRIPT='/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0 } \
41
- END{ print "\#include \"unity.h\" //Autogenerated by awk in Makefile" ; \
42
- for (i=0; i<d; i++) { print declarations[i] ";" } \
43
- printf "int main()\n{\n UNITY_BEGIN();\n" ; \
44
- for (i=0; i<t; i++) { print " RUN_TEST(" tests[i] ");" } \
45
- printf " return UNITY_END();\n}\n" }'
51
+ AWK_SCRIPT=\
52
+ '/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \
53
+ END{ print "\#include \"unity.h\" /* Autogenerated by awk in Makefile */" ; \
54
+ for (i=0; i<d; i++) { print declarations[i] ";" } \
55
+ printf "int main(void)\n{\n UNITY_BEGIN();\n" ; \
56
+ for (i=0; i<t; i++) { print " RUN_TEST(" tests[i] ", " line[i] ");" } \
57
+ printf " return UNITY_END();\n}\n" }'
46
58
 
47
59
  $(BUILD_DIR):
48
60
  mkdir -p $(BUILD_DIR)
@@ -22,7 +22,6 @@ compiler:
22
22
  items:
23
23
  - UNITY_EXCLUDE_STDINT_H
24
24
  - UNITY_EXCLUDE_LIMITS_H
25
- - UNITY_EXCLUDE_SIZEOF
26
25
  - UNITY_INCLUDE_DOUBLE
27
26
  - UNITY_SUPPORT_TEST_CASES
28
27
  - UNITY_INT_WIDTH=32
@@ -22,7 +22,6 @@ compiler:
22
22
  items:
23
23
  - UNITY_EXCLUDE_STDINT_H
24
24
  - UNITY_EXCLUDE_LIMITS_H
25
- - UNITY_EXCLUDE_SIZEOF
26
25
  - UNITY_INCLUDE_DOUBLE
27
26
  - UNITY_SUPPORT_TEST_CASES
28
27
  - UNITY_SUPPORT_64
@@ -18,20 +18,26 @@ void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking t
18
18
 
19
19
  #define VERIFY_FAILS_END \
20
20
  } \
21
- Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \
21
+ Unity.CurrentTestFailed = (Unity.CurrentTestFailed != 0) ? 0 : 1; \
22
22
  if (Unity.CurrentTestFailed == 1) { \
23
23
  SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
24
- UnityPrint("[[[[ Previous Test Should Have Failed But Did Not ]]]]"); \
24
+ UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
25
+ UNITY_OUTPUT_CHAR(':'); \
26
+ UnityPrint(Unity.CurrentTestName); \
27
+ UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \
25
28
  UNITY_OUTPUT_CHAR('\n'); \
26
29
  }
27
30
 
28
31
  #define VERIFY_IGNORES_END \
29
32
  } \
30
- Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \
33
+ Unity.CurrentTestFailed = (Unity.CurrentTestIgnored != 0) ? 0 : 1; \
31
34
  Unity.CurrentTestIgnored = 0; \
32
35
  if (Unity.CurrentTestFailed == 1) { \
33
36
  SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
34
- UnityPrint("[[[[ Previous Test Should Have Ignored But Did Not ]]]]"); \
37
+ UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
38
+ UNITY_OUTPUT_CHAR(':'); \
39
+ UnityPrint(Unity.CurrentTestName); \
40
+ UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \
35
41
  UNITY_OUTPUT_CHAR('\n'); \
36
42
  }
37
43
 
@@ -50,7 +56,7 @@ void tearDown(void)
50
56
  TEST_FAIL_MESSAGE("<= Failed in tearDown");
51
57
  if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
52
58
  {
53
- UnityPrint("[[[[ Previous Test Should Have Passed But Did Not ]]]]");
59
+ UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
54
60
  UNITY_OUTPUT_CHAR('\n');
55
61
  }
56
62
  }
@@ -4,8 +4,8 @@
4
4
  [Released under MIT License. Please refer to license.txt for details]
5
5
  ========================================== */
6
6
 
7
- #include <setjmp.h>
8
7
  #include "unity.h"
8
+ #include <setjmp.h>
9
9
  #include <string.h>
10
10
 
11
11
  // Dividing by these constants produces +/- infinity.
@@ -19,31 +19,42 @@ static const _UD d_zero = 0.0;
19
19
  #endif
20
20
 
21
21
  #define EXPECT_ABORT_BEGIN \
22
+ startPutcharSpy(); \
22
23
  if (TEST_PROTECT()) \
23
24
  {
24
25
 
25
26
  #define VERIFY_FAILS_END \
26
27
  } \
28
+ endPutcharSpy(); /* start/end Spy to suppress output of failure message */ \
27
29
  Unity.CurrentTestFailed = (Unity.CurrentTestFailed == 1) ? 0 : 1; \
28
30
  if (Unity.CurrentTestFailed == 1) { \
29
31
  SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
30
32
  UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
31
33
  UNITY_OUTPUT_CHAR(':'); \
32
34
  UnityPrint(Unity.CurrentTestName); \
33
- UnityPrint("[[[[ Previous Test Should Have Failed But Did Not ]]]]"); \
35
+ UnityPrint(":FAIL: [[[[ Test Should Have Failed But Did Not ]]]]"); \
34
36
  UNITY_OUTPUT_CHAR('\n'); \
35
37
  }
36
38
 
37
39
  #define VERIFY_IGNORES_END \
38
40
  } \
41
+ endPutcharSpy(); /* start/end Spy to suppress output of ignore message */ \
39
42
  Unity.CurrentTestFailed = (Unity.CurrentTestIgnored == 1) ? 0 : 1; \
40
43
  Unity.CurrentTestIgnored = 0; \
41
44
  if (Unity.CurrentTestFailed == 1) { \
42
45
  SetToOneMeanWeAlreadyCheckedThisGuy = 1; \
43
- UnityPrint("[[[[ Previous Test Should Have Ignored But Did Not ]]]]"); \
46
+ UnityPrintNumberUnsigned(Unity.CurrentTestLineNumber); \
47
+ UNITY_OUTPUT_CHAR(':'); \
48
+ UnityPrint(Unity.CurrentTestName); \
49
+ UnityPrint(":FAIL: [[[[ Test Should Have Ignored But Did Not ]]]]"); \
44
50
  UNITY_OUTPUT_CHAR('\n'); \
45
51
  }
46
52
 
53
+ void startPutcharSpy(void);
54
+ void endPutcharSpy(void);
55
+ char* getBufferPutcharSpy(void);
56
+ void putcharSpy(int c);
57
+
47
58
  static int SetToOneToFailInTearDown;
48
59
  static int SetToOneMeanWeAlreadyCheckedThisGuy;
49
60
 
@@ -59,7 +70,7 @@ void tearDown(void)
59
70
  TEST_FAIL_MESSAGE("<= Failed in tearDown");
60
71
  if ((SetToOneMeanWeAlreadyCheckedThisGuy == 0) && (Unity.CurrentTestFailed > 0))
61
72
  {
62
- UnityPrint("[[[[ Previous Test Should Have Passed But Did Not ]]]]");
73
+ UnityPrint(": [[[[ Test Should Have Passed But Did Not ]]]]");
63
74
  UNITY_OUTPUT_CHAR('\n');
64
75
  }
65
76
  }
@@ -1370,7 +1381,7 @@ void testNotEqualString4(void)
1370
1381
  void testNotEqualStringLen4(void)
1371
1382
  {
1372
1383
  EXPECT_ABORT_BEGIN
1373
- TEST_ASSERT_EQUAL_STRING_LEN("\r\x16", "bar\n", 4);
1384
+ TEST_ASSERT_EQUAL_STRING_LEN("ba\r\x16", "ba\r\n", 4);
1374
1385
  VERIFY_FAILS_END
1375
1386
  }
1376
1387
 
@@ -2272,6 +2283,14 @@ void testFailureCountIncrementsAndIsReturnedAtEnd(void)
2272
2283
  TEST_ASSERT_EQUAL(1, failures);
2273
2284
  }
2274
2285
 
2286
+ void testCstringsEscapeSequence(void)
2287
+ {
2288
+ startPutcharSpy();
2289
+ UnityPrint("\x16\x10");
2290
+ endPutcharSpy();
2291
+ TEST_ASSERT_EQUAL_STRING("\\x16\\x10", getBufferPutcharSpy());
2292
+ }
2293
+
2275
2294
  #define TEST_ASSERT_EQUAL_PRINT_NUMBERS(expected, actual) { \
2276
2295
  startPutcharSpy(); UnityPrintNumber((actual)); endPutcharSpy(); \
2277
2296
  TEST_ASSERT_EQUAL_STRING((expected), getBufferPutcharSpy()); \
@@ -2778,14 +2797,12 @@ void testFloatsNotEqualExpectedNaN(void)
2778
2797
  #endif
2779
2798
  }
2780
2799
 
2781
- void testFloatsNotEqualBothNaN(void)
2800
+ void testFloatsEqualBothNaN(void)
2782
2801
  {
2783
2802
  #ifdef UNITY_EXCLUDE_FLOAT
2784
2803
  TEST_IGNORE();
2785
2804
  #else
2786
- EXPECT_ABORT_BEGIN
2787
2805
  TEST_ASSERT_EQUAL_FLOAT(0.0f / f_zero, 0.0f / f_zero);
2788
- VERIFY_FAILS_END
2789
2806
  #endif
2790
2807
  }
2791
2808
 
@@ -2833,14 +2850,12 @@ void testFloatsNotEqualExpectedInf(void)
2833
2850
  #endif
2834
2851
  }
2835
2852
 
2836
- void testFloatsNotEqualBothInf(void)
2853
+ void testFloatsEqualBothInf(void)
2837
2854
  {
2838
2855
  #ifdef UNITY_EXCLUDE_FLOAT
2839
2856
  TEST_IGNORE();
2840
2857
  #else
2841
- EXPECT_ABORT_BEGIN
2842
2858
  TEST_ASSERT_EQUAL_FLOAT(1.0f / f_zero, 1.0f / f_zero);
2843
- VERIFY_FAILS_END
2844
2859
  #endif
2845
2860
  }
2846
2861
 
@@ -3175,7 +3190,7 @@ void testNotEqualFloatArraysNegative3(void)
3175
3190
  #endif
3176
3191
  }
3177
3192
 
3178
- void testNotEqualFloatArraysNaN(void)
3193
+ void testEqualFloatArraysNaN(void)
3179
3194
  {
3180
3195
  #ifdef UNITY_EXCLUDE_FLOAT
3181
3196
  TEST_IGNORE();
@@ -3183,13 +3198,11 @@ void testNotEqualFloatArraysNaN(void)
3183
3198
  float p0[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f};
3184
3199
  float p1[] = {1.0f, 0.0f / f_zero, 25.4f, 0.253f};
3185
3200
 
3186
- EXPECT_ABORT_BEGIN
3187
3201
  TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
3188
- VERIFY_FAILS_END
3189
3202
  #endif
3190
3203
  }
3191
3204
 
3192
- void testNotEqualFloatArraysInf(void)
3205
+ void testEqualFloatArraysInf(void)
3193
3206
  {
3194
3207
  #ifdef UNITY_EXCLUDE_FLOAT
3195
3208
  TEST_IGNORE();
@@ -3197,9 +3210,7 @@ void testNotEqualFloatArraysInf(void)
3197
3210
  float p0[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f};
3198
3211
  float p1[] = {1.0f, 1.0f / f_zero, 25.4f, 0.253f};
3199
3212
 
3200
- EXPECT_ABORT_BEGIN
3201
3213
  TEST_ASSERT_EQUAL_FLOAT_ARRAY(p0, p1, 4);
3202
- VERIFY_FAILS_END
3203
3214
  #endif
3204
3215
  }
3205
3216
 
@@ -3310,14 +3321,12 @@ void testDoublesNotEqualExpectedNaN(void)
3310
3321
  #endif
3311
3322
  }
3312
3323
 
3313
- void testDoublesNotEqualBothNaN(void)
3324
+ void testDoublesEqualBothNaN(void)
3314
3325
  {
3315
3326
  #ifdef UNITY_EXCLUDE_DOUBLE
3316
3327
  TEST_IGNORE();
3317
3328
  #else
3318
- EXPECT_ABORT_BEGIN
3319
3329
  TEST_ASSERT_EQUAL_DOUBLE(0.0 / d_zero, 0.0 / d_zero);
3320
- VERIFY_FAILS_END
3321
3330
  #endif
3322
3331
  }
3323
3332
 
@@ -3365,14 +3374,12 @@ void testDoublesNotEqualExpectedInf(void)
3365
3374
  #endif
3366
3375
  }
3367
3376
 
3368
- void testDoublesNotEqualBothInf(void)
3377
+ void testDoublesEqualBothInf(void)
3369
3378
  {
3370
3379
  #ifdef UNITY_EXCLUDE_DOUBLE
3371
3380
  TEST_IGNORE();
3372
3381
  #else
3373
- EXPECT_ABORT_BEGIN
3374
3382
  TEST_ASSERT_EQUAL_DOUBLE(1.0 / d_zero, 1.0 / d_zero);
3375
- VERIFY_FAILS_END
3376
3383
  #endif
3377
3384
  }
3378
3385
 
@@ -3706,7 +3713,7 @@ void testNotEqualDoubleArraysNegative3(void)
3706
3713
  #endif
3707
3714
  }
3708
3715
 
3709
- void testNotEqualDoubleArraysNaN(void)
3716
+ void testEqualDoubleArraysNaN(void)
3710
3717
  {
3711
3718
  #ifdef UNITY_EXCLUDE_DOUBLE
3712
3719
  TEST_IGNORE();
@@ -3714,13 +3721,11 @@ void testNotEqualDoubleArraysNaN(void)
3714
3721
  double p0[] = {1.0, 0.0 / d_zero, 25.4, 0.253};
3715
3722
  double p1[] = {1.0, 0.0 / d_zero, 25.4, 0.253};
3716
3723
 
3717
- EXPECT_ABORT_BEGIN
3718
3724
  TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
3719
- VERIFY_FAILS_END
3720
3725
  #endif
3721
3726
  }
3722
3727
 
3723
- void testNotEqualDoubleArraysInf(void)
3728
+ void testEqualDoubleArraysInf(void)
3724
3729
  {
3725
3730
  #ifdef UNITY_EXCLUDE_DOUBLE
3726
3731
  TEST_IGNORE();
@@ -3728,9 +3733,7 @@ void testNotEqualDoubleArraysInf(void)
3728
3733
  double p0[] = {1.0, 1.0 / d_zero, 25.4, 0.253};
3729
3734
  double p1[] = {1.0, 1.0 / d_zero, 25.4, 0.253};
3730
3735
 
3731
- EXPECT_ABORT_BEGIN
3732
3736
  TEST_ASSERT_EQUAL_DOUBLE_ARRAY(p0, p1, 4);
3733
- VERIFY_FAILS_END
3734
3737
  #endif
3735
3738
  }
3736
3739
 
@@ -11,46 +11,8 @@
11
11
  require 'rubygems'
12
12
  require 'fileutils'
13
13
 
14
- HERE = File.expand_path(File.dirname(__FILE__)) + '/'
15
-
16
- #help text when requested
17
- HELP_TEXT = [ "\nGENERATE MODULE\n-------- ------",
18
- "\nUsage: ruby generate_module [options] module_name",
19
- " -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
20
- " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
21
- " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
22
- " -p\"MCH\" sets the output pattern to MCH.",
23
- " dh - driver hardware.",
24
- " dih - driver interrupt hardware.",
25
- " mch - model conductor hardware.",
26
- " mvp - model view presenter.",
27
- " src - just a single source module. (DEFAULT)",
28
- " -d destroy module instead of creating it.",
29
- " -u update subversion too (requires subversion command line)",
30
- " -y\"my.yml\" selects a different yaml config file for module generation",
31
- "" ].join("\n")
32
-
33
- #Built in patterns
34
- PATTERNS = { 'src' => {'' => { :inc => [] } },
35
- 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
36
- 'Hardware' => { :inc => [] }
37
- },
38
- 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
39
- 'Interrupt'=> { :inc => ['%1$sHardware.h'] },
40
- 'Hardware' => { :inc => [] }
41
- },
42
- 'mch' => {'Model' => { :inc => [] },
43
- 'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
44
- 'Hardware' => { :inc => [] }
45
- },
46
- 'mvp' => {'Model' => { :inc => [] },
47
- 'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
48
- 'View' => { :inc => [] }
49
- }
50
- }
51
-
52
14
  #TEMPLATE_TST
53
- TEMPLATE_TST = %q[#include "unity.h"
15
+ TEMPLATE_TST ||= %q[#include "unity.h"
54
16
  %2$s#include "%1$s.h"
55
17
 
56
18
  void setUp(void)
@@ -68,135 +30,229 @@ void test_%1$s_NeedToImplement(void)
68
30
  ]
69
31
 
70
32
  #TEMPLATE_SRC
71
- TEMPLATE_SRC = %q[%2$s#include "%1$s.h"
33
+ TEMPLATE_SRC ||= %q[%2$s#include "%1$s.h"
72
34
  ]
73
35
 
74
36
  #TEMPLATE_INC
75
- TEMPLATE_INC = %q[#ifndef _%3$s_H
37
+ TEMPLATE_INC ||= %q[#ifndef _%3$s_H
76
38
  #define _%3$s_H%2$s
77
39
 
78
40
  #endif // _%3$s_H
79
41
  ]
80
42
 
81
- # Parse the command line parameters.
82
- ARGV.each do |arg|
83
- case(arg)
84
- when /^-d/ then @destroy = true
85
- when /^-u/ then @update_svn = true
86
- when /^-p(\w+)/ then @pattern = $1
87
- when /^-s(.+)/ then @path_src = $1
88
- when /^-i(.+)/ then @path_inc = $1
89
- when /^-t(.+)/ then @path_tst = $1
90
- when /^-y(.+)/ then @yaml_config = $1
91
- when /^(\w+)/
92
- raise "ERROR: You can't have more than one Module name specified!" unless @module_name.nil?
93
- @module_name = arg
94
- when /^-(h|-help)/
95
- puts HELP_TEXT
96
- exit
97
- else
98
- raise "ERROR: Unknown option specified '#{arg}'"
43
+ class UnityModuleGenerator
44
+
45
+ ############################
46
+ def initialize(options=nil)
47
+
48
+ here = File.expand_path(File.dirname(__FILE__)) + '/'
49
+
50
+ @options = UnityModuleGenerator.default_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"
56
+ end
57
+
58
+ # Create default file paths if none were provided
59
+ @options[:path_src] = here + "../src/" if @options[:path_src].nil?
60
+ @options[:path_inc] = @options[:path_src] if @options[:path_inc].nil?
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 = { 'src' => {'' => { :inc => [] } },
68
+ 'dh' => {'Driver' => { :inc => ['%1$sHardware.h'] },
69
+ 'Hardware' => { :inc => [] }
70
+ },
71
+ 'dih' => {'Driver' => { :inc => ['%1$sHardware.h', '%1$sInterrupt.h'] },
72
+ 'Interrupt'=> { :inc => ['%1$sHardware.h'] },
73
+ 'Hardware' => { :inc => [] }
74
+ },
75
+ 'mch' => {'Model' => { :inc => [] },
76
+ 'Conductor'=> { :inc => ['%1$sModel.h', '%1$sHardware.h'] },
77
+ 'Hardware' => { :inc => [] }
78
+ },
79
+ 'mvp' => {'Model' => { :inc => [] },
80
+ 'Presenter'=> { :inc => ['%1$sModel.h', '%1$sView.h'] },
81
+ 'View' => { :inc => [] }
82
+ }
83
+ }
99
84
  end
100
- end
101
- raise "ERROR: You must have a Module name specified! (use option -h for help)" if @module_name.nil?
102
-
103
- #load yaml file if one was requested
104
- if @yaml_config
105
- require 'yaml'
106
- cfg = YAML.load_file(HERE + @yaml_config)[:generate_module]
107
- @path_src = cfg[:defaults][:path_src] if @path_src.nil?
108
- @path_inc = cfg[:defaults][:path_inc] if @path_inc.nil?
109
- @path_tst = cfg[:defaults][:path_tst] if @path_tst.nil?
110
- @update_svn = cfg[:defaults][:update_svn] if @update_svn.nil?
111
- @extra_inc = cfg[:includes]
112
- @boilerplates = cfg[:boilerplates]
113
- else
114
- @boilerplates = {}
115
- end
116
85
 
117
- # Create default file paths if none were provided
118
- @path_src = HERE + "../src/" if @path_src.nil?
119
- @path_inc = @path_src if @path_inc.nil?
120
- @path_tst = HERE + "../test/" if @path_tst.nil?
121
- @path_src += '/' unless (@path_src[-1] == 47)
122
- @path_inc += '/' unless (@path_inc[-1] == 47)
123
- @path_tst += '/' unless (@path_tst[-1] == 47)
124
- @pattern = 'src' if @pattern.nil?
125
- @includes = { :src => [], :inc => [], :tst => [] }
126
- @includes.merge!(@extra_inc) unless @extra_inc.nil?
127
-
128
- #create triad definition
129
- TRIAD = [ { :ext => '.c', :path => @path_src, :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @boilerplates[:src] },
130
- { :ext => '.h', :path => @path_inc, :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @boilerplates[:inc] },
131
- { :ext => '.c', :path => @path_tst+'Test', :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @boilerplates[:tst] },
132
- ]
133
-
134
- #prepare the pattern for use
135
- @patterns = PATTERNS[@pattern.downcase]
136
- raise "ERROR: The design pattern specified isn't one that I recognize!" if @patterns.nil?
137
-
138
- # Assemble the path/names of the files we need to work with.
139
- files = []
140
- TRIAD.each do |triad|
141
- @patterns.each_pair do |pattern_file, pattern_traits|
142
- files << {
143
- :path => "#{triad[:path]}#{@module_name}#{pattern_file}#{triad[:ext]}",
144
- :name => "#{@module_name}#{pattern_file}",
145
- :template => triad[:template],
146
- :boilerplate => triad[:boilerplate],
147
- :includes => case(triad[:inc])
148
- when :src then @includes[:src] | pattern_traits[:inc].map{|f| f % [@module_name]}
149
- when :inc then @includes[:inc]
150
- when :tst then @includes[:tst] | pattern_traits[:inc].map{|f| "Mock#{f}"% [@module_name]}
151
- end
86
+ ############################
87
+ def self.default_options
88
+ {
89
+ :pattern => "src",
90
+ :includes =>
91
+ {
92
+ :src => [],
93
+ :inc => [],
94
+ :tst => [],
95
+ },
96
+ :update_svn => false,
97
+ :boilerplates => {},
98
+ :test_prefix => 'Test',
152
99
  }
153
100
  end
154
- end
155
101
 
156
- # destroy files if that was what was requested
157
- if @destroy
158
- files.each do |filespec|
159
- file = filespec[:path]
160
- if File.exist?(file)
161
- if @update_svn
162
- `svn delete \"#{file}\" --force`
163
- puts "File #{file} deleted and removed from source control"
102
+ ############################
103
+ def self.grab_config(config_file)
104
+ options = self.default_options
105
+ unless (config_file.nil? or config_file.empty?)
106
+ require 'yaml'
107
+ yaml_guts = YAML.load_file(config_file)
108
+ options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
109
+ raise "No :unity or :cmock section found in #{config_file}" unless options
110
+ end
111
+ return(options)
112
+ end
113
+
114
+ ############################
115
+ def files_to_operate_on(module_name, pattern=nil)
116
+ #create triad definition
117
+ prefix = @options[:test_prefix] || 'Test'
118
+ triad = [ { :ext => '.c', :path => @options[:path_src], :template => TEMPLATE_SRC, :inc => :src, :boilerplate => @options[:boilerplates][:src] },
119
+ { :ext => '.h', :path => @options[:path_inc], :template => TEMPLATE_INC, :inc => :inc, :boilerplate => @options[:boilerplates][:inc] },
120
+ { :ext => '.c', :path => @options[:path_tst]+prefix, :template => TEMPLATE_TST, :inc => :tst, :boilerplate => @options[:boilerplates][:tst] },
121
+ ]
122
+
123
+ #prepare the pattern for use
124
+ patterns = @patterns[(pattern || @options[:pattern] || 'src').downcase]
125
+ raise "ERROR: The design pattern '#{pattern}' specified isn't one that I recognize!" if patterns.nil?
126
+
127
+ # Assemble the path/names of the files we need to work with.
128
+ files = []
129
+ triad.each do |triad|
130
+ patterns.each_pair do |pattern_file, pattern_traits|
131
+ files << {
132
+ :path => "#{triad[:path]}#{module_name}#{pattern_file}#{triad[:ext]}",
133
+ :name => "#{module_name}#{pattern_file}",
134
+ :template => triad[:template],
135
+ :boilerplate => triad[:boilerplate],
136
+ :includes => case(triad[:inc])
137
+ when :src then @options[:includes][:src] | pattern_traits[:inc].map{|f| f % [module_name]}
138
+ when :inc then @options[:includes][:inc]
139
+ when :tst then @options[:includes][:tst] | pattern_traits[:inc].map{|f| "Mock#{f}"% [module_name]}
140
+ end
141
+ }
142
+ end
143
+ end
144
+
145
+ return files
146
+ end
147
+
148
+ ############################
149
+ def generate(module_name, pattern=nil)
150
+
151
+ files = files_to_operate_on(module_name, pattern)
152
+
153
+ #Abort if any module already exists
154
+ files.each do |file|
155
+ raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
156
+ end
157
+
158
+ # Create Source Modules
159
+ files.each_with_index do |file, i|
160
+ File.open(file[:path], 'w') do |f|
161
+ f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
162
+ f.write(file[:template] % [ file[:name],
163
+ file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
164
+ file[:name].upcase ]
165
+ )
166
+ end
167
+ if (@options[:update_svn])
168
+ `svn add \"#{file[:path]}\"`
169
+ if $?.exitstatus == 0
170
+ puts "File #{file[:path]} created and added to source control"
171
+ else
172
+ puts "File #{file[:path]} created but FAILED adding to source control!"
173
+ end
164
174
  else
165
- FileUtils.remove(file)
166
- puts "File #{file} deleted"
175
+ puts "File #{file[:path]} created"
167
176
  end
168
- else
169
- puts "File #{file} does not exist so cannot be removed."
170
177
  end
178
+ puts 'Generate Complete'
171
179
  end
172
- puts "Destroy Complete"
173
- exit
174
- end
175
180
 
176
- #Abort if any module already exists
177
- files.each do |file|
178
- raise "ERROR: File #{file[:name]} already exists. Exiting." if File.exist?(file[:path])
179
- end
181
+ ############################
182
+ def destroy(module_name, pattern=nil)
180
183
 
181
- # Create Source Modules
182
- files.each_with_index do |file, i|
183
- File.open(file[:path], 'w') do |f|
184
- f.write(file[:boilerplate] % [file[:name]]) unless file[:boilerplate].nil?
185
- f.write(file[:template] % [ file[:name],
186
- file[:includes].map{|f| "#include \"#{f}\"\n"}.join,
187
- file[:name].upcase ]
188
- )
184
+ files_to_operate_on(module_name, pattern).each do |filespec|
185
+ file = filespec[:path]
186
+ if File.exist?(file)
187
+ if @options[:update_svn]
188
+ `svn delete \"#{file}\" --force`
189
+ puts "File #{file} deleted and removed from source control"
190
+ else
191
+ FileUtils.remove(file)
192
+ puts "File #{file} deleted"
193
+ end
194
+ else
195
+ puts "File #{file} does not exist so cannot be removed."
196
+ end
197
+ end
198
+ puts "Destroy Complete"
189
199
  end
190
- if (@update_svn)
191
- `svn add \"#{file[:path]}\"`
192
- if $?.exitstatus == 0
193
- puts "File #{file[:path]} created and added to source control"
194
- else
195
- puts "File #{file[:path]} created but FAILED adding to source control!"
200
+
201
+ end
202
+
203
+ ############################
204
+ #Handle As Command Line If Called That Way
205
+ if ($0 == __FILE__)
206
+ destroy = false
207
+ options = { }
208
+ module_name = nil
209
+
210
+ # Parse the command line parameters.
211
+ ARGV.each do |arg|
212
+ case(arg)
213
+ when /^-d/ then destroy = true
214
+ when /^-u/ then options[:update_svn] = true
215
+ when /^-p(\w+)/ then options[:pattern] = $1
216
+ when /^-s(.+)/ then options[:path_src] = $1
217
+ when /^-i(.+)/ then options[:path_inc] = $1
218
+ when /^-t(.+)/ then options[:path_tst] = $1
219
+ when /^-y(.+)/ then options = UnityModuleGenerator.grab_config($1)
220
+ when /^(\w+)/
221
+ raise "ERROR: You can't have more than one Module name specified!" unless module_name.nil?
222
+ module_name = arg
223
+ when /^-(h|-help)/
224
+ ARGV = []
225
+ else
226
+ raise "ERROR: Unknown option specified '#{arg}'"
196
227
  end
228
+ end
229
+
230
+ if (!ARGV[0])
231
+ puts [ "\nGENERATE MODULE\n-------- ------",
232
+ "\nUsage: ruby generate_module [options] module_name",
233
+ " -i\"include\" sets the path to output headers to 'include' (DEFAULT ../src)",
234
+ " -s\"../src\" sets the path to output source to '../src' (DEFAULT ../src)",
235
+ " -t\"C:/test\" sets the path to output source to 'C:/test' (DEFAULT ../test)",
236
+ " -p\"MCH\" sets the output pattern to MCH.",
237
+ " dh - driver hardware.",
238
+ " dih - driver interrupt hardware.",
239
+ " mch - model conductor hardware.",
240
+ " mvp - model view presenter.",
241
+ " src - just a single source module. (DEFAULT)",
242
+ " -d destroy module instead of creating it.",
243
+ " -u update subversion too (requires subversion command line)",
244
+ " -y\"my.yml\" selects a different yaml config file for module generation",
245
+ "" ].join("\n")
246
+ exit
247
+ end
248
+
249
+ raise "ERROR: You must have a Module name specified! (use option -h for help)" if module_name.nil?
250
+ if (destroy)
251
+ UnityModuleGenerator.new(options).destroy(module_name)
197
252
  else
198
- puts "File #{file[:path]} created"
253
+ UnityModuleGenerator.new(options).generate(module_name)
199
254
  end
255
+
200
256
  end
201
257
 
202
- puts 'Generate Complete'
258
+