[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:       Christoph Cullmann <cullmann () absint ! com>
Date:       2015-08-11 20:24:18
Message-ID: 1877036032.1222079.1439324658159.JavaMail.zimbra () absint ! com
[Download RAW message or body]

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/fe6909806d076a0fed0d895b5b5bf2fde15fa0ec
> > 
> > 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")); }
> 
> 

-- 
----------------------------- Dr.-Ing. Christoph Cullmann ---------
AbsInt Angewandte Informatik GmbH      Email: cullmann@AbsInt.com
Science Park 1                         Tel:   +49-681-38360-22
66123 Saarbrücken                      Fax:   +49-681-38360-20
GERMANY                                WWW:   http://www.AbsInt.com
--------------------------------------------------------------------
Geschäftsführung: Dr.-Ing. Christian Ferdinand
Eingetragen im Handelsregister des Amtsgerichts Saarbrücken, HRB 11234


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

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