[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktexteditor] src: make unit tests more stable, don't use user config at all, ever
From:       Christoph Cullmann <cullmann () kde ! org>
Date:       2015-08-11 20:07:57
Message-ID: E1ZPFq1-0006dm-Df () scm ! kde ! org
[Download RAW message or body]

Git commit fe6909806d076a0fed0d895b5b5bf2fde15fa0ec by Christoph Cullmann.
Committed on 11/08/2015 at 20:07.
Pushed by cullmann into branch 'master'.

make unit tests more stable, don't use user config at all, ever

M  +1    -1    src/syntax/katesyntaxmanager.cpp
M  +4    -1    src/utils/kateglobal.h
M  +5    -1    src/vimode/globalstate.cpp

http://commits.kde.org/ktexteditor/fe6909806d076a0fed0d895b5b5bf2fde15fa0ec

diff --git a/src/syntax/katesyntaxmanager.cpp b/src/syntax/katesyntaxmanage=
r.cpp
index ba65948..d81afe6 100644
--- a/src/syntax/katesyntaxmanager.cpp
+++ b/src/syntax/katesyntaxmanager.cpp
@@ -67,7 +67,7 @@ bool compareKateHighlighting(const KateHighlighting *cons=
t left, const KateHighl
 KateHlManager::KateHlManager()
     : QObject()
     , m_config(KTextEditor::EditorPrivate::unitTestMode() ? QString() :QSt=
ringLiteral("katesyntaxhighlightingrc")
-        , KTextEditor::EditorPrivate::unitTestMode() ? KConfig::SimpleConf=
ig : KConfig::NoGlobals)
+        , KTextEditor::EditorPrivate::unitTestMode() ? KConfig::SimpleConf=
ig : KConfig::NoGlobals) // skip config for unit tests!
     , commonSuffixes({QStringLiteral(".orig"), QStringLiteral(".new"), QSt=
ringLiteral("~"), QStringLiteral(".bak"), QStringLiteral(".BAK")})
     , dynamicCtxsCount(0)
     , forceNoDCReset(false)
diff --git a/src/utils/kateglobal.h b/src/utils/kateglobal.h
index d555385..89b4d18 100644
--- a/src/utils/kateglobal.h
+++ b/src/utils/kateglobal.h
@@ -242,7 +242,10 @@ public:
      */
     static KSharedConfigPtr config()
     {
-        return KSharedConfig::openConfig(QStringLiteral("katepartrc"));
+        // use dummy config for unit tests!
+        return KTextEditor::EditorPrivate::unitTestMode()
+            ? KSharedConfig::openConfig(QStringLiteral("katepartrc-unittes=
t"), KConfig::SimpleConfig, QStandardPaths::TempLocation)
+            : KSharedConfig::openConfig(QStringLiteral("katepartrc"));
     }
 =

     /**
diff --git a/src/vimode/globalstate.cpp b/src/vimode/globalstate.cpp
index 5afc57e..78cb956 100644
--- a/src/vimode/globalstate.cpp
+++ b/src/vimode/globalstate.cpp
@@ -25,6 +25,7 @@
 #include "macros.h"
 #include "mappings.h"
 #include "registers.h"
+#include "kateglobal.h"
 =

 #include <kconfiggroup.h>
 =

@@ -76,5 +77,8 @@ void GlobalState::readConfig(const KConfig *configFile)
 =

 KSharedConfigPtr GlobalState::config() const
 {
-    return KSharedConfig::openConfig(QStringLiteral("katevirc"));
+    // use dummy config for unit tests!
+    return KTextEditor::EditorPrivate::unitTestMode()
+            ? KSharedConfig::openConfig(QStringLiteral("katevirc-unittest"=
), KConfig::SimpleConfig, QStandardPaths::TempLocation)
+            : KSharedConfig::openConfig(QStringLiteral("katevirc"));
 }
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic