summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestRunTest.cxx
diff options
context:
space:
mode:
authorAlex Reinking <alex.reinking@gmail.com>2022-08-14 08:11:35 (GMT)
committerBrad King <brad.king@kitware.com>2022-08-15 18:19:16 (GMT)
commite2854b4fa25778b66473a75a0bf3ca4bfdec5a54 (patch)
treebeb60b0d5d91cfb38f06869ca5240a9c8d61d53f /Source/CTest/cmCTestRunTest.cxx
parentbfa1c5285b0db8f7dfe8e7c5ac546312723f59db (diff)
downloadCMake-e2854b4fa25778b66473a75a0bf3ca4bfdec5a54.zip
CMake-e2854b4fa25778b66473a75a0bf3ca4bfdec5a54.tar.gz
CMake-e2854b4fa25778b66473a75a0bf3ca4bfdec5a54.tar.bz2
cmCTestRunTest: Implement the ENVIRONMENT test property with EnvDiff too
Going through the same internal API for both `ENVIRONMENT` and `ENVIRONMENT_MODIFICATION` properties will make it easier to implement checkpointing for `MYVAR=reset:` more efficiently if the need ever presents itself. It also makes the two-stage nature of the environment mutation clearer in the code itself.
Diffstat (limited to 'Source/CTest/cmCTestRunTest.cxx')
-rw-r--r--Source/CTest/cmCTestRunTest.cxx15
1 files changed, 7 insertions, 8 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 11be132..5efe69f 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -784,16 +784,15 @@ bool cmCTestRunTest::ForkProcess(
this->TestProcess->SetTimeout(timeout);
cmSystemTools::SaveRestoreEnvironment sre;
-
std::ostringstream envMeasurement;
+
+ // We split processing ENVIRONMENT and ENVIRONMENT_MODIFICATION into two
+ // phases to ensure that MYVAR=reset: in the latter phase resets to the
+ // former phase's settings, rather than to the original environment.
if (environment && !environment->empty()) {
- // Environment modification works on the assumption that the environment is
- // actually modified here. If another strategy is used, there will need to
- // be updates in `EnvDiff::ParseOperation`.
- cmSystemTools::AppendEnv(*environment);
- for (auto const& var : *environment) {
- envMeasurement << var << std::endl;
- }
+ cmSystemTools::EnvDiff diff;
+ diff.AppendEnv(*environment);
+ diff.ApplyToCurrentEnv(&envMeasurement);
}
if (environment_modification && !environment_modification->empty()) {