Clang*: Use new plugin test setup scheme

Change-Id: I636b93d74b4f9ab9ade28c46c6e84b461ccf34be
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-02-09 14:16:43 +01:00
parent 19a975735d
commit b30a74130f
6 changed files with 29 additions and 60 deletions

View File

@@ -43,8 +43,7 @@ using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace ClangCodeModel { namespace ClangCodeModel::Internal {
namespace Internal {
void ClangCodeModelPlugin::generateCompilationDB() void ClangCodeModelPlugin::generateCompilationDB()
{ {
@@ -78,8 +77,7 @@ ClangCodeModelPlugin::~ClangCodeModelPlugin()
void ClangCodeModelPlugin::initialize() void ClangCodeModelPlugin::initialize()
{ {
TaskHub::addCategory(Constants::TASK_CATEGORY_DIAGNOSTICS, TaskHub::addCategory(Constants::TASK_CATEGORY_DIAGNOSTICS, Tr::tr("Clang Code Model"));
Tr::tr("Clang Code Model"));
connect(ProjectExplorerPlugin::instance(), connect(ProjectExplorerPlugin::instance(),
&ProjectExplorerPlugin::finishedInitialization, &ProjectExplorerPlugin::finishedInitialization,
@@ -90,6 +88,18 @@ void ClangCodeModelPlugin::initialize()
std::make_unique<ClangModelManagerSupport>()); std::make_unique<ClangModelManagerSupport>());
createCompilationDBAction(); createCompilationDBAction();
#ifdef WITH_TESTS
addTest<Tests::ActivationSequenceProcessorTest>();
addTest<Tests::ClangdTestCompletion>();
addTest<Tests::ClangdTestExternalChanges>();
addTest<Tests::ClangdTestFindReferences>();
addTest<Tests::ClangdTestFollowSymbol>();
addTest<Tests::ClangdTestHighlighting>();
addTest<Tests::ClangdTestLocalReferences>();
addTest<Tests::ClangdTestTooltips>();
addTest<Tests::ClangFixItTest>();
#endif
} }
void ClangCodeModelPlugin::createCompilationDBAction() void ClangCodeModelPlugin::createCompilationDBAction()
@@ -178,22 +188,4 @@ void ClangCodeModelPlugin::maybeHandleBatchFileAndExit() const
#endif #endif
} }
#ifdef WITH_TESTS } // ClangCodeModel::Internal
QVector<QObject *> ClangCodeModelPlugin::createTestObjects() const
{
return {
new Tests::ActivationSequenceProcessorTest,
new Tests::ClangdTestCompletion,
new Tests::ClangdTestExternalChanges,
new Tests::ClangdTestFindReferences,
new Tests::ClangdTestFollowSymbol,
new Tests::ClangdTestHighlighting,
new Tests::ClangdTestLocalReferences,
new Tests::ClangdTestTooltips,
new Tests::ClangFixItTest,
};
}
#endif
} // namespace Internal
} // namespace Clang

View File

@@ -11,8 +11,7 @@
#include <QFutureWatcher> #include <QFutureWatcher>
namespace ClangCodeModel { namespace ClangCodeModel::Internal {
namespace Internal {
class ClangCodeModelPlugin final: public ExtensionSystem::IPlugin class ClangCodeModelPlugin final: public ExtensionSystem::IPlugin
{ {
@@ -31,10 +30,6 @@ private:
Utils::ParameterAction *m_generateCompilationDBAction = nullptr; Utils::ParameterAction *m_generateCompilationDBAction = nullptr;
QFutureWatcher<GenerateCompilationDbResult> m_generatorWatcher; QFutureWatcher<GenerateCompilationDbResult> m_generatorWatcher;
#ifdef WITH_TESTS
QVector<QObject *> createTestObjects() const override;
#endif
}; };
} // namespace Internal } // ClangCodeModel::Internal
} // namespace Clang

View File

@@ -103,15 +103,10 @@ void ClangFormatPlugin::initialize()
openClangFormatConfigAction->setData(doc->filePath().toVariant()); openClangFormatConfigAction->setData(doc->filePath().toVariant());
}); });
} }
}
QVector<QObject *> ClangFormatPlugin::createTestObjects() const
{
return {
#ifdef WITH_TESTS #ifdef WITH_TESTS
new Internal::ClangFormatTest, addTest<Internal::ClangFormatTest>();
#endif #endif
};
} }
} // namespace ClangFormat } // ClangFormat

