diff options
author | Christian Stenger <christian.stenger@qt.io> | 2021-06-30 09:44:15 +0200 |
---|---|---|
committer | Christian Stenger <christian.stenger@qt.io> | 2021-07-02 07:48:41 +0000 |
commit | 4430c3345855bad95ebff62f7321b28b23537086 (patch) | |
tree | 16aa71dad528fd5f08f98153b066151a9da1d284 /src/plugins/autotest | |
parent | 2971aac8c2637dc5c138bcaadd60b429eb23de45 (diff) |
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 <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/autotest')
-rw-r--r-- | src/plugins/autotest/ctest/ctesttreeitem.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/plugins/autotest/ctest/ctesttreeitem.cpp b/src/plugins/autotest/ctest/ctesttreeitem.cpp index 25e7ad44f1..382241b880 100644 --- a/src/plugins/autotest/ctest/ctesttreeitem.cpp +++ b/src/plugins/autotest/ctest/ctesttreeitem.cpp @@ -32,6 +32,7 @@ #include "../testsettings.h" #include <projectexplorer/buildsystem.h> +#include <projectexplorer/environmentaspect.h> #include <projectexplorer/project.h> #include <projectexplorer/session.h> #include <projectexplorer/target.h> @@ -115,13 +116,17 @@ QList<ITestConfiguration *> CTestTreeItem::testConfigurationsFor(const QStringLi CTestConfiguration *config = new CTestConfiguration(testBase()); config->setProject(project); config->setCommandLine(command); - const QList<ProjectExplorer::BuildConfiguration *> 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<ProjectExplorer::EnvironmentAspect>()) + 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 |