diff options
-rw-r--r-- | autotests/test_kconf_update.cpp | 4 | ||||
-rw-r--r-- | src/kconf_update/kconf_update.cpp | 5 |
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"))); |