ClangTools: Provide more information if plugin tests fail

Print the error text we are showing in the info bar. For example:

  QWARN  : ...testProject(simple.pro) Error: Failed to build the project.
  FAIL!  : ...testProject(simple.pro) 'finishedSuccessfully' returned FALSE. ()

Change-Id: I7df91909dc4974a2c3aa9d44cb7511222517198c
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Nikolai Kosjar
2019-11-28 16:17:57 +01:00
parent 07ec6de8d9
commit ab47d562a1
5 changed files with 14 additions and 12 deletions

View File

@@ -107,19 +107,26 @@ void ClangToolsUnitTests::testProject()
QSKIP("This test is mingw specific, does not run for other toolchains");
}
// Open project
Tests::ProjectOpenerAndCloser projectManager;
const ProjectInfo projectInfo = projectManager.open(projectFilePath, true);
QVERIFY(projectInfo.isValid());
const bool isProjectOpen = projectInfo.isValid();
QVERIFY(isProjectOpen);
// Run tool
ClangTool *tool = ClangTool::instance();
tool->startTool(ClangTool::FileSelection::AllFiles,
ClangToolsSettings::instance()->runSettings(),
diagnosticConfig);
QSignalSpy waiter(tool, SIGNAL(finished(bool)));
QVERIFY(waiter.wait(30000));
QSignalSpy waitForFinishedTool(tool, &ClangTool::finished);
QVERIFY(waitForFinishedTool.wait(30000));
const QList<QVariant> arguments = waiter.takeFirst();
QVERIFY(arguments.first().toBool());
// Check for errors
const QString errorText = waitForFinishedTool.takeFirst().first().toString();
const bool finishedSuccessfully = errorText.isEmpty();
if (!finishedSuccessfully)
qWarning("Error: %s", qPrintable(errorText));
QVERIFY(finishedSuccessfully);
QCOMPARE(tool->diagnostics().count(), expectedDiagCount);
}