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
+8 -2
View File
@@ -7,6 +7,7 @@ Perform the :ref:`CTest Submit Step` as a :ref:`Dashboard Client`.
ctest_submit([PARTS <part>...] [FILES <file>...] ctest_submit([PARTS <part>...] [FILES <file>...]
[SUBMIT_URL <url>] [SUBMIT_URL <url>]
[BUILD_ID <result-var>]
[HTTPHEADER <header>] [HTTPHEADER <header>]
[RETRY_COUNT <count>] [RETRY_COUNT <count>]
[RETRY_DELAY <delay>] [RETRY_DELAY <delay>]
@@ -44,6 +45,10 @@ The options are:
The ``http`` or ``https`` URL of the dashboard server to send the submission 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. 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>`` ``HTTPHEADER <HTTP-header>``
Specify HTTP header to be included in the request to CDash during submission. Specify HTTP header to be included in the request to CDash during submission.
For example, CDash can be configured to only accept submissions from 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 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. to tell CDash which handler to use to process the data.
This signature accepts the ``SUBMIT_URL``, ``HTTPHEADER``, ``RETRY_COUNT``, This signature accepts the ``SUBMIT_URL``, ``BUILD_ID``, ``HTTPHEADER``,
``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options as described above. ``RETRY_COUNT``, ``RETRY_DELAY``, ``RETURN_VALUE`` and ``QUIET`` options
as described above.
@@ -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.
+32 -1
View File
@@ -12,6 +12,29 @@
class cmExecutionStatus; 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() cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
{ {
const char* submitURL = !this->SubmitURL.empty() const char* submitURL = !this->SubmitURL.empty()
@@ -111,7 +134,15 @@ bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) cmExecutionStatus& status)
{ {
this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD"; 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) bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
+8 -20
View File
@@ -25,26 +25,8 @@ class cmExecutionStatus;
class cmCTestSubmitCommand : public cmCTestHandlerCommand class cmCTestSubmitCommand : public cmCTestHandlerCommand
{ {
public: public:
cmCTestSubmitCommand() cmCTestSubmitCommand();
{ cmCommand* Clone() override;
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;
}
bool InitialPass(std::vector<std::string> const& args, bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus& status) override; cmExecutionStatus& status) override;
@@ -75,6 +57,12 @@ protected:
ArgumentDoingLast2 ArgumentDoingLast2
}; };
enum
{
cts_BUILD_ID = ct_LAST,
cts_LAST
};
bool PartsMentioned; bool PartsMentioned;
std::set<cmCTest::Part> Parts; std::set<cmCTest::Part> Parts;
bool FilesMentioned; bool FilesMentioned;
@@ -31,7 +31,7 @@ run_ctest_submit(CDashUploadNone CDASH_UPLOAD)
run_ctest_submit(CDashUploadMissingFile CDASH_UPLOAD bad-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(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(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(FILESNoBuildId FILES ${CMAKE_CURRENT_LIST_FILE})
run_ctest_submit_debug(CDashSubmitHeaders HTTPHEADER "Authorization: Bearer asdf") 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") run_ctest_submit_debug(CDashUploadHeaders CDASH_UPLOAD ${CMAKE_CURRENT_LIST_FILE} CDASH_UPLOAD_TYPE foo HTTPHEADER "Authorization: Bearer asdf")