[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:19:14
Message-ID: 2304741.NJOszD3tB4 () amonsul
[Download RAW message or body]

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

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

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