Skip to content

Commit 9f657fd

Browse files
author
Kimmo Linnavuo
committed
Fix #80
Now we take FATAL messages into consideration from the test runner
1 parent bbe9499 commit 9f657fd

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

src/tmcoutputpane.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,6 @@ void TmcOutputPane::addTestResult(const TmcTestResult &result)
143143
navigateStateChanged();
144144
}
145145

146-
// TODO: remove when not needed
147-
void TmcOutputPane::addTestResults(const QList<TmcTestResult> &results)
148-
{
149-
m_model->addResults(results);
150-
151-
// Focus on the results pane
152-
flash();
153-
navigateStateChanged();
154-
}
155-
156146
const TmcTestResult TmcOutputPane::testResult(const QModelIndex &idx)
157147
{
158148
if (!idx.isValid())

src/tmcoutputpane.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ class TmcOutputPane : public Core::IOutputPane
5959
void goToPrev() override;
6060

6161
void addTestResult(const TmcTestResult &result);
62-
void addTestResults(const QList<TmcTestResult> &results);
6362
const TmcTestResult testResult(const QModelIndex &idx);
6463

6564
void onCustomContextMenuRequested(const QPoint &pos);

src/tmcresultmodel.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ void TmcResultModel::addResults(const QList<TmcTestResult> &results)
4242

4343
void TmcResultModel::clearResults()
4444
{
45+
if (m_results.empty())
46+
return;
4547
beginRemoveRows(QModelIndex(), 0, m_results.count() - 1);
4648
m_results.erase(m_results.begin(), m_results.end());
4749
endRemoveRows();

src/tmcresultreader.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include <autotest/testtreemodel.h>
66

77
#include <QDebug>
8+
#include <algorithm>
89

910
using namespace Autotest::Internal;
1011

@@ -36,6 +37,7 @@ void TmcResultReader::testProject(Project *project)
3637
qDebug() << "Testing project null!";
3738
return;
3839
}
40+
3941
m_testResults.clear();
4042
m_project = project;
4143
TestRunner *runner = TestRunner::instance();
@@ -92,6 +94,14 @@ void TmcResultReader::readTestResult(const TestResultPtr &result) {
9294
// emit testResultReady(TmcTestResult(TmcResult::TestCaseEnd));
9395
break;
9496

97+
case Result::MessageFatal:
98+
// Test runner has most likely crashed, mark the test as invalid
99+
m_openResult.setResult(TmcResult::Invalid);
100+
m_openResult.setMessage("Test runner failed to run. It may have crashed or failed to build.");
101+
m_testResults.append(m_openResult);
102+
emit testResultReady(m_openResult);
103+
break;
104+
95105
default:
96106
break;
97107
}
@@ -104,16 +114,12 @@ void TmcResultReader::resultsReady() {
104114
return;
105115
}
106116

107-
bool testsPassed = true;
108-
foreach (TmcTestResult r, m_testResults) {
109-
qDebug() << r.name() << r.result() << r.points();
110-
if (r.result() != TmcResult::Pass) {
111-
testsPassed = false;
112-
}
113-
}
114-
115117
emit testRunFinished();
116118

119+
auto not_passing = std::find_if(m_testResults.begin(), m_testResults.end(),
120+
[](TmcTestResult r) { return r.result() != TmcResult::Pass; });
121+
bool testsPassed = not_passing == m_testResults.end();
122+
117123
if (testsPassed) {
118124
qDebug("Project tests passed");
119125
emit projectTestsPassed(m_project);

src/tmctestresult.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,17 @@ QString TmcTestResult::toString() const
2020
foreach (QString point, m_points) {
2121
points.append(QString("[ %1 ]").arg(point));
2222
}
23-
return QString("[%1]: %2, points awarded: %3").arg(m_name, "PASSED", points);
23+
return QString("[%1]: PASSED, points awarded: %2").arg(m_name, points);
2424
}
2525

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

2929
case TmcResult::Invalid:
30-
return QString("Invalid");
30+
if (m_name.isEmpty())
31+
return QString("INVALID: %1").arg(m_message);
32+
else
33+
return QString("[%1]: INVALID: %2").arg(m_name, m_message);
3134

3235
case TmcResult::TestCaseStart:
3336
return "";

0 commit comments

Comments
 (0)