diff options
author | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-04-24 19:59:51 (GMT) |
---|---|---|
committer | Andy Cedilnik <andy.cedilnik@kitware.com> | 2005-04-24 19:59:51 (GMT) |
commit | d395b563ede173721c240df2daad23284f453c4a (patch) | |
tree | 84178ad0d725b16b92f84549bd106e05038c90d5 /Source/cmAddTestCommand.cxx | |
parent | 3a8e7599b10806b43179e18c23218fe68a4d2eb5 (diff) | |
download | CMake-d395b563ede173721c240df2daad23284f453c4a.zip CMake-d395b563ede173721c240df2daad23284f453c4a.tar.gz CMake-d395b563ede173721c240df2daad23284f453c4a.tar.bz2 |
ENH: Improve internal test handling by creating a test class. Command cmEnableTesting now only sets CMAKE_TESTING_ENABLED and cmAddTest only adds a test to the list. The actual test files are written by local generator. This way we can at some point in the future replace DartTestfile with some XML file
Diffstat (limited to 'Source/cmAddTestCommand.cxx')
-rw-r--r-- | Source/cmAddTestCommand.cxx | 70 |
1 files changed, 9 insertions, 61 deletions
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index c5db5ef..187a3ad 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -16,6 +16,9 @@ =========================================================================*/ #include "cmAddTestCommand.h" +#include "cmTest.h" + + // cmExecutableCommand bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args) { @@ -32,67 +35,12 @@ bool cmAddTestCommand::InitialPass(std::vector<std::string> const& args) // store the arguments for the final pass // also expand any CMake variables - m_Args = args; - 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() -{ - // Create a full path filename for output Testfile - std::string fname; - fname = m_Makefile->GetStartOutputDirectory(); - fname += "/"; - if ( m_Makefile->IsSet("CTEST_NEW_FORMAT") ) - { - fname += "CTestTestfile.cmake"; - } - else - { - fname += "DartTestfile.txt"; - } - - - // If the file doesn't exist, then ENABLE_TESTING hasn't been run - if (cmSystemTools::FileExists(fname.c_str())) - { - // Open the output Testfile - std::ofstream fout(fname.c_str(), std::ios::app); - if (!fout) - { - cmSystemTools::Error("Error Writing ", fname.c_str()); - return; - } + std::vector<cmStdString> arguments; + arguments.assign(args.begin() + 2, args.end()); - std::vector<std::string>::iterator it; + cmTest* test = m_Makefile->CreateTest(args[0].c_str()); + test->SetCommand(args[1].c_str()); + test->SetArguments(arguments); - // for each arg in the test - fout << "ADD_TEST("; - it = m_Args.begin(); - fout << (*it).c_str(); - ++it; - for (; it != m_Args.end(); ++it) - { - // Just double-quote all arguments so they are re-parsed - // correctly by the test system. - fout << " \""; - for(std::string::iterator c = it->begin(); c != it->end(); ++c) - { - // Escape quotes within arguments. We should escape - // backslashes too but we cannot because it makes the result - // inconsistent with previous behavior of this command. - if((*c == '"')) - { - fout << '\\'; - } - fout << *c; - } - fout << "\""; - } - fout << ")" << std::endl; - fout.close(); - } - return; + return true; } - |