Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
119 lines (96 loc) · 2.57 KB

File metadata and controls

119 lines (96 loc) · 2.57 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
SPDX-FileCopyrightText: 2012 Miha Čančula <miha@noughmad.eu>
SPDX-License-Identifier: LGPL-2.0-or-later
*/
#include "projecttestjob.h"
#include <interfaces/icore.h>
#include <interfaces/itestcontroller.h>
#include <interfaces/iproject.h>
#include <interfaces/itestsuite.h>
#include <KLocalizedString>
using namespace KDevelop;
class KDevelop::ProjectTestJobPrivate
{
public:
explicit ProjectTestJobPrivate(ProjectTestJob* q)
: q(q)
, m_currentJob(nullptr)
, m_currentSuite(nullptr)
{}
void runNext();
void gotResult(ITestSuite* suite, const TestResult& result);
ProjectTestJob* q;
QList<ITestSuite*> m_suites;
KJob* m_currentJob;
ITestSuite* m_currentSuite;
ProjectTestResult m_result;
};
void ProjectTestJobPrivate::runNext()
{
m_currentSuite = m_suites.takeFirst();
m_currentJob = m_currentSuite->launchAllCases(ITestSuite::Silent);
m_currentJob->start();
}
void ProjectTestJobPrivate::gotResult(ITestSuite* suite, const TestResult& result)
{
if (suite == m_currentSuite) {
m_result.total++;
q->emitPercent(m_result.total, m_result.total + m_suites.size());
switch (result.suiteResult) {
case TestResult::Passed:
m_result.passed++;
break;
case TestResult::Failed:
m_result.failed++;
break;
case TestResult::Error:
m_result.error++;
break;
default:
break;
}
if (m_suites.isEmpty()) {
q->emitResult();
} else {
runNext();
}
}
}
ProjectTestJob::ProjectTestJob(IProject* project, QObject* parent)
: KJob(parent)
, d_ptr(new ProjectTestJobPrivate(this))
{
Q_D(ProjectTestJob);
setCapabilities(Killable);
setObjectName(i18n("Run all tests in %1", project->name()));
d->m_suites = ICore::self()->testController()->testSuitesForProject(project);
connect(ICore::self()->testController(), &ITestController::testRunFinished,
this, [this](ITestSuite* suite, const TestResult& result) {
Q_D(ProjectTestJob);
d->gotResult(suite, result);
});
}
ProjectTestJob::~ProjectTestJob()
{
}
void ProjectTestJob::start()
{
Q_D(ProjectTestJob);
d->runNext();
}
bool ProjectTestJob::doKill()
{
Q_D(ProjectTestJob);
if (d->m_currentJob) {
d->m_currentJob->kill();
} else {
d->m_suites.clear();
}
return true;
}
ProjectTestResult ProjectTestJob::testResult()
{
Q_D(ProjectTestJob);
return d->m_result;
}
#include "moc_projecttestjob.cpp"
Morty Proxy This is a proxified and sanitized view of the page, visit original site.