CTest: Optionally add a ChangeId attribute on XML Site tags
Add variable CTEST_CHANGE_ID to configure the setting. This allows CTest clients to give CDash information about what change is being tested so that CDash can take actions to report the results (e.g. to a pull request page).
This commit is contained in:
parent
7a40998329
commit
601ff0ec55
|
@ -351,6 +351,7 @@ Variables for CTest
|
||||||
/variable/CTEST_BUILD_NAME
|
/variable/CTEST_BUILD_NAME
|
||||||
/variable/CTEST_BZR_COMMAND
|
/variable/CTEST_BZR_COMMAND
|
||||||
/variable/CTEST_BZR_UPDATE_OPTIONS
|
/variable/CTEST_BZR_UPDATE_OPTIONS
|
||||||
|
/variable/CTEST_CHANGE_ID
|
||||||
/variable/CTEST_CHECKOUT_COMMAND
|
/variable/CTEST_CHECKOUT_COMMAND
|
||||||
/variable/CTEST_CONFIGURATION_TYPE
|
/variable/CTEST_CONFIGURATION_TYPE
|
||||||
/variable/CTEST_CONFIGURE_COMMAND
|
/variable/CTEST_CONFIGURE_COMMAND
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
CTEST_CHANGE_ID
|
||||||
|
---------------
|
||||||
|
|
||||||
|
Specify the CTest ``ChangeId`` setting
|
||||||
|
in a :manual:`ctest(1)` dashboard client script.
|
||||||
|
|
||||||
|
This setting allows CTest to pass arbitrary information about this
|
||||||
|
build up to CDash. One use of this feature is to allow CDash to
|
||||||
|
post comments on your pull request if anything goes wrong with your build.
|
|
@ -109,6 +109,12 @@ bool cmCTestHandlerCommand
|
||||||
this->Quiet);
|
this->Quiet);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(const char* changeId =
|
||||||
|
this->Makefile->GetDefinition("CTEST_CHANGE_ID"))
|
||||||
|
{
|
||||||
|
this->CTest->SetCTestConfiguration("ChangeId", changeId, this->Quiet);
|
||||||
|
}
|
||||||
|
|
||||||
cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
|
cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
|
||||||
cmCTestGenericHandler* handler = this->InitializeHandler();
|
cmCTestGenericHandler* handler = this->InitializeHandler();
|
||||||
if ( !handler )
|
if ( !handler )
|
||||||
|
|
|
@ -1567,6 +1567,13 @@ void cmCTest::StartXML(cmXMLWriter& xml, bool append)
|
||||||
xml.Attribute("LogicalProcessorsPerPhysical",
|
xml.Attribute("LogicalProcessorsPerPhysical",
|
||||||
info.GetLogicalProcessorsPerPhysical());
|
info.GetLogicalProcessorsPerPhysical());
|
||||||
xml.Attribute("ProcessorClockFrequency", info.GetProcessorClockFrequency());
|
xml.Attribute("ProcessorClockFrequency", info.GetProcessorClockFrequency());
|
||||||
|
|
||||||
|
std::string changeId = this->GetCTestConfiguration("ChangeId");
|
||||||
|
if(!changeId.empty())
|
||||||
|
{
|
||||||
|
xml.Attribute("ChangeId", changeId);
|
||||||
|
}
|
||||||
|
|
||||||
this->AddSiteProperties(xml);
|
this->AddSiteProperties(xml);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
file(GLOB build_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Build.xml")
|
||||||
|
if(build_xml_file)
|
||||||
|
file(READ "${build_xml_file}" build_xml LIMIT 4096)
|
||||||
|
if(NOT build_xml MATCHES [[ChangeId="<>1"]])
|
||||||
|
string(REPLACE "\n" "\n " build_xml " ${build_xml}")
|
||||||
|
set(RunCMake_TEST_FAILED
|
||||||
|
"Build.xml does not have expected ChangeId:\n${build_xml}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(RunCMake_TEST_FAILED "Build.xml not found")
|
||||||
|
endif()
|
|
@ -31,3 +31,12 @@ endif()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
run_BuildFailure()
|
run_BuildFailure()
|
||||||
|
|
||||||
|
function(run_BuildChangeId)
|
||||||
|
set(CASE_TEST_PREFIX_CODE [[
|
||||||
|
set(CTEST_CHANGE_ID "<>1")
|
||||||
|
]])
|
||||||
|
|
||||||
|
run_ctest(BuildChangeId)
|
||||||
|
endfunction()
|
||||||
|
run_BuildChangeId()
|
||||||
|
|
|
@ -49,3 +49,13 @@ set(CASE_CTEST_TEST_LOAD "ERR3")
|
||||||
run_ctest_test(TestLoadOrder TEST_LOAD "ERR4")
|
run_ctest_test(TestLoadOrder TEST_LOAD "ERR4")
|
||||||
|
|
||||||
unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})
|
unset(ENV{__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING})
|
||||||
|
unset(CASE_CTEST_TEST_LOAD)
|
||||||
|
|
||||||
|
function(run_TestChangeId)
|
||||||
|
set(CASE_TEST_PREFIX_CODE [[
|
||||||
|
set(CTEST_CHANGE_ID "<>1")
|
||||||
|
]])
|
||||||
|
|
||||||
|
run_ctest(TestChangeId)
|
||||||
|
endfunction()
|
||||||
|
run_TestChangeId()
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
|
||||||
|
if(test_xml_file)
|
||||||
|
file(READ "${test_xml_file}" test_xml LIMIT 4096)
|
||||||
|
if(NOT test_xml MATCHES [[ChangeId="<>1"]])
|
||||||
|
string(REPLACE "\n" "\n " test_xml " ${test_xml}")
|
||||||
|
set(RunCMake_TEST_FAILED
|
||||||
|
"Test.xml does not have expected ChangeId:\n${test_xml}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(RunCMake_TEST_FAILED "Test.xml not found")
|
||||||
|
endif()
|
|
@ -1,4 +1,5 @@
|
||||||
cmake_minimum_required(VERSION 3.1)
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
@CASE_TEST_PREFIX_CODE@
|
||||||
|
|
||||||
set(CTEST_SITE "test-site")
|
set(CTEST_SITE "test-site")
|
||||||
set(CTEST_BUILD_NAME "test-build-name")
|
set(CTEST_BUILD_NAME "test-build-name")
|
||||||
|
|
Loading…
Reference in New Issue