mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2026-01-23 00:15:58 +01:00
- Fixed cases with wildcards in file handling.
This commit is contained in:
15
src/unity.c
15
src/unity.c
@@ -1371,6 +1371,9 @@ int IsStringInBiggerString(const char* longstring, const char* shortstring)
|
|||||||
char* sptr = (char*)shortstring;
|
char* sptr = (char*)shortstring;
|
||||||
char* lnext = lptr;
|
char* lnext = lptr;
|
||||||
|
|
||||||
|
if (*sptr == '*')
|
||||||
|
return 1;
|
||||||
|
|
||||||
while (*lptr)
|
while (*lptr)
|
||||||
{
|
{
|
||||||
lnext = lptr + 1;
|
lnext = lptr + 1;
|
||||||
@@ -1408,6 +1411,7 @@ int UnityStringArgumentMatches(const char* str)
|
|||||||
int retval;
|
int retval;
|
||||||
const char* ptr1;
|
const char* ptr1;
|
||||||
const char* ptr2;
|
const char* ptr2;
|
||||||
|
const char* ptrf;
|
||||||
|
|
||||||
//Go through the options and get the substrings for matching one at a time
|
//Go through the options and get the substrings for matching one at a time
|
||||||
ptr1 = str;
|
ptr1 = str;
|
||||||
@@ -1418,10 +1422,13 @@ int UnityStringArgumentMatches(const char* str)
|
|||||||
|
|
||||||
//look for the start of the next partial
|
//look for the start of the next partial
|
||||||
ptr2 = ptr1;
|
ptr2 = ptr1;
|
||||||
|
ptrf = 0;
|
||||||
do {
|
do {
|
||||||
ptr2++;
|
ptr2++;
|
||||||
} while ((ptr2[0] != 0) && (ptr2[0] != ':') && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','));
|
if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','))
|
||||||
while ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))
|
ptrf = &ptr2[1];
|
||||||
|
} while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ','));
|
||||||
|
while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ',')))
|
||||||
ptr2++;
|
ptr2++;
|
||||||
|
|
||||||
//done if complete filename match
|
//done if complete filename match
|
||||||
@@ -1430,9 +1437,9 @@ int UnityStringArgumentMatches(const char* str)
|
|||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
//done if testname match after filename partial match
|
//done if testname match after filename partial match
|
||||||
if (retval == 2)
|
if ((retval == 2) && (ptrf != 0))
|
||||||
{
|
{
|
||||||
if (IsStringInBiggerString(Unity.CurrentTestName, ptr2))
|
if (IsStringInBiggerString(Unity.CurrentTestName, ptrf))
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
test/testdata/testRunnerGeneratorSmall.c
vendored
Normal file
65
test/testdata/testRunnerGeneratorSmall.c
vendored
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
/* This Test File Is Used To Verify Many Combinations Of Using the Generate Test Runner Script */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "unity.h"
|
||||||
|
#include "Defs.h"
|
||||||
|
|
||||||
|
/* Notes about prefixes:
|
||||||
|
test - normal default prefix. these are "always run" tests for this procedure
|
||||||
|
spec - normal default prefix. required to run default setup/teardown calls.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Support for Meta Test Rig */
|
||||||
|
#define TEST_CASE(a)
|
||||||
|
void putcharSpy(int c) { (void)putchar(c);} // include passthrough for linking tests
|
||||||
|
|
||||||
|
/* Global Variables Used During These Tests */
|
||||||
|
int CounterSetup = 0;
|
||||||
|
int CounterTeardown = 0;
|
||||||
|
int CounterSuiteSetup = 0;
|
||||||
|
|
||||||
|
void setUp(void)
|
||||||
|
{
|
||||||
|
CounterSetup = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tearDown(void)
|
||||||
|
{
|
||||||
|
CounterTeardown = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_setup(void)
|
||||||
|
{
|
||||||
|
CounterSetup = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void custom_teardown(void)
|
||||||
|
{
|
||||||
|
CounterTeardown = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_ThisTestAlwaysPasses(void)
|
||||||
|
{
|
||||||
|
TEST_PASS();
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_ThisTestAlwaysFails(void)
|
||||||
|
{
|
||||||
|
TEST_FAIL_MESSAGE("This Test Should Fail");
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_ThisTestAlwaysIgnored(void)
|
||||||
|
{
|
||||||
|
TEST_IGNORE_MESSAGE("This Test Should Be Ignored");
|
||||||
|
}
|
||||||
|
|
||||||
|
void spec_ThisTestPassesWhenNormalSetupRan(void)
|
||||||
|
{
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(1, CounterSetup, "Normal Setup Wasn't Run");
|
||||||
|
}
|
||||||
|
|
||||||
|
void spec_ThisTestPassesWhenNormalTeardownRan(void)
|
||||||
|
{
|
||||||
|
TEST_ASSERT_EQUAL_MESSAGE(1, CounterTeardown, "Normal Teardown Wasn't Run");
|
||||||
|
}
|
||||||
|
|
||||||
@@ -774,6 +774,82 @@ RUNNER_TESTS = [
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
{ :name => 'ArgsNameFilterWithWildcardOnFile',
|
||||||
|
:testfile => 'testdata/testRunnerGeneratorSmall.c',
|
||||||
|
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
||||||
|
:options => {
|
||||||
|
:cmdline_args => true,
|
||||||
|
},
|
||||||
|
:cmdline_args => "-n testRunnerGeneratorSma*",
|
||||||
|
:expected => {
|
||||||
|
:to_pass => [ 'test_ThisTestAlwaysPasses',
|
||||||
|
'spec_ThisTestPassesWhenNormalSetupRan',
|
||||||
|
'spec_ThisTestPassesWhenNormalTeardownRan' ],
|
||||||
|
:to_fail => [ 'test_ThisTestAlwaysFails' ],
|
||||||
|
:to_ignore => [ 'test_ThisTestAlwaysIgnored' ],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{ :name => 'ArgsNameFilterWithWildcardAsName',
|
||||||
|
:testfile => 'testdata/testRunnerGeneratorSmall.c',
|
||||||
|
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
||||||
|
:options => {
|
||||||
|
:cmdline_args => true,
|
||||||
|
},
|
||||||
|
:cmdline_args => "-n testRunnerGeneratorSmall:*",
|
||||||
|
:expected => {
|
||||||
|
:to_pass => [ 'test_ThisTestAlwaysPasses',
|
||||||
|
'spec_ThisTestPassesWhenNormalSetupRan',
|
||||||
|
'spec_ThisTestPassesWhenNormalTeardownRan' ],
|
||||||
|
:to_fail => [ 'test_ThisTestAlwaysFails' ],
|
||||||
|
:to_ignore => [ 'test_ThisTestAlwaysIgnored' ],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{ :name => 'ArgsNameFilterWithWildcardOnName',
|
||||||
|
:testfile => 'testdata/testRunnerGeneratorSmall.c',
|
||||||
|
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
||||||
|
:options => {
|
||||||
|
:cmdline_args => true,
|
||||||
|
},
|
||||||
|
:cmdline_args => "-n testRunnerGeneratorSmall:test_*",
|
||||||
|
:expected => {
|
||||||
|
:to_pass => [ 'test_ThisTestAlwaysPasses' ],
|
||||||
|
:to_fail => [ 'test_ThisTestAlwaysFails' ],
|
||||||
|
:to_ignore => [ 'test_ThisTestAlwaysIgnored' ],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{ :name => 'ArgsNameFilterWithWildcardAndShortName',
|
||||||
|
:testfile => 'testdata/testRunnerGeneratorSmall.c',
|
||||||
|
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
||||||
|
:options => {
|
||||||
|
:cmdline_args => true,
|
||||||
|
},
|
||||||
|
:cmdline_args => "-n testRunnerGeneratorSmall:te*",
|
||||||
|
:expected => {
|
||||||
|
:to_pass => [ 'test_ThisTestAlwaysPasses' ],
|
||||||
|
:to_fail => [ 'test_ThisTestAlwaysFails' ],
|
||||||
|
:to_ignore => [ 'test_ThisTestAlwaysIgnored' ],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
{ :name => 'ArgsNameFilterWithWildcardOnBoth',
|
||||||
|
:testfile => 'testdata/testRunnerGeneratorSmall.c',
|
||||||
|
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
||||||
|
:options => {
|
||||||
|
:cmdline_args => true,
|
||||||
|
},
|
||||||
|
:cmdline_args => "-n testRunnerGeneratorSm*:*",
|
||||||
|
:expected => {
|
||||||
|
:to_pass => [ 'test_ThisTestAlwaysPasses',
|
||||||
|
'spec_ThisTestPassesWhenNormalSetupRan',
|
||||||
|
'spec_ThisTestPassesWhenNormalTeardownRan' ],
|
||||||
|
:to_fail => [ 'test_ThisTestAlwaysFails' ],
|
||||||
|
:to_ignore => [ 'test_ThisTestAlwaysIgnored' ],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
{ :name => 'ArgsExcludeFilterJustTest',
|
{ :name => 'ArgsExcludeFilterJustTest',
|
||||||
:testfile => 'testdata/testRunnerGenerator.c',
|
:testfile => 'testdata/testRunnerGenerator.c',
|
||||||
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
:testdefines => ['TEST', 'UNITY_USE_COMMAND_LINE_ARGS'],
|
||||||
|
|||||||
Reference in New Issue
Block a user