aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2015-08-05 10:00:33 +0200
committerDavid Faure <faure@kde.org>2015-08-05 10:00:33 +0200
commit27e145e797a265de93cc1238d6e6ee5d3f3c1998 (patch)
tree76e8c37ea9e290ef571aa4d153c1563c5f359d12
parente537a69c5f8c86a5c291764fd89b7a0ffe233606 (diff)
downloadkconfig-27e145e797a265de93cc1238d6e6ee5d3f3c1998.tar.gz
kconfig-27e145e797a265de93cc1238d6e6ee5d3f3c1998.tar.bz2
test_kconf_update: use QStandardPaths test mode
to avoid touching the user's real files
-rw-r--r--autotests/test_kconf_update.cpp4
-rw-r--r--src/kconf_update/kconf_update.cpp5
2 files changed, 8 insertions, 1 deletions
diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp
index dc03f9ff..41806194 100644
--- a/autotests/test_kconf_update.cpp
+++ b/autotests/test_kconf_update.cpp
@@ -35,6 +35,8 @@ QTEST_GUILESS_MAIN(TestKConfUpdate)
void TestKConfUpdate::initTestCase()
{
+ QStandardPaths::setTestModeEnabled(true);
+
// Ensure it all works with spaces in paths (as happens more commonly on OSX where it's ~/Library/Application Support/)
qputenv("XDG_DATA_HOME", "/tmp/a b");
}
@@ -76,7 +78,7 @@ static QTemporaryFile *writeUpdFile(const QString &content)
static void runKConfUpdate(const QString &updPath)
{
QVERIFY(QFile::exists(KCONF_UPDATE_EXECUTABLE));
- QCOMPARE(0, QProcess::execute(KCONF_UPDATE_EXECUTABLE, QStringList() << "--debug" << updPath));
+ QCOMPARE(0, QProcess::execute(KCONF_UPDATE_EXECUTABLE, QStringList() << "--testmode" << "--debug" << updPath));
}
void TestKConfUpdate::test_data()
diff --git a/src/kconf_update/kconf_update.cpp b/src/kconf_update/kconf_update.cpp
index 7659e7b2..bd346234 100644
--- a/src/kconf_update/kconf_update.cpp
+++ b/src/kconf_update/kconf_update.cpp
@@ -117,6 +117,10 @@ KonfUpdate::KonfUpdate(QCommandLineParser *parser)
m_debug = parser->isSet("debug");
+ if (parser->isSet("testmode")) {
+ QStandardPaths::setTestModeEnabled(true);
+ }
+
m_bUseConfigInfo = false;
if (parser->isSet("check")) {
m_bUseConfigInfo = true;
@@ -948,6 +952,7 @@ int main(int argc, char **argv)
parser.setApplicationDescription(QCoreApplication::translate("main", "KDE Tool for updating user configuration files"));
parser.addHelpOption();
parser.addOption(QCommandLineOption(QStringList() << "debug", QCoreApplication::translate("main", "Keep output results from scripts")));
+ parser.addOption(QCommandLineOption(QStringList() << "testmode", QCoreApplication::translate("main", "For unit tests only: use test directories to stay away from the user's real files")));
parser.addOption(QCommandLineOption(QStringList() << "check", QCoreApplication::translate("main", "Check whether config file itself requires updating"), "update-file"));
//parser.addOption(QCommandLineOption(QStringList() << "+[file]", QCoreApplication::translate("main", "File to read update instructions from")));