diff --git a/src/autotests/PartTest.cpp b/src/autotests/PartTest.cpp index 2aa77161..2c84c86c 100644 --- a/src/autotests/PartTest.cpp +++ b/src/autotests/PartTest.cpp @@ -40,6 +40,24 @@ using namespace Konsole; +void PartTest::initTestCase() +{ + /* Try to test against build konsolepart, so move directory containing + executable to front of libraryPaths. KPluginLoader should find the + part first in the build dir over the system installed ones. + I believe the CI installs first and then runs the test so the other + paths can not be removed. + */ + const auto libraryPaths = QCoreApplication::libraryPaths(); + auto buildPath = libraryPaths.last(); + QCoreApplication::removeLibraryPath(buildPath); + // konsolepart.so is in ../autotests/ + if (buildPath.endsWith(QStringLiteral("/autotests"))) { + buildPath.chop(10); + } + QCoreApplication::addLibraryPath(buildPath); +} + void PartTest::testFd() { // find ping @@ -62,7 +80,7 @@ void PartTest::testFd() // create a Konsole part and attempt to connect to it KParts::Part *terminalPart = createPart(); if (terminalPart == nullptr) { // not found - QSKIP("konsolepart not found."); + QFAIL("konsolepart not found."); return; } @@ -97,13 +115,15 @@ void PartTest::testFd() ptyProcess.waitForFinished(1000); } + KParts::Part *PartTest::createPart() { - KService::Ptr service = KService::serviceByDesktopName(QStringLiteral("konsolepart")); - if (!service) { // not found + auto konsolePartPlugin = KPluginLoader::findPlugin(QStringLiteral("konsolepart")); + if (konsolePartPlugin.isNull()) { return nullptr; } - KPluginFactory *factory = KPluginLoader(service->library()).factory(); + + KPluginFactory *factory = KPluginLoader(konsolePartPlugin).factory(); if (factory == nullptr) { // not found return nullptr; } diff --git a/src/autotests/PartTest.h b/src/autotests/PartTest.h index acd1a02b..fc3808a8 100644 --- a/src/autotests/PartTest.h +++ b/src/autotests/PartTest.h @@ -33,6 +33,7 @@ class PartTest : public QObject Q_OBJECT private Q_SLOTS: + void initTestCase(); void testFd(); private: