| 44 | |
| 45 | |
| 46 | static 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 | |
| 89 | void CTestRunJob::start() |
| 90 | { |
no test coverage detected