diff options
Diffstat (limited to 'Source/cmAddTestCommand.cxx')
-rw-r--r-- | Source/cmAddTestCommand.cxx | 43 |
1 files changed, 39 insertions, 4 deletions
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index 4e76b07..1c12b32 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -48,22 +48,57 @@ bool cmAddTestCommand::InitialPass(std::vector<std::string>& args) // Second argument is the name of the executable to run (a target or external // program) // Remaining arguments are the arguments to pass to the executable - if(args.size() < 2 ) { this->SetError("called with incorrect number of arguments"); return false; } + + // store the aruments for the final pass + std::copy(args.begin(),args.end(),m_Args.begin()); + return true; +} + +// we append to the file in the final pass because Enable Testing command +// creates the file in the final pass. +void cmAddTestCommand::FinalPass() +{ // Expand any CMake variables std::vector<std::string>::iterator s; - for (s = args.begin(); s != args.end(); ++s) + for (s = m_Args.begin(); s != m_Args.end(); ++s) { m_Makefile->ExpandVariablesInString(*s); } - m_Makefile->AddTest(args); + // Create a full path filename for output Testfile + std::string fname; + fname = m_Makefile->GetStartOutputDirectory(); + fname += "/"; + fname += "CMakeTestfile.txt"; - return true; + // Open the output Testfile + std::ofstream fout(fname.c_str()); + if (!fout) + { + cmSystemTools::Error("Error Writing ", fname.c_str()); + return; + } + + std::vector<std::string>::iterator it; + + // for each arg in the test + fout << "ADD_TEST("; + it = m_Args.begin(); + fout << (*it).c_str(); + ++it; + for (; it != m_Args.end(); ++it) + { + fout << " " << (*it).c_str(); + } + fout << ")" << std::endl; + fout.close(); + + return; } |