@@ -46,21 +46,25 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void))
46
46
return (int )Unity .TestFailures ;
47
47
}
48
48
49
- static int selected (const char * filter , const char * name )
49
+ static int selected (const char * filter , const char * select , const char * name )
50
50
{
51
- if (filter == 0 )
51
+ if (filter == 0 && select == 0 )
52
52
return 1 ;
53
- return strstr (name , filter ) ? 1 : 0 ;
53
+ if (filter && strstr (name , filter ))
54
+ return 1 ;
55
+ if (select && strcmp (name , select ) == 0 )
56
+ return 1 ;
57
+ return 0 ;
54
58
}
55
59
56
60
static int testSelected (const char * test )
57
61
{
58
- return selected (UnityFixture .NameFilter , test );
62
+ return selected (UnityFixture .NameFilter , UnityFixture . Name , test );
59
63
}
60
64
61
65
static int groupSelected (const char * group )
62
66
{
63
- return selected (UnityFixture .GroupFilter , group );
67
+ return selected (UnityFixture .GroupFilter , UnityFixture . Group , group );
64
68
}
65
69
66
70
void UnityTestRunner (unityfunction * setup ,
@@ -96,17 +100,20 @@ void UnityTestRunner(unityfunction* setup,
96
100
Unity .NumberOfTests ++ ;
97
101
UnityPointer_Init ();
98
102
99
- UNITY_EXEC_TIME_START ();
103
+ if (!UnityFixture .DryRun ) {
104
+ UNITY_EXEC_TIME_START ();
100
105
101
- if (TEST_PROTECT ())
102
- {
103
- setup ();
104
- testBody ();
105
- }
106
- if (TEST_PROTECT ())
107
- {
108
- teardown ();
106
+ if (TEST_PROTECT ())
107
+ {
108
+ setup ();
109
+ testBody ();
110
+ }
111
+ if (TEST_PROTECT ())
112
+ {
113
+ teardown ();
114
+ }
109
115
}
116
+
110
117
if (TEST_PROTECT ())
111
118
{
112
119
UnityPointer_UndoAllSets ();
@@ -183,8 +190,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
183
190
int i ;
184
191
UnityFixture .Verbose = 0 ;
185
192
UnityFixture .Silent = 0 ;
193
+ UnityFixture .DryRun = 0 ;
186
194
UnityFixture .GroupFilter = 0 ;
195
+ UnityFixture .Group = 0 ;
187
196
UnityFixture .NameFilter = 0 ;
197
+ UnityFixture .Name = 0 ;
188
198
UnityFixture .RepeatCount = 1 ;
189
199
190
200
if (argc == 1 )
@@ -207,10 +217,16 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
207
217
UNITY_PRINT_EOL ();
208
218
UnityPrint (" -s Silent mode: minimal output showing only test failures" );
209
219
UNITY_PRINT_EOL ();
220
+ UnityPrint (" -d Dry run all tests" );
221
+ UNITY_PRINT_EOL ();
210
222
UnityPrint (" -g NAME Only run tests in groups that contain the string NAME" );
211
223
UNITY_PRINT_EOL ();
224
+ UnityPrint (" -G NAME Only run tests in groups named NAME" );
225
+ UNITY_PRINT_EOL ();
212
226
UnityPrint (" -n NAME Only run tests whose name contains the string NAME" );
213
227
UNITY_PRINT_EOL ();
228
+ UnityPrint (" -N NAME Only run tests named NAME" );
229
+ UNITY_PRINT_EOL ();
214
230
UnityPrint (" -r NUMBER Repeatedly run all tests NUMBER times" );
215
231
UNITY_PRINT_EOL ();
216
232
UnityPrint (" -h, --help Display this help message" );
@@ -237,6 +253,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
237
253
UnityFixture .Silent = 1 ;
238
254
i ++ ;
239
255
}
256
+ else if (strcmp (argv [i ], "-d" ) == 0 )
257
+ {
258
+ UnityFixture .DryRun = 1 ;
259
+ i ++ ;
260
+ }
240
261
else if (strcmp (argv [i ], "-g" ) == 0 )
241
262
{
242
263
i ++ ;
@@ -245,6 +266,14 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
245
266
UnityFixture .GroupFilter = argv [i ];
246
267
i ++ ;
247
268
}
269
+ else if (strcmp (argv [i ], "-G" ) == 0 )
270
+ {
271
+ i ++ ;
272
+ if (i >= argc )
273
+ return 1 ;
274
+ UnityFixture .Group = argv [i ];
275
+ i ++ ;
276
+ }
248
277
else if (strcmp (argv [i ], "-n" ) == 0 )
249
278
{
250
279
i ++ ;
@@ -253,6 +282,14 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
253
282
UnityFixture .NameFilter = argv [i ];
254
283
i ++ ;
255
284
}
285
+ else if (strcmp (argv [i ], "-N" ) == 0 )
286
+ {
287
+ i ++ ;
288
+ if (i >= argc )
289
+ return 1 ;
290
+ UnityFixture .Name = argv [i ];
291
+ i ++ ;
292
+ }
256
293
else if (strcmp (argv [i ], "-r" ) == 0 )
257
294
{
258
295
UnityFixture .RepeatCount = 2 ;
0 commit comments