|  | @@ -429,6 +429,7 @@ void cmCTestRunTest::StartFailure(std::string const& output,
 | 
	
		
			
				|  |  |    this->TestResult.Path = this->TestProperties->Directory;
 | 
	
		
			
				|  |  |    this->TestResult.Output = output;
 | 
	
		
			
				|  |  |    this->TestResult.FullCommandLine.clear();
 | 
	
		
			
				|  |  | +  this->TestResult.Environment.clear();
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  std::string cmCTestRunTest::GetTestPrefix(size_t completed, size_t total) const
 | 
	
	
		
			
				|  | @@ -500,6 +501,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total)
 | 
	
		
			
				|  |  |      this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
 | 
	
		
			
				|  |  |      this->TestResult.Output = "Disabled";
 | 
	
		
			
				|  |  |      this->TestResult.FullCommandLine.clear();
 | 
	
		
			
				|  |  | +    this->TestResult.Environment.clear();
 | 
	
		
			
				|  |  |      return false;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -519,6 +521,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total)
 | 
	
		
			
				|  |  |      cmCTestLog(this->CTest, HANDLER_OUTPUT, msg << std::endl);
 | 
	
		
			
				|  |  |      this->TestResult.Output = msg;
 | 
	
		
			
				|  |  |      this->TestResult.FullCommandLine.clear();
 | 
	
		
			
				|  |  | +    this->TestResult.Environment.clear();
 | 
	
		
			
				|  |  |      this->TestResult.CompletionStatus = "Fixture dependency failed";
 | 
	
		
			
				|  |  |      this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
 | 
	
		
			
				|  |  |      return false;
 | 
	
	
		
			
				|  | @@ -539,6 +542,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total)
 | 
	
		
			
				|  |  |      cmCTestLog(this->CTest, ERROR_MESSAGE, msg << std::endl);
 | 
	
		
			
				|  |  |      this->TestResult.Output = msg;
 | 
	
		
			
				|  |  |      this->TestResult.FullCommandLine.clear();
 | 
	
		
			
				|  |  | +    this->TestResult.Environment.clear();
 | 
	
		
			
				|  |  |      this->TestResult.CompletionStatus = "Missing Configuration";
 | 
	
		
			
				|  |  |      this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
 | 
	
		
			
				|  |  |      return false;
 | 
	
	
		
			
				|  | @@ -554,6 +558,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total)
 | 
	
		
			
				|  |  |                   "Unable to find required file: " << file << std::endl);
 | 
	
		
			
				|  |  |        this->TestResult.Output = "Unable to find required file: " + file;
 | 
	
		
			
				|  |  |        this->TestResult.FullCommandLine.clear();
 | 
	
		
			
				|  |  | +      this->TestResult.Environment.clear();
 | 
	
		
			
				|  |  |        this->TestResult.CompletionStatus = "Required Files Missing";
 | 
	
		
			
				|  |  |        this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
 | 
	
		
			
				|  |  |        return false;
 | 
	
	
		
			
				|  | @@ -569,6 +574,7 @@ bool cmCTestRunTest::StartTest(size_t completed, size_t total)
 | 
	
		
			
				|  |  |                 "Unable to find executable: " << args[1] << std::endl);
 | 
	
		
			
				|  |  |      this->TestResult.Output = "Unable to find executable: " + args[1];
 | 
	
		
			
				|  |  |      this->TestResult.FullCommandLine.clear();
 | 
	
		
			
				|  |  | +    this->TestResult.Environment.clear();
 | 
	
		
			
				|  |  |      this->TestResult.CompletionStatus = "Unable to find executable";
 | 
	
		
			
				|  |  |      this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
 | 
	
		
			
				|  |  |      return false;
 | 
	
	
		
			
				|  | @@ -713,25 +719,43 @@ bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout,
 | 
	
		
			
				|  |  |    cmSystemTools::SaveRestoreEnvironment sre;
 | 
	
		
			
				|  |  |  #endif
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  std::ostringstream envMeasurement;
 | 
	
		
			
				|  |  |    if (environment && !environment->empty()) {
 | 
	
		
			
				|  |  |      cmSystemTools::AppendEnv(*environment);
 | 
	
		
			
				|  |  | +    for (auto const& var : *environment) {
 | 
	
		
			
				|  |  | +      envMeasurement << var << std::endl;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    if (this->UseAllocatedResources) {
 | 
	
		
			
				|  |  | -    this->SetupResourcesEnvironment();
 | 
	
		
			
				|  |  | +    std::vector<std::string> envLog;
 | 
	
		
			
				|  |  | +    this->SetupResourcesEnvironment(&envLog);
 | 
	
		
			
				|  |  | +    for (auto const& var : envLog) {
 | 
	
		
			
				|  |  | +      envMeasurement << var << std::endl;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  |      cmSystemTools::UnsetEnv("CTEST_RESOURCE_GROUP_COUNT");
 | 
	
		
			
				|  |  | +    // Signify that this variable is being actively unset
 | 
	
		
			
				|  |  | +    envMeasurement << "#CTEST_RESOURCE_GROUP_COUNT=" << std::endl;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  this->TestResult.Environment = envMeasurement.str();
 | 
	
		
			
				|  |  | +  // Remove last newline
 | 
	
		
			
				|  |  | +  this->TestResult.Environment.erase(this->TestResult.Environment.length() -
 | 
	
		
			
				|  |  | +                                     1);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    return this->TestProcess->StartProcess(this->MultiTestHandler.Loop,
 | 
	
		
			
				|  |  |                                           affinity);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -void cmCTestRunTest::SetupResourcesEnvironment()
 | 
	
		
			
				|  |  | +void cmCTestRunTest::SetupResourcesEnvironment(std::vector<std::string>* log)
 | 
	
		
			
				|  |  |  {
 | 
	
		
			
				|  |  |    std::string processCount = "CTEST_RESOURCE_GROUP_COUNT=";
 | 
	
		
			
				|  |  |    processCount += std::to_string(this->AllocatedResources.size());
 | 
	
		
			
				|  |  |    cmSystemTools::PutEnv(processCount);
 | 
	
		
			
				|  |  | +  if (log) {
 | 
	
		
			
				|  |  | +    log->push_back(processCount);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    std::size_t i = 0;
 | 
	
		
			
				|  |  |    for (auto const& process : this->AllocatedResources) {
 | 
	
	
		
			
				|  | @@ -757,8 +781,14 @@ void cmCTestRunTest::SetupResourcesEnvironment()
 | 
	
		
			
				|  |  |          var += "id:" + it2.Id + ",slots:" + std::to_string(it2.Slots);
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        cmSystemTools::PutEnv(var);
 | 
	
		
			
				|  |  | +      if (log) {
 | 
	
		
			
				|  |  | +        log->push_back(var);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      cmSystemTools::PutEnv(resourceList);
 | 
	
		
			
				|  |  | +    if (log) {
 | 
	
		
			
				|  |  | +      log->push_back(resourceList);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |      ++i;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  }
 |