Skip to content

Commit

Permalink
Fix #80
Browse files Browse the repository at this point in the history
Now we take FATAL messages into consideration from the test runner
  • Loading branch information
Kimmo Linnavuo committed Dec 2, 2018
1 parent bbe9499 commit 9f657fd
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
10 changes: 0 additions & 10 deletions src/tmcoutputpane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,6 @@ void TmcOutputPane::addTestResult(const TmcTestResult &result)
navigateStateChanged();
}

// TODO: remove when not needed
void TmcOutputPane::addTestResults(const QList<TmcTestResult> &results)
{
m_model->addResults(results);

// Focus on the results pane
flash();
navigateStateChanged();
}

const TmcTestResult TmcOutputPane::testResult(const QModelIndex &idx)
{
if (!idx.isValid())
Expand Down
1 change: 0 additions & 1 deletion src/tmcoutputpane.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ class TmcOutputPane : public Core::IOutputPane
void goToPrev() override;

void addTestResult(const TmcTestResult &result);
void addTestResults(const QList<TmcTestResult> &results);
const TmcTestResult testResult(const QModelIndex &idx);

void onCustomContextMenuRequested(const QPoint &pos);
Expand Down
2 changes: 2 additions & 0 deletions src/tmcresultmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ void TmcResultModel::addResults(const QList<TmcTestResult> &results)

void TmcResultModel::clearResults()
{
if (m_results.empty())
return;
beginRemoveRows(QModelIndex(), 0, m_results.count() - 1);
m_results.erase(m_results.begin(), m_results.end());
endRemoveRows();
Expand Down
22 changes: 14 additions & 8 deletions src/tmcresultreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <autotest/testtreemodel.h>

#include <QDebug>
#include <algorithm>

using namespace Autotest::Internal;

Expand Down Expand Up @@ -36,6 +37,7 @@ void TmcResultReader::testProject(Project *project)
qDebug() << "Testing project null!";
return;
}

m_testResults.clear();
m_project = project;
TestRunner *runner = TestRunner::instance();
Expand Down Expand Up @@ -92,6 +94,14 @@ void TmcResultReader::readTestResult(const TestResultPtr &result) {
// emit testResultReady(TmcTestResult(TmcResult::TestCaseEnd));
break;

case Result::MessageFatal:
// Test runner has most likely crashed, mark the test as invalid
m_openResult.setResult(TmcResult::Invalid);
m_openResult.setMessage("Test runner failed to run. It may have crashed or failed to build.");
m_testResults.append(m_openResult);
emit testResultReady(m_openResult);
break;

default:
break;
}
Expand All @@ -104,16 +114,12 @@ void TmcResultReader::resultsReady() {
return;
}

bool testsPassed = true;
foreach (TmcTestResult r, m_testResults) {
qDebug() << r.name() << r.result() << r.points();
if (r.result() != TmcResult::Pass) {
testsPassed = false;
}
}

emit testRunFinished();

auto not_passing = std::find_if(m_testResults.begin(), m_testResults.end(),
[](TmcTestResult r) { return r.result() != TmcResult::Pass; });
bool testsPassed = not_passing == m_testResults.end();

if (testsPassed) {
qDebug("Project tests passed");
emit projectTestsPassed(m_project);
Expand Down
9 changes: 6 additions & 3 deletions src/tmctestresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ QString TmcTestResult::toString() const
foreach (QString point, m_points) {
points.append(QString("[ %1 ]").arg(point));
}
return QString("[%1]: %2, points awarded: %3").arg(m_name, "PASSED", points);
return QString("[%1]: PASSED, points awarded: %2").arg(m_name, points);
}

case TmcResult::Fail:
return QString("[%1]: %2 %3").arg(m_name, "FAILED", m_message);
return QString("[%1]: FAILED: %2").arg(m_name, m_message);

case TmcResult::Invalid:
return QString("Invalid");
if (m_name.isEmpty())
return QString("INVALID: %1").arg(m_message);
else
return QString("[%1]: INVALID: %2").arg(m_name, m_message);

case TmcResult::TestCaseStart:
return "";
Expand Down

0 comments on commit 9f657fd

Please sign in to comment.