summaryrefslogtreecommitdiff
path: root/Source/cmTest.cxx
blob: 912ec7634af7eb6db4aeb7ec6f56fb49f355da33 (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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*============================================================================
  CMake - Cross Platform Makefile Generator
  Copyright 2000-2009 Kitware, Inc., Insight Software Consortium

  Distributed under the OSI-approved BSD License (the "License");
  see accompanying file Copyright.txt for details.

  This software is distributed WITHOUT ANY WARRANTY; without even the
  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  See the License for more information.
============================================================================*/
#include "cmTest.h"
#include "cmSystemTools.h"

#include "cmake.h"
#include "cmMakefile.h"

//----------------------------------------------------------------------------
cmTest::cmTest(cmMakefile* mf)
{
  this->Makefile = mf;
  this->OldStyle = true;
  this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
  this->Backtrace = new cmListFileBacktrace;
  this->Makefile->GetBacktrace(*this->Backtrace);
}

//----------------------------------------------------------------------------
cmTest::~cmTest()
{
  delete this->Backtrace;
}

//----------------------------------------------------------------------------
cmListFileBacktrace const& cmTest::GetBacktrace() const
{
  return *this->Backtrace;
}

//----------------------------------------------------------------------------
void cmTest::SetName(const char* name)
{
  if ( !name )
    {
    name = "";
    }
  this->Name = name;
}

//----------------------------------------------------------------------------
void cmTest::SetCommand(std::vector<std::string> const& command)
{
  this->Command = command;
}

//----------------------------------------------------------------------------
const char *cmTest::GetProperty(const char* prop) const
{
  bool chain = false;
  const char *retVal =
    this->Properties.GetPropertyValue(prop, cmProperty::TEST, chain);
  if (chain)
    {
    return this->Makefile->GetProperty(prop,cmProperty::TEST);
    }
  return retVal;
}

//----------------------------------------------------------------------------
bool cmTest::GetPropertyAsBool(const char* prop) const
{
  return cmSystemTools::IsOn(this->GetProperty(prop));
}

//----------------------------------------------------------------------------
void cmTest::SetProperty(const char* prop, const char* value)
{
  if (!prop)
    {
    return;
    }

  this->Properties.SetProperty(prop, value, cmProperty::TEST);
}

//----------------------------------------------------------------------------
void cmTest::AppendProperty(const char* prop, const char* value, bool asString)
{
  if (!prop)
    {
    return;
    }
  this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString);
}

//----------------------------------------------------------------------------
void cmTest::DefineProperties(cmake *cm)
{
  cm->DefineProperty
    ("ATTACHED_FILES", cmProperty::TEST,
     "Attach a list of files to a dashboard submission.",
     "Set this property to a list of files that will be encoded and "
     "submitted to the dashboard as an addition to the test result.");

  cm->DefineProperty
    ("ATTACHED_FILES_ON_FAIL", cmProperty::TEST,
     "Attach a list of files to a dashboard submission if the test fails.",
     "Same as ATTACHED_FILES, but these files will only be included if the "
     "test does not pass.");

  cm->DefineProperty
    ("COST", cmProperty::TEST,
     "Set this to a floating point value. Tests in a test set will be "
     "run in descending order of cost.", "This property describes the cost "
     "of a test. You can explicitly set this value; tests with higher COST "
     "values will run first.");

  cm->DefineProperty
    ("DEPENDS", cmProperty::TEST,
     "Specifies that this test should only be run after the specified "
     "list of tests.",
     "Set this to a list of tests that must finish before this test is run.");

  cm->DefineProperty
    ("ENVIRONMENT", cmProperty::TEST,
     "Specify environment variables that should be defined for running "
     "a test.",
     "If set to a list of environment variables and values of the form "
     "MYVAR=value those environment variables will be defined while "
     "running the test. The environment is restored to its previous state "
     "after the test is done.");

  cm->DefineProperty
    ("FAIL_REGULAR_EXPRESSION", cmProperty::TEST,
     "If the output matches this regular expression the test will fail.",
     "If set, if the output matches one of "
     "specified regular expressions, the test will fail."
     "For example: PASS_REGULAR_EXPRESSION \"[^a-z]Error;ERROR;Failed\"");

  cm->DefineProperty
    ("LABELS", cmProperty::TEST,
     "Specify a list of text labels associated with a test.",
     "The list is reported in dashboard submissions.");

  cm->DefineProperty
    ("RESOURCE_LOCK", cmProperty::TEST,
    "Specify a list of resources that are locked by this test.",
    "If multiple tests specify the same resource lock, they are guaranteed "
    "not to run concurrently.");

  cm->DefineProperty
    ("MEASUREMENT", cmProperty::TEST,
     "Specify a CDASH measurement and value to be reported for a test.",
     "If set to a name then that name will be reported to CDASH as a "
     "named measurement with a value of 1. You may also specify a value "
     "by setting MEASUREMENT to \"measurement=value\".");

  cm->DefineProperty
    ("PASS_REGULAR_EXPRESSION", cmProperty::TEST,
     "The output must match this regular expression for the test to pass.",
     "If set, the test output will be checked "
     "against the specified regular expressions and at least one of the"
     " regular expressions has to match, otherwise the test will fail.");

  cm->DefineProperty
    ("PROCESSORS", cmProperty::TEST,
     "How many process slots this test requires",
     "Denotes the number of processors that this test will require. This is "
     "typically used for MPI tests, and should be used in conjunction with "
     "the ctest_test PARALLEL_LEVEL option.");

  cm->DefineProperty
    ("REQUIRED_FILES", cmProperty::TEST,
     "List of files required to run the test.",
     "If set to a list of files, the test will not be run unless all of the "
     "files exist.");

  cm->DefineProperty
    ("RUN_SERIAL", cmProperty::TEST,
     "Do not run this test in parallel with any other test.",
     "Use this option in conjunction with the ctest_test PARALLEL_LEVEL "
     "option to specify that this test should not be run in parallel with "
     "any other tests.");

  cm->DefineProperty
    ("TIMEOUT", cmProperty::TEST,
     "How many seconds to allow for this test.",
     "This property if set will limit a test to not take more than "
     "the specified number of seconds to run. If it exceeds that the "
     "test process will be killed and ctest will move to the next test. "
     "This setting takes precedence over "
     "CTEST_TESTING_TIMEOUT.");

  cm->DefineProperty
    ("WILL_FAIL", cmProperty::TEST,
     "If set to true, this will invert the pass/fail flag of the test.",
     "This property can be used for tests that are expected to fail and "
     "return a non zero return code.");

  cm->DefineProperty
    ("WORKING_DIRECTORY", cmProperty::TEST,
     "The directory from which the test executable will be called.",
     "If this is not set it is called from the directory the test executable "
     "is located in.");
}