ctest_start: Add QUIET option

This suppresses all non-error messages that would have otherwise
been printed by this function.
This commit is contained in:
Zack Galbreath 2015-02-17 09:58:25 -05:00 committed by Brad King
parent 1643b905e0
commit 19d1a5599a
10 changed files with 102 additions and 42 deletions

View File

@ -5,7 +5,7 @@ Starts the testing for a given model
:: ::
ctest_start(Model [TRACK <track>] [APPEND] [source [binary]]) ctest_start(Model [TRACK <track>] [APPEND] [source [binary]] [QUIET])
Starts the testing for a given model. The command should be called Starts the testing for a given model. The command should be called
after the binary directory is initialized. If the 'source' and 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 If the track is
specified, the submissions will go to the specified track. If APPEND 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 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 If the :variable:`CTEST_CHECKOUT_COMMAND` variable
(or the :variable:`CTEST_CVS_CHECKOUT` variable) (or the :variable:`CTEST_CVS_CHECKOUT` variable)

View File

@ -20,6 +20,7 @@
cmCTestStartCommand::cmCTestStartCommand() cmCTestStartCommand::cmCTestStartCommand()
{ {
this->CreateNewTag = true; this->CreateNewTag = true;
this->Quiet = false;
} }
bool cmCTestStartCommand bool cmCTestStartCommand
@ -57,6 +58,14 @@ bool cmCTestStartCommand
this->CreateNewTag = false; this->CreateNewTag = false;
} }
} }
if (cnt < args.size())
{
if (args[cnt] == "QUIET")
{
cnt ++;
this->Quiet = true;
}
}
if ( cnt < args.size() ) if ( cnt < args.size() )
{ {
@ -95,18 +104,20 @@ bool cmCTestStartCommand
std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir); std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir);
std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir); std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir);
this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str()); this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(),
this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.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 << smodel << std::endl
<< " Source directory: " << src_dir << 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(); const char* track = this->CTest->GetSpecificTrack();
if ( track ) if ( track )
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
" Track: " << track << std::endl); " Track: " << track << std::endl, this->Quiet);
} }
// Log startup actions. // Log startup actions.

View File

@ -34,6 +34,7 @@ public:
ni->CTest = this->CTest; ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler; ni->CTestScriptHandler = this->CTestScriptHandler;
ni->CreateNewTag = this->CreateNewTag; ni->CreateNewTag = this->CreateNewTag;
ni->Quiet = this->Quiet;
return ni; return ni;
} }
@ -52,6 +53,14 @@ public:
return this->CreateNewTag; return this->CreateNewTag;
} }
/**
* 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. * The name of the command as specified in CMakeList.txt.
*/ */
@ -62,6 +71,7 @@ public:
private: private:
bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir); bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir);
bool CreateNewTag; bool CreateNewTag;
bool Quiet;
}; };

View File

@ -463,7 +463,13 @@ cmCTest::Part cmCTest::GetPartFromName(const char* name)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command) 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) if(!this->InteractiveDebugMode)
{ {
this->BlockTestErrorDiagnostics(); this->BlockTestErrorDiagnostics();
@ -478,24 +484,23 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
this->UpdateCTestConfiguration(); this->UpdateCTestConfiguration();
cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
if ( this->ProduceXML ) if ( this->ProduceXML )
{ {
cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl, quiet);
cmCTestLog(this, OUTPUT, cmCTestOptionalLog(this, OUTPUT,
" Site: " << this->GetCTestConfiguration("Site") << std::endl " Site: " << this->GetCTestConfiguration("Site") << std::endl <<
<< " Build name: " " Build name: " << cmCTest::SafeBuildIdField(
<< cmCTest::SafeBuildIdField( this->GetCTestConfiguration("BuildName")) << std::endl, quiet);
this->GetCTestConfiguration("BuildName")) cmCTestOptionalLog(this, DEBUG, "Produce XML is on" << std::endl, quiet);
<< std::endl);
cmCTestLog(this, DEBUG, "Produce XML is on" << std::endl);
if ( this->TestModel == cmCTest::NIGHTLY && if ( this->TestModel == cmCTest::NIGHTLY &&
this->GetCTestConfiguration("NightlyStartTime").empty() ) this->GetCTestConfiguration("NightlyStartTime").empty() )
{ {
cmCTestLog(this, WARNING, cmCTestOptionalLog(this, WARNING,
"WARNING: No nightly start time found please set in" "WARNING: No nightly start time found please set in CTestConfig.cmake"
" CTestConfig.cmake or DartConfig.cmake" << std::endl); " or DartConfig.cmake" << std::endl, quiet);
cmCTestLog(this, DEBUG, "Here: " << __LINE__ << std::endl); cmCTestOptionalLog(this, DEBUG, "Here: " << __LINE__ << std::endl,
quiet);
return 0; return 0;
} }
} }
@ -507,8 +512,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
cmMakefile *mf = lg->GetMakefile(); cmMakefile *mf = lg->GetMakefile();
if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) ) if ( !this->ReadCustomConfigurationFileTree(this->BinaryDir.c_str(), mf) )
{ {
cmCTestLog(this, DEBUG, "Cannot find custom configuration file tree" cmCTestOptionalLog(this, DEBUG,
<< std::endl); "Cannot find custom configuration file tree" << std::endl, quiet);
return 0; return 0;
} }
@ -583,9 +588,10 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
} }
if (tag.empty() || (0 != command) || this->Parts[PartStart]) if (tag.empty() || (0 != command) || this->Parts[PartStart])
{ {
cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString() cmCTestOptionalLog(this, DEBUG, "TestModel: " <<
<< std::endl); this->GetTestModelString() << std::endl, quiet);
cmCTestLog(this, DEBUG, "TestModel: " << this->TestModel << std::endl); cmCTestOptionalLog(this, DEBUG, "TestModel: " <<
this->TestModel << std::endl, quiet);
if ( this->TestModel == cmCTest::NIGHTLY ) if ( this->TestModel == cmCTest::NIGHTLY )
{ {
lctime = this->GetNightlyTime( lctime = this->GetNightlyTime(
@ -609,8 +615,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
ofs.close(); ofs.close();
if ( 0 == command ) if ( 0 == command )
{ {
cmCTestLog(this, OUTPUT, "Create new tag: " << tag << " - " cmCTestOptionalLog(this, OUTPUT, "Create new tag: " << tag << " - "
<< this->GetTestModelString() << std::endl); << this->GetTestModelString() << std::endl, quiet);
} }
} }
} }
@ -630,8 +636,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
return 0; return 0;
} }
cmCTestLog(this, OUTPUT, " Use existing tag: " << tag << " - " cmCTestOptionalLog(this, OUTPUT, " Use existing tag: " << tag << " - "
<< this->GetTestModelString() << std::endl); << this->GetTestModelString() << std::endl, quiet);
} }
this->CurrentTag = tag; this->CurrentTag = tag;
@ -675,8 +681,8 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
if ( !fname.empty() ) if ( !fname.empty() )
{ {
cmCTestLog(this, OUTPUT, " Reading ctest configuration file: " cmCTestOptionalLog(this, OUTPUT, " Reading ctest configuration file: "
<< fname << std::endl); << fname << std::endl, command->ShouldBeQuiet());
bool readit = mf->ReadListFile(mf->GetCurrentListFile(), bool readit = mf->ReadListFile(mf->GetCurrentListFile(),
fname.c_str() ); fname.c_str() );
if(!readit) if(!readit)
@ -689,19 +695,20 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
} }
else else
{ {
cmCTestLog(this, WARNING, cmCTestOptionalLog(this, WARNING,
"Cannot locate CTest configuration: in BuildDirectory: " "Cannot locate CTest configuration: in BuildDirectory: "
<< bld_dir_fname << std::endl); << bld_dir_fname << std::endl, command->ShouldBeQuiet());
cmCTestLog(this, WARNING, cmCTestOptionalLog(this, WARNING,
"Cannot locate CTest configuration: in SourceDirectory: " "Cannot locate CTest configuration: in SourceDirectory: "
<< src_dir_fname << std::endl); << src_dir_fname << std::endl, command->ShouldBeQuiet());
} }
this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime", this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
"CTEST_NIGHTLY_START_TIME"); "CTEST_NIGHTLY_START_TIME", command->ShouldBeQuiet());
this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE"); this->SetCTestConfigurationFromCMakeVariable(mf, "Site", "CTEST_SITE",
command->ShouldBeQuiet());
this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName", this->SetCTestConfigurationFromCMakeVariable(mf, "BuildName",
"CTEST_BUILD_NAME"); "CTEST_BUILD_NAME", command->ShouldBeQuiet());
const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION"); const char* dartVersion = mf->GetDefinition("CTEST_DART_SERVER_VERSION");
if ( dartVersion ) if ( dartVersion )
{ {
@ -720,8 +727,9 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{ {
return false; return false;
} }
cmCTestLog(this, OUTPUT, " Use " << this->GetTestModelString() cmCTestOptionalLog(this, OUTPUT, " Use " << this->GetTestModelString()
<< " tag: " << this->GetCurrentTag() << std::endl); << " tag: " << this->GetCurrentTag() << std::endl,
command->ShouldBeQuiet());
return true; return true;
} }

View File

@ -129,6 +129,7 @@ add_RunCMake_test(build_command)
add_RunCMake_test(export) add_RunCMake_test(export)
add_RunCMake_test(cmake_minimum_required) add_RunCMake_test(cmake_minimum_required)
add_RunCMake_test(continue) add_RunCMake_test(continue)
add_RunCMake_test(ctest_start)
add_RunCMake_test(ctest_submit) add_RunCMake_test(ctest_submit)
add_RunCMake_test(file) add_RunCMake_test(file)
add_RunCMake_test(find_library) add_RunCMake_test(find_library)

View File

@ -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)

View File

@ -0,0 +1 @@
set(CTEST_PROJECT_NAME "CTestStart@CASE_NAME@")

View File

@ -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)

View File

@ -0,0 +1 @@
^$

View File

@ -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})