From f3ca72f989e9a8e8c1933c165aff74ee85c01228 Mon Sep 17 00:00:00 2001 From: Nikolai Kosjar <nikolai.kosjar@digia.com> Date: Tue, 3 Sep 2013 15:17:24 +0200 Subject: [PATCH] Plugin tests: Run in separate settings path ...if no settings path is specified by the user. The default settins path for tests will be set to the system's temporary directory + "/qtc-${IDE_VERSION_LONG}-test-settings". Change-Id: Ibeaf8883c80169b4d6a3a97020a16f910292d67a Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Christian Stenger <christian.stenger@digia.com> --- src/app/main.cpp | 9 +++++++++ src/libs/extensionsystem/pluginmanager.cpp | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 81d9ff84f94..4b2d15b7239 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -82,6 +82,7 @@ static const char HELP_OPTION4[] = "--help"; static const char VERSION_OPTION[] = "-version"; static const char CLIENT_OPTION[] = "-client"; static const char SETTINGS_OPTION[] = "-settingspath"; +static const char TEST_OPTION[] = "-test"; static const char PID_OPTION[] = "-pid"; static const char BLOCK_OPTION[] = "-block"; static const char PLUGINPATH_OPTION[] = "-pluginpath"; @@ -319,6 +320,7 @@ int main(int argc, char **argv) QStringList customPluginPaths; QStringList arguments = app.arguments(); // adapted arguments list is passed to plugin manager later QMutableStringListIterator it(arguments); + bool testOptionProvided = false; while (it.hasNext()) { const QString &arg = it.next(); if (arg == QLatin1String(SETTINGS_OPTION)) { @@ -333,8 +335,15 @@ int main(int argc, char **argv) customPluginPaths << QDir::fromNativeSeparators(it.next()); it.remove(); } + } else if (arg == QLatin1String(TEST_OPTION)) { + testOptionProvided = true; } } + if (settingsPath.isEmpty() && testOptionProvided) { + settingsPath = QDir::tempPath() + QString::fromLatin1("/qtc-%1-test-settings") + .arg(QLatin1String(Core::Constants::IDE_VERSION_LONG)); + settingsPath = QDir::cleanPath(settingsPath); + } if (!settingsPath.isEmpty()) QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsPath); diff --git a/src/libs/extensionsystem/pluginmanager.cpp b/src/libs/extensionsystem/pluginmanager.cpp index 22d7837ebf9..ae837fd1151 100644 --- a/src/libs/extensionsystem/pluginmanager.cpp +++ b/src/libs/extensionsystem/pluginmanager.cpp @@ -614,7 +614,8 @@ void PluginManager::formatOptions(QTextStream &str, int optionIndentation, int d #ifdef WITH_TESTS formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION) + QLatin1String(" <plugin>[,testfunction[:testdata]]..."), QString(), - QLatin1String("Run plugin's tests"), optionIndentation, descriptionIndentation); + QLatin1String("Run plugin's tests (by default a separate settings path is used)"), + optionIndentation, descriptionIndentation); formatOption(str, QString::fromLatin1(OptionsParser::TEST_OPTION) + QLatin1String(" all"), QString(), QLatin1String("Run tests from all plugins"), optionIndentation, descriptionIndentation); -- GitLab