[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: Re: [ktexteditor] src: make unit tests more stable, don't use user config at all, ever
From: Michal Humpula <michal.humpula () hudrydum ! cz>
Date: 2015-08-11 20:30:57
Message-ID: 1610007.IDVIDUQXKp () amonsul
[Download RAW message or body]
As far as I can recall I've seen some test changing configuration
persistently, but it might be already fixed.
So, what about letting KConfig eat /dev/null when in test mode? It's not
exactly platform independent, but it would completely decouple the tests;)
On Tuesday 11 of August 2015 22:24:18 Christoph Cullmann wrote:
> Hi,
>
> as no test ever touches the global config, there is no chance for such an
> dependencies ATM. And I doubt that we want to introduce tests that trigger
> global config changes.
>
> Beside: The ENV var solution is nice, but does not work out of the box.
> This change solves the problem for any average user just doing "make test"
> without a special setup. (Even nicer would be some 'in memory only' KConfig
> like I did for the KateSchemaConfig, but that is no one liner for
> KSharedConfig, at least not with some memleak or static object ;=))
>
> Greetings
> Christoph
>
> ----- Ursprüngliche Mail -----
>
> > by choosing the fixed config name in code (although different) IMHO you've
> > only shifted the problem a step further. Now the tests are not dependent
> > on
> > production runtime, but are dependent still on each other. Using config
> > supplied from ENV variable at all time and choosing temporary file in test
> > run, would in my opinion completely removed the possibility of collisions.
> >
> > On Tuesday 11 of August 2015 20:07:57 Christoph Cullmann wrote:
> > > 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/fe6909806d076a0fed0d895b5b5bf2fde15fa
> > > 0ec
> > >
> > > diff --git a/src/syntax/katesyntaxmanager.cpp
> > > b/src/syntax/katesyntaxmanager.cpp index ba65948..d81afe6 100644
> > > --- a/src/syntax/katesyntaxmanager.cpp
> > > +++ b/src/syntax/katesyntaxmanager.cpp
> > > @@ -67,7 +67,7 @@ bool compareKateHighlighting(const KateHighlighting
> > > *const
> > > left, const KateHighl KateHlManager::KateHlManager()
> > >
> > > : QObject()
> > >
> > > , m_config(KTextEditor::EditorPrivate::unitTestMode() ? QString()
> > > :
> > > :QStringLiteral("katesyntaxhighlightingrc") - ,
> > >
> > > KTextEditor::EditorPrivate::unitTestMode() ? KConfig::SimpleConfig :
> > > KConfig::NoGlobals) + ,
> > > KTextEditor::EditorPrivate::unitTestMode() ?
> > > KConfig::SimpleConfig : KConfig::NoGlobals) // skip config for unit
> > > tests!
> > > , commonSuffixes({QStringLiteral(".orig"), QStringLiteral(".new"),
> > > QStringLiteral("~"), 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-unittest"),
> > > 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