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)
|
if (m_state != State::StoppedByUser && m_state != State::PreparationFailed)
|
||||||
setState(State::AnalyzerFinished);
|
setState(State::AnalyzerFinished);
|
||||||
emit finished(m_runWorker->success());
|
emit finished(m_infoBarWidget->errorText());
|
||||||
}
|
}
|
||||||
|
|
||||||
void ClangTool::update()
|
void ClangTool::update()
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ public:
|
|||||||
QAction *startOnCurrentFileAction() const { return m_startOnCurrentFileAction; }
|
QAction *startOnCurrentFileAction() const { return m_startOnCurrentFileAction; }
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void finished(bool success); // For testing.
|
void finished(const QString &errorText); // For testing.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum class State {
|
enum class State {
|
||||||
|
|||||||
@@ -319,7 +319,6 @@ void ClangToolRunWorker::start()
|
|||||||
m_runners.clear();
|
m_runners.clear();
|
||||||
const int parallelRuns = m_runSettings.parallelJobs();
|
const int parallelRuns = m_runSettings.parallelJobs();
|
||||||
QTC_ASSERT(parallelRuns >= 1, reportFailure(); return);
|
QTC_ASSERT(parallelRuns >= 1, reportFailure(); return);
|
||||||
m_success = true;
|
|
||||||
|
|
||||||
if (m_queue.isEmpty()) {
|
if (m_queue.isEmpty()) {
|
||||||
finalize();
|
finalize();
|
||||||
@@ -420,7 +419,6 @@ void ClangToolRunWorker::onRunnerFinishedWithFailure(const QString &errorMessage
|
|||||||
|
|
||||||
m_filesAnalyzed.remove(fileToAnalyze);
|
m_filesAnalyzed.remove(fileToAnalyze);
|
||||||
m_filesNotAnalyzed.insert(fileToAnalyze);
|
m_filesNotAnalyzed.insert(fileToAnalyze);
|
||||||
m_success = false;
|
|
||||||
|
|
||||||
const QString message = tr("Failed to analyze \"%1\": %2").arg(fileToAnalyze, errorMessage);
|
const QString message = tr("Failed to analyze \"%1\": %2").arg(fileToAnalyze, errorMessage);
|
||||||
appendMessage(message, Utils::StdErrFormat);
|
appendMessage(message, Utils::StdErrFormat);
|
||||||
|
|||||||
@@ -72,8 +72,6 @@ public:
|
|||||||
const FileInfos &fileInfos,
|
const FileInfos &fileInfos,
|
||||||
bool buildBeforeAnalysis);
|
bool buildBeforeAnalysis);
|
||||||
|
|
||||||
bool success() const { return m_success; } // For testing.
|
|
||||||
|
|
||||||
int filesAnalyzed() const { return m_filesAnalyzed.size(); }
|
int filesAnalyzed() const { return m_filesAnalyzed.size(); }
|
||||||
int filesNotAnalyzed() const { return m_filesNotAnalyzed.size(); }
|
int filesNotAnalyzed() const { return m_filesNotAnalyzed.size(); }
|
||||||
int totalFilesToAnalyze() const { return m_fileInfos.size(); }
|
int totalFilesToAnalyze() const { return m_fileInfos.size(); }
|
||||||
@@ -125,7 +123,6 @@ private:
|
|||||||
int m_initialQueueSize = 0;
|
int m_initialQueueSize = 0;
|
||||||
QSet<QString> m_filesAnalyzed;
|
QSet<QString> m_filesAnalyzed;
|
||||||
QSet<QString> m_filesNotAnalyzed;
|
QSet<QString> m_filesNotAnalyzed;
|
||||||
bool m_success = false;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -107,19 +107,26 @@ void ClangToolsUnitTests::testProject()
|
|||||||
QSKIP("This test is mingw specific, does not run for other toolchains");
|
QSKIP("This test is mingw specific, does not run for other toolchains");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Open project
|
||||||
Tests::ProjectOpenerAndCloser projectManager;
|
Tests::ProjectOpenerAndCloser projectManager;
|
||||||
const ProjectInfo projectInfo = projectManager.open(projectFilePath, true);
|
const ProjectInfo projectInfo = projectManager.open(projectFilePath, true);
|
||||||
QVERIFY(projectInfo.isValid());
|
const bool isProjectOpen = projectInfo.isValid();
|
||||||
|
QVERIFY(isProjectOpen);
|
||||||
|
|
||||||
|
// Run tool
|
||||||
ClangTool *tool = ClangTool::instance();
|
ClangTool *tool = ClangTool::instance();
|
||||||
tool->startTool(ClangTool::FileSelection::AllFiles,
|
tool->startTool(ClangTool::FileSelection::AllFiles,
|
||||||
ClangToolsSettings::instance()->runSettings(),
|
ClangToolsSettings::instance()->runSettings(),
|
||||||
diagnosticConfig);
|
diagnosticConfig);
|
||||||
QSignalSpy waiter(tool, SIGNAL(finished(bool)));
|
QSignalSpy waitForFinishedTool(tool, &ClangTool::finished);
|
||||||
QVERIFY(waiter.wait(30000));
|
QVERIFY(waitForFinishedTool.wait(30000));
|
||||||
|
|
||||||
const QList<QVariant> arguments = waiter.takeFirst();
|
// Check for errors
|
||||||
QVERIFY(arguments.first().toBool());
|
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);
|
QCOMPARE(tool->diagnostics().count(), expectedDiagCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user