MCPcopy Create free account
hub / github.com/KDE/kdevelop / testRun

Method testRun

plugins/cmake/tests/test_cmakeserver.cpp:47–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45 }
46
47 void testRun()
48 {
49 CMakeServer server(nullptr);
50 QSignalSpy spyConnected(&server, &CMakeServer::connected);
51 QVERIFY(server.isServerAvailable() || spyConnected.wait());
52
53 QSignalSpy spy(&server, &CMakeServer::response);
54 QJsonObject codeModel;
55 int errors = 0;
56 connect(&server, &CMakeServer::response, this, [&errors, &codeModel, &server](const QJsonObject &response) {
57 if (response.value(QStringLiteral("type")) == QLatin1String("reply")) {
58 if (response.value(QStringLiteral("inReplyTo")) == QLatin1String("configure"))
59 server.compute();
60 else if (response.value(QStringLiteral("inReplyTo")) == QLatin1String("compute"))
61 server.codemodel();
62 else if(response.value(QStringLiteral("inReplyTo")) == QLatin1String("codemodel"))
63 codeModel = response;
64 } else if(response.value(QStringLiteral("type")) == QLatin1String("error")) {
65 ++errors;
66 }
67 });
68
69 const QString name = QStringLiteral("single_subdirectory");
70 const auto paths = projectPaths(name);
71 const QString builddir = QStringLiteral(CMAKE_TESTS_BINARY_DIR "/cmake-server-test-builddir/") + name;
72 QVERIFY(QDir(builddir).removeRecursively());
73 QVERIFY(QDir(builddir).mkpath(builddir));
74
75 QVERIFY(spy.wait());
76 server.handshake(paths.sourceDir, Path(builddir));
77 QVERIFY(spy.wait());
78 server.configure({});
79 while(codeModel.isEmpty())
80 QVERIFY(spy.wait());
81 QCOMPARE(errors, 0);
82 QVERIFY(!codeModel.isEmpty());
83 qDebug() << "codemodel" << codeModel;
84 }
85};
86
87QTEST_MAIN( CMakeServerTest )

Callers

nothing calls this directly

Calls 12

projectPathsFunction · 0.85
isServerAvailableMethod · 0.80
waitMethod · 0.80
computeMethod · 0.80
codemodelMethod · 0.80
removeRecursivelyMethod · 0.80
handshakeMethod · 0.80
QDirClass · 0.50
PathClass · 0.50
valueMethod · 0.45
configureMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected