13
int main (int argc, char **argv)
19
cout << "Usage: PATH_TO_TEST_BINARY --gtest_list_tests | ./build_test_cases PATH_TO_TEST_BINARY";
23
map<string, vector<string> > testCases;
25
string currentTestCase;
27
while (getline (cin, line))
30
if (line.find (" ") == 0)
31
testCases[currentTestCase].push_back (currentTestCase + line.substr (2));
33
currentTestCase = line;
37
ofstream testfilecmake;
38
char *base = basename (argv[1]);
39
string gtestName (base);
41
testfilecmake.open (string (gtestName + "_test.cmake").c_str (), ios::out | ios::trunc);
43
if (testfilecmake.is_open ())
45
for (map <string, vector<string> >::iterator it = testCases.begin ();
46
it != testCases.end (); it++)
48
for (vector <string>::iterator jt = it->second.begin ();
49
jt != it->second.end (); jt++)
51
if (testfilecmake.good ())
53
string addTest ("ADD_TEST (");
54
string testExec (" \"" + string (argv[1]) + "\"");
55
string gTestFilter ("\"--gtest_filter=\"");
56
string filterBegin ("\"");
57
string filterEnd ("\")");
59
testfilecmake << addTest << *jt << testExec << gTestFilter << filterBegin << *jt << filterEnd << endl;
64
testfilecmake.close ();
67
ifstream CTestTestfile ("CTestTestfile.cmake", ifstream::in);
68
bool needsInclude = true;
71
string includeLine = string ("INCLUDE (") +
73
string ("_test.cmake)");
75
if (CTestTestfile.is_open ())
77
while (CTestTestfile.good ())
79
getline (CTestTestfile, line);
81
if (line == includeLine)
85
CTestTestfile.close ();
90
ofstream CTestTestfileW ("CTestTestfile.cmake", ofstream::app | ofstream::out);
92
if (CTestTestfileW.is_open ())
94
CTestTestfileW << includeLine << endl;
95
CTestTestfileW.close ();