diff --git a/src/tmcoutputpane.cpp b/src/tmcoutputpane.cpp index a69f941..98d7a7c 100644 --- a/src/tmcoutputpane.cpp +++ b/src/tmcoutputpane.cpp @@ -143,16 +143,6 @@ void TmcOutputPane::addTestResult(const TmcTestResult &result) navigateStateChanged(); } -// TODO: remove when not needed -void TmcOutputPane::addTestResults(const QList &results) -{ - m_model->addResults(results); - - // Focus on the results pane - flash(); - navigateStateChanged(); -} - const TmcTestResult TmcOutputPane::testResult(const QModelIndex &idx) { if (!idx.isValid()) diff --git a/src/tmcoutputpane.h b/src/tmcoutputpane.h index d3d4b20..e5c88fb 100644 --- a/src/tmcoutputpane.h +++ b/src/tmcoutputpane.h @@ -59,7 +59,6 @@ class TmcOutputPane : public Core::IOutputPane void goToPrev() override; void addTestResult(const TmcTestResult &result); - void addTestResults(const QList &results); const TmcTestResult testResult(const QModelIndex &idx); void onCustomContextMenuRequested(const QPoint &pos); diff --git a/src/tmcresultmodel.cpp b/src/tmcresultmodel.cpp index 8059782..99a839b 100644 --- a/src/tmcresultmodel.cpp +++ b/src/tmcresultmodel.cpp @@ -42,6 +42,8 @@ void TmcResultModel::addResults(const QList &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(); diff --git a/src/tmcresultreader.cpp b/src/tmcresultreader.cpp index 8b37712..e5de972 100644 --- a/src/tmcresultreader.cpp +++ b/src/tmcresultreader.cpp @@ -5,6 +5,7 @@ #include #include +#include using namespace Autotest::Internal; @@ -36,6 +37,7 @@ void TmcResultReader::testProject(Project *project) qDebug() << "Testing project null!"; return; } + m_testResults.clear(); m_project = project; TestRunner *runner = TestRunner::instance(); @@ -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; } @@ -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); diff --git a/src/tmctestresult.cpp b/src/tmctestresult.cpp index 4d63a7e..f0d20a3 100644 --- a/src/tmctestresult.cpp +++ b/src/tmctestresult.cpp @@ -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 "";