cmCTestLaunch.cxx 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCTestLaunch.h"
  11. #include "cmGeneratedFileStream.h"
  12. #include "cmSystemTools.h"
  13. #include "cmXMLSafe.h"
  14. #include "cmake.h"
  15. #include <cmsys/MD5.h>
  16. #include <cmsys/Process.h>
  17. #include <cmsys/RegularExpression.hxx>
  18. //----------------------------------------------------------------------------
  19. cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
  20. {
  21. this->Passthru = true;
  22. this->Process = 0;
  23. this->ExitCode = 1;
  24. this->CWD = cmSystemTools::GetCurrentWorkingDirectory();
  25. if(!this->ParseArguments(argc, argv))
  26. {
  27. return;
  28. }
  29. this->ComputeFileNames();
  30. this->ScrapeRulesLoaded = false;
  31. this->HaveOut = false;
  32. this->HaveErr = false;
  33. this->Process = cmsysProcess_New();
  34. }
  35. //----------------------------------------------------------------------------
  36. cmCTestLaunch::~cmCTestLaunch()
  37. {
  38. cmsysProcess_Delete(this->Process);
  39. if(!this->Passthru)
  40. {
  41. cmSystemTools::RemoveFile(this->LogOut.c_str());
  42. cmSystemTools::RemoveFile(this->LogErr.c_str());
  43. }
  44. }
  45. //----------------------------------------------------------------------------
  46. bool cmCTestLaunch::ParseArguments(int argc, const char* const* argv)
  47. {
  48. // Launcher options occur first and are separated from the real
  49. // command line by a '--' option.
  50. enum Doing { DoingNone,
  51. DoingOutput,
  52. DoingSource,
  53. DoingLanguage,
  54. DoingTargetName,
  55. DoingTargetType,
  56. DoingBuildDir,
  57. DoingCount };
  58. Doing doing = DoingNone;
  59. int arg0 = 0;
  60. for(int i=1; !arg0 && i < argc; ++i)
  61. {
  62. const char* arg = argv[i];
  63. if(strcmp(arg, "--") == 0)
  64. {
  65. arg0 = i+1;
  66. }
  67. else if(strcmp(arg, "--output") == 0)
  68. {
  69. doing = DoingOutput;
  70. }
  71. else if(strcmp(arg, "--source") == 0)
  72. {
  73. doing = DoingSource;
  74. }
  75. else if(strcmp(arg, "--language") == 0)
  76. {
  77. doing = DoingLanguage;
  78. }
  79. else if(strcmp(arg, "--target-name") == 0)
  80. {
  81. doing = DoingTargetName;
  82. }
  83. else if(strcmp(arg, "--target-type") == 0)
  84. {
  85. doing = DoingTargetType;
  86. }
  87. else if(strcmp(arg, "--build-dir") == 0)
  88. {
  89. doing = DoingBuildDir;
  90. }
  91. else if(doing == DoingOutput)
  92. {
  93. this->OptionOutput = arg;
  94. doing = DoingNone;
  95. }
  96. else if(doing == DoingSource)
  97. {
  98. this->OptionSource = arg;
  99. doing = DoingNone;
  100. }
  101. else if(doing == DoingLanguage)
  102. {
  103. this->OptionLanguage = arg;
  104. if(this->OptionLanguage == "CXX")
  105. {
  106. this->OptionLanguage = "C++";
  107. }
  108. doing = DoingNone;
  109. }
  110. else if(doing == DoingTargetName)
  111. {
  112. this->OptionTargetName = arg;
  113. doing = DoingNone;
  114. }
  115. else if(doing == DoingTargetType)
  116. {
  117. this->OptionTargetType = arg;
  118. doing = DoingNone;
  119. }
  120. else if(doing == DoingBuildDir)
  121. {
  122. this->OptionBuildDir = arg;
  123. doing = DoingNone;
  124. }
  125. }
  126. // Extract the real command line.
  127. if(arg0)
  128. {
  129. this->RealArgC = argc - arg0;
  130. this->RealArgV = argv + arg0;
  131. for(int i=0; i < this->RealArgC; ++i)
  132. {
  133. this->HandleRealArg(this->RealArgV[i]);
  134. }
  135. return true;
  136. }
  137. else
  138. {
  139. this->RealArgC = 0;
  140. this->RealArgV = 0;
  141. std::cerr << "No launch/command separator ('--') found!\n";
  142. return false;
  143. }
  144. }
  145. //----------------------------------------------------------------------------
  146. void cmCTestLaunch::HandleRealArg(const char* arg)
  147. {
  148. #ifdef _WIN32
  149. // Expand response file arguments.
  150. if(arg[0] == '@' && cmSystemTools::FileExists(arg+1))
  151. {
  152. std::ifstream fin(arg+1);
  153. std::string line;
  154. while(cmSystemTools::GetLineFromStream(fin, line))
  155. {
  156. cmSystemTools::ParseWindowsCommandLine(line.c_str(), this->RealArgs);
  157. }
  158. return;
  159. }
  160. #endif
  161. this->RealArgs.push_back(arg);
  162. }
  163. //----------------------------------------------------------------------------
  164. void cmCTestLaunch::ComputeFileNames()
  165. {
  166. // We just passthru the behavior of the real command unless the
  167. // CTEST_LAUNCH_LOGS environment variable is set.
  168. const char* d = getenv("CTEST_LAUNCH_LOGS");
  169. if(!(d && *d))
  170. {
  171. return;
  172. }
  173. this->Passthru = false;
  174. // The environment variable specifies the directory into which we
  175. // generate build logs.
  176. this->LogDir = d;
  177. cmSystemTools::ConvertToUnixSlashes(this->LogDir);
  178. this->LogDir += "/";
  179. // We hash the input command working dir and command line to obtain
  180. // a repeatable and (probably) unique name for log files.
  181. char hash[32];
  182. cmsysMD5* md5 = cmsysMD5_New();
  183. cmsysMD5_Initialize(md5);
  184. cmsysMD5_Append(md5, (unsigned char const*)(this->CWD.c_str()), -1);
  185. for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
  186. ai != this->RealArgs.end(); ++ai)
  187. {
  188. cmsysMD5_Append(md5, (unsigned char const*)ai->c_str(), -1);
  189. }
  190. cmsysMD5_FinalizeHex(md5, hash);
  191. cmsysMD5_Delete(md5);
  192. this->LogHash.assign(hash, 32);
  193. // We store stdout and stderr in temporary log files.
  194. this->LogOut = this->LogDir;
  195. this->LogOut += "launch-";
  196. this->LogOut += this->LogHash;
  197. this->LogOut += "-out.txt";
  198. this->LogErr = this->LogDir;
  199. this->LogErr += "launch-";
  200. this->LogErr += this->LogHash;
  201. this->LogErr += "-err.txt";
  202. }
  203. //----------------------------------------------------------------------------
  204. void cmCTestLaunch::RunChild()
  205. {
  206. // Ignore noopt make rules
  207. if(this->RealArgs.empty() || this->RealArgs[0] == ":")
  208. {
  209. this->ExitCode = 0;
  210. return;
  211. }
  212. // Prepare to run the real command.
  213. cmsysProcess* cp = this->Process;
  214. cmsysProcess_SetCommand(cp, this->RealArgV);
  215. std::ofstream fout;
  216. std::ofstream ferr;
  217. if(this->Passthru)
  218. {
  219. // In passthru mode we just share the output pipes.
  220. cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDOUT, 1);
  221. cmsysProcess_SetPipeShared(cp, cmsysProcess_Pipe_STDERR, 1);
  222. }
  223. else
  224. {
  225. // In full mode we record the child output pipes to log files.
  226. fout.open(this->LogOut.c_str(),
  227. std::ios::out | std::ios::binary);
  228. ferr.open(this->LogErr.c_str(),
  229. std::ios::out | std::ios::binary);
  230. }
  231. // Run the real command.
  232. cmsysProcess_Execute(cp);
  233. // Record child stdout and stderr if necessary.
  234. if(!this->Passthru)
  235. {
  236. char* data = 0;
  237. int length = 0;
  238. while(int p = cmsysProcess_WaitForData(cp, &data, &length, 0))
  239. {
  240. if(p == cmsysProcess_Pipe_STDOUT)
  241. {
  242. fout.write(data, length);
  243. std::cout.write(data, length);
  244. this->HaveOut = true;
  245. }
  246. else if(p == cmsysProcess_Pipe_STDERR)
  247. {
  248. ferr.write(data, length);
  249. std::cerr.write(data, length);
  250. this->HaveErr = true;
  251. }
  252. }
  253. }
  254. // Wait for the real command to finish.
  255. cmsysProcess_WaitForExit(cp, 0);
  256. this->ExitCode = cmsysProcess_GetExitValue(cp);
  257. }
  258. //----------------------------------------------------------------------------
  259. int cmCTestLaunch::Run()
  260. {
  261. if(!this->Process)
  262. {
  263. std::cerr << "Could not allocate cmsysProcess instance!\n";
  264. return -1;
  265. }
  266. this->RunChild();
  267. if(this->CheckResults())
  268. {
  269. return this->ExitCode;
  270. }
  271. this->LoadConfig();
  272. this->WriteXML();
  273. return this->ExitCode;
  274. }
  275. //----------------------------------------------------------------------------
  276. void cmCTestLaunch::LoadLabels()
  277. {
  278. if(this->OptionBuildDir.empty() || this->OptionTargetName.empty())
  279. {
  280. return;
  281. }
  282. // Labels are listed in per-target files.
  283. std::string fname = this->OptionBuildDir;
  284. fname += cmake::GetCMakeFilesDirectory();
  285. fname += "/";
  286. fname += this->OptionTargetName;
  287. fname += ".dir/Labels.txt";
  288. // We are interested in per-target labels for this source file.
  289. std::string source = this->OptionSource;
  290. cmSystemTools::ConvertToUnixSlashes(source);
  291. // Load the labels file.
  292. std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
  293. if(!fin) { return; }
  294. bool inTarget = true;
  295. bool inSource = false;
  296. std::string line;
  297. while(cmSystemTools::GetLineFromStream(fin, line))
  298. {
  299. if(line.empty() || line[0] == '#')
  300. {
  301. // Ignore blank and comment lines.
  302. continue;
  303. }
  304. else if(line[0] == ' ')
  305. {
  306. // Label lines appear indented by one space.
  307. if(inTarget || inSource)
  308. {
  309. this->Labels.insert(line.c_str()+1);
  310. }
  311. }
  312. else if(!this->OptionSource.empty() && !inSource)
  313. {
  314. // Non-indented lines specify a source file name. The first one
  315. // is the end of the target-wide labels. Use labels following a
  316. // matching source.
  317. inTarget = false;
  318. inSource = this->SourceMatches(line, source);
  319. }
  320. else
  321. {
  322. return;
  323. }
  324. }
  325. }
  326. //----------------------------------------------------------------------------
  327. bool cmCTestLaunch::SourceMatches(std::string const& lhs,
  328. std::string const& rhs)
  329. {
  330. // TODO: Case sensitivity, UseRelativePaths, etc. Note that both
  331. // paths in the comparison get generated by CMake. This is done for
  332. // every source in the target, so it should be efficient (cannot use
  333. // cmSystemTools::IsSameFile).
  334. return lhs == rhs;
  335. }
  336. //----------------------------------------------------------------------------
  337. bool cmCTestLaunch::IsError() const
  338. {
  339. return this->ExitCode != 0;
  340. }
  341. //----------------------------------------------------------------------------
  342. void cmCTestLaunch::WriteXML()
  343. {
  344. // Name the xml file.
  345. std::string logXML = this->LogDir;
  346. logXML += this->IsError()? "error-" : "warning-";
  347. logXML += this->LogHash;
  348. logXML += ".xml";
  349. // Use cmGeneratedFileStream to atomically create the report file.
  350. cmGeneratedFileStream fxml(logXML.c_str());
  351. fxml << "\t<Failure type=\""
  352. << (this->IsError()? "Error" : "Warning") << "\">\n";
  353. this->WriteXMLAction(fxml);
  354. this->WriteXMLCommand(fxml);
  355. this->WriteXMLResult(fxml);
  356. this->WriteXMLLabels(fxml);
  357. fxml << "\t</Failure>\n";
  358. }
  359. //----------------------------------------------------------------------------
  360. void cmCTestLaunch::WriteXMLAction(std::ostream& fxml)
  361. {
  362. fxml << "\t\t<!-- Meta-information about the build action -->\n";
  363. fxml << "\t\t<Action>\n";
  364. // TargetName
  365. if(!this->OptionTargetName.empty())
  366. {
  367. fxml << "\t\t\t<TargetName>"
  368. << cmXMLSafe(this->OptionTargetName)
  369. << "</TargetName>\n";
  370. }
  371. // Language
  372. if(!this->OptionLanguage.empty())
  373. {
  374. fxml << "\t\t\t<Language>"
  375. << cmXMLSafe(this->OptionLanguage)
  376. << "</Language>\n";
  377. }
  378. // SourceFile
  379. if(!this->OptionSource.empty())
  380. {
  381. std::string source = this->OptionSource;
  382. cmSystemTools::ConvertToUnixSlashes(source);
  383. // If file is in source tree use its relative location.
  384. if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
  385. cmSystemTools::FileIsFullPath(source.c_str()) &&
  386. cmSystemTools::IsSubDirectory(source.c_str(),
  387. this->SourceDir.c_str()))
  388. {
  389. source = cmSystemTools::RelativePath(this->SourceDir.c_str(),
  390. source.c_str());
  391. }
  392. fxml << "\t\t\t<SourceFile>"
  393. << cmXMLSafe(source)
  394. << "</SourceFile>\n";
  395. }
  396. // OutputFile
  397. if(!this->OptionOutput.empty())
  398. {
  399. fxml << "\t\t\t<OutputFile>"
  400. << cmXMLSafe(this->OptionOutput)
  401. << "</OutputFile>\n";
  402. }
  403. // OutputType
  404. const char* outputType = 0;
  405. if(!this->OptionTargetType.empty())
  406. {
  407. if(this->OptionTargetType == "EXECUTABLE")
  408. {
  409. outputType = "executable";
  410. }
  411. else if(this->OptionTargetType == "SHARED_LIBRARY")
  412. {
  413. outputType = "shared library";
  414. }
  415. else if(this->OptionTargetType == "MODULE_LIBRARY")
  416. {
  417. outputType = "module library";
  418. }
  419. else if(this->OptionTargetType == "STATIC_LIBRARY")
  420. {
  421. outputType = "static library";
  422. }
  423. }
  424. else if(!this->OptionSource.empty())
  425. {
  426. outputType = "object file";
  427. }
  428. if(outputType)
  429. {
  430. fxml << "\t\t\t<OutputType>"
  431. << cmXMLSafe(outputType)
  432. << "</OutputType>\n";
  433. }
  434. fxml << "\t\t</Action>\n";
  435. }
  436. //----------------------------------------------------------------------------
  437. void cmCTestLaunch::WriteXMLCommand(std::ostream& fxml)
  438. {
  439. fxml << "\n";
  440. fxml << "\t\t<!-- Details of command -->\n";
  441. fxml << "\t\t<Command>\n";
  442. if(!this->CWD.empty())
  443. {
  444. fxml << "\t\t\t<WorkingDirectory>"
  445. << cmXMLSafe(this->CWD)
  446. << "</WorkingDirectory>\n";
  447. }
  448. for(std::vector<std::string>::const_iterator ai = this->RealArgs.begin();
  449. ai != this->RealArgs.end(); ++ai)
  450. {
  451. fxml << "\t\t\t<Argument>"
  452. << cmXMLSafe(ai->c_str())
  453. << "</Argument>\n";
  454. }
  455. fxml << "\t\t</Command>\n";
  456. }
  457. //----------------------------------------------------------------------------
  458. void cmCTestLaunch::WriteXMLResult(std::ostream& fxml)
  459. {
  460. fxml << "\n";
  461. fxml << "\t\t<!-- Result of command -->\n";
  462. fxml << "\t\t<Result>\n";
  463. // StdOut
  464. fxml << "\t\t\t<StdOut>";
  465. this->DumpFileToXML(fxml, this->LogOut);
  466. fxml << "</StdOut>\n";
  467. // StdErr
  468. fxml << "\t\t\t<StdErr>";
  469. this->DumpFileToXML(fxml, this->LogErr);
  470. fxml << "</StdErr>\n";
  471. // ExitCondition
  472. fxml << "\t\t\t<ExitCondition>";
  473. cmsysProcess* cp = this->Process;
  474. switch (cmsysProcess_GetState(cp))
  475. {
  476. case cmsysProcess_State_Starting:
  477. fxml << "No process has been executed"; break;
  478. case cmsysProcess_State_Executing:
  479. fxml << "The process is still executing"; break;
  480. case cmsysProcess_State_Disowned:
  481. fxml << "Disowned"; break;
  482. case cmsysProcess_State_Killed:
  483. fxml << "Killed by parent"; break;
  484. case cmsysProcess_State_Expired:
  485. fxml << "Killed when timeout expired"; break;
  486. case cmsysProcess_State_Exited:
  487. fxml << this->ExitCode; break;
  488. case cmsysProcess_State_Exception:
  489. fxml << "Terminated abnormally: "
  490. << cmXMLSafe(cmsysProcess_GetExceptionString(cp)); break;
  491. case cmsysProcess_State_Error:
  492. fxml << "Error administrating child process: "
  493. << cmXMLSafe(cmsysProcess_GetErrorString(cp)); break;
  494. };
  495. fxml << "</ExitCondition>\n";
  496. fxml << "\t\t</Result>\n";
  497. }
  498. //----------------------------------------------------------------------------
  499. void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml)
  500. {
  501. this->LoadLabels();
  502. if(!this->Labels.empty())
  503. {
  504. fxml << "\n";
  505. fxml << "\t\t<!-- Interested parties -->\n";
  506. fxml << "\t\t<Labels>\n";
  507. for(std::set<cmStdString>::const_iterator li = this->Labels.begin();
  508. li != this->Labels.end(); ++li)
  509. {
  510. fxml << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
  511. }
  512. fxml << "\t\t</Labels>\n";
  513. }
  514. }
  515. //----------------------------------------------------------------------------
  516. void cmCTestLaunch::DumpFileToXML(std::ostream& fxml,
  517. std::string const& fname)
  518. {
  519. std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
  520. std::string line;
  521. const char* sep = "";
  522. while(cmSystemTools::GetLineFromStream(fin, line))
  523. {
  524. fxml << sep << cmXMLSafe(line).Quotes(false);
  525. sep = "\n";
  526. }
  527. }
  528. //----------------------------------------------------------------------------
  529. bool cmCTestLaunch::CheckResults()
  530. {
  531. // Skip XML in passthru mode.
  532. if(this->Passthru)
  533. {
  534. return true;
  535. }
  536. // We always report failure for error conditions.
  537. if(this->IsError())
  538. {
  539. return false;
  540. }
  541. // Scrape the output logs to look for warnings.
  542. if((this->HaveErr && this->ScrapeLog(this->LogErr)) ||
  543. (this->HaveOut && this->ScrapeLog(this->LogOut)))
  544. {
  545. return false;
  546. }
  547. return true;
  548. }
  549. //----------------------------------------------------------------------------
  550. void cmCTestLaunch::LoadScrapeRules()
  551. {
  552. if(this->ScrapeRulesLoaded)
  553. {
  554. return;
  555. }
  556. this->ScrapeRulesLoaded = true;
  557. // Common compiler warning formats. These are much simpler than the
  558. // full log-scraping expressions because we do not need to extract
  559. // file and line information.
  560. this->RegexWarning.push_back("(^|[ :])[Ww][Aa][Rr][Nn][Ii][Nn][Gg]");
  561. this->RegexWarning.push_back("(^|[ :])[Rr][Ee][Mm][Aa][Rr][Kk]");
  562. this->RegexWarning.push_back("(^|[ :])[Nn][Oo][Tt][Ee]");
  563. // Load custom match rules given to us by CTest.
  564. this->LoadScrapeRules("Warning", this->RegexWarning);
  565. this->LoadScrapeRules("WarningSuppress", this->RegexWarningSuppress);
  566. }
  567. //----------------------------------------------------------------------------
  568. void
  569. cmCTestLaunch
  570. ::LoadScrapeRules(const char* purpose,
  571. std::vector<cmsys::RegularExpression>& regexps)
  572. {
  573. std::string fname = this->LogDir;
  574. fname += "Custom";
  575. fname += purpose;
  576. fname += ".txt";
  577. std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
  578. std::string line;
  579. cmsys::RegularExpression rex;
  580. while(cmSystemTools::GetLineFromStream(fin, line))
  581. {
  582. if(rex.compile(line.c_str()))
  583. {
  584. regexps.push_back(rex);
  585. }
  586. }
  587. }
  588. //----------------------------------------------------------------------------
  589. bool cmCTestLaunch::ScrapeLog(std::string const& fname)
  590. {
  591. this->LoadScrapeRules();
  592. // Look for log file lines matching warning expressions but not
  593. // suppression expressions.
  594. std::ifstream fin(fname.c_str(), std::ios::in | std::ios::binary);
  595. std::string line;
  596. while(cmSystemTools::GetLineFromStream(fin, line))
  597. {
  598. if(this->Match(line.c_str(), this->RegexWarning) &&
  599. !this->Match(line.c_str(), this->RegexWarningSuppress))
  600. {
  601. return true;
  602. }
  603. }
  604. return false;
  605. }
  606. //----------------------------------------------------------------------------
  607. bool cmCTestLaunch::Match(std::string const& line,
  608. std::vector<cmsys::RegularExpression>& regexps)
  609. {
  610. for(std::vector<cmsys::RegularExpression>::iterator ri = regexps.begin();
  611. ri != regexps.end(); ++ri)
  612. {
  613. if(ri->find(line.c_str()))
  614. {
  615. return true;
  616. }
  617. }
  618. return false;
  619. }
  620. //----------------------------------------------------------------------------
  621. int cmCTestLaunch::Main(int argc, const char* const argv[])
  622. {
  623. if(argc == 2)
  624. {
  625. std::cerr << "ctest --launch: this mode is for internal CTest use only"
  626. << std::endl;
  627. return 1;
  628. }
  629. cmCTestLaunch self(argc, argv);
  630. return self.Run();
  631. }
  632. //----------------------------------------------------------------------------
  633. #include "cmGlobalGenerator.h"
  634. #include "cmLocalGenerator.h"
  635. #include "cmMakefile.h"
  636. #include "cmake.h"
  637. #include <cmsys/auto_ptr.hxx>
  638. void cmCTestLaunch::LoadConfig()
  639. {
  640. cmake cm;
  641. cmGlobalGenerator gg;
  642. gg.SetCMakeInstance(&cm);
  643. cmsys::auto_ptr<cmLocalGenerator> lg(gg.CreateLocalGenerator());
  644. cmMakefile* mf = lg->GetMakefile();
  645. std::string fname = this->LogDir;
  646. fname += "CTestLaunchConfig.cmake";
  647. if(cmSystemTools::FileExists(fname.c_str()) &&
  648. mf->ReadListFile(0, fname.c_str()))
  649. {
  650. this->SourceDir = mf->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
  651. cmSystemTools::ConvertToUnixSlashes(this->SourceDir);
  652. }
  653. }