cmAddTestCommand.cxx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmAddTestCommand.h"
  14. #include "cmTestGenerator.h"
  15. #include "cmTest.h"
  16. // cmExecutableCommand
  17. bool cmAddTestCommand
  18. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  19. {
  20. // First argument is the name of the test Second argument is the name of
  21. // the executable to run (a target or external program) Remaining arguments
  22. // are the arguments to pass to the executable
  23. if(args.size() < 2 )
  24. {
  25. this->SetError("called with incorrect number of arguments");
  26. return false;
  27. }
  28. // Collect the command with arguments.
  29. std::vector<std::string> command;
  30. for(std::vector<std::string>::const_iterator it = args.begin() + 1;
  31. it != args.end(); ++it)
  32. {
  33. command.push_back(*it);
  34. }
  35. // Create the test but add a generator only the first time it is
  36. // seen. This preserves behavior from before test generators.
  37. cmTest* test = this->Makefile->GetTest(args[0].c_str());
  38. if(!test)
  39. {
  40. test = this->Makefile->CreateTest(args[0].c_str());
  41. this->Makefile->AddTestGenerator(new cmTestGenerator(test));
  42. }
  43. test->SetCommand(command);
  44. return true;
  45. }