summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestTestCommand.cxx
blob: 24de5b4034aaef1cc9fd19c5257f47d20d080639 (plain)
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
/* 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 "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestTestHandler.h"
#include "cmDuration.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"

#include <chrono>
#include <sstream>
#include <stdlib.h>
#include <vector>

cmCTestTestCommand::cmCTestTestCommand()
{
  this->Arguments[ctt_START] = "START";
  this->Arguments[ctt_END] = "END";
  this->Arguments[ctt_STRIDE] = "STRIDE";
  this->Arguments[ctt_EXCLUDE] = "EXCLUDE";
  this->Arguments[ctt_INCLUDE] = "INCLUDE";
  this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL";
  this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL";
  this->Arguments[ctt_EXCLUDE_FIXTURE] = "EXCLUDE_FIXTURE";
  this->Arguments[ctt_EXCLUDE_FIXTURE_SETUP] = "EXCLUDE_FIXTURE_SETUP";
  this->Arguments[ctt_EXCLUDE_FIXTURE_CLEANUP] = "EXCLUDE_FIXTURE_CLEANUP";
  this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL";
  this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM";
  this->Arguments[ctt_STOP_TIME] = "STOP_TIME";
  this->Arguments[ctt_TEST_LOAD] = "TEST_LOAD";
  this->Arguments[ctt_LAST] = nullptr;
  this->Last = ctt_LAST;
}

cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
{
  const char* ctestTimeout =
    this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");

  cmDuration timeout;
  if (ctestTimeout) {
    timeout = cmDuration(atof(ctestTimeout));
  } 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);
  cmCTestGenericHandler* handler = this->InitializeActualHandler();
  if (this->Values[ctt_START] || this->Values[ctt_END] ||
      this->Values[ctt_STRIDE]) {
    std::ostringstream testsToRunString;
    if (this->Values[ctt_START]) {
      testsToRunString << this->Values[ctt_START];
    }
    testsToRunString << ",";
    if (this->Values[ctt_END]) {
      testsToRunString << this->Values[ctt_END];
    }
    testsToRunString << ",";
    if (this->Values[ctt_STRIDE]) {
      testsToRunString << this->Values[ctt_STRIDE];
    }
    handler->SetOption("TestsToRunInformation",
                       testsToRunString.str().c_str());
  }
  if (this->Values[ctt_EXCLUDE]) {
    handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
  }
  if (this->Values[ctt_INCLUDE]) {
    handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
  }
  if (this->Values[ctt_EXCLUDE_LABEL]) {
    handler->SetOption("ExcludeLabelRegularExpression",
                       this->Values[ctt_EXCLUDE_LABEL]);
  }
  if (this->Values[ctt_INCLUDE_LABEL]) {
    handler->SetOption("LabelRegularExpression",
                       this->Values[ctt_INCLUDE_LABEL]);
  }
  if (this->Values[ctt_EXCLUDE_FIXTURE]) {
    handler->SetOption("ExcludeFixtureRegularExpression",
                       this->Values[ctt_EXCLUDE_FIXTURE]);
  }
  if (this->Values[ctt_EXCLUDE_FIXTURE_SETUP]) {
    handler->SetOption("ExcludeFixtureSetupRegularExpression",
                       this->Values[ctt_EXCLUDE_FIXTURE_SETUP]);
  }
  if (this->Values[ctt_EXCLUDE_FIXTURE_CLEANUP]) {
    handler->SetOption("ExcludeFixtureCleanupRegularExpression",
                       this->Values[ctt_EXCLUDE_FIXTURE_CLEANUP]);
  }
  if (this->Values[ctt_PARALLEL_LEVEL]) {
    handler->SetOption("ParallelLevel", this->Values[ctt_PARALLEL_LEVEL]);
  }
  if (this->Values[ctt_SCHEDULE_RANDOM]) {
    handler->SetOption("ScheduleRandom", this->Values[ctt_SCHEDULE_RANDOM]);
  }
  if (this->Values[ctt_STOP_TIME]) {
    this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
  }

  // 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;
  const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
  if (this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD]) {
    if (!cmStrToULong(this->Values[ctt_TEST_LOAD], &testLoad)) {
      testLoad = 0;
      cmCTestLog(this->CTest, WARNING,
                 "Invalid value for 'TEST_LOAD' : "
                   << this->Values[ctt_TEST_LOAD] << std::endl);
    }
  } else if (ctestTestLoad && *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 (const char* labelsForSubprojects =
        this->Makefile->GetDefinition("CTEST_LABELS_FOR_SUBPROJECTS")) {
    this->CTest->SetCTestConfiguration("LabelsForSubprojects",
                                       labelsForSubprojects, this->Quiet);
  }

  handler->SetQuiet(this->Quiet);
  return handler;
}

cmCTestGenericHandler* cm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