diff options
author | Montel Laurent <montel@kde.org> | 2015-01-06 21:54:21 +0100 |
---|---|---|
committer | Montel Laurent <montel@kde.org> | 2015-01-06 21:59:25 +0100 |
commit | 915976c1238be811f169eab1b02f7e8dad6410e0 (patch) | |
tree | a1a8980b028fddb0c40c63b5488f7dbcdaead909 /autotests/test_kconf_update.cpp | |
parent | 19ae8748a9352aa31c4919ca09b6f6eb6f03e45e (diff) | |
download | kconfig-915976c1238be811f169eab1b02f7e8dad6410e0.tar.gz kconfig-915976c1238be811f169eab1b02f7e8dad6410e0.tar.bz2 |
Don't upgrate config file with upd file from kde4.
This patch is necessary because:
When we use kf5 + kde4 application, kconf_update which launchs at the start when we launch kde.
But it will migrate some config file, for example it will show that we need to migrate konversation
so it will create a konversationrc in .config/
But when we launch konversation there is a kdelibs4migrator which wants to migrate settings and config in .config
but it shows a konversationrc in .config so it will never migrate and we will lose all settings.
So we can force to remove all .upd in kf5 but it will not fix problem during migration or when we have kde4 application
install in same directory as kf5.
So now I force for each upd file to have a "Version=5" so kconf_update (kf5) will migrate just kf5 upd file and it will fix my bugs.
REVIEW: 121797
CHANGELOG: Now kconf_update doesn't process upd file from kde4. We need to add "Version=5" in top of the upd file otherwise it will be skipped.
Diffstat (limited to 'autotests/test_kconf_update.cpp')
-rw-r--r-- | autotests/test_kconf_update.cpp | 78 |
1 files changed, 72 insertions, 6 deletions
diff --git a/autotests/test_kconf_update.cpp b/autotests/test_kconf_update.cpp index d4f5c52d..e4e2b416 100644 --- a/autotests/test_kconf_update.cpp +++ b/autotests/test_kconf_update.cpp @@ -82,6 +82,8 @@ void TestKConfUpdate::test_data() QTest::addColumn<QString>("newConfName"); QTest::addColumn<QString>("expectedNewConfContent"); QTest::addColumn<QString>("expectedOldConfContent"); + QTest::addColumn<bool>("useVersion5"); + QTest::addColumn<bool>("shouldUpdateWork"); QTest::newRow("moveKeysSameFile") << @@ -104,6 +106,8 @@ void TestKConfUpdate::test_data() "new=value\n" << "" + << true + << true ; QTest::newRow("moveKeysOtherFile") << @@ -132,6 +136,8 @@ void TestKConfUpdate::test_data() "\n" "[stay]\n" "foo=bar\n" + << true + << true ; QTest::newRow("allKeys") << @@ -161,6 +167,8 @@ void TestKConfUpdate::test_data() "foo=bar\n" << "" + << true + << true ; QTest::newRow("allKeysSubGroup") << @@ -198,6 +206,8 @@ void TestKConfUpdate::test_data() "foo=bar\n" << "" + << true + << true ; QTest::newRow("removeGroup") << @@ -221,6 +231,8 @@ void TestKConfUpdate::test_data() "key=value\n" << "" + << true + << true ; QTest::newRow("moveKeysSameFileDontExist") << @@ -247,6 +259,50 @@ void TestKConfUpdate::test_data() "key1=value1\n" << "" + << true + << true + ; + QTest::newRow("DontMigrateWhenFileDoesntHaveVersion") + << + "File=testrc\n" + "Group=group\n" + "Key=old,new\n" + "Options=overwrite\n" + << + "testrc" + << + "[group]\n" + "old=value\n" + << + "testrc" + << + "[group]\n" + "old=value\n" + << + "" + << false + << false + ; + + QTest::newRow("DontMigrateWhenUpdateCantDoItMissingFilename") + << + "Group=group\n" + "Key=old,new\n" + "Options=overwrite\n" + << + "testrc" + << + "[group]\n" + "old=value\n" + << + "testrc" + << + "[group]\n" + "old=value\n" + << + "" + << true + << false ; } @@ -258,9 +314,14 @@ void TestKConfUpdate::test() QFETCH(QString, newConfName); QFETCH(QString, expectedNewConfContent); QFETCH(QString, expectedOldConfContent); + QFETCH(bool, useVersion5); + QFETCH(bool, shouldUpdateWork); - // Prepend the Id= field to the upd content - updContent = QString("Id=%1\n").arg(QTest::currentDataTag()) + updContent; + // Prepend Version and the Id= field to the upd content + const QString header = QString("Id=%1\n").arg(QTest::currentDataTag()); + updContent = header + updContent; + if (useVersion5) + updContent.prepend("Version=5\n"); QString oldConfPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + oldConfName; QString newConfPath = QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation) + QLatin1Char('/') + newConfName; @@ -278,12 +339,16 @@ void TestKConfUpdate::test() .arg(QTest::currentDataTag()); QString newConfContentAfter = readFile(newConfPath); - expectedNewConfContent = expectedNewConfContent.arg(updateInfo); + if (shouldUpdateWork) { + expectedNewConfContent = expectedNewConfContent.arg(updateInfo); + } QCOMPARE(newConfContentAfter, expectedNewConfContent); if (oldConfName != newConfName) { QString oldConfContentAfter = readFile(oldConfPath); - expectedOldConfContent = expectedOldConfContent.arg(updateInfo); + if (shouldUpdateWork) { + expectedOldConfContent = expectedOldConfContent.arg(updateInfo); + } QCOMPARE(oldConfContentAfter, expectedOldConfContent); } } @@ -548,8 +613,8 @@ void TestKConfUpdate::testScript() QFETCH(QString, oldConfContent); QFETCH(QString, expectedNewConfContent); - // Prepend the Id= field to the upd content - updContent = QString("Id=%1\n").arg(QTest::currentDataTag()) + updContent; + // Prepend the Version and Id= field to the upd content + updContent = QString("Version=5\nId=%1\n").arg(QTest::currentDataTag()) + updContent; QSharedPointer<QTemporaryFile> updFile(writeUpdFile(updContent)); @@ -573,3 +638,4 @@ void TestKConfUpdate::testScript() QCOMPARE(newConfContent, expectedNewConfContent); } + |