1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestTestCommand.h"
#include <chrono>
#include <cstdlib>
#include <ratio>
#include <sstream>
#include <cmext/string_view>
#include "cmCTest.h"
#include "cmCTestTestHandler.h"
#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmValue.h"
void cmCTestTestCommand::BindArguments()
{
this->cmCTestHandlerCommand::BindArguments();
this->Bind("START"_s, this->Start);
this->Bind("END"_s, this->End);
this->Bind("STRIDE"_s, this->Stride);
this->Bind("EXCLUDE"_s, this->Exclude);
this->Bind("INCLUDE"_s, this->Include);
this->Bind("EXCLUDE_LABEL"_s, this->ExcludeLabel);
this->Bind("INCLUDE_LABEL"_s, this->IncludeLabel);
this->Bind("EXCLUDE_FROM_FILE"_s, this->ExcludeTestsFromFile);
this->Bind("INCLUDE_FROM_FILE"_s, this->IncludeTestsFromFile);
this->Bind("EXCLUDE_FIXTURE"_s, this->ExcludeFixture);
this->Bind("EXCLUDE_FIXTURE_SETUP"_s, this->ExcludeFixtureSetup);
this->Bind("EXCLUDE_FIXTURE_CLEANUP"_s, this->ExcludeFixtureCleanup);
this->Bind("PARALLEL_LEVEL"_s, this->ParallelLevel);
this->Bind("REPEAT"_s, this->Repeat);
this->Bind("SCHEDULE_RANDOM"_s, this->ScheduleRandom);
this->Bind("STOP_TIME"_s, this->StopTime);
this->Bind("TEST_LOAD"_s, this->TestLoad);
this->Bind("RESOURCE_SPEC_FILE"_s, this->ResourceSpecFile);
this->Bind("STOP_ON_FAILURE"_s, this->StopOnFailure);
this->Bind("OUTPUT_JUNIT"_s, this->OutputJUnit);
}
cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
{
cmValue ctestTimeout = this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
cmDuration timeout;
if (ctestTimeout) {
timeout = cmDuration(atof(ctestTimeout->c_str()));
} else {
timeout = this->CTest->GetTimeOut();
if (timeout <= cmDuration::zero()) {
// By default use timeout of 10 minutes
timeout = std::chrono::minutes(10);
}
}
this->CTest->SetTimeOut(timeout);
cmValue resourceSpecFile =
this->Makefile->GetDefinition("CTEST_RESOURCE_SPEC_FILE");
if (this->ResourceSpecFile.empty() && resourceSpecFile) {
this->ResourceSpecFile = *resourceSpecFile;
}
cmCTestTestHandler* handler = this->InitializeActualHandler();
if (!this->Start.empty() || !this->End.empty() || !this->Stride.empty()) {
handler->SetOption(
"TestsToRunInformation",
cmStrCat(this->Start, ',', this->End, ',', this->Stride));
}
if (!this->Exclude.empty()) {
handler->SetOption("ExcludeRegularExpression", this->Exclude);
}
if (!this->Include.empty()) {
handler->SetOption("IncludeRegularExpression", this->Include);
}
if (!this->ExcludeLabel.empty()) {
handler->AddMultiOption("ExcludeLabelRegularExpression",
this->ExcludeLabel);
}
if (!this->IncludeLabel.empty()) {
handler->AddMultiOption("LabelRegularExpression", this->IncludeLabel);
}
if (!this->ExcludeTestsFromFile.empty()) {
handler->SetOption("ExcludeTestListFile", this->ExcludeTestsFromFile);
}
if (!this->IncludeTestsFromFile.empty()) {
handler->SetOption("TestListFile", this->IncludeTestsFromFile);
}
if (!this->ExcludeFixture.empty()) {
handler->SetOption("ExcludeFixtureRegularExpression",
this->ExcludeFixture);
}
if (!this->ExcludeFixtureSetup.empty()) {
handler->SetOption("ExcludeFixtureSetupRegularExpression",
this->ExcludeFixtureSetup);
}
if (!this->ExcludeFixtureCleanup.empty()) {
handler->SetOption("ExcludeFixtureCleanupRegularExpression",
this->ExcludeFixtureCleanup);
}
if (this->StopOnFailure) {
handler->SetOption("StopOnFailure", "ON");
}
if (!this->ParallelLevel.empty()) {
handler->SetOption("ParallelLevel", this->ParallelLevel);
}
if (!this->Repeat.empty()) {
handler->SetOption("Repeat", this->Repeat);
}
if (!this->ScheduleRandom.empty()) {
handler->SetOption("ScheduleRandom", this->ScheduleRandom);
}
if (!this->ResourceSpecFile.empty()) {
handler->SetOption("ResourceSpecFile", this->ResourceSpecFile);
}
if (!this->StopTime.empty()) {
this->CTest->SetStopTime(this->StopTime);
}
// Test load is determined by: TEST_LOAD argument,
// or CTEST_TEST_LOAD script variable, or ctest --test-load
// command line argument... in that order.
unsigned long testLoad;
cmValue ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
if (!this->TestLoad.empty()) {
if (!cmStrToULong(this->TestLoad, &testLoad)) {
testLoad = 0;
cmCTestLog(this->CTest, WARNING,
"Invalid value for 'TEST_LOAD' : " << this->TestLoad
<< std::endl);
}
} else if (cmNonempty(ctestTestLoad)) {
if (!cmStrToULong(*ctestTestLoad, &testLoad)) {
testLoad = 0;
cmCTestLog(this->CTest, WARNING,
"Invalid value for 'CTEST_TEST_LOAD' : " << *ctestTestLoad
<< std::endl);
}
} else {
testLoad = this->CTest->GetTestLoad();
}
handler->SetTestLoad(testLoad);
if (cmValue labelsForSubprojects =
this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
this->CTest->SetCTestConfiguration("LabelsForSubprojects",
*labelsForSubprojects, this->Quiet);
}
if (!this->OutputJUnit.empty()) {
handler->SetJUnitXMLFileName(this->OutputJUnit);
}
handler->SetQuiet(this->Quiet);
return handler;
}
cmCTestTestHandler* cmCTestTestCommand::InitializeActualHandler()
{
cmCTestTestHandler* handler = this->CTest->GetTestHandler();
handler->Initialize();
return handler;
}
|