From 19d1a5599a08f2e8d74c4483cb9ee6d34e38ecba Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Tue, 17 Feb 2015 09:58:25 -0500 Subject: ctest_start: Add QUIET option This suppresses all non-error messages that would have otherwise been printed by this function. --- Help/command/ctest_start.rst | 5 +- Source/CTest/cmCTestStartCommand.cxx | 23 +++++-- Source/CTest/cmCTestStartCommand.h | 10 ++++ Source/cmCTest.cxx | 76 +++++++++++++----------- Tests/RunCMake/CMakeLists.txt | 1 + Tests/RunCMake/ctest_start/CMakeLists.txt.in | 4 ++ Tests/RunCMake/ctest_start/CTestConfig.cmake.in | 1 + Tests/RunCMake/ctest_start/RunCMakeTest.cmake | 10 ++++ Tests/RunCMake/ctest_start/StartQuiet-stdout.txt | 1 + Tests/RunCMake/ctest_start/test.cmake.in | 13 ++++ 10 files changed, 102 insertions(+), 42 deletions(-) create mode 100644 Tests/RunCMake/ctest_start/CMakeLists.txt.in create mode 100644 Tests/RunCMake/ctest_start/CTestConfig.cmake.in create mode 100644 Tests/RunCMake/ctest_start/RunCMakeTest.cmake create mode 100644 Tests/RunCMake/ctest_start/StartQuiet-stdout.txt create mode 100644 Tests/RunCMake/ctest_start/test.cmake.in diff --git a/Help/command/ctest_start.rst b/Help/command/ctest_start.rst index d7472db..b5c7b34 100644 --- a/Help/command/ctest_start.rst +++ b/Help/command/ctest_start.rst @@ -5,7 +5,7 @@ Starts the testing for a given model :: - ctest_start(Model [TRACK ] [APPEND] [source [binary]]) + ctest_start(Model [TRACK ] [APPEND] [source [binary]] [QUIET]) Starts the testing for a given model. The command should be called after the binary directory is initialized. If the 'source' and @@ -14,7 +14,8 @@ after the binary directory is initialized. If the 'source' and If the track is specified, the submissions will go to the specified track. If APPEND is used, the existing TAG is used rather than creating a new one based -on the current time stamp. +on the current time stamp. If QUIET is used, CTest will suppress any +non-error messages that it otherwise would have printed to the console. If the :variable:`CTEST_CHECKOUT_COMMAND` variable (or the :variable:`CTEST_CVS_CHECKOUT` variable) diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx index 8ea6cef..e19e4f4 100644 --- a/Source/CTest/cmCTestStartCommand.cxx +++ b/Source/CTest/cmCTestStartCommand.cxx @@ -20,6 +20,7 @@ cmCTestStartCommand::cmCTestStartCommand() { this->CreateNewTag = true; + this->Quiet = false; } bool cmCTestStartCommand @@ -57,6 +58,14 @@ bool cmCTestStartCommand this->CreateNewTag = false; } } + if (cnt < args.size()) + { + if (args[cnt] == "QUIET") + { + cnt ++; + this->Quiet = true; + } + } if ( cnt < args.size() ) { @@ -95,18 +104,20 @@ bool cmCTestStartCommand std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir); std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir); - this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str()); - this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str()); + this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(), + this->Quiet); + this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(), + this->Quiet); - cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model " << smodel << std::endl << " Source directory: " << src_dir << std::endl - << " Build directory: " << bld_dir << std::endl); + << " Build directory: " << bld_dir << std::endl, this->Quiet); const char* track = this->CTest->GetSpecificTrack(); if ( track ) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, - " Track: " << track << std::endl); + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, + " Track: " << track << std::endl, this->Quiet); } // Log startup actions. diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h index 3b8843f..eed1962 100644 --- a/Source/CTest/cmCTestStartCommand.h +++ b/Source/CTest/cmCTestStartCommand.h @@ -34,6 +34,7 @@ public: ni->CTest = this->CTest; ni->CTestScriptHandler = this->CTestScriptHandler; ni->CreateNewTag = this->CreateNewTag; + ni->Quiet = this->Quiet; return ni; } @@ -53,6 +54,14 @@ public: } /** + * Should this invocation of ctest_start output non-error messages? + */ + bool ShouldBeQuiet() + { + return this->Quiet; + } + + /** * The name of the command as specified in CMakeList.txt. */ virtual std::string GetName() const { return "ctest_start";} @@ -62,6 +71,7 @@ public: private: bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir); bool CreateNewTag; + bool Quiet; }; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 9975802..d7fe22d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -463,7 +463,13 @@ cmCTest::Part cmCTest::GetPartFromName(const char* name) //---------------------------------------------------------------------- int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) { - cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); + bool quiet = false; + if (command && command->ShouldBeQuiet()) + { + quiet = true; + } + + cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet); if(!this->InteractiveDebugMode) { this->BlockTestErrorDiagnostics(); @@ -478,24 +484,23 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) this->UpdateCTestConfiguration(); - cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); + cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet); if ( this->ProduceXML ) { - cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); - cmCTestLog(this, OUTPUT, - " Site: " << this->GetCTestConfiguration("Site") << std::endl - << " Build name: " - << cmCTest::SafeBuildIdField( - this->GetCTestConfiguration("BuildName")) - << std::endl); - cmCTestLog(this, DEBUG, "Produce XML is on" << std::endl); + cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet); + cmCTestOptionalLog(this, OUTPUT, + " Site: " << this->GetCTestConfiguration("Site") << std::endl << + " Build name: " << cmCTest::SafeBuildIdField( + this->GetCTestConfiguration("BuildName")) << std::endl, quiet); + cmCTestOptionalLog(this, DEBUG, "Produce XML is on" << std::endl, quiet); if ( this->TestModel == cmCTest::NIGHTLY && this->GetCTestConfiguration("NightlyStartTime").empty() ) { - cmCTestLog(this, WARNING, - "WARNING: No nightly start time found please set in" - " CTestConfig.cmake or DartConfig.cmake" << std::endl); - cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); + cmCTestOptionalLog(this, WARNING, + "WARNING: No nightly start time found please set in CTestConfig.cmake" + " or DartConfig.cmake" << std::endl, quiet); + cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, + quiet); return 0; } } @@ -507,8 +512,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) cmMakefile *mf = lg->GetMakefile(); if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) { - cmCTestLog(this, DEBUG, "Cannot find custom configuration file tree" - << std::endl); + cmCTestOptionalLog(this, DEBUG, + "Cannot find custom configuration file tree" << std::endl, quiet); return 0; } @@ -583,9 +588,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) } if (tag.empty() || (0 != command) || this->Parts[PartStart]) { - cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString() - << std::endl); - cmCTestLog(this, DEBUG, "TestModel: " << this->TestModel << std::endl); + cmCTestOptionalLog(this, DEBUG, "TestModel: " << + this->GetTestModelString() << std::endl, quiet); + cmCTestOptionalLog(this, DEBUG, "TestModel: " << + this->TestModel << std::endl, quiet); if ( this->TestModel == cmCTest::NIGHTLY ) { lctime = this->GetNightlyTime( @@ -609,8 +615,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) ofs.close(); if ( 0 == command ) { - cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - " - << this->GetTestModelString() << std::endl); + cmCTestOptionalLog(this, OUTPUT, "Create new tag: " << tag << " - " + << this->GetTestModelString() << std::endl, quiet); } } } @@ -630,8 +636,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) return 0; } - cmCTestLog(this, OUTPUT, " Use existing tag: " << tag << " - " - << this->GetTestModelString() << std::endl); + cmCTestOptionalLog(this, OUTPUT, " Use existing tag: " << tag << " - " + << this->GetTestModelString() << std::endl, quiet); } this->CurrentTag = tag; @@ -675,8 +681,8 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) if ( !fname.empty() ) { - cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " - << fname << std::endl); + cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: " + << fname << std::endl, command->ShouldBeQuiet()); bool readit = mf->ReadListFile(mf->GetCurrentListFile(), fname.c_str() ); if(!readit) @@ -689,19 +695,20 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) } else { - cmCTestLog(this, WARNING, + cmCTestOptionalLog(this, WARNING, "Cannot locate CTest configuration: in BuildDirectory: " - << bld_dir_fname << std::endl); - cmCTestLog(this, WARNING, + << bld_dir_fname << std::endl, command->ShouldBeQuiet()); + cmCTestOptionalLog(this, WARNING, "Cannot locate CTest configuration: in SourceDirectory: " - << src_dir_fname << std::endl); + << src_dir_fname << std::endl, command->ShouldBeQuiet()); } this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", - "CTEST_NIGHTLY_START_TIME"); - this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE"); + "CTEST_NIGHTLY_START_TIME", command->ShouldBeQuiet()); + this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE", + command->ShouldBeQuiet()); this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName", - "CTEST_BUILD_NAME"); + "CTEST_BUILD_NAME", command->ShouldBeQuiet()); const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION"); if ( dartVersion ) { @@ -720,8 +727,9 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) { return false; } - cmCTestLog(this, OUTPUT, " Use " << this->GetTestModelString() - << " tag: " << this->GetCurrentTag() << std::endl); + cmCTestOptionalLog(this, OUTPUT, " Use " << this->GetTestModelString() + << " tag: " << this->GetCurrentTag() << std::endl, + command->ShouldBeQuiet()); return true; } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 59c6918..a9b8bf3 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -129,6 +129,7 @@ add_RunCMake_test(build_command) add_RunCMake_test(export) add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(continue) +add_RunCMake_test(ctest_start) add_RunCMake_test(ctest_submit) add_RunCMake_test(file) add_RunCMake_test(find_library) diff --git a/Tests/RunCMake/ctest_start/CMakeLists.txt.in b/Tests/RunCMake/ctest_start/CMakeLists.txt.in new file mode 100644 index 0000000..913239c --- /dev/null +++ b/Tests/RunCMake/ctest_start/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(CTestStart@CASE_NAME@ NONE) +include(CTest) +add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) diff --git a/Tests/RunCMake/ctest_start/CTestConfig.cmake.in b/Tests/RunCMake/ctest_start/CTestConfig.cmake.in new file mode 100644 index 0000000..e75d14f --- /dev/null +++ b/Tests/RunCMake/ctest_start/CTestConfig.cmake.in @@ -0,0 +1 @@ +set(CTEST_PROJECT_NAME "CTestStart@CASE_NAME@") diff --git a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake new file mode 100644 index 0000000..f765a0f --- /dev/null +++ b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake @@ -0,0 +1,10 @@ +include(RunCTest) + +set(CASE_CTEST_START_ARGS "") + +function(run_ctest_start CASE_NAME) + set(CASE_CTEST_START_ARGS "${ARGN}") + run_ctest(${CASE_NAME}) +endfunction() + +run_ctest_start(StartQuiet Experimental QUIET) diff --git a/Tests/RunCMake/ctest_start/StartQuiet-stdout.txt b/Tests/RunCMake/ctest_start/StartQuiet-stdout.txt new file mode 100644 index 0000000..10f3293 --- /dev/null +++ b/Tests/RunCMake/ctest_start/StartQuiet-stdout.txt @@ -0,0 +1 @@ +^$ diff --git a/Tests/RunCMake/ctest_start/test.cmake.in b/Tests/RunCMake/ctest_start/test.cmake.in new file mode 100644 index 0000000..21e3fad --- /dev/null +++ b/Tests/RunCMake/ctest_start/test.cmake.in @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.1) + +set(CTEST_SITE "test-site") +set(CTEST_BUILD_NAME "test-build-name") +set(CTEST_SOURCE_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@") +set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@/@CASE_NAME@-build") +set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") +set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") +set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") +set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") + +set(ctest_start_args "@CASE_CTEST_START_ARGS@") +ctest_start(${ctest_start_args}) -- cgit v0.12