Пример #1
0
void Test::TestFindRailsRoot()
{
    KDevelop::Path path;

    // Empty URL.
    path = Helpers::findRailsRoot(QUrl(""));
    Q_ASSERT(!path.isValid());

    // App.
    path = Helpers::findRailsRoot(QUrl("/rails/app/controllers/file.rb"));
    Q_ASSERT(path.isValid());
    QCOMPARE(path.toLocalFile(), QString("/rails"));
    path = Helpers::findRailsRoot(QUrl("/rails/app/models/file.rb"));
    Q_ASSERT(path.isValid());
    QCOMPARE(path.toLocalFile(), QString("/rails"));
    path = Helpers::findRailsRoot(QUrl("/rails/app/views/file.rb"));
    Q_ASSERT(path.isValid());
    QCOMPARE(path.toLocalFile(), QString("/rails"));

    // Tests.
    path = Helpers::findRailsRoot(QUrl("/rails/test/file.rb"));
    Q_ASSERT(path.isValid());
    QCOMPARE(path.toLocalFile(), QString("/rails"));
    path = Helpers::findRailsRoot(QUrl("/rails/dir/test/file.rb"));
    Q_ASSERT(path.isValid());
    QCOMPARE(path.toLocalFile(), QString("/rails/dir"));

    // Invalids
    path = Helpers::findRailsRoot(QUrl("/rails/app/test/file.rb"));
    Q_ASSERT(!path.isValid());
    path = Helpers::findRailsRoot(QUrl("/rails/app/controllers"));
    Q_ASSERT(!path.isValid());
}
Пример #2
0
///NOTE: when you change this, update @c defaultConfigure in cmakemanagertest.cpp
bool checkForNeedingConfigure( KDevelop::IProject* project )
{
    const KDevelop::Path builddir = currentBuildDir(project);
    if( !builddir.isValid() )
    {
        CMakeBuildDirChooser bd;

        KDevelop::Path folder = project->path();
        QString relative=CMake::projectRootRelative(project);
        folder.cd(relative);

        bd.setSourceFolder( folder );
        bd.setAlreadyUsed( CMake::allBuildDirs(project) );
        bd.setCMakeBinary( currentCMakeBinary(project) );

        if( !bd.exec() )
        {
            return false;
        }

        QString newbuilddir = bd.buildFolder().toLocalFile();
        int addedBuildDirIndex = buildDirCount( project ); // old count is the new index

        // Initialize the kconfig items with the values from the dialog, this ensures the settings
        // end up in the config file once the changes are saved
        qCDebug(CMAKE) << "adding to cmake config: new builddir index" << addedBuildDirIndex;
        qCDebug(CMAKE) << "adding to cmake config: builddir path " << bd.buildFolder();
        qCDebug(CMAKE) << "adding to cmake config: installdir " << bd.installPrefix();
        qCDebug(CMAKE) << "adding to cmake config: extra args" << bd.extraArguments();
        qCDebug(CMAKE) << "adding to cmake config: build type " << bd.buildType();
        qCDebug(CMAKE) << "adding to cmake config: cmake binary " << bd.cmakeBinary();
        qCDebug(CMAKE) << "adding to cmake config: environment <null>";
        CMake::setBuildDirCount( project, addedBuildDirIndex + 1 );
        CMake::setCurrentBuildDirIndex( project, addedBuildDirIndex );
        CMake::setCurrentBuildDir( project, bd.buildFolder() );
        CMake::setCurrentInstallDir( project, bd.installPrefix() );
        CMake::setCurrentExtraArguments( project, bd.extraArguments() );
        CMake::setCurrentBuildType( project, bd.buildType() );
        CMake::setCurrentCMakeBinary( project, bd.cmakeBinary() );
        CMake::setCurrentEnvironment( project, QString() );

        return true;
    } else if( !QFile::exists( KDevelop::Path(builddir, "CMakeCache.txt").toLocalFile() ) ||
                //TODO: maybe we could use the builder for that?
               !(QFile::exists( KDevelop::Path(builddir, "Makefile").toLocalFile() ) ||
                    QFile::exists( KDevelop::Path(builddir, "build.ninja").toLocalFile() ) ) )
    {
        // User entered information already, but cmake hasn't actually been run yet.
        return true;
    }
    return false;
}