ctest_submit: Add option BUILD_ID

Fixes: #18968
This commit is contained in:
Zack Galbreath
2019-03-19 11:09:19 -04:00
parent 89abbdd8c8
commit ba7e44eb7a
5 changed files with 55 additions and 24 deletions

View File

@@ -7,6 +7,7 @@ Perform the :ref:`CTest Submit Step` as a :ref:`Dashboard Client`.
ctest_submit([PARTS <part>...] [FILES <file>...]
[SUBMIT_URL <url>]
[BUILD_ID <result-var>]
[HTTPHEADER <header>]
[RETRY_COUNT <count>]
[RETRY_DELAY <delay>]
@@ -44,6 +45,10 @@ The options are:
The ``http`` or ``https`` URL of the dashboard server to send the submission
to. If not given, the :variable:`CTEST_SUBMIT_URL` variable is used.
``BUILD_ID <result-var>``
Store in the ``<result-var>`` variable the ID assigned to this build by
CDash.
``HTTPHEADER <HTTP-header>``
Specify HTTP header to be included in the request to CDash during submission.
For example, CDash can be configured to only accept submissions from
@@ -94,5 +99,6 @@ with a content hash of the file. If CDash does not already have the file,
then it is uploaded. Along with the file, a CDash type string is specified
to tell CDash which handler to use to process the data.
This signature accepts the ``SUBMIT_URL``, ``HTTPHEADER``, ``RETRY_COUNT``,
``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options as described above.
This signature accepts the ``SUBMIT_URL``, ``BUILD_ID``, ``HTTPHEADER``,
``RETRY_COUNT``, ``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options
as described above.

View File

@@ -0,0 +1,6 @@
ctest_submit_get_buildid
--------------------------
* The :command:`ctest_submit` command learned a new option: ``BUILD_ID``.
This can be used to store the ID assigned to this build by CDash to a
variable.

View File

@@ -12,6 +12,29 @@
class cmExecutionStatus;
cmCTestSubmitCommand::cmCTestSubmitCommand()
{
this->PartsMentioned = false;
this->FilesMentioned = false;
this->InternalTest = false;
this->RetryCount = "";
this->RetryDelay = "";
this->CDashUpload = false;
this->Arguments[cts_BUILD_ID] = "BUILD_ID";
this->Last = cts_LAST;
}
/**
* This is a virtual constructor for the command.
*/
cmCommand* cmCTestSubmitCommand::Clone()
{
cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
}
cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
{
const char* submitURL = !this->SubmitURL.empty()
@@ -111,7 +134,15 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD";
return this->cmCTestHandlerCommand::InitialPass(args, status);
bool ret = this->cmCTestHandlerCommand::InitialPass(args, status);
if (this->Values[cts_BUILD_ID] && *this->Values[cts_BUILD_ID]) {
this->Makefile->AddDefinition(this->Values[cts_BUILD_ID],
this->CTest->GetBuildID().c_str());
}
return ret;
}
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)

View File

@@ -25,26 +25,8 @@ class cmExecutionStatus;
class cmCTestSubmitCommand : public cmCTestHandlerCommand
{
public:
cmCTestSubmitCommand()
{
this->PartsMentioned = false;
this->FilesMentioned = false;
this->InternalTest = false;
this->RetryCount = "";
this->RetryDelay = "";
this->CDashUpload = false;
}
/**
* This is a virtual constructor for the command.
*/
cmCommand* Clone() override
{
cmCTestSubmitCommand* ni = new cmCTestSubmitCommand;
ni->CTest = this->CTest;
ni->CTestScriptHandler = this->CTestScriptHandler;
return ni;
}
cmCTestSubmitCommand();
cmCommand* Clone() override;
bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override;
@@ -75,6 +57,12 @@ protected:
ArgumentDoingLast2
};
enum
{
cts_BUILD_ID = ct_LAST,
cts_LAST
};
bool PartsMentioned;
std::set<cmCTest::Part> Parts;
bool FilesMentioned;

View File

@@ -31,7 +31,7 @@ run_ctest_submit(CDashUploadNone CDASH_UPLOAD)
run_ctest_submit(CDashUploadMissingFile CDASH_UPLOAD bad-upload)
run_ctest_submit(CDashUploadRetry CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo RETRY_COUNT 2 RETRY_DELAY 1 INTERNAL_TEST_CHECKSUM)
run_ctest_submit(CDashSubmitQuiet QUIET)
run_ctest_submit_debug(CDashSubmitVerbose)
run_ctest_submit_debug(CDashSubmitVerbose BUILD_ID my_build_id)
run_ctest_submit_debug(FILESNoBuildId FILES ${CMAKE_CURRENT_LIST_FILE})
run_ctest_submit_debug(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf")
run_ctest_submit_debug(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf")