Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CTest / cmCTestMultiProcessHandler.h
blob97a250d9906c5e86ff689d0d5fa173ad4753506d
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmCTestMultiProcessHandler.h,v $
5 Language: C++
6 Date: $Date: 2008-07-07 00:03:08 $
7 Version: $Revision: 1.3 $
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 #ifndef cmCTestMultiProcessHandler_h
18 #define cmCTestMultiProcessHandler_h
20 class cmProcess;
21 #include <cmStandardIncludes.h>
22 #include <cmCTestTestHandler.h>
24 /** \class cmCTestMultiProcessHandler
25 * \brief run parallel ctest
27 * cmCTestMultiProcessHandler
29 class cmCTestMultiProcessHandler
31 public:
32 struct TestSet : public std::set<int> {};
33 struct TestMap : public std::map<int, TestSet> {};
34 cmCTestMultiProcessHandler();
35 // Set the tests
36 void SetTests(TestMap& tests,
37 std::map<int, cmStdString>& testNames);
38 // Set the max number of tests that can be run at the same time.
39 void SetParallelLevel(size_t);
40 void RunTests();
41 void PrintTests();
42 void SetCTestCommand(const char* c) { this->CTestCommand = c;}
43 void SetTestCacheFile(const char* c) { this->CTestCacheFile = c;}
44 void SetPassFailVectors(std::vector<cmStdString>* passed,
45 std::vector<cmStdString>* failed)
47 this->Passed = passed;
48 this->Failed = failed;
50 void SetTestResults(std::vector<cmCTestTestHandler::cmCTestTestResult>* r)
52 this->TestResults = r;
54 void SetCTest(cmCTest* ctest) { this->CTest = ctest;}
55 protected:
56 cmCTest* CTest;
57 // Start the next test or tests as many as are allowed by
58 // ParallelLevel
59 void StartNextTests();
60 void StartTestProcess(int test);
61 bool StartTest(int test);
62 void EndTest(cmProcess*);
63 // Return true if there are still tests running
64 // check all running processes for output and exit case
65 bool CheckOutput();
66 // map from test number to set of depend tests
67 TestMap Tests;
68 std::map<int, cmStdString> TestNames;
69 std::map<int, bool> TestRunningMap;
70 std::map<int, bool> TestFinishMap;
71 std::map<int, cmStdString> TestOutput;
72 std::string CTestCommand;
73 std::string CTestCacheFile;
74 std::vector<cmStdString>* Passed;
75 std::vector<cmStdString>* Failed;
76 std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
77 int ProcessId;
78 size_t ParallelLevel; // max number of process that can be run at once
79 std::set<cmProcess*> RunningTests; // current running tests
82 #endif