Initial commit.
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CTest / cmCTestSleepCommand.cxx
blob662645d027f8b3cd7fd51afda8145461f3ea18ba
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestSleepCommand.cxx,v $
5 Language: C++
6 Date: $Date: 2008/01/23 15:28:01 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #include "cmCTestSleepCommand.h"
19 #include "cmCTestScriptHandler.h"
20 #include <stdlib.h> // required for atoi
22 bool cmCTestSleepCommand
23 ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
25 if (args.size() < 1)
27 this->SetError("called with incorrect number of arguments");
28 return false;
31 // sleep for specified seconds
32 unsigned int time1 = atoi(args[0].c_str());
33 if(args.size() == 1 )
35 cmCTestScriptHandler::SleepInSeconds(time1);
36 // update the elapsed time since it could have slept for a while
37 this->CTestScriptHandler->UpdateElapsedTime();
38 return true;
41 // sleep up to a duration
42 if(args.size() == 3 )
44 unsigned int duration = atoi(args[1].c_str());
45 unsigned int time2 = atoi(args[2].c_str());
46 if (time1 + duration > time2)
48 duration = (time1 + duration - time2);
49 cmCTestScriptHandler::SleepInSeconds(duration);
50 // update the elapsed time since it could have slept for a while
51 this->CTestScriptHandler->UpdateElapsedTime();
53 return true;
56 this->SetError("called with incorrect number of arguments");
57 return false;