Пример #1
0
void TestCompilerProvider::testStorageBackwardsCompatible()
{
    SettingsManager settings;
    QTemporaryFile file;
    QVERIFY(file.open());
    QTextStream stream(&file);
    stream << "[Buildset]\n" <<
      "BuildItems=@Variant(\\x00\\x00\\x00\\t\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0b\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x1a\\x00S\\x00i\\x00m\\x00p\\x00l\\x00e\\x00P\\x00r\\x00o\\x00j\\x00e\\x00c\\x00t)\n" <<
      "[CustomBuildSystem]\n" << "CurrentConfiguration=BuildConfig0\n" <<
      "[CustomDefinesAndIncludes][ProjectPath0]\n" <<
      "Defines=\\x00\\x00\\x00\\x02\\x00\\x00\\x00\\x0c\\x00_\\x00D\\x00E\\x00B\\x00U\\x00G\\x00\\x00\\x00\\n\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x10\\x00V\\x00A\\x00R\\x00I\\x00A\\x00B\\x00L\\x00E\\x00\\x00\\x00\\n\\x00\\x00\\x00\\x00\\n\\x00V\\x00A\\x00L\\x00U\\x00E\n" <<
      "Includes=\\x00\\x00\\x00\\x01\\x00\\x00\\x00$\\x00/\\x00u\\x00s\\x00r\\x00/\\x00i\\x00n\\x00c\\x00l\\x00u\\x00d\\x00e\\x00/\\x00m\\x00y\\x00d\\x00i\\x00r\n" <<
      "Path=/\n" <<
      "[CustomDefinesAndIncludes][ProjectPath0][Compiler]\nName=GCC\nPath=gcc\nType=GCC\n";
    file.close();
    KConfig config(file.fileName());
    auto entries = settings.readPaths(&config);
    QCOMPARE(entries.size(), 1);
    auto entry = entries.first();
    Defines defines;
    defines["VARIABLE"] = "VALUE";
    defines["_DEBUG"] = QString();
    QCOMPARE(entry.defines, defines);
    QStringList includes = QStringList() << "/usr/include/mydir";
    QCOMPARE(entry.includes, includes);
    QCOMPARE(entry.path, QString("/"));
    QVERIFY(entry.compiler);

    testCompilerEntry(settings, &config);
    testAddingEntry(settings, &config);
}
Пример #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::testStorageNewSystem()
{
    SettingsManager settings;
    QTemporaryFile file;
    QVERIFY(file.open());
    QTextStream stream(&file);
    stream << "[Buildset]\n" <<
      "BuildItems=@Variant(\\x00\\x00\\x00\\t\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0b\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x1a\\x00S\\x00i\\x00m\\x00p\\x00l\\x00e\\x00P\\x00r\\x00o\\x00j\\x00e\\x00c\\x00t)\n\n" <<
      "[CustomBuildSystem]\n" << "CurrentConfiguration=BuildConfig0\n\n" <<
      "[CustomDefinesAndIncludes][ProjectPath0]\n" << "Path=/\n\n" <<
      "[CustomDefinesAndIncludes][ProjectPath0][Defines]\n" <<
      "_DEBUG=\n" <<
      "VARIABLE=VALUE\n" <<
      "[CustomDefinesAndIncludes][ProjectPath0][Includes]\n" <<
      "1=/usr/include/mydir\n" <<
      "2=/usr/local/include/mydir\n" <<
      "[CustomDefinesAndIncludes][ProjectPath0][Compiler]\nName=GCC\nPath=gcc\nType=GCC\n";
    file.close();
    KConfig config(file.fileName());
    auto entries = settings.readPaths(&config);
    QCOMPARE(entries.size(), 1);
    auto entry = entries.first();
    QCOMPARE(entry.path, QString("/"));
    Defines defines;
    defines["VARIABLE"] = "VALUE";
    defines["_DEBUG"] = QString();
    QCOMPARE(entry.defines, defines);
    QMap<QString, QString> includeMap;
    includeMap["1"] = "/usr/include/mydir";
    includeMap["2"] = "/usr/local/include/mydir";

    int i = 0;
    for(auto it = includeMap.begin(); it != includeMap.end(); it++)
    {
        QCOMPARE(entry.includes.at(i++), it.value());
    }

    testCompilerEntry(settings, &config);
    testAddingEntry(settings, &config);
}