예제 #1
0
void TestCompilerProvider::testRegisterCompiler()
{
    SettingsManager settings;
    auto provider = settings.provider();
    auto cf = provider->compilerFactories();
    for (int i = 0 ; i < cf.size(); ++i) {
        auto compiler = cf[i]->createCompiler(QString::number(i), QString::number(i));
        QVERIFY(provider->registerCompiler(compiler));
        QVERIFY(!provider->registerCompiler(compiler));
        QVERIFY(provider->compilers().contains(compiler));
    }
    QVERIFY(!provider->registerCompiler({}));
}
예제 #2
0
void TestCompilerProvider::testCompilerIncludesAndDefinesForProject()
{
    auto project = ProjectsGenerator::GenerateMultiPathProject();
    Q_ASSERT(project);

    SettingsManager settings;
    auto provider = settings.provider();

    Q_ASSERT(!provider->compilerFactories().isEmpty());
    auto compiler = provider->compilerFactories().first()->createCompiler("name", "path");

    QVERIFY(provider->registerCompiler(compiler));
    QVERIFY(provider->compilers().contains(compiler));

    auto projectCompiler = provider->compilerForItem(project->projectItem());

    QVERIFY(projectCompiler);
    QVERIFY(projectCompiler != compiler);

    ProjectBaseItem* mainfile = nullptr;
    for (const auto& file: project->fileSet() ) {
        for (auto i: project->filesForPath(file)) {
            if( i->text() == "main.cpp" ) {
                mainfile = i;
                break;
            }
        }
    }
    QVERIFY(mainfile);
    auto mainCompiler = provider->compilerForItem(mainfile);
    QVERIFY(mainCompiler);
    QVERIFY(mainCompiler->name() == projectCompiler->name());

    ConfigEntry entry;
    entry.path = "src/main.cpp";
    entry.compiler = compiler;

    auto entries = settings.readPaths(project->projectConfiguration().data());
    entries.append(entry);
    settings.writePaths(project->projectConfiguration().data(), entries);

    mainCompiler = provider->compilerForItem(mainfile);
    QVERIFY(mainCompiler);
    QVERIFY(mainCompiler->name() == compiler->name());

    ICore::self()->projectController()->closeProject(project);
}
예제 #3
0
void TestCompilerProvider::testCompilerIncludesAndDefines()
{
    SettingsManager settings;
    auto provider = settings.provider();
    for (auto c : provider->compilers()) {
        if (!c->editable() && !c->path().isEmpty()) {
            QVERIFY(!c->defines({}).isEmpty());
            QVERIFY(!c->includes({}).isEmpty());
        }
    }

    QVERIFY(!provider->defines(nullptr).isEmpty());
    QVERIFY(!provider->includes(nullptr).isEmpty());

    auto compiler = provider->compilerForItem(nullptr);
    QVERIFY(compiler);
    QVERIFY(!compiler->defines(QStringLiteral("--std=c++11")).isEmpty());
    QVERIFY(!compiler->includes(QStringLiteral("--std=c++11")).isEmpty());
}