View File

@@ -16,7 +16,6 @@ class ClangFormatPlugin : public ExtensionSystem::IPlugin
~ClangFormatPlugin() override; ~ClangFormatPlugin() override;
void initialize() final; void initialize() final;
QVector<QObject *> createTestObjects() const override;
TextEditor::ICodeStylePreferencesFactory *m_factory = nullptr; TextEditor::ICodeStylePreferencesFactory *m_factory = nullptr;
}; };

View File

@@ -5,7 +5,6 @@
#include "clangtool.h" #include "clangtool.h"
#include "clangtoolsconstants.h" #include "clangtoolsconstants.h"
#include "clangtoolsprojectsettings.h"
#include "clangtoolsprojectsettingswidget.h" #include "clangtoolsprojectsettingswidget.h"
#include "clangtoolstr.h" #include "clangtoolstr.h"
#include "documentclangtoolrunner.h" #include "documentclangtoolrunner.h"
@@ -49,8 +48,7 @@
using namespace Core; using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace ClangTools { namespace ClangTools::Internal {
namespace Internal {
static ProjectPanelFactory *m_projectPanelFactoryInstance = nullptr; static ProjectPanelFactory *m_projectPanelFactoryInstance = nullptr;
@@ -112,6 +110,12 @@ void ClangToolsPlugin::initialize()
&Core::EditorManager::currentEditorChanged, &Core::EditorManager::currentEditorChanged,
this, this,
&ClangToolsPlugin::onCurrentEditorChanged); &ClangToolsPlugin::onCurrentEditorChanged);
#ifdef WITH_TESTS
addTest<PreconfiguredSessionTests>();
addTest<ClangToolsUnitTests>();
addTest<ReadExportedDiagnosticsTest>();
#endif
} }
void ClangToolsPlugin::onCurrentEditorChanged() void ClangToolsPlugin::onCurrentEditorChanged()
@@ -185,16 +189,4 @@ void ClangToolsPlugin::registerAnalyzeActions()
}); });
} }
QVector<QObject *> ClangToolsPlugin::createTestObjects() const } // ClangTools::Internal
{
QVector<QObject *> tests;
#ifdef WITH_TESTS
tests << new PreconfiguredSessionTests;
tests << new ClangToolsUnitTests;
tests << new ReadExportedDiagnosticsTest;
#endif
return tests;
}
} // namespace Internal
} // namespace ClangTools

View File

@@ -8,8 +8,7 @@
namespace Core { class IDocument; } namespace Core { class IDocument; }
namespace ProjectExplorer { class ProjectPanelFactory; } namespace ProjectExplorer { class ProjectPanelFactory; }
namespace ClangTools { namespace ClangTools::Internal {
namespace Internal {
ProjectExplorer::ProjectPanelFactory *projectPanelFactory(); ProjectExplorer::ProjectPanelFactory *projectPanelFactory();
@@ -27,10 +26,7 @@ private:
void registerAnalyzeActions(); void registerAnalyzeActions();
void onCurrentEditorChanged(); void onCurrentEditorChanged();
QVector<QObject *> createTestObjects() const final;
class ClangToolsPluginPrivate *d = nullptr; class ClangToolsPluginPrivate *d = nullptr;
}; };
} // namespace Internal } // ClangTools::Internal
} // namespace ClangTools