| 140 | } // namespace |
| 141 | |
| 142 | bool cmCTestUpdateCommand::ExecuteUpdate(UpdateArguments& args, |
| 143 | cmExecutionStatus& status) const |
| 144 | { |
| 145 | cmMakefile& mf = status.GetMakefile(); |
| 146 | |
| 147 | std::string const& source_dir = !args.Source.empty() |
| 148 | ? args.Source |
| 149 | : mf.GetSafeDefinition("CTEST_SOURCE_DIRECTORY"); |
| 150 | if (source_dir.empty()) { |
| 151 | status.SetError("called with no source directory specified. " |
| 152 | "Use SOURCE argument or set CTEST_SOURCE_DIRECTORY."); |
| 153 | return false; |
| 154 | } |
| 155 | |
| 156 | std::string const currentTag = this->CTest->GetCurrentTag(); |
| 157 | if (currentTag.empty()) { |
| 158 | status.SetError("called with no current tag."); |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | // Detect the VCS managing the source tree. |
| 163 | int updateType = DetectVCS(source_dir); |
| 164 | |
| 165 | // Get update command |
| 166 | std::string updateCommand = mf.GetSafeDefinition("CTEST_UPDATE_COMMAND"); |
| 167 | |
| 168 | if (updateType == e_UNKNOWN && !updateCommand.empty()) { |
| 169 | updateType = DetermineType(updateCommand); |
| 170 | } |
| 171 | if (updateType == e_UNKNOWN) { |
| 172 | updateType = DetermineType(mf.GetSafeDefinition("CTEST_UPDATE_TYPE")); |
| 173 | } |
| 174 | |
| 175 | // If no update command was specified, lookup one for this VCS tool. |
| 176 | if (updateCommand.empty()) { |
| 177 | char const* key = TypeToCommandKey(updateType); |
| 178 | if (key) { |
| 179 | updateCommand = mf.GetSafeDefinition(key); |
| 180 | } |
| 181 | |
| 182 | if (updateCommand.empty()) { |
| 183 | std::ostringstream e; |
| 184 | e << "called with no update command specified. " |
| 185 | "Please set CTEST_UPDATE_COMMAND"; |
| 186 | if (key) { |
| 187 | e << " or " << key; |
| 188 | } |
| 189 | e << '.'; |
| 190 | status.SetError(e.str()); |
| 191 | return false; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | cmGeneratedFileStream ofs; |
| 196 | if (!this->CTest->GetShowOnly()) { |
| 197 | std::string logFile = cmStrCat("LastUpdate_", currentTag, ".log"); |
| 198 | if (!this->CTest->OpenOutputFile("Temporary", logFile, ofs)) { |
| 199 | status.SetError(cmStrCat("cannot create log file: ", logFile)); |
no test coverage detected