forked from qt-creator/qt-creator
Plugin Tests: Create settings dir with QTemporaryDir
Create a clean and unique settings directory for "-test" runs if no settings path is provided explicitly. Change-Id: Ida2f5a74d42a5292963dd8d5d1f9dcddcdd24fd4 Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
#include <QApplication>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QTemporaryDir>
|
||||
|
||||
#ifdef ENABLE_QT_BREAKPAD
|
||||
#include <qtsystemexceptionhandler.h>
|
||||
@@ -338,10 +339,14 @@ int main(int argc, char **argv)
|
||||
testOptionProvided = true;
|
||||
}
|
||||
}
|
||||
QScopedPointer<QTemporaryDir> temporaryCleanSettingsDir;
|
||||
if (settingsPath.isEmpty() && testOptionProvided) {
|
||||
settingsPath = QDir::tempPath() + QString::fromLatin1("/qtc-%1-test-settings")
|
||||
.arg(QLatin1String(Core::Constants::IDE_VERSION_LONG));
|
||||
settingsPath = QDir::cleanPath(settingsPath);
|
||||
const QString settingsPathTemplate = QDir::cleanPath(QDir::tempPath()
|
||||
+ QString::fromLatin1("/qtc-test-settings-XXXXXX"));
|
||||
temporaryCleanSettingsDir.reset(new QTemporaryDir(settingsPathTemplate));
|
||||
if (!temporaryCleanSettingsDir->isValid())
|
||||
return 1;
|
||||
settingsPath = temporaryCleanSettingsDir->path();
|
||||
}
|
||||
if (!settingsPath.isEmpty())
|
||||
QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, settingsPath);
|
||||
|
||||
Reference in New Issue
Block a user