ceedling 0.15.6 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ceedling/version.rb +3 -3
- data/lib/ceedling/version.rb.erb +1 -1
- data/vendor/cmock/lib/cmock_config.rb +1 -0
- data/vendor/cmock/lib/cmock_generator.rb +1 -1
- data/vendor/cmock/lib/cmock_generator_utils.rb +1 -0
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +4 -0
- data/vendor/cmock/test/unit/cmock_generator_utils_test.rb +3 -0
- data/vendor/unity/README.md +203 -0
- data/vendor/unity/auto/generate_test_runner.rb +45 -18
- data/vendor/unity/docs/license.txt +18 -28
- data/vendor/unity/examples/example_1/makefile +18 -13
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +3 -3
- data/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +3 -3
- data/vendor/unity/examples/example_2/makefile +14 -10
- data/vendor/unity/examples/example_3/makefile +18 -13
- data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +3 -3
- data/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +3 -3
- data/vendor/unity/extras/fixture/rakefile_helper.rb +18 -18
- data/vendor/unity/extras/fixture/src/unity_fixture.c +2 -1
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +1 -1
- data/vendor/unity/src/unity.c +78 -55
- data/vendor/unity/src/unity_internals.h +7 -3
- data/vendor/unity/test/expectdata/testsample_cmd.c +3 -3
- data/vendor/unity/test/expectdata/testsample_def.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_cmd.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_def.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_new1.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_new2.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_param.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_run1.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_run2.c +3 -3
- data/vendor/unity/test/expectdata/testsample_mock_yaml.c +3 -3
- data/vendor/unity/test/expectdata/testsample_new1.c +3 -3
- data/vendor/unity/test/expectdata/testsample_new2.c +3 -3
- data/vendor/unity/test/expectdata/testsample_param.c +3 -3
- data/vendor/unity/test/expectdata/testsample_run1.c +3 -3
- data/vendor/unity/test/expectdata/testsample_run2.c +3 -3
- data/vendor/unity/test/expectdata/testsample_yaml.c +3 -3
- data/vendor/unity/test/rakefile +1 -1
- data/vendor/unity/test/tests/test_generate_test_runner.rb +8 -8
- data/vendor/unity/test/tests/testunity.c +1 -1
- metadata +3 -3
- data/ceedling-0.15.5.gem +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0bbc0e24ac717498dcfd29be1f5d3b37892f7235
|
|
4
|
+
data.tar.gz: 2cce01afc4ac51d222d48d409cd18af01b818188
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 303937a2c0426d57785ab525cd99f4a6d98865243e847e26d4a1250c9eed1a0c872882cc7f5f64cad20de40eeb9d52c91bf3d3c8b9d245cb648750f2388a8d4c
|
|
7
|
+
data.tar.gz: bb4a3b809e65a0589965882b54e7c0262213f36d7f1773757b6e3de91235102fe97b8c72a28ad5776278c354a2bf3fa2c25b49ad8ae6fb3e037222cea3a6ab35
|
data/lib/ceedling/version.rb
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
module Ceedling
|
|
3
3
|
module Version
|
|
4
4
|
# @private
|
|
5
|
-
GEM = "0.
|
|
5
|
+
GEM = "0.16.0"
|
|
6
6
|
|
|
7
7
|
# @private
|
|
8
8
|
CEEDLING = GEM
|
|
9
9
|
# @private
|
|
10
10
|
CEXCEPTION = "1.3.17"
|
|
11
11
|
# @private
|
|
12
|
-
CMOCK = "2.0
|
|
12
|
+
CMOCK = "2.1.0"
|
|
13
13
|
# @private
|
|
14
|
-
UNITY = "2.
|
|
14
|
+
UNITY = "2.2.0"
|
|
15
15
|
end
|
|
16
16
|
end
|
data/lib/ceedling/version.rb.erb
CHANGED
|
@@ -69,7 +69,7 @@ class CMockGenerator
|
|
|
69
69
|
file << "#ifndef _#{define_name}_H\n"
|
|
70
70
|
file << "#define _#{define_name}_H\n\n"
|
|
71
71
|
@includes_h_pre_orig_header.each {|inc| file << "#include #{inc}\n"}
|
|
72
|
-
file <<
|
|
72
|
+
file << @config.orig_header_include_fmt.gsub(/%s/, "#{orig_filename}") + "\n"
|
|
73
73
|
@includes_h_post_orig_header.each {|inc| file << "#include #{inc}\n"}
|
|
74
74
|
plugin_includes = @plugins.run(:include_files)
|
|
75
75
|
file << plugin_includes if (!plugin_includes.empty?)
|
|
@@ -38,6 +38,7 @@ class CMockGeneratorUtils
|
|
|
38
38
|
lines = " CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_#{func_name}_CALL_INSTANCE));\n"
|
|
39
39
|
lines << " CMOCK_#{func_name}_CALL_INSTANCE* cmock_call_instance = (CMOCK_#{func_name}_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n"
|
|
40
40
|
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n"
|
|
41
|
+
lines << " memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n"
|
|
41
42
|
lines << " Mock.#{func_name}_CallInstance = CMock_Guts_MemChain(Mock.#{func_name}_CallInstance, cmock_guts_index);\n"
|
|
42
43
|
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n" if (@ignore)
|
|
43
44
|
lines << " cmock_call_instance->LineNumber = cmock_line;\n"
|
|
@@ -103,6 +103,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|
|
103
103
|
"\n",
|
|
104
104
|
]
|
|
105
105
|
|
|
106
|
+
@config.expect.orig_header_include_fmt.returns("#include \"%s\"")
|
|
106
107
|
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
|
107
108
|
|
|
108
109
|
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
|
@@ -147,6 +148,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|
|
147
148
|
"\n",
|
|
148
149
|
]
|
|
149
150
|
|
|
151
|
+
@config.expect.orig_header_include_fmt.returns("#include \"%s\"")
|
|
150
152
|
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
|
151
153
|
|
|
152
154
|
@cmock_generator2.create_mock_header_header(output, "MockPout-Pout Fish.h")
|
|
@@ -177,6 +179,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|
|
177
179
|
"\n",
|
|
178
180
|
]
|
|
179
181
|
|
|
182
|
+
@config.expect.orig_header_include_fmt.returns("#include \"%s\"")
|
|
180
183
|
@plugins.expect.run(:include_files).returns('')
|
|
181
184
|
|
|
182
185
|
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
|
@@ -208,6 +211,7 @@ class CMockGeneratorTest < Test::Unit::TestCase
|
|
|
208
211
|
"\n",
|
|
209
212
|
]
|
|
210
213
|
|
|
214
|
+
@config.expect.orig_header_include_fmt.returns("#include \"%s\"")
|
|
211
215
|
@plugins.expect.run(:include_files).returns("#include \"PluginRequiredHeader.h\"\n")
|
|
212
216
|
|
|
213
217
|
@cmock_generator.create_mock_header_header(output, "MockPoutPoutFish.h")
|
|
@@ -62,6 +62,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
|
62
62
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
|
63
63
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
|
64
64
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n" +
|
|
65
|
+
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
|
65
66
|
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
|
66
67
|
" cmock_call_instance->LineNumber = cmock_line;\n"
|
|
67
68
|
output = @cmock_generator_utils_simple.code_add_base_expectation("Apple")
|
|
@@ -73,6 +74,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
|
73
74
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
|
74
75
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
|
75
76
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n" +
|
|
77
|
+
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
|
76
78
|
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
|
77
79
|
" Mock.Apple_IgnoreBool = (int)0;\n" +
|
|
78
80
|
" cmock_call_instance->LineNumber = cmock_line;\n" +
|
|
@@ -87,6 +89,7 @@ class CMockGeneratorUtilsTest < Test::Unit::TestCase
|
|
|
87
89
|
" CMOCK_MEM_INDEX_TYPE cmock_guts_index = CMock_Guts_MemNew(sizeof(CMOCK_Apple_CALL_INSTANCE));\n" +
|
|
88
90
|
" CMOCK_Apple_CALL_INSTANCE* cmock_call_instance = (CMOCK_Apple_CALL_INSTANCE*)CMock_Guts_GetAddressFor(cmock_guts_index);\n" +
|
|
89
91
|
" UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, \"CMock has run out of memory. Please allocate more.\");\n" +
|
|
92
|
+
" memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n" +
|
|
90
93
|
" Mock.Apple_CallInstance = CMock_Guts_MemChain(Mock.Apple_CallInstance, cmock_guts_index);\n" +
|
|
91
94
|
" Mock.Apple_IgnoreBool = (int)0;\n" +
|
|
92
95
|
" cmock_call_instance->LineNumber = cmock_line;\n" +
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
Unity Test API
|
|
2
|
+
==============
|
|
3
|
+
|
|
4
|
+
[](https://travis-ci.org/ThrowTheSwitch/Unity)
|
|
5
|
+
__Copyright (c) 2007 - 2014 Unity Project by Mike Karlesky, Mark VanderVoord, and Greg Williams__
|
|
6
|
+
|
|
7
|
+
Running Tests
|
|
8
|
+
-------------
|
|
9
|
+
|
|
10
|
+
RUN_TEST(func, linenum)
|
|
11
|
+
|
|
12
|
+
Each Test is run within the macro `RUN_TEST`. This macro performs necessary setup before the test is called and handles cleanup and result tabulation afterwards.
|
|
13
|
+
|
|
14
|
+
Ignoring Tests
|
|
15
|
+
--------------
|
|
16
|
+
|
|
17
|
+
There are times when a test is incomplete or not valid for some reason. At these times, TEST_IGNORE can be called. Control will immediately be returned to the caller of the test, and no failures will be returned.
|
|
18
|
+
|
|
19
|
+
TEST_IGNORE()
|
|
20
|
+
|
|
21
|
+
Ignore this test and return immediately
|
|
22
|
+
|
|
23
|
+
TEST_IGNORE_MESSAGE (message)
|
|
24
|
+
|
|
25
|
+
Ignore this test and return immediately. Output a message stating why the test was ignored.
|
|
26
|
+
|
|
27
|
+
Aborting Tests
|
|
28
|
+
--------------
|
|
29
|
+
|
|
30
|
+
There are times when a test will contain an infinite loop on error conditions, or there may be reason to escape from the test early without executing the rest of the test. A pair of macros support this functionality in Unity. The first `TEST_PROTECT` sets up the feature, and handles emergency abort cases. `TEST_ABORT` can then be used at any time within the tests to return to the last `TEST_PROTECT` call.
|
|
31
|
+
|
|
32
|
+
TEST_PROTECT()
|
|
33
|
+
|
|
34
|
+
Setup and Catch macro
|
|
35
|
+
|
|
36
|
+
TEST_ABORT()
|
|
37
|
+
|
|
38
|
+
Abort Test macro
|
|
39
|
+
|
|
40
|
+
Example:
|
|
41
|
+
|
|
42
|
+
main()
|
|
43
|
+
{
|
|
44
|
+
if (TEST_PROTECT() == 0)
|
|
45
|
+
{
|
|
46
|
+
MyTest();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
If MyTest calls `TEST_ABORT`, program control will immediately return to `TEST_PROTECT` with a non-zero return value.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Unity Assertion Summary
|
|
54
|
+
=======================
|
|
55
|
+
|
|
56
|
+
Basic Validity Tests
|
|
57
|
+
--------------------
|
|
58
|
+
|
|
59
|
+
TEST_ASSERT_TRUE(condition)
|
|
60
|
+
|
|
61
|
+
Evaluates whatever code is in condition and fails if it evaluates to false
|
|
62
|
+
|
|
63
|
+
TEST_ASSERT_FALSE(condition)
|
|
64
|
+
|
|
65
|
+
Evaluates whatever code is in condition and fails if it evaluates to true
|
|
66
|
+
|
|
67
|
+
TEST_ASSERT(condition)
|
|
68
|
+
|
|
69
|
+
Another way of calling `TEST_ASSERT_TRUE`
|
|
70
|
+
|
|
71
|
+
TEST_ASSERT_UNLESS(condition)
|
|
72
|
+
|
|
73
|
+
Another way of calling `TEST_ASSERT_FALSE`
|
|
74
|
+
|
|
75
|
+
TEST_FAIL()
|
|
76
|
+
TEST_FAIL_MESSAGE(message)
|
|
77
|
+
|
|
78
|
+
This test is automatically marked as a failure. The message is output stating why.
|
|
79
|
+
|
|
80
|
+
Numerical Assertions: Integers
|
|
81
|
+
------------------------------
|
|
82
|
+
|
|
83
|
+
TEST_ASSERT_EQUAL_INT(expected, actual)
|
|
84
|
+
TEST_ASSERT_EQUAL_INT8(expected, actual)
|
|
85
|
+
TEST_ASSERT_EQUAL_INT16(expected, actual)
|
|
86
|
+
TEST_ASSERT_EQUAL_INT32(expected, actual)
|
|
87
|
+
TEST_ASSERT_EQUAL_INT64(expected, actual)
|
|
88
|
+
|
|
89
|
+
Compare two integers for equality and display errors as signed integers. A cast will be performed
|
|
90
|
+
to your natural integer size so often this can just be used. When you need to specify the exact size,
|
|
91
|
+
like when comparing arrays, you can use a specific version:
|
|
92
|
+
|
|
93
|
+
TEST_ASSERT_EQUAL_UINT(expected, actual)
|
|
94
|
+
TEST_ASSERT_EQUAL_UINT8(expected, actual)
|
|
95
|
+
TEST_ASSERT_EQUAL_UINT16(expected, actual)
|
|
96
|
+
TEST_ASSERT_EQUAL_UINT32(expected, actual)
|
|
97
|
+
TEST_ASSERT_EQUAL_UINT64(expected, actual)
|
|
98
|
+
|
|
99
|
+
Compare two integers for equality and display errors as unsigned integers. Like INT, there are
|
|
100
|
+
variants for different sizes also.
|
|
101
|
+
|
|
102
|
+
TEST_ASSERT_EQUAL_HEX(expected, actual)
|
|
103
|
+
TEST_ASSERT_EQUAL_HEX8(expected, actual)
|
|
104
|
+
TEST_ASSERT_EQUAL_HEX16(expected, actual)
|
|
105
|
+
TEST_ASSERT_EQUAL_HEX32(expected, actual)
|
|
106
|
+
TEST_ASSERT_EQUAL_HEX64(expected, actual)
|
|
107
|
+
|
|
108
|
+
Compares two integers for equality and display errors as hexadecimal. Like the other integer comparisons,
|
|
109
|
+
you can specify the size... here the size will also effect how many nibbles are shown (for example, `HEX16`
|
|
110
|
+
will show 4 nibbles).
|
|
111
|
+
|
|
112
|
+
_ARRAY
|
|
113
|
+
|
|
114
|
+
You can append `_ARRAY` to any of these macros to make an array comparison of that type. Here you will
|
|
115
|
+
need to care a bit more about the actual size of the value being checked. You will also specify an
|
|
116
|
+
additional argument which is the number of elements to compare. For example:
|
|
117
|
+
|
|
118
|
+
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, elements)
|
|
119
|
+
|
|
120
|
+
TEST_ASSERT_EQUAL(expected, actual)
|
|
121
|
+
|
|
122
|
+
Another way of calling TEST_ASSERT_EQUAL_INT
|
|
123
|
+
|
|
124
|
+
TEST_ASSERT_INT_WITHIN(delta, expected, actual)
|
|
125
|
+
|
|
126
|
+
Asserts that the actual value is within plus or minus delta of the expected value. This also comes in
|
|
127
|
+
size specific variants.
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
Numerical Assertions: Bitwise
|
|
131
|
+
-----------------------------
|
|
132
|
+
|
|
133
|
+
TEST_ASSERT_BITS(mask, expected, actual)
|
|
134
|
+
|
|
135
|
+
Use an integer mask to specify which bits should be compared between two other integers. High bits in the mask are compared, low bits ignored.
|
|
136
|
+
|
|
137
|
+
TEST_ASSERT_BITS_HIGH(mask, actual)
|
|
138
|
+
|
|
139
|
+
Use an integer mask to specify which bits should be inspected to determine if they are all set high. High bits in the mask are compared, low bits ignored.
|
|
140
|
+
|
|
141
|
+
TEST_ASSERT_BITS_LOW(mask, actual)
|
|
142
|
+
|
|
143
|
+
Use an integer mask to specify which bits should be inspected to determine if they are all set low. High bits in the mask are compared, low bits ignored.
|
|
144
|
+
|
|
145
|
+
TEST_ASSERT_BIT_HIGH(bit, actual)
|
|
146
|
+
|
|
147
|
+
Test a single bit and verify that it is high. The bit is specified 0-31 for a 32-bit integer.
|
|
148
|
+
|
|
149
|
+
TEST_ASSERT_BIT_LOW(bit, actual)
|
|
150
|
+
|
|
151
|
+
Test a single bit and verify that it is low. The bit is specified 0-31 for a 32-bit integer.
|
|
152
|
+
|
|
153
|
+
Numerical Assertions: Floats
|
|
154
|
+
----------------------------
|
|
155
|
+
|
|
156
|
+
TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual)
|
|
157
|
+
|
|
158
|
+
Asserts that the actual value is within plus or minus delta of the expected value.
|
|
159
|
+
|
|
160
|
+
TEST_ASSERT_EQUAL_FLOAT(expected, actual)
|
|
161
|
+
TEST_ASSERT_EQUAL_DOUBLE(expected, actual)
|
|
162
|
+
|
|
163
|
+
Asserts that two floating point values are "equal" within a small % delta of the expected value.
|
|
164
|
+
|
|
165
|
+
String Assertions
|
|
166
|
+
-----------------
|
|
167
|
+
|
|
168
|
+
TEST_ASSERT_EQUAL_STRING(expected, actual)
|
|
169
|
+
|
|
170
|
+
Compare two null-terminate strings. Fail if any character is different or if the lengths are different.
|
|
171
|
+
|
|
172
|
+
TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message)
|
|
173
|
+
|
|
174
|
+
Compare two null-terminate strings. Fail if any character is different or if the lengths are different. Output a custom message on failure.
|
|
175
|
+
|
|
176
|
+
Pointer Assertions
|
|
177
|
+
------------------
|
|
178
|
+
|
|
179
|
+
Most pointer operations can be performed by simply using the integer comparisons above. However, a couple of special cases are added for clarity.
|
|
180
|
+
|
|
181
|
+
TEST_ASSERT_NULL(pointer)
|
|
182
|
+
|
|
183
|
+
Fails if the pointer is not equal to NULL
|
|
184
|
+
|
|
185
|
+
TEST_ASSERT_NOT_NULL(pointer)
|
|
186
|
+
|
|
187
|
+
Fails if the pointer is equal to NULL
|
|
188
|
+
|
|
189
|
+
Memory Assertions
|
|
190
|
+
-----------------
|
|
191
|
+
|
|
192
|
+
TEST_ASSERT_EQUAL_MEMORY(expected, actual, len)
|
|
193
|
+
|
|
194
|
+
Compare two blocks of memory. This is a good generic assertion for types that can't be coerced into acting like
|
|
195
|
+
standard types... but since it's a memory compare, you have to be careful that your data types are packed.
|
|
196
|
+
|
|
197
|
+
_MESSAGE
|
|
198
|
+
--------
|
|
199
|
+
|
|
200
|
+
you can append _MESSAGE to any of the macros to make them take an additional argument. This argument
|
|
201
|
+
is a string that will be printed at the end of the failure strings. This is useful for specifying more
|
|
202
|
+
information about the problem.
|
|
203
|
+
|
|
@@ -10,7 +10,7 @@ File.expand_path(File.join(File.dirname(__FILE__),'colour_prompt'))
|
|
|
10
10
|
class UnityTestRunnerGenerator
|
|
11
11
|
|
|
12
12
|
def initialize(options = nil)
|
|
13
|
-
@options =
|
|
13
|
+
@options = UnityTestRunnerGenerator.default_options
|
|
14
14
|
case(options)
|
|
15
15
|
when NilClass then @options
|
|
16
16
|
when String then @options.merge!(UnityTestRunnerGenerator.grab_config(options))
|
|
@@ -19,12 +19,23 @@ class UnityTestRunnerGenerator
|
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
+
def self.default_options
|
|
23
|
+
{
|
|
24
|
+
:includes => [],
|
|
25
|
+
:plugins => [],
|
|
26
|
+
:framework => :unity,
|
|
27
|
+
:test_prefix => "test|spec|should",
|
|
28
|
+
:setup_name => "setUp",
|
|
29
|
+
:teardown_name => "tearDown",
|
|
30
|
+
}
|
|
31
|
+
end
|
|
32
|
+
|
|
22
33
|
def self.grab_config(config_file)
|
|
23
|
-
options =
|
|
34
|
+
options = self.default_options
|
|
24
35
|
unless (config_file.nil? or config_file.empty?)
|
|
25
36
|
require 'yaml'
|
|
26
37
|
yaml_guts = YAML.load_file(config_file)
|
|
27
|
-
options.merge!(yaml_guts[:unity]
|
|
38
|
+
options.merge!(yaml_guts[:unity] || yaml_guts[:cmock])
|
|
28
39
|
raise "No :unity or :cmock section found in #{config_file}" unless options
|
|
29
40
|
end
|
|
30
41
|
return(options)
|
|
@@ -78,7 +89,7 @@ class UnityTestRunnerGenerator
|
|
|
78
89
|
|
|
79
90
|
lines.each_with_index do |line, index|
|
|
80
91
|
#find tests
|
|
81
|
-
if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((
|
|
92
|
+
if line =~ /^((?:\s*TEST_CASE\s*\(.*?\)\s*)*)\s*void\s+((?:#{@options[:test_prefix]}).*)\s*\(\s*(.*)\s*\)/
|
|
82
93
|
arguments = $1
|
|
83
94
|
name = $2
|
|
84
95
|
call = $3
|
|
@@ -160,8 +171,8 @@ class UnityTestRunnerGenerator
|
|
|
160
171
|
|
|
161
172
|
def create_externs(output, tests, mocks)
|
|
162
173
|
output.puts("\n//=======External Functions This Runner Calls=====")
|
|
163
|
-
output.puts("extern void
|
|
164
|
-
output.puts("extern void
|
|
174
|
+
output.puts("extern void #{@options[:setup_name]}(void);")
|
|
175
|
+
output.puts("extern void #{@options[:teardown_name]}(void);")
|
|
165
176
|
tests.each do |test|
|
|
166
177
|
output.puts("extern void #{test[:test]}(#{test[:call] || 'void'});")
|
|
167
178
|
end
|
|
@@ -235,13 +246,13 @@ class UnityTestRunnerGenerator
|
|
|
235
246
|
output.puts(" { \\")
|
|
236
247
|
output.puts(" CEXCEPTION_T e; \\") if cexception
|
|
237
248
|
output.puts(" Try { \\") if cexception
|
|
238
|
-
output.puts("
|
|
249
|
+
output.puts(" #{@options[:setup_name]}(); \\")
|
|
239
250
|
output.puts(" TestFunc(#{va_args2}); \\")
|
|
240
251
|
output.puts(" } Catch(e) { TEST_ASSERT_EQUAL_HEX32_MESSAGE(CEXCEPTION_NONE, e, \"Unhandled Exception!\"); } \\") if cexception
|
|
241
252
|
output.puts(" } \\")
|
|
242
253
|
output.puts(" if (TEST_PROTECT() && !TEST_IS_IGNORED) \\")
|
|
243
254
|
output.puts(" { \\")
|
|
244
|
-
output.puts("
|
|
255
|
+
output.puts(" #{@options[:teardown_name]}(); \\")
|
|
245
256
|
output.puts(" CMock_Verify(); \\") unless (used_mocks.empty?)
|
|
246
257
|
output.puts(" } \\")
|
|
247
258
|
output.puts(" CMock_Destroy(); \\") unless (used_mocks.empty?)
|
|
@@ -251,13 +262,14 @@ class UnityTestRunnerGenerator
|
|
|
251
262
|
|
|
252
263
|
def create_reset(output, used_mocks)
|
|
253
264
|
output.puts("\n//=======Test Reset Option=====")
|
|
254
|
-
output.puts("void resetTest()")
|
|
265
|
+
output.puts("void resetTest(void);")
|
|
266
|
+
output.puts("void resetTest(void)")
|
|
255
267
|
output.puts("{")
|
|
256
268
|
output.puts(" CMock_Verify();") unless (used_mocks.empty?)
|
|
257
269
|
output.puts(" CMock_Destroy();") unless (used_mocks.empty?)
|
|
258
|
-
output.puts("
|
|
270
|
+
output.puts(" #{@options[:teardown_name]}();")
|
|
259
271
|
output.puts(" CMock_Init();") unless (used_mocks.empty?)
|
|
260
|
-
output.puts("
|
|
272
|
+
output.puts(" #{@options[:setup_name]}();")
|
|
261
273
|
output.puts("}")
|
|
262
274
|
end
|
|
263
275
|
|
|
@@ -290,30 +302,45 @@ if ($0 == __FILE__)
|
|
|
290
302
|
options = { :includes => [] }
|
|
291
303
|
yaml_file = nil
|
|
292
304
|
|
|
293
|
-
#parse out all the options first
|
|
305
|
+
#parse out all the options first (these will all be removed as we go)
|
|
294
306
|
ARGV.reject! do |arg|
|
|
295
307
|
case(arg)
|
|
296
308
|
when '-cexception'
|
|
297
309
|
options[:plugins] = [:cexception]; true
|
|
298
|
-
when /\.*\.
|
|
310
|
+
when /\.*\.ya?ml/
|
|
299
311
|
options = UnityTestRunnerGenerator.grab_config(arg); true
|
|
312
|
+
when /\.*\.h/
|
|
313
|
+
options[:includes] << arg; true
|
|
314
|
+
when /--(\w+)=\"?(.*)\"?/
|
|
315
|
+
options[$1.to_sym] = $2; true
|
|
300
316
|
else false
|
|
301
317
|
end
|
|
302
318
|
end
|
|
303
319
|
|
|
304
320
|
#make sure there is at least one parameter left (the input file)
|
|
305
321
|
if !ARGV[0]
|
|
306
|
-
puts ["
|
|
307
|
-
"
|
|
308
|
-
" -
|
|
322
|
+
puts ["\nusage: ruby #{__FILE__} (files) (options) input_test_file (output)",
|
|
323
|
+
"\n input_test_file - this is the C file you want to create a runner for",
|
|
324
|
+
" output - this is the name of the runner file to generate",
|
|
325
|
+
" defaults to (input_test_file)_Runner",
|
|
326
|
+
" files:",
|
|
327
|
+
" *.yml / *.yaml - loads configuration from here in :unity or :cmock",
|
|
328
|
+
" *.h - header files are added as #includes in runner",
|
|
329
|
+
" options:",
|
|
330
|
+
" -cexception - include cexception support",
|
|
331
|
+
" --setup_name=\"\" - redefine setUp func name to something else",
|
|
332
|
+
" --teardown_name=\"\" - redefine tearDown func name to something else",
|
|
333
|
+
" --test_prefix=\"\" - redefine test prefix from default test|spec|should",
|
|
334
|
+
" --suite_setup=\"\" - code to execute for setup of entire suite",
|
|
335
|
+
" --suite_teardown=\"\" - code to execute for teardown of entire suite",
|
|
336
|
+
" --use_param_tests=1 - enable parameterized tests (disabled by default)",
|
|
337
|
+
].join("\n")
|
|
309
338
|
exit 1
|
|
310
339
|
end
|
|
311
340
|
|
|
312
341
|
#create the default test runner name if not specified
|
|
313
342
|
ARGV[1] = ARGV[0].gsub(".c","_Runner.c") if (!ARGV[1])
|
|
314
343
|
|
|
315
|
-
#everything else is an include file
|
|
316
|
-
options[:includes] ||= (ARGV.slice(2..-1).flatten.compact) if (ARGV.size > 2)
|
|
317
344
|
|
|
318
345
|
UnityTestRunnerGenerator.new(options).run(ARGV[0], ARGV[1])
|
|
319
346
|
end
|