diff --git a/plugins/perforce/tests/CMakeLists.txt b/plugins/perforce/tests/CMakeLists.txt --- a/plugins/perforce/tests/CMakeLists.txt +++ b/plugins/perforce/tests/CMakeLists.txt @@ -9,11 +9,7 @@ ${kdevperforce_LOG_PART_SRCS} ) -if(WIN32) - add_definitions( "-DP4_CLIENT_STUB_EXE=\"${CMAKE_CURRENT_BINARY_DIR}/../../../bin/p4clientstub.exe\"" ) -else() - add_definitions( "-DP4_CLIENT_STUB_EXE=\"${CMAKE_CURRENT_BINARY_DIR}/../p4clientstub/p4clientstub\"" ) -endif() +add_definitions( "-DP4_BINARY_DIR=\"${PROJECT_BINARY_DIR}\"") ecm_add_test(${perforceplugintest_SRCS} TEST_NAME test_kdevperforce diff --git a/plugins/perforce/tests/test_perforce.cpp b/plugins/perforce/tests/test_perforce.cpp --- a/plugins/perforce/tests/test_perforce.cpp +++ b/plugins/perforce/tests/test_perforce.cpp @@ -22,6 +22,8 @@ #include "test_perforce.h" #include +#include +#include #include #include @@ -52,6 +54,19 @@ AutoTestShell::init({QStringLiteral("kdevperforce")}); TestCore::initialize(); m_plugin = new PerforcePlugin(TestCore::self()); + + /// During test we are setting the executable the plugin uses to our own stub + QDirIterator it(P4_BINARY_DIR , QStringList() << QStringLiteral("*"), QDir::Dirs | QDir::NoDotAndDotDot, QDirIterator::Subdirectories); + QStringList pathsToSearch; + while (it.hasNext()) { + it.next(); + pathsToSearch << it.filePath(); + } + QString p4stubPath = QStandardPaths::findExecutable("p4clientstub", pathsToSearch); + qDebug() << "found p4stub executable :" << p4stubPath; + QVERIFY(!p4stubPath.isEmpty()); + + m_plugin->m_perforceExecutable = p4stubPath; } void PerforcePluginTest::cleanupTestCase() @@ -63,8 +78,6 @@ void PerforcePluginTest::init() { - /// During test we are setting the executable the plugin uses to our own stub - m_plugin->m_perforceExecutable = P4_CLIENT_STUB_EXE; removeTempDirsIfAny(); createNewTempDirs(); } @@ -187,7 +200,7 @@ srcRevision.setRevisionValue(QVariant(1), VcsRevision::GlobalNumber); VcsRevision dstRevision; dstRevision.setRevisionValue(QVariant(2), VcsRevision::GlobalNumber); - + VcsJob* j = m_plugin->diff( QUrl::fromLocalFile(perforceTestBaseDir + perforceTest_FileName), srcRevision, dstRevision); VERIFYJOB(j); }