Index: kdevplatform/project/tests/abstractfilemanagerpluginimportbenchmark.cpp =================================================================== --- kdevplatform/project/tests/abstractfilemanagerpluginimportbenchmark.cpp +++ kdevplatform/project/tests/abstractfilemanagerpluginimportbenchmark.cpp @@ -17,19 +17,24 @@ Boston, MA 02110-1301, USA. */ +#include +#include +#include + #include #include #include #include #include +#include #include #include #include -#include +#include #include #include #include @@ -46,9 +51,10 @@ Q_OBJECT public: AbstractFileManagerPluginImportBenchmark(AbstractFileManagerPlugin* manager, const QString& path, - QObject* parent) - : QObject(parent) + TestCore* core) + : QObject(core) , m_out(stdout) + , m_core(core) { m_manager = manager; m_project = new TestProject(Path(path)); @@ -58,6 +64,8 @@ { m_projectNumber = s_numBenchmarksRunning++; m_out << "Starting import of project " << m_project->path().toLocalFile() << endl; + // emulate the signal from the ProjectController to the ProjectFilterProvider(s): + emit m_core->projectController()->projectAboutToBeOpened(m_project); m_timer.start(); auto root = m_manager->import(m_project); int elapsed = m_timer.elapsed(); @@ -75,6 +83,7 @@ QElapsedTimer m_timer; int m_projectNumber; QTextStream m_out; + TestCore* m_core; static int s_numBenchmarksRunning; @@ -86,8 +95,9 @@ { Q_UNUSED(job); int elapsed = m_timer.elapsed(); - m_out << "importing project " << m_projectNumber << " took " - << elapsed / 1000.0 << " seconds" << endl; + m_out << "importing " << m_project->fileSet().size() + << " items into project #" << m_projectNumber + << " took " << elapsed / 1000.0 << " seconds" << endl; s_numBenchmarksRunning -= 1; if (s_numBenchmarksRunning <= 0) { @@ -103,10 +113,10 @@ int main(int argc, char** argv) { if (argc < 2) { - qWarning() << "Usage:" << argv[0] << "projectDir1 [...projectDirN]"; + qWarning() << "Usage:" << argv[0] << "[--withFilters] projectDir1 [...projectDirN]"; return 1; } - QCoreApplication app(argc, argv); + QApplication app(argc, argv); QTextStream qout(stdout); // measure the total test time, this provides an indication // of overhead and how well multiple projects are imported in parallel @@ -117,15 +127,23 @@ QElapsedTimer runTimer; AutoTestShell::init({"no plugins"}); - auto core = TestCore::initialize(Core::NoUi); + bool withFilters = argc >= 2 && strcmp(argv[1], "--withFilters") == 0; + // The Project Filter plugin will not be available when TestCore::initialize() + // is called with Core::NoUI, which provides a simple mechanism to determine + // whether project filters will be applied or not. + auto core = TestCore::initialize(withFilters ? Core::Default : Core::NoUi); + // attempt to load the plugin; will succeed depending on the TestCore::initialize() call. + if (core->pluginController()->allPluginsForExtension(QStringLiteral("org.kdevelop.IProjectFilter")).size() < 1) { + qWarning() << "The project filter plugin was not loaded"; + } auto manager = new AbstractFileManagerPlugin({}, core); const char *kdwMethod[] = {"FAM", "Inotify", "Stat", "QFSWatch"}; qout << "KDirWatch backend: " << kdwMethod[KDirWatch().internalMethod()] << endl; QList benchmarks; - for (int i = 1 ; i < argc ; ++i) { + for (int i = withFilters ? 2 : 1 ; i < argc ; ++i) { const QString path = QString::fromUtf8(argv[i]); if (QFileInfo(path).isDir()) { const auto benchmark = new AbstractFileManagerPluginImportBenchmark(manager, path, core);