int main(int argc, char ** argv) { int i; vector<string> cpps; string class_dir; TestSuite t; //If they did not provide the minimum set of args if( argc < 3 ) { cout << "Usage: ./tester [-g|-r] [directory]" << endl; cout << " -g: Generate test cases from \"golden\" .cpp" << endl; cout << " -r: Run tests on student programs." << endl; return -1; } class_dir = argv[2]; if(chdir(argv[2])) { cout << "Failed to change to directory: " << class_dir; } //Choose one of two modes. [R]unning tests or [G]enerating tests. string flag = argv[1]; if(flag == "-g") { //Call test generation function t.helper_func(); } else if(flag == "-r") { //fill "cpps" with the name of every .cpp to be ran t.dirCrawl(".cpp", ".", cpps); //loop through every .cpp and run it for(i=0;i<cpps.size();i++) { //Excludes the "golden" .cpp from being evaluated if(count(cpps.at(i).begin(), cpps.at(i).end(), '/') > 1) { //t.initTest(argv[1],".tst",".ans"); t.initTest( cpps.at(i) ,".tst",".ans"); t.runTests(); t.outputLogFile(); t.reset(); } } //end for loop t.createSummary(); } else { cout << "Unrecognized command line option. [-g|-r]" << endl; return -2; } return 0; }