From 4430c3345855bad95ebff62f7321b28b23537086 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 30 Jun 2021 09:44:15 +0200 Subject: [PATCH] AutoTest: Fix environment for ctest execution The build environment may or may not contain the respective paths to get the tests running, but the run environment usually must have them correctly. Change-Id: I392f6b61551b5927646daf3055134628f6d4f536 Reviewed-by: David Schulz --- src/plugins/autotest/ctest/ctesttreeitem.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index 25e7ad44f14..382241b8805 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -32,6 +32,7 @@ #include "../testsettings.h" #include +#include #include #include #include @@ -115,13 +116,17 @@ QList CTestTreeItem::testConfigurationsFor(const QStringLi CTestConfiguration *config = new CTestConfiguration(testBase()); config->setProject(project); config->setCommandLine(command); - const QList buildConfigs = target->buildConfigurations(); - if (QTC_GUARD(!buildConfigs.isEmpty())) { - config->setEnvironment(buildConfigs.first()->environment()); - config->setWorkingDirectory(buildConfigs.first()->buildDirectory().toString()); - } else { - config->setEnvironment(Utils::Environment::systemEnvironment()); + const ProjectExplorer::RunConfiguration *runConfig = target->activeRunConfiguration(); + if (QTC_GUARD(runConfig)) { + if (auto envAspect = runConfig->aspect()) + config->setEnvironment(envAspect->environment()); + else + config->setEnvironment(Utils::Environment::systemEnvironment()); } + const ProjectExplorer::BuildConfiguration *buildConfig = target->activeBuildConfiguration(); + if (QTC_GUARD(buildConfig)) + config->setWorkingDirectory(buildConfig->buildDirectory().toString()); + if (selected.isEmpty()) config->setTestCaseCount(testBase()->asTestTool()->rootNode()->childCount()); else