@@ -46,21 +46,25 @@ int UnityMain(int argc, const char* argv[], void (*runAllTests)(void))
4646 return (int )Unity .TestFailures ;
4747}
4848
49- static int selected (const char * filter , const char * name )
49+ static int selected (const char * filter , const char * select , const char * name )
5050{
51- if (filter == 0 )
51+ if (filter == 0 && select == 0 )
5252 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 ;
5458}
5559
5660static int testSelected (const char * test )
5761{
58- return selected (UnityFixture .NameFilter , test );
62+ return selected (UnityFixture .NameFilter , UnityFixture . Name , test );
5963}
6064
6165static int groupSelected (const char * group )
6266{
63- return selected (UnityFixture .GroupFilter , group );
67+ return selected (UnityFixture .GroupFilter , UnityFixture . Group , group );
6468}
6569
6670void UnityTestRunner (unityfunction * setup ,
@@ -96,17 +100,20 @@ void UnityTestRunner(unityfunction* setup,
96100 Unity .NumberOfTests ++ ;
97101 UnityPointer_Init ();
98102
99- UNITY_EXEC_TIME_START ();
103+ if (!UnityFixture .DryRun ) {
104+ UNITY_EXEC_TIME_START ();
100105
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+ }
109115 }
116+
110117 if (TEST_PROTECT ())
111118 {
112119 UnityPointer_UndoAllSets ();
@@ -183,8 +190,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
183190 int i ;
184191 UnityFixture .Verbose = 0 ;
185192 UnityFixture .Silent = 0 ;
193+ UnityFixture .DryRun = 0 ;
186194 UnityFixture .GroupFilter = 0 ;
195+ UnityFixture .Group = 0 ;
187196 UnityFixture .NameFilter = 0 ;
197+ UnityFixture .Name = 0 ;
188198 UnityFixture .RepeatCount = 1 ;
189199
190200 if (argc == 1 )
@@ -207,10 +217,16 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
207217 UNITY_PRINT_EOL ();
208218 UnityPrint (" -s Silent mode: minimal output showing only test failures" );
209219 UNITY_PRINT_EOL ();
220+ UnityPrint (" -d Dry run all tests" );
221+ UNITY_PRINT_EOL ();
210222 UnityPrint (" -g NAME Only run tests in groups that contain the string NAME" );
211223 UNITY_PRINT_EOL ();
224+ UnityPrint (" -G NAME Only run tests in groups named NAME" );
225+ UNITY_PRINT_EOL ();
212226 UnityPrint (" -n NAME Only run tests whose name contains the string NAME" );
213227 UNITY_PRINT_EOL ();
228+ UnityPrint (" -N NAME Only run tests named NAME" );
229+ UNITY_PRINT_EOL ();
214230 UnityPrint (" -r NUMBER Repeatedly run all tests NUMBER times" );
215231 UNITY_PRINT_EOL ();
216232 UnityPrint (" -h, --help Display this help message" );
@@ -237,6 +253,11 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
237253 UnityFixture .Silent = 1 ;
238254 i ++ ;
239255 }
256+ else if (strcmp (argv [i ], "-d" ) == 0 )
257+ {
258+ UnityFixture .DryRun = 1 ;
259+ i ++ ;
260+ }
240261 else if (strcmp (argv [i ], "-g" ) == 0 )
241262 {
242263 i ++ ;
@@ -245,6 +266,14 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
245266 UnityFixture .GroupFilter = argv [i ];
246267 i ++ ;
247268 }
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+ }
248277 else if (strcmp (argv [i ], "-n" ) == 0 )
249278 {
250279 i ++ ;
@@ -253,6 +282,14 @@ int UnityGetCommandLineOptions(int argc, const char* argv[])
253282 UnityFixture .NameFilter = argv [i ];
254283 i ++ ;
255284 }
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+ }
256293 else if (strcmp (argv [i ], "-r" ) == 0 )
257294 {
258295 UnityFixture .RepeatCount = 2 ;
0 commit comments