ClangCodeModel: Use a configurable timeout in the tests

Change-Id: Ie3923217f79a72d2774aaa2a499144c3191cb478
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-10-16 13:43:54 +02:00
parent 30f21bcf01
commit 3ff8c42431
3 changed files with 17 additions and 13 deletions

View File

@@ -58,10 +58,11 @@
#include <QThread> #include <QThread>
using namespace ClangBackEnd; using namespace ClangBackEnd;
using namespace ClangCodeModel;
using namespace ClangCodeModel::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
namespace ClangCodeModel {
namespace Internal {
static Q_LOGGING_CATEGORY(debug, "qtc.clangcodemodel.batch", QtWarningMsg); static Q_LOGGING_CATEGORY(debug, "qtc.clangcodemodel.batch", QtWarningMsg);
static int timeOutFromEnvironmentVariable() static int timeOutFromEnvironmentVariable()
@@ -78,7 +79,7 @@ static int timeOutFromEnvironmentVariable()
return intervalAsInt; return intervalAsInt;
} }
static int timeOutInMs() int timeOutInMs()
{ {
static int timeOut = timeOutFromEnvironmentVariable(); static int timeOut = timeOutFromEnvironmentVariable();
return timeOut; return timeOut;
@@ -747,9 +748,6 @@ bool BatchFileParser::parseLine(const QString &line)
} // anonymous namespace } // anonymous namespace
namespace ClangCodeModel {
namespace Internal {
static QString applySubstitutions(const QString &filePath, const QString &text) static QString applySubstitutions(const QString &filePath, const QString &text)
{ {
const QString dirPath = QFileInfo(filePath).absolutePath(); const QString dirPath = QFileInfo(filePath).absolutePath();

View File

@@ -30,6 +30,8 @@
namespace ClangCodeModel { namespace ClangCodeModel {
namespace Internal { namespace Internal {
int timeOutInMs();
bool runClangBatchFile(const QString &filePath); bool runClangBatchFile(const QString &filePath);
} // namespace Internal } // namespace Internal

View File

@@ -26,6 +26,7 @@
#include "clangcodecompletion_test.h" #include "clangcodecompletion_test.h"
#include "clangautomationutils.h" #include "clangautomationutils.h"
#include "clangbatchfileprocessor.h"
#include "../clangcompletionassistinterface.h" #include "../clangcompletionassistinterface.h"
#include "../clangmodelmanagersupport.h" #include "../clangmodelmanagersupport.h"
@@ -344,7 +345,7 @@ public:
if (!textToInsert.isEmpty()) if (!textToInsert.isEmpty())
openEditor.editor()->insert(textToInsert); openEditor.editor()->insert(textToInsert);
proposal = completionResults(openEditor.editor(), includePaths, 15000); proposal = completionResults(openEditor.editor(), includePaths, timeOutInMs());
} }
TextEditor::ProposalModelPtr proposal; TextEditor::ProposalModelPtr proposal;
@@ -657,7 +658,8 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCode()
OpenEditorAtCursorPosition openEditor(testDocument); OpenEditorAtCursorPosition openEditor(testDocument);
QVERIFY(openEditor.succeeded()); QVERIFY(openEditor.succeeded());
TextEditor::ProposalModelPtr proposal = completionResults(openEditor.editor()); TextEditor::ProposalModelPtr proposal = completionResults(openEditor.editor(), {},
timeOutInMs());
QVERIFY(hasItem(proposal, "projectConfiguration1")); QVERIFY(hasItem(proposal, "projectConfiguration1"));
} }
@@ -670,7 +672,8 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCodeAfterChangingProje
QVERIFY(openEditor.succeeded()); QVERIFY(openEditor.succeeded());
// Check completion without project // Check completion without project
TextEditor::ProposalModelPtr proposal = completionResults(openEditor.editor()); TextEditor::ProposalModelPtr proposal = completionResults(openEditor.editor(), {},
timeOutInMs());
QVERIFY(hasItem(proposal, "noProjectConfigurationDetected")); QVERIFY(hasItem(proposal, "noProjectConfigurationDetected"));
{ {
@@ -681,7 +684,7 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCodeAfterChangingProje
QVERIFY(projectLoader.load()); QVERIFY(projectLoader.load());
openEditor.waitUntilProjectPartChanged(QLatin1String("myproject.project")); openEditor.waitUntilProjectPartChanged(QLatin1String("myproject.project"));
proposal = completionResults(openEditor.editor()); proposal = completionResults(openEditor.editor(), {}, timeOutInMs());
QVERIFY(hasItem(proposal, "projectConfiguration1")); QVERIFY(hasItem(proposal, "projectConfiguration1"));
QVERIFY(!hasItem(proposal, "projectConfiguration2")); QVERIFY(!hasItem(proposal, "projectConfiguration2"));
@@ -689,7 +692,7 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCodeAfterChangingProje
// Check completion with project configuration 2 // Check completion with project configuration 2
QVERIFY(projectLoader.updateProject({{"PROJECT_CONFIGURATION_2"}})); QVERIFY(projectLoader.updateProject({{"PROJECT_CONFIGURATION_2"}}));
openEditor.waitUntilBackendIsNotified(); openEditor.waitUntilBackendIsNotified();
proposal = completionResults(openEditor.editor()); proposal = completionResults(openEditor.editor(), {}, timeOutInMs());
QVERIFY(!hasItem(proposal, "projectConfiguration1")); QVERIFY(!hasItem(proposal, "projectConfiguration1"));
QVERIFY(hasItem(proposal, "projectConfiguration2")); QVERIFY(hasItem(proposal, "projectConfiguration2"));
@@ -697,7 +700,7 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCodeAfterChangingProje
// Check again completion without project // Check again completion without project
openEditor.waitUntilProjectPartChanged(QLatin1String("")); openEditor.waitUntilProjectPartChanged(QLatin1String(""));
proposal = completionResults(openEditor.editor()); proposal = completionResults(openEditor.editor(), {}, timeOutInMs());
QVERIFY(hasItem(proposal, "noProjectConfigurationDetected")); QVERIFY(hasItem(proposal, "noProjectConfigurationDetected"));
} }
@@ -723,7 +726,8 @@ void ClangCodeCompletionTest::testCompleteProjectDependingCodeInGeneratedUiFile(
QVERIFY(openSource.succeeded()); QVERIFY(openSource.succeeded());
// ...and check comletions // ...and check comletions
TextEditor::ProposalModelPtr proposal = completionResults(openSource.editor()); TextEditor::ProposalModelPtr proposal = completionResults(openSource.editor(), {},
timeOutInMs());
QVERIFY(hasItem(proposal, "menuBar")); QVERIFY(hasItem(proposal, "menuBar"));
QVERIFY(hasItem(proposal, "statusBar")); QVERIFY(hasItem(proposal, "statusBar"));
QVERIFY(hasItem(proposal, "centralWidget")); QVERIFY(hasItem(proposal, "centralWidget"));