diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index b5b46f60b..60695daa1 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -412,6 +412,30 @@ bool cmCTestRunTest::StartTest(size_t total) this->TestResult.TestCount = this->TestProperties->Index; this->TestResult.Name = this->TestProperties->Name; this->TestResult.Path = this->TestProperties->Directory.c_str(); + + if(args.size() >= 2 && args[1] == "NOT_AVAILABLE") + { + this->TestProcess = new cmProcess; + std::string msg; + if(this->CTest->GetConfigType().empty()) + { + msg = "Test not available without configuration."; + msg += " (Missing \"-C \"?)"; + } + else + { + msg = "Test not available in configuration \""; + msg += this->CTest->GetConfigType(); + msg += "\"."; + } + *this->TestHandler->LogFile << msg << std::endl; + cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl); + this->TestResult.Output = msg; + this->TestResult.FullCommandLine = ""; + this->TestResult.CompletionStatus = "Not Run"; + this->TestResult.Status = cmCTestTestHandler::NOT_RUN; + return false; + } // Check if all required files exist for(std::vector::iterator i = diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 56f663009..e3b81df88 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1320,6 +1320,10 @@ std::string cmCTestTestHandler::FindTheExecutable(const char *exe) std::string resConfig; std::vector extraPaths; std::vector failedPaths; + if(strcmp(exe, "NOT_AVAILABLE") == 0) + { + return exe; + } return cmCTestTestHandler::FindExecutable(this->CTest, exe, resConfig, extraPaths, diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 39f86388b..e0892b282 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -129,6 +129,22 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, os << ")\n"; } +//---------------------------------------------------------------------------- +void cmTestGenerator::GenerateScriptNoConfig(std::ostream& os, + Indent const& indent) +{ + os << indent << "ADD_TEST(" << this->Test->GetName() << " NOT_AVAILABLE)\n"; +} + +//---------------------------------------------------------------------------- +bool cmTestGenerator::NeedsScriptNoConfig() const +{ + return (this->TestGenerated && // test generated for at least one config + this->ActionsPerConfig && // test is config-aware + this->Configurations.empty() && // test runs in all configs + !this->ConfigurationTypes->empty()); // config-dependent command +} + //---------------------------------------------------------------------------- void cmTestGenerator::GenerateOldStyle(std::ostream& fout, Indent const& indent) diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h index 85d9091d6..2c69fc3c5 100644 --- a/Source/cmTestGenerator.h +++ b/Source/cmTestGenerator.h @@ -34,6 +34,8 @@ protected: virtual void GenerateScriptForConfig(std::ostream& os, const char* config, Indent const& indent); + virtual void GenerateScriptNoConfig(std::ostream& os, Indent const& indent); + virtual bool NeedsScriptNoConfig() const; void GenerateOldStyle(std::ostream& os, Indent const& indent); cmTest* Test; diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1be2a245e..2ad9a7759 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1310,7 +1310,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/ --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM} --build-exe-dir "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory" --force-new-ctest-process - --test-command ${CMAKE_CTEST_COMMAND} -V + --test-command ${CMAKE_CTEST_COMMAND} -V -C \${CTEST_CONFIGURATION_TYPE} ) LIST(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/TestsWorkingDirectory")