ENH: perform case insensitive comparison on test names
This commit is contained in:
parent
b63d6ee7dd
commit
e081345595
|
@ -58,6 +58,7 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
|
||||
fout <<
|
||||
"#include <stdio.h>\n"
|
||||
"#include <stdlib.h>\n"
|
||||
"#include <string.h>\n"
|
||||
"\n"
|
||||
"// Forward declare test functions\n"
|
||||
|
@ -112,6 +113,25 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
fout <<
|
||||
"};\n"
|
||||
"\n"
|
||||
"// Allocate and create a lowercased copy of string\n"
|
||||
"\n"
|
||||
"char* lowercase(const char *string)\n"
|
||||
"{\n"
|
||||
" char *new_string = new char[strlen(string) + 1];\n"
|
||||
" if (!new_string)\n"
|
||||
" {\n"
|
||||
" return NULL;\n"
|
||||
" }\n"
|
||||
" strcpy(new_string, string);\n"
|
||||
" char *p = new_string;\n"
|
||||
" while (*p != NULL)\n"
|
||||
" {\n"
|
||||
" *p = tolower(*p);\n"
|
||||
" ++p;\n"
|
||||
" }\n"
|
||||
" return new_string;\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"int main(int ac, char** av)\n"
|
||||
"{\n"
|
||||
" int NumTests = " << numTests << ";\n"
|
||||
|
@ -151,20 +171,21 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& argsIn)
|
|||
" return -1;\n"
|
||||
" }\n"
|
||||
" \n"
|
||||
" // A test name was given, try to find it\n"
|
||||
" char *arg = lowercase(av[1 + partial_match]);\n"
|
||||
" for (i =0; i < NumTests; ++i)\n"
|
||||
" {\n"
|
||||
" if (partial_match && \n"
|
||||
" strstr(cmakeGeneratedFunctionMapEntries[i].name, av[2]) != NULL)\n"
|
||||
" char *test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);\n"
|
||||
" if (partial_match && strstr(test_name, arg) != NULL)\n"
|
||||
" {\n"
|
||||
" return (*cmakeGeneratedFunctionMapEntries[i].func)(ac - 2, av + 2);\n"
|
||||
" }\n"
|
||||
" else if (!partial_match && \n"
|
||||
" strcmp(cmakeGeneratedFunctionMapEntries[i].name, av[1]) == 0)\n"
|
||||
" else if (!partial_match && strcmp(test_name, arg) == 0)\n"
|
||||
" {\n"
|
||||
" return (*cmakeGeneratedFunctionMapEntries[i].func)(ac - 1, av + 1);\n"
|
||||
" }\n"
|
||||
" delete [] test_name;\n"
|
||||
" }\n"
|
||||
" delete [] arg;\n"
|
||||
" \n"
|
||||
" // If the test was not found but there is only one test, then\n"
|
||||
" // run it with the arguments\n"
|
||||
|
|
Loading…
Reference in New Issue