~ubuntu-branches/ubuntu/jaunty/cmake/jaunty-security

« back to all changes in this revision

Viewing changes to Source/CTest/cmCTestHandlerCommand.cxx

  • Committer: Bazaar Package Importer
  • Author(s): A. Maitland Bottoms
  • Date: 2006-06-18 16:34:11 UTC
  • mfrom: (1.4.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060618163411-pi234s3v6jwlcmof
Tags: 2.4.2-1
* New upstream release (Closes: #338324)
* Put cmake .vim files into /usr/share/vim/addons/plugin/
  where they can be used. (Closes: #366663)
* Install cmake-mode.el so it can be used. (Closes: #366664)
* Ensure cmake FindKDE locates KDE libraries on Debian
  based distributions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
  Program:   CMake - Cross-Platform Makefile Generator
4
4
  Module:    $RCSfile: cmCTestHandlerCommand.cxx,v $
5
5
  Language:  C++
6
 
  Date:      $Date: 2005/06/23 17:04:17 $
7
 
  Version:   $Revision: 1.1 $
 
6
  Date:      $Date: 2006/05/11 02:15:09 $
 
7
  Version:   $Revision: 1.7.2.1 $
8
8
 
9
9
  Copyright (c) 2002 Kitware, Inc., Insight Consortium.  All rights reserved.
10
10
  See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
11
11
 
12
 
     This software is distributed WITHOUT ANY WARRANTY; without even 
13
 
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
 
12
     This software is distributed WITHOUT ANY WARRANTY; without even
 
13
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
14
     PURPOSE.  See the above copyright notices for more information.
15
15
 
16
16
=========================================================================*/
23
23
{
24
24
  const size_t INIT_SIZE = 100;
25
25
  size_t cc;
26
 
  m_Arguments.reserve(INIT_SIZE);
 
26
  this->Arguments.reserve(INIT_SIZE);
27
27
  for ( cc = 0; cc < INIT_SIZE; ++ cc )
28
28
    {
29
 
    m_Arguments[cc] = 0;
 
29
    this->Arguments.push_back(0);
30
30
    }
31
 
  m_Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
32
 
  m_Arguments[ct_SOURCE] = "SOURCE";
33
 
  m_Arguments[ct_BUILD] = "BUILD";
34
 
  m_Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX";
35
 
  m_Last = ct_LAST;
 
31
  this->Arguments[ct_RETURN_VALUE] = "RETURN_VALUE";
 
32
  this->Arguments[ct_SOURCE] = "SOURCE";
 
33
  this->Arguments[ct_BUILD] = "BUILD";
 
34
  this->Arguments[ct_SUBMIT_INDEX] = "SUBMIT_INDEX";
 
35
  this->Last = ct_LAST;
36
36
}
37
37
 
38
38
bool cmCTestHandlerCommand::InitialPass(
39
39
  std::vector<std::string> const& args)
40
40
{
41
 
  if ( !this->ProcessArguments(args, m_Last, &*m_Arguments.begin(), m_Values) )
 
41
  if ( !this->ProcessArguments(args, (unsigned int)this->Last, 
 
42
                               &*this->Arguments.begin(),this->Values) )
42
43
    {
43
44
    return false;
44
45
    }
45
46
 
 
47
  cmCTestLog(this->CTest, DEBUG, "Initialize handler" << std::endl;);
46
48
  cmCTestGenericHandler* handler = this->InitializeHandler();
47
49
  if ( !handler )
48
50
    {
50
52
    return false;
51
53
    }
52
54
 
53
 
  if ( m_Values[ct_BUILD] )
54
 
    {
55
 
    m_CTest->SetCTestConfiguration("BuildDirectory", m_Values[ct_BUILD]);
56
 
    }
57
 
  if ( m_Values[ct_SUBMIT_INDEX] )
58
 
    {
59
 
    if ( m_CTest->GetDartVersion() <= 1 )
 
55
  cmCTestLog(this->CTest, DEBUG, "Populate Custom Vectors" << std::endl;);
 
56
  handler->PopulateCustomVectors(this->Makefile);
 
57
 
 
58
  if ( this->Values[ct_BUILD] )
 
59
    {
 
60
    this->CTest->SetCTestConfiguration("BuildDirectory",
 
61
      this->Values[ct_BUILD]);
 
62
    }
 
63
  else
 
64
    {
 
65
    this->CTest->SetCTestConfiguration("BuildDirectory",
 
66
      this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY"));
 
67
    }
 
68
  if ( this->Values[ct_SOURCE] )
 
69
    {
 
70
    cmCTestLog(this->CTest, DEBUG,
 
71
      "Set source directory to: " << this->Values[ct_SOURCE] << std::endl);
 
72
    this->CTest->SetCTestConfiguration("SourceDirectory",
 
73
      this->Values[ct_SOURCE]);
 
74
    }
 
75
  else
 
76
    {
 
77
    this->CTest->SetCTestConfiguration("SourceDirectory",
 
78
      this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY"));
 
79
    }
 
80
  if ( this->Values[ct_SUBMIT_INDEX] )
 
81
    {
 
82
    if ( this->CTest->GetDartVersion() <= 1 )
60
83
      {
61
 
      cmCTestLog(m_CTest, ERROR_MESSAGE, "Dart before version 2.0 does not support collecting submissions." << std::endl
62
 
        << "Please upgrade the server to Dart 2 or higher, or do not use SUBMIT_INDEX." << std::endl);
 
84
      cmCTestLog(this->CTest, ERROR_MESSAGE,
 
85
        "Dart before version 2.0 does not support collecting submissions."
 
86
        << std::endl
 
87
        << "Please upgrade the server to Dart 2 or higher, or do not use "
 
88
        "SUBMIT_INDEX." << std::endl);
63
89
      }
64
90
    else
65
91
      {
66
 
      handler->SetSubmitIndex(atoi(m_Values[ct_SUBMIT_INDEX]));
 
92
      handler->SetSubmitIndex(atoi(this->Values[ct_SUBMIT_INDEX]));
67
93
      }
68
94
    }
69
95
 
70
 
 
71
96
  std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
72
 
  cmSystemTools::ChangeDirectory(m_CTest->GetCTestConfiguration("BuildDirectory").c_str());
 
97
  cmSystemTools::ChangeDirectory(
 
98
    this->CTest->GetCTestConfiguration("BuildDirectory").c_str());
73
99
  int res = handler->ProcessHandler();
74
 
  if ( m_Values[ct_RETURN_VALUE] && *m_Values[ct_RETURN_VALUE])
 
100
  if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE])
75
101
    {
76
102
    cmOStringStream str;
77
103
    str << res;
78
 
    m_Makefile->AddDefinition(m_Values[ct_RETURN_VALUE], str.str().c_str());
 
104
    this->Makefile->AddDefinition(
 
105
      this->Values[ct_RETURN_VALUE], str.str().c_str());
79
106
    }
80
107
  cmSystemTools::ChangeDirectory(current_dir.c_str());
81
108
  return true;
82
109
}
83
110
 
84
 
bool cmCTestHandlerCommand::ProcessArguments(std::vector<std::string> const& args,
85
 
  int last, const char** strings, std::vector<const char*>& values)
 
111
bool cmCTestHandlerCommand::ProcessArguments(
 
112
  std::vector<std::string> const& args, int last, const char** strings,
 
113
  std::vector<const char*>& values)
86
114
{
87
115
  int state = 0;
88
116
  int cc;
97
125
    if ( state > 0 && state < last )
98
126
      {
99
127
      values[state] = args[i].c_str();
100
 
#undef cerr
101
 
      cmCTestLog(m_CTest, DEBUG, "Set " << strings[state] << " to " << args[i].c_str() << std::endl);
 
128
      cmCTestLog(this->CTest, DEBUG, "Set " << strings[state] << " to "
 
129
        << args[i].c_str() << std::endl);
102
130
      state = 0;
103
131
      }
104
132
    else
112
140
          if ( values[state] )
113
141
            {
114
142
            cmOStringStream ostr;
115
 
            ostr << "called with incorrect number of arguments. " << strings[state] << " specified twice.";
 
143
            ostr << "called with incorrect number of arguments. "
 
144
              << strings[state] << " specified twice.";
116
145
            this->SetError(ostr.str().c_str());
117
146
            return false;
118
147
            }
123
152
      if ( !found )
124
153
        {
125
154
        cmOStringStream str;
126
 
        str << "called with incorrect number of arguments. Extra argument is: " << args[i].c_str() << ".";
 
155
        str
 
156
          << "called with incorrect number of arguments. Extra argument is: "
 
157
          << args[i].c_str() << ".";
127
158
        this->SetError(str.str().c_str());
128
159
        return false;
129
160
        }