| 329 | #endif |
| 330 | |
| 331 | void cmLocalGenerator::GenerateTestFiles() |
| 332 | { |
| 333 | if (!this->Makefile->IsOn("CMAKE_TESTING_ENABLED")) { |
| 334 | return; |
| 335 | } |
| 336 | |
| 337 | // Compute the set of configurations. |
| 338 | std::vector<std::string> configurationTypes = |
| 339 | this->Makefile->GetGeneratorConfigs(cmMakefile::OnlyMultiConfig); |
| 340 | std::string config = this->Makefile->GetDefaultConfiguration(); |
| 341 | |
| 342 | std::string file = |
| 343 | cmStrCat(this->StateSnapshot.GetDirectory().GetCurrentBinary(), |
| 344 | "/CTestTestfile.cmake"); |
| 345 | this->GlobalGenerator->AddTestFile(file); |
| 346 | |
| 347 | cmGeneratedFileStream fout(file); |
| 348 | |
| 349 | fout << "# CMake generated Testfile for \n" |
| 350 | "# Source directory: " |
| 351 | << this->StateSnapshot.GetDirectory().GetCurrentSource() |
| 352 | << "\n" |
| 353 | "# Build directory: " |
| 354 | << this->StateSnapshot.GetDirectory().GetCurrentBinary() |
| 355 | << "\n" |
| 356 | "# \n" |
| 357 | "# This file includes the relevant testing commands " |
| 358 | "required for \n" |
| 359 | "# testing this directory and lists subdirectories to " |
| 360 | "be tested as well.\n"; |
| 361 | |
| 362 | std::string resourceSpecFile = |
| 363 | this->Makefile->GetSafeDefinition("CTEST_RESOURCE_SPEC_FILE"); |
| 364 | if (!resourceSpecFile.empty()) { |
| 365 | fout << "set(CTEST_RESOURCE_SPEC_FILE \"" << resourceSpecFile << "\")\n"; |
| 366 | } |
| 367 | |
| 368 | cmValue testIncludeFile = this->Makefile->GetProperty("TEST_INCLUDE_FILE"); |
| 369 | if (testIncludeFile) { |
| 370 | fout << "include(\"" << *testIncludeFile << "\")\n"; |
| 371 | } |
| 372 | |
| 373 | cmValue testIncludeFiles = this->Makefile->GetProperty("TEST_INCLUDE_FILES"); |
| 374 | if (testIncludeFiles) { |
| 375 | cmList includesList{ *testIncludeFiles }; |
| 376 | for (std::string const& i : includesList) { |
| 377 | fout << "include(\"" << i << "\")\n"; |
| 378 | } |
| 379 | } |
| 380 | |
| 381 | // Ask each test generator to write its code. |
| 382 | for (auto const& tester : this->Makefile->GetTestGenerators()) { |
| 383 | tester->Compute(this); |
| 384 | tester->Generate(fout, config, configurationTypes); |
| 385 | } |
| 386 | using vec_t = std::vector<cmStateSnapshot>; |
| 387 | vec_t const& children = this->Makefile->GetStateSnapshot().GetChildren(); |
| 388 | for (cmStateSnapshot const& i : children) { |
no test coverage detected