CTest: Output test-specific env vars in verbose mode (#15446)

Any environment vars that were configured for a test via the
ENVIRONMENT property will now be output when the test is run
with verbose logging enabled.
This commit is contained in:
Zach Mullen 2015-03-15 13:00:31 -04:00 committed by Brad King
parent 607131bf8c
commit 874fdd914a
6 changed files with 68 additions and 0 deletions

View File

@ -536,11 +536,26 @@ void cmCTestRunTest::ComputeArguments()
} }
this->TestResult.FullCommandLine = testCommand; this->TestResult.FullCommandLine = testCommand;
// Print the test command in verbose mode
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
<< this->Index << ": " << this->Index << ": "
<< (this->TestHandler->MemCheck?"MemCheck":"Test") << (this->TestHandler->MemCheck?"MemCheck":"Test")
<< " command: " << testCommand << " command: " << testCommand
<< std::endl); << std::endl);
// Print any test-specific env vars in verbose mode
if (this->TestProperties->Environment.size())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": "
<< "Environment variables: " << std::endl);
}
for(std::vector<std::string>::const_iterator e =
this->TestProperties->Environment.begin();
e != this->TestProperties->Environment.end(); ++e)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index << ": " << *e
<< std::endl);
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -2561,6 +2561,17 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log" --output-log "${CMake_BINARY_DIR}/Tests/CTestTestParallel/testOutput.log"
) )
configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestVerboseOutput/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/test.cmake" @ONLY ESCAPE_QUOTES)
add_test(CTestTestVerboseOutput ${CMAKE_CTEST_COMMAND}
-S "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/test.cmake" -VV
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestVerboseOutput/testOutput.log"
-C "\${CTestTest_CONFIG}"
)
set_property(TEST CTestTestVerboseOutput PROPERTY PASS_REGULAR_EXPRESSION
"Environment variables:.*foo=bar.*this=that"
)
configure_file( configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in" "${CMake_SOURCE_DIR}/Tests/CTestTestSkipReturnCode/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake" "${CMake_BINARY_DIR}/Tests/CTestTestSkipReturnCode/test.cmake"

View File

@ -0,0 +1,11 @@
cmake_minimum_required (VERSION 2.6)
project(CTestTestVerboseOutput)
include(CTest)
add_executable(nop nop.c)
add_test(NAME TestWithProperties COMMAND nop)
set_property(TEST TestWithProperties PROPERTY ENVIRONMENT
"foo=bar"
"this=that"
)

View File

@ -0,0 +1,7 @@
set(CTEST_PROJECT_NAME "CTestTestVerboseOutput")
set(CTEST_NIGHTLY_START_TIME "21:00:00 EDT")
set(CTEST_DART_SERVER_VERSION "2")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "open.cdash.org")
set(CTEST_DROP_LOCATION "/submit.php?project=PublicDashboard")
set(CTEST_DROP_SITE_CDASH TRUE)

View File

@ -0,0 +1,4 @@
int main()
{
return 0;
}

View File

@ -0,0 +1,20 @@
cmake_minimum_required(VERSION 2.4)
# Settings:
set(CTEST_DASHBOARD_ROOT "@CMake_BINARY_DIR@/Tests/CTestTest")
set(CTEST_SITE "@SITE@")
set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-VerboseOutput")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestVerboseOutput")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestVerboseOutput")
set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@CMAKE_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
CTEST_START(Experimental)
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}")