diff options
Diffstat (limited to 'Source/cmCTest.h')
-rw-r--r-- | Source/cmCTest.h | 266 |
1 files changed, 66 insertions, 200 deletions
diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 92a02c3..d300c33 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -10,13 +10,22 @@ #include <chrono> #include <map> -#include <set> +#include <memory> // IWYU pragma: keep #include <sstream> #include <string> #include <time.h> #include <vector> -class cmCTestGenericHandler; +class cmCTestBuildHandler; +class cmCTestBuildAndTestHandler; +class cmCTestCoverageHandler; +class cmCTestScriptHandler; +class cmCTestTestHandler; +class cmCTestUpdateHandler; +class cmCTestConfigureHandler; +class cmCTestMemCheckHandler; +class cmCTestSubmitHandler; +class cmCTestUploadHandler; class cmCTestStartCommand; class cmGeneratedFileStream; class cmMakefile; @@ -31,9 +40,6 @@ class cmXMLWriter; */ class cmCTest { - friend class cmCTestRunTest; - friend class cmCTestMultiProcessHandler; - public: typedef cmProcessOutput::Encoding Encoding; /** Enumerate parts of the testing and submission process. */ @@ -54,44 +60,10 @@ public: PartCount // Update names in constructor when adding a part }; - /** Representation of one part. */ - struct PartInfo - { - void SetName(const std::string& name) { this->Name = name; } - const std::string& GetName() const { return this->Name; } - - void Enable() { this->Enabled = true; } - explicit operator bool() const { return this->Enabled; } - - std::vector<std::string> SubmitFiles; - - private: - bool Enabled = false; - std::string Name; - }; -#ifdef CMAKE_BUILD_WITH_CMAKE - enum HTTPMethod - { - HTTP_GET, - HTTP_POST, - HTTP_PUT - }; - - /** - * Perform an HTTP request. - */ - static int HTTPRequest(std::string url, HTTPMethod method, - std::string& response, std::string const& fields = "", - std::string const& putFile = "", int timeout = 0); -#endif - /** Get a testing part id from its string name. Returns PartCount if the string does not name a valid part. */ Part GetPartFromName(const char* name); - typedef std::vector<std::string> VectorOfStrings; - typedef std::set<std::string> SetOfStrings; - /** Process Command line arguments */ int Run(std::vector<std::string>&, std::string* output = nullptr); @@ -128,7 +100,7 @@ public: /** * Is the tomorrow tag set? */ - bool GetTomorrowTag() { return this->TomorrowTag; } + bool GetTomorrowTag() const; /** * Try to run tests of the project @@ -137,16 +109,16 @@ public: /** what is the configuration type, e.g. Debug, Release etc. */ std::string const& GetConfigType(); - cmDuration GetTimeOut() { return this->TimeOut; } - void SetTimeOut(cmDuration t) { this->TimeOut = t; } + cmDuration GetTimeOut() const; + void SetTimeOut(cmDuration t); - cmDuration GetGlobalTimeout() { return this->GlobalTimeout; } + cmDuration GetGlobalTimeout() const; /** how many test to run at the same time */ - int GetParallelLevel() { return this->ParallelLevel; } + int GetParallelLevel() const; void SetParallelLevel(int); - unsigned long GetTestLoad() { return this->TestLoad; } + unsigned long GetTestLoad() const; void SetTestLoad(unsigned long); /** @@ -164,7 +136,7 @@ public: * Set the cmake test mode (experimental, nightly, continuous). */ void SetTestModel(int mode); - int GetTestModel() { return this->TestModel; } + int GetTestModel() const; std::string GetTestModelString(); static int GetTestModelFromString(const char* str); @@ -182,6 +154,9 @@ public: cmCTest(); ~cmCTest(); + cmCTest(const cmCTest&) = delete; + cmCTest& operator=(const cmCTest&) = delete; + /** Set the notes files to be created. */ void SetNotesFiles(const char* notes); @@ -219,26 +194,23 @@ public: int GetOutputAsJsonVersion(); - bool ShouldUseHTTP10() { return this->UseHTTP10; } + bool ShouldUseHTTP10() const; - bool ShouldPrintLabels() { return this->PrintLabels; } + bool ShouldPrintLabels() const; bool ShouldCompressTestOutput(); bool CompressString(std::string& str); - std::chrono::system_clock::time_point GetStopTime() - { - return this->StopTime; - } + std::chrono::system_clock::time_point GetStopTime() const; void SetStopTime(std::string const& time); /** Used for parallel ctest job scheduling */ - std::string GetScheduleType() { return this->ScheduleType; } - void SetScheduleType(std::string const& type) { this->ScheduleType = type; } + std::string GetScheduleType() const; + void SetScheduleType(std::string const& type); /** The max output width */ int GetMaxTestNameWidth() const; - void SetMaxTestNameWidth(int w) { this->MaxTestNameWidth = w; } + void SetMaxTestNameWidth(int w); /** * Run a single executable command and put the stdout and stderr @@ -277,8 +249,9 @@ public: * Run command specialized for make and configure. Returns process status * and retVal is return value or exception. */ - int RunMakeCommand(const char* command, std::string& output, int* retVal, - const char* dir, cmDuration timeout, std::ostream& ofs, + int RunMakeCommand(const std::string& command, std::string& output, + int* retVal, const char* dir, cmDuration timeout, + std::ostream& ofs, Encoding encoding = cmProcessOutput::Auto); /** Return the current tag */ @@ -331,16 +304,18 @@ public: Encoding encoding = cmProcessOutput::Auto); /** - * Execute handler and return its result. If the handler fails, it returns - * negative value. - */ - int ExecuteHandler(const char* handler); - - /** * Get the handler object */ - cmCTestGenericHandler* GetHandler(const char* handler); - cmCTestGenericHandler* GetInitializedHandler(const char* handler); + cmCTestBuildHandler* GetBuildHandler(); + cmCTestBuildAndTestHandler* GetBuildAndTestHandler(); + cmCTestCoverageHandler* GetCoverageHandler(); + cmCTestScriptHandler* GetScriptHandler(); + cmCTestTestHandler* GetTestHandler(); + cmCTestUpdateHandler* GetUpdateHandler(); + cmCTestConfigureHandler* GetConfigureHandler(); + cmCTestMemCheckHandler* GetMemCheckHandler(); + cmCTestSubmitHandler* GetSubmitHandler(); + cmCTestUploadHandler* GetUploadHandler(); /** * Set the CTest variable from CMake variable @@ -350,9 +325,6 @@ public: const std::string& cmake_var, bool suppress = false); - /** Make string safe to be sent as a URL */ - static std::string MakeURLSafe(const std::string&); - /** Decode a URL to the original string. */ static std::string DecodeURL(const std::string&); @@ -360,10 +332,7 @@ public: * Should ctect configuration be updated. When using new style ctest * script, this should be true. */ - void SetSuppressUpdatingCTestConfiguration(bool val) - { - this->SuppressUpdatingCTestConfiguration = val; - } + void SetSuppressUpdatingCTestConfiguration(bool val); /** * Add overwrite to ctest configuration. @@ -373,14 +342,14 @@ public: void AddCTestConfigurationOverwrite(const std::string& encstr); /** Create XML file that contains all the notes specified */ - int GenerateNotesFile(const VectorOfStrings& files); + int GenerateNotesFile(std::vector<std::string> const& files); /** Create XML file to indicate that build is complete */ int GenerateDoneFile(); /** Submit extra files to the server */ bool SubmitExtraFiles(const char* files); - bool SubmitExtraFiles(const VectorOfStrings& files); + bool SubmitExtraFiles(std::vector<std::string> const& files); /** Set the output log file name */ void SetOutputLogFileName(const char* name); @@ -420,62 +389,52 @@ public: std::string GetColorCode(Color color) const; /** The Build ID is assigned by CDash */ - void SetBuildID(const std::string& id) { this->BuildID = id; } - std::string GetBuildID() { return this->BuildID; } + void SetBuildID(const std::string& id); + std::string GetBuildID() const; /** Add file to be submitted */ void AddSubmitFile(Part part, const char* name); - std::vector<std::string> const& GetSubmitFiles(Part part) - { - return this->Parts[part].SubmitFiles; - } - void ClearSubmitFiles(Part part) { this->Parts[part].SubmitFiles.clear(); } + std::vector<std::string> const& GetSubmitFiles(Part part) const; + void ClearSubmitFiles(Part part); /** * Read the custom configuration files and apply them to the current ctest */ int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf); - std::vector<std::string>& GetInitialCommandLineArguments() - { - return this->InitialCommandLineArguments; - } + std::vector<std::string>& GetInitialCommandLineArguments(); /** Set the track to submit to */ void SetSpecificTrack(const char* track); const char* GetSpecificTrack(); - void SetFailover(bool failover) { this->Failover = failover; } - bool GetFailover() { return this->Failover; } + void SetFailover(bool failover); + bool GetFailover() const; - bool GetTestProgressOutput() const { return this->TestProgressOutput; } + bool GetTestProgressOutput() const; - bool GetVerbose() { return this->Verbose; } - bool GetExtraVerbose() { return this->ExtraVerbose; } + bool GetVerbose() const; + bool GetExtraVerbose() const; /** Direct process output to given streams. */ - void SetStreams(std::ostream* out, std::ostream* err) - { - this->StreamOut = out; - this->StreamErr = err; - } + void SetStreams(std::ostream* out, std::ostream* err); + void AddSiteProperties(cmXMLWriter& xml); - bool GetLabelSummary() { return this->LabelSummary; } - bool GetSubprojectSummary() { return this->SubprojectSummary; } + bool GetLabelSummary() const; + bool GetSubprojectSummary() const; std::string GetCostDataFile(); - const std::map<std::string, std::string>& GetDefinitions() - { - return this->Definitions; - } + bool GetOutputTestOutputOnTestFailure() const; + + const std::map<std::string, std::string>& GetDefinitions() const; /** Return the number of times a test should be run */ - int GetTestRepeat() { return this->RepeatTests; } + int GetTestRepeat() const; /** Return true if test should run until fail */ - bool GetRepeatUntilFail() { return this->RepeatUntilFail; } + bool GetRepeatUntilFail() const; void GenerateSubprojectsOutput(cmXMLWriter& xml); std::vector<std::string> GetLabelsForSubprojects(); @@ -483,85 +442,8 @@ public: void SetRunCurrentScript(bool value); private: - int RepeatTests; - bool RepeatUntilFail; - std::string ConfigType; - std::string ScheduleType; - std::chrono::system_clock::time_point StopTime; - bool TestProgressOutput; - bool Verbose; - bool ExtraVerbose; - bool ProduceXML; - bool LabelSummary; - bool SubprojectSummary; - bool UseHTTP10; - bool PrintLabels; - bool Failover; - - bool FlushTestProgressLine; - - bool ForceNewCTestProcess; - - bool RunConfigurationScript; - int GenerateNotesFile(const char* files); - // these are helper classes - typedef std::map<std::string, cmCTestGenericHandler*> t_TestingHandlers; - t_TestingHandlers TestingHandlers; - - bool ShowOnly; - bool OutputAsJson; - int OutputAsJsonVersion; - - /** Map of configuration properties */ - typedef std::map<std::string, std::string> CTestConfigurationMap; - - // TODO: The ctest configuration should be a hierarchy of - // configuration option sources: command-line, script, ini file. - // Then the ini file can get re-loaded whenever it changes without - // affecting any higher-precedence settings. - CTestConfigurationMap CTestConfiguration; - CTestConfigurationMap CTestConfigurationOverwrites; - PartInfo Parts[PartCount]; - typedef std::map<std::string, Part> PartMapType; - PartMapType PartMap; - - std::string CurrentTag; - bool TomorrowTag; - - int TestModel; - std::string SpecificTrack; - - cmDuration TimeOut; - - cmDuration GlobalTimeout; - - int MaxTestNameWidth; - - int ParallelLevel; - bool ParallelLevelSetInCli; - - unsigned long TestLoad; - - int CompatibilityMode; - - // information for the --build-and-test options - std::string BinaryDir; - - std::string NotesFiles; - - bool InteractiveDebugMode; - - bool ShortDateFormat; - - bool CompressXMLFiles; - bool CompressTestOutput; - - void InitStreams(); - std::ostream* StreamOut; - std::ostream* StreamErr; - void BlockTestErrorDiagnostics(); /** @@ -606,7 +488,8 @@ private: bool UpdateCTestConfiguration(); /** Create note from files. */ - int GenerateCTestNotesOutput(cmXMLWriter& xml, const VectorOfStrings& files); + int GenerateCTestNotesOutput(cmXMLWriter& xml, + std::vector<std::string> const& files); /** Check if the argument is the one specified */ bool CheckArgument(const std::string& arg, const char* varg1, @@ -626,25 +509,8 @@ private: int RunCMakeAndTest(std::string* output); int ExecuteTests(); - bool SuppressUpdatingCTestConfiguration; - - bool Debug; - bool ShowLineNumbers; - bool Quiet; - - std::string BuildID; - - std::vector<std::string> InitialCommandLineArguments; - - int SubmitIndex; - - cmGeneratedFileStream* OutputLogFile; - int OutputLogFileLastTag; - - bool OutputTestOutputOnTestFailure; - bool OutputColorCode; - - std::map<std::string, std::string> Definitions; + struct Private; + std::unique_ptr<Private> Impl; }; class cmCTestLogWrite |