MCPcopy Create free account
hub / github.com/KDE/kdevelop / createTestJob

Function createTestJob

plugins/cmake/testing/ctestrunjob.cpp:46–87  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45
46static KJob* createTestJob(const QString& launchModeId, const QStringList& arguments, const QString &workingDirectory)
47{
48 LaunchConfigurationType* type = ICore::self()->runController()->launchConfigurationTypeForId( QStringLiteral("Native Application") );
49 ILaunchMode* mode = ICore::self()->runController()->launchModeForId( launchModeId );
50
51 qCDebug(CMAKE_TESTING) << "got mode and type:" << type << type->id() << mode << mode->id();
52 Q_ASSERT(type && mode);
53
54 ILauncher* launcher = [type, mode]() {
55 const auto launchers = type->launchers();
56 auto it = std::find_if(launchers.begin(), launchers.end(), [mode](ILauncher *l) {
57 return l->supportedModes().contains(mode->id());
58 });
59 Q_ASSERT(it != launchers.end());
60 return *it;
61 }();
62 Q_ASSERT(launcher);
63
64 auto ilaunch = [type]() {
65 const auto launchConfigurations = ICore::self()->runController()->launchConfigurations();
66 auto it = std::find_if(launchConfigurations.begin(), launchConfigurations.end(),
67 [type](ILaunchConfiguration* l) {
68 return (l->type() == type && l->config().readEntry("ConfiguredByCTest", false));
69 });
70 return it == launchConfigurations.end() ? nullptr : *it;
71 }();
72
73 if (!ilaunch) {
74 ilaunch = ICore::self()->runController()->createLaunchConfiguration( type,
75 qMakePair( mode->id(), launcher->id() ),
76 nullptr, //TODO add project
77 i18n("CTest") );
78 ilaunch->config().writeEntry("ConfiguredByCTest", true);
79 //qCDebug(CMAKE_TESTING) << "created config, launching";
80 } else {
81 //qCDebug(CMAKE_TESTING) << "reusing generated config, launching";
82 }
83 if (!workingDirectory.isEmpty())
84 ilaunch->config().writeEntry( "Working Directory", QUrl::fromLocalFile( workingDirectory ) );
85 type->configureLaunchFromCmdLineArguments( ilaunch->config(), arguments );
86 return ICore::self()->runController()->execute(launchModeId, ilaunch);
87}
88
89void CTestRunJob::start()
90{

Callers 1

startMethod · 0.85

Calls 15

runControllerMethod · 0.80
launchModeForIdMethod · 0.80
launchersMethod · 0.80
launchConfigurationsMethod · 0.80
readEntryMethod · 0.80
writeEntryMethod · 0.80
idMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
containsMethod · 0.45

Tested by

no test coverage detected