forked from qt-creator/qt-creator
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:
@@ -1063,7 +1063,7 @@ void ClangTool::onRunControlStopped()
|
||||
{
|
||||
if (m_state != State::StoppedByUser && m_state != State::PreparationFailed)
|
||||
setState(State::AnalyzerFinished);
|
||||
emit finished(m_runWorker->success());
|
||||
emit finished(m_infoBarWidget->errorText());
|
||||
}
|
||||
|
||||
void ClangTool::update()
|
||||
|
||||
@@ -109,7 +109,7 @@ public:
|
||||
QAction *startOnCurrentFileAction() const { return m_startOnCurrentFileAction; }
|
||||
|
||||
signals:
|
||||
void finished(bool success); // For testing.
|
||||
void finished(const QString &errorText); // For testing.
|
||||
|
||||
private:
|
||||
enum class State {
|
||||
|
||||
@@ -319,7 +319,6 @@ void ClangToolRunWorker::start()
|
||||
m_runners.clear();
|
||||
const int parallelRuns = m_runSettings.parallelJobs();
|
||||
QTC_ASSERT(parallelRuns >= 1, reportFailure(); return);
|
||||
m_success = true;
|
||||
|
||||
if (m_queue.isEmpty()) {
|
||||
finalize();
|
||||
@@ -420,7 +419,6 @@ void ClangToolRunWorker::onRunnerFinishedWithFailure(const QString &errorMessage
|
||||
|
||||
m_filesAnalyzed.remove(fileToAnalyze);
|
||||
m_filesNotAnalyzed.insert(fileToAnalyze);
|
||||
m_success = false;
|
||||
|
||||
const QString message = tr("Failed to analyze \"%1\": %2").arg(fileToAnalyze, errorMessage);
|
||||
appendMessage(message, Utils::StdErrFormat);
|
||||
|
||||
@@ -72,8 +72,6 @@ public:
|
||||
const FileInfos &fileInfos,
|
||||
bool buildBeforeAnalysis);
|
||||
|
||||
bool success() const { return m_success; } // For testing.
|
||||
|
||||
int filesAnalyzed() const { return m_filesAnalyzed.size(); }
|
||||
int filesNotAnalyzed() const { return m_filesNotAnalyzed.size(); }
|
||||
int totalFilesToAnalyze() const { return m_fileInfos.size(); }
|
||||
@@ -125,7 +123,6 @@ private:
|
||||
int m_initialQueueSize = 0;
|
||||
QSet<QString> m_filesAnalyzed;
|
||||
QSet<QString> m_filesNotAnalyzed;
|
||||
bool m_success = false;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user