Add unit tests.

These test the complete workflow as the user experiences it when
clicking "Start".
Intended usage:
    (1) Run sdktool to set up a kit with the toolchain you want
        to test against (using a temporary directory).
        The tests assume exactly one Kit to be present.
    (2) Start Creator with a matching settings path and
        "-load ClangStaticAnalyzer -test ClangStaticAnalyzer".
    (3) Repeat until all toolchains have been tested.
The initial implementation tests one trivial source file
with both qbs and qmake.

Change-Id: I810f23e2990a789a4dd9f1dd16335fbcf5c5f39f
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Christian Kandeler
2015-02-04 15:19:30 +01:00
parent c632be5c92
commit 2946364ce6
13 changed files with 227 additions and 0 deletions

View File

@@ -54,6 +54,7 @@ ClangStaticAnalyzerTool::ClangStaticAnalyzerTool(QObject *parent)
, m_diagnosticView(0)
, m_goBack(0)
, m_goNext(0)
, m_running(false)
{
setObjectName(QLatin1String("ClangStaticAnalyzerTool"));
setRunMode(ProjectExplorer::ClangStaticAnalyzerMode);
@@ -206,6 +207,7 @@ void ClangStaticAnalyzerTool::startTool(StartMode mode)
QTC_ASSERT(project, return);
m_projectInfoBeforeBuild = CppTools::CppModelManager::instance()->projectInfo(project);
QTC_ASSERT(m_projectInfoBeforeBuild.isValid(), return);
m_running = true;
ProjectExplorerPlugin::instance()->runProject(project, runMode());
}
@@ -220,6 +222,11 @@ void ClangStaticAnalyzerTool::resetCursorAndProjectInfoBeforeBuild()
m_projectInfoBeforeBuild = CppTools::ProjectInfo();
}
QList<Diagnostic> ClangStaticAnalyzerTool::diagnostics() const
{
return m_diagnosticModel->diagnostics();
}
void ClangStaticAnalyzerTool::onEngineIsStarting()
{
QTC_ASSERT(m_diagnosticModel, return);
@@ -246,6 +253,8 @@ void ClangStaticAnalyzerTool::onEngineFinished()
AnalyzerManager::showStatusMessage(issuesFound > 0
? AnalyzerManager::tr("Clang Static Analyzer finished, %n issues were found.", 0, issuesFound)
: AnalyzerManager::tr("Clang Static Analyzer finished, no issues were found."));
m_running = false;
emit finished();
}
void ClangStaticAnalyzerTool::setBusyCursor(bool busy)