Commit e53e8c48 authored by Morten Volden's avatar Morten Volden

Use the moved projectsgenerator class in custom-buildsystem test. Also cleanup...

Use the moved projectsgenerator class in custom-buildsystem test. Also cleanup the now unused projectfiles
parent 33f8fd4f
Pipeline #2528 failed with stage
in 60 minutes
...@@ -88,7 +88,13 @@ IProject* ProjectsGenerator::GenerateSimpleProject() ...@@ -88,7 +88,13 @@ IProject* ProjectsGenerator::GenerateSimpleProject()
createFile( file ); createFile( file );
QTextStream stream( &file ); QTextStream stream( &file );
stream << "[Buildset]\n" << 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" << "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" <<
"[CustomBuildSystem][BuildConfig0]\n" <<
"BuildDir=file:///" << rootFolder.absolutePath() << "/build\n" <<
"Title=mainbuild\n\n" <<
"[CustomDefinesAndIncludes][ProjectPath0]\n" << "[CustomDefinesAndIncludes][ProjectPath0]\n" <<
"Path=/\n" << "Path=/\n" <<
"[CustomDefinesAndIncludes][ProjectPath0][Defines]\n" << "[CustomDefinesAndIncludes][ProjectPath0][Defines]\n" <<
...@@ -131,7 +137,11 @@ IProject* ProjectsGenerator::GenerateMultiPathProject() ...@@ -131,7 +137,11 @@ IProject* ProjectsGenerator::GenerateMultiPathProject()
createFile( file ); createFile( file );
QTextStream stream( &file ); QTextStream stream( &file );
stream << "[Buildset]\n" << 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 \\x00M\\x00u\\x00l\\x00t\\x00i\\x00P\\x00a\\x00t\\x00h\\x00P\\x00r\\x00o\\x00j\\x00e\\x00c\\x00t)\n" << "BuildItems=@Variant(\\x00\\x00\\x00\\t\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00\\x0b\\x00\\x00\\x00\\x00\\x01\\x00\\x00\\x00 \\x00M\\x00u\\x00l\\x00t\\x00i\\x00P\\x00a\\x00t\\x00h\\x00P\\x00r\\x00o\\x00j\\x00e\\x00c\\x00t)\n\n" <<
"[CustomBuildSystem]\n" <<
"CurrentConfiguration=BuildConfig0\n\n" <<
"[CustomBuildSystem][BuildConfig0]\n" <<
"BuildDir=file:///" << rootFolder.absolutePath() << "/build\n" <<
"[CustomDefinesAndIncludes][ProjectPath0]\n" << "[CustomDefinesAndIncludes][ProjectPath0]\n" <<
"Path=.\n" << "Path=.\n" <<
"[CustomDefinesAndIncludes][ProjectPath0][Defines]\n" << "[CustomDefinesAndIncludes][ProjectPath0][Defines]\n" <<
...@@ -195,4 +205,51 @@ IProject* ProjectsGenerator::GenerateEmptyProject() ...@@ -195,4 +205,51 @@ IProject* ProjectsGenerator::GenerateEmptyProject()
} }
return loadProject(QDir::tempPath() + QStringLiteral( "/emptyproject/emptyproject.kdev4" ), QStringLiteral("EmptyProject")); return loadProject(QDir::tempPath() + QStringLiteral( "/emptyproject/emptyproject.kdev4" ), QStringLiteral("EmptyProject"));
} }
IProject* ProjectsGenerator::GenerateEmptyBuildDirProject()
{
const QString ebp = QStringLiteral( "emptybuilddirproject" );
auto rootFolder = QDir::temp();
QDir(rootFolder.absolutePath() + QStringLiteral( "/" ) + ebp).removeRecursively();
rootFolder.mkdir( ebp );
rootFolder.cd( ebp );
rootFolder.mkdir( QStringLiteral("src") );
rootFolder.mkdir( QStringLiteral(".kdev4") );
{
QFile file( rootFolder.filePath( QStringLiteral("emptybuilddirproject.kdev4") ) );
createFile( file );
QTextStream stream1( &file );
stream1 << "[Project]\nName=EmptyBuildDirProject\nManager=KDevCustomBuildSystem";
}
{
QFile file( rootFolder.filePath( QStringLiteral("src/main.cpp") ) );
createFile( file );
}
{
QFile file( rootFolder.filePath( QStringLiteral(".kdev4/emptybuilddirproject.kdev4") ) );
createFile( file );
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(\x00E\x00m\x00p\x00t\x00y\x00B\x00u\x00i\x00l\x00d\x00d\x00i\x00r\x00P\x00r\x00o\x00j\x00e\x00c\x00t)\n\n" <<
"[CustomBuildSystem]\n" <<
"CurrentConfiguration=BuildConfig0\n\n" <<
"[CustomBuildSystem][BuildConfig0]\n" <<
"BuildDir=" <<
"Title=mainbuild\n\n" <<
"[CustomDefinesAndIncludes][ProjectPath0]\n" <<
"Path=/\n" <<
"[CustomDefinesAndIncludes][ProjectPath0][Defines]\n" <<
"_DEBUG=\n" <<
"VARIABLE=VALUE\n" <<
"[CustomDefinesAndIncludes][ProjectPath0][Includes]\n" <<
"1=" << QDir::rootPath() << "usr/include/mydir\n" <<
"[Project]\n" <<
"VersionControlSupport=\n";
}
return loadProject( QDir::tempPath() + QStringLiteral( "/simpleproject/simpleproject.kdev4" ), QStringLiteral("SimpleProject") );
}
} // KDevelop } // KDevelop
...@@ -75,6 +75,16 @@ public: ...@@ -75,6 +75,16 @@ public:
* Files are located in the OS temporary folder, subfolder 'emptyproject' * Files are located in the OS temporary folder, subfolder 'emptyproject'
*/ */
KDevelop::IProject* GenerateEmptyProject(); KDevelop::IProject* GenerateEmptyProject();
/**
* Generates a pointer to a project with the following directory structure:
* ./emptybuilddirproject.kdev4
* ./src/main.cpp
* ./.kdev4/emptybuilddirproject.kdev4
*
* Files are located in the OS temporary folder, subfolder 'emptybuilddirproject'
*/
IProject* GenerateEmptyBuildDirProject();
}; };
} }
......
add_definitions(-DTRANSLATION_DOMAIN=\"kdevcustombuildsystem\") add_definitions(-DTRANSLATION_DOMAIN=\"kdevcustombuildsystem\")
declare_qt_logging_category(custom_LOG_SRCS declare_qt_logging_category(custom_LOG_SRCS
TYPE PLUGIN TYPE PLUGIN
IDENTIFIER CUSTOMBUILDSYSTEM IDENTIFIER CUSTOMBUILDSYSTEM
...@@ -25,6 +24,7 @@ target_link_libraries(kdevcustombuildsystem ...@@ -25,6 +24,7 @@ target_link_libraries(kdevcustombuildsystem
KDev::Interfaces KDev::Interfaces
KDev::Util KDev::Util
KDev::OutputView KDev::OutputView
KDev::Tests
) )
## Unittests ## Unittests
......
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x00)
[CustomBuildSystem]
CurrentConfiguration=BuildConfig0
[CustomBuildSystem][BuildConfig0]
BuildDir=
Title=mainbuild
[CustomBuildSystem][BuildConfig0][ToolBuild]
Arguments=
Enabled=false
Environment=
Executable=
Type=0
[CustomBuildSystem][BuildConfig0][ToolClean]
Arguments=
Enabled=false
Environment=
Executable=
Type=3
[CustomBuildSystem][BuildConfig0][ToolConfigure]
Arguments=
Enabled=false
Environment=
Executable=
Type=1
[CustomBuildSystem][BuildConfig0][ToolInstall]
Arguments=
Enabled=false
Environment=
Executable=
Type=2
[CustomBuildSystem][BuildConfig0][ToolPrune]
Arguments=
Enabled=false
Environment=
Executable=
Type=4
[Defines And Includes][Compiler]
Name=GCC
Path=gcc
Type=GCC
[MakeBuilder]
Number Of Jobs=1
[Project]
VersionControlSupport=kdevgit
[Project]
Name=BuilddirProject
Manager=KDevCustomBuildSystem
[Buildset]
BuildItems=@Variant(\x00\x00\x00\t\x00\x00\x00\x00\x01\x00\x00\x00\x0b\x00\x00\x00\x00\x01\x00\x00\x00 \x00M\x00u\x00l\x00t\x00i\x00P\x00a\x00t\x00h\x00P\x00r\x00o\x00j\x00e\x00c\x00t)
[CustomBuildSystem]
CurrentConfiguration=BuildConfig0
[CustomBuildSystem][BuildConfig0]
BuildDir=file:///home/andreas/projects/testcustom/build2
Title=main
[CustomBuildSystem][BuildConfig0][ToolBuild]
Arguments=
Enabled=false
Environment=
Executable=
Type=0
[CustomBuildSystem][BuildConfig0][ToolClean]
Arguments=
Enabled=false
Environment=
Executable=
Type=3
[CustomBuildSystem][BuildConfig0][ToolConfigure]
Arguments=
Enabled=false
Environment=
Executable=
Type=1
[CustomBuildSystem][BuildConfig0][ToolInstall]
Arguments=
Enabled=false
Environment=
Executable=
Type=2
[Defines And Includes][Compiler]
Name=GCC
Path=gcc
Type=GCC
[Project]
VersionControlSupport=
[Project]
Name=MultiPathProject
Manager=KDevCustomBuildSystem
[Buildset]
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)
[CustomBuildSystem]
CurrentConfiguration=BuildConfig0
[CustomBuildSystem][BuildConfig0]
BuildDir=file:///home/andreas/projects/testcustom/build
Title=mainbuild
[CustomBuildSystem][BuildConfig0][ToolBuild]
Arguments=
Enabled=false
Environment=
Executable=
Type=0
[CustomBuildSystem][BuildConfig0][ToolClean]
Arguments=
Enabled=false
Environment=
Executable=
Type=3
[CustomBuildSystem][BuildConfig0][ToolConfigure]
Arguments=
Enabled=false
Environment=
Executable=
Type=1
[CustomBuildSystem][BuildConfig0][ToolInstall]
Arguments=
Enabled=false
Environment=
Executable=
Type=2
[Defines And Includes][Compiler]
Name=GCC
Path=gcc
Type=GCC
[Project]
VersionControlSupport=
#ifndef CONFIG_H
#define CONFIG_H
#define myvar
#endif
[Project]
Name=SimpleProject
Manager=KDevCustomBuildSystem
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <tests/autotestshell.h> #include <tests/autotestshell.h>
#include <tests/testcore.h> #include <tests/testcore.h>
#include <tests/kdevsignalspy.h> #include <tests/kdevsignalspy.h>
#include <tests/projectsgenerator.h>
#include <shell/sessioncontroller.h> #include <shell/sessioncontroller.h>
#include <interfaces/iprojectcontroller.h> #include <interfaces/iprojectcontroller.h>
#include <interfaces/isession.h> #include <interfaces/isession.h>
...@@ -42,10 +43,16 @@ using KDevelop::IProject; ...@@ -42,10 +43,16 @@ using KDevelop::IProject;
using KDevelop::TestCore; using KDevelop::TestCore;
using KDevelop::AutoTestShell; using KDevelop::AutoTestShell;
using KDevelop::KDevSignalSpy; using KDevelop::KDevSignalSpy;
using KDevelop::ProjectsGenerator;
using KDevelop::Path; using KDevelop::Path;
QTEST_MAIN(TestCustomBuildSystemPlugin) QTEST_MAIN(TestCustomBuildSystemPlugin)
void TestCustomBuildSystemPlugin::init()
{
m_projectGenerator = new ProjectsGenerator;
}
void TestCustomBuildSystemPlugin::cleanupTestCase() void TestCustomBuildSystemPlugin::cleanupTestCase()
{ {
TestCore::shutdown(); TestCore::shutdown();
...@@ -56,49 +63,37 @@ void TestCustomBuildSystemPlugin::initTestCase() ...@@ -56,49 +63,37 @@ void TestCustomBuildSystemPlugin::initTestCase()
TestCore::initialize(); TestCore::initialize();
} }
void TestCustomBuildSystemPlugin::cleanup()
{
ICore::self()->projectController()->closeAllProjects( );
delete m_projectGenerator;
}
void TestCustomBuildSystemPlugin::loadSimpleProject() void TestCustomBuildSystemPlugin::loadSimpleProject()
{ {
QUrl projecturl = QUrl::fromLocalFile( PROJECTS_SOURCE_DIR"/simpleproject/simpleproject.kdev4" ); m_currentProject = m_projectGenerator->GenerateSimpleProject();
auto* projectSpy = new KDevSignalSpy( ICore::self()->projectController(), SIGNAL(projectOpened(KDevelop::IProject*)) ); QVERIFY( m_currentProject );
ICore::self()->projectController()->openProject( projecturl ); QCOMPARE( m_currentProject->buildSystemManager()->buildDirectory( m_currentProject->projectItem() ),
// Wait for the project to be opened Path( QStringLiteral("file:///") + QDir::temp().absolutePath() + QStringLiteral("/simpleproject/build/") ) );
QVERIFY(projectSpy->wait(10000));
IProject* project = ICore::self()->projectController()->findProjectByName( QStringLiteral("SimpleProject") );
QVERIFY( project );
QCOMPARE( project->buildSystemManager()->buildDirectory( project->projectItem() ),
Path( "file:///home/andreas/projects/testcustom/build/" ) );
} }
void TestCustomBuildSystemPlugin::buildDirProject() void TestCustomBuildSystemPlugin::buildDirProject()
{ {
QUrl projecturl = QUrl::fromLocalFile( PROJECTS_SOURCE_DIR"/builddirproject/builddirproject.kdev4" ); m_currentProject = m_projectGenerator->GenerateEmptyBuildDirProject();
auto* projectSpy = new KDevSignalSpy( ICore::self()->projectController(), SIGNAL(projectOpened(KDevelop::IProject*)) ); QVERIFY( m_currentProject );
ICore::self()->projectController()->openProject( projecturl ); QCOMPARE( m_currentProject->buildSystemManager()->buildDirectory( m_currentProject->projectItem() ),
// Wait for the project to be opened Path( QStringLiteral("file:///") + QDir::temp().absolutePath() + QStringLiteral("/simpleproject/build/") ) );
QVERIFY(projectSpy->wait(10000));
IProject* project = ICore::self()->projectController()->findProjectByName( QStringLiteral("BuilddirProject") );
QVERIFY( project );
Path currentBuilddir = project->buildSystemManager()->buildDirectory( project->projectItem() );
QCOMPARE( currentBuilddir, Path( projecturl ).parent() );
} }
void TestCustomBuildSystemPlugin::loadMultiPathProject() void TestCustomBuildSystemPlugin::loadMultiPathProject()
{ {
QUrl projecturl = QUrl::fromLocalFile( PROJECTS_SOURCE_DIR"/multipathproject/multipathproject.kdev4" ); m_currentProject = m_projectGenerator->GenerateMultiPathProject();
auto* projectSpy = new KDevSignalSpy( ICore::self()->projectController(), SIGNAL(projectOpened(KDevelop::IProject*)) ); QVERIFY( m_currentProject );
ICore::self()->projectController()->openProject( projecturl );
// Wait for the project to be opened
QVERIFY(projectSpy->wait(10000));
IProject* project = ICore::self()->projectController()->findProjectByName( QStringLiteral("MultiPathProject") );
QVERIFY( project );
KDevelop::ProjectBaseItem* mainfile = nullptr; KDevelop::ProjectBaseItem* mainfile = nullptr;
const auto& files = project->fileSet(); const auto& files = m_currentProject->fileSet();
for (const auto& file : files) { for (const auto& file : files) {
const auto& filesForPath = project->filesForPath(file); const auto& filesForPath = m_currentProject->filesForPath(file);
for (auto i: filesForPath) { for (auto i: filesForPath) {
if( i->text() == QLatin1String("main.cpp") ) { if( i->text() == QLatin1String("main.cpp") ) {
mainfile = i; mainfile = i;
...@@ -108,7 +103,7 @@ void TestCustomBuildSystemPlugin::loadMultiPathProject() ...@@ -108,7 +103,7 @@ void TestCustomBuildSystemPlugin::loadMultiPathProject()
} }
QVERIFY(mainfile); QVERIFY(mainfile);
QCOMPARE( project->buildSystemManager()->buildDirectory( mainfile ), QCOMPARE( m_currentProject->buildSystemManager()->buildDirectory( mainfile ),
Path( "file:///home/andreas/projects/testcustom/build2/src" ) ); Path( QStringLiteral("file:///") + QDir::temp().absolutePath() + QStringLiteral("/multipathproject/build/src") ) );
} }
...@@ -25,17 +25,24 @@ ...@@ -25,17 +25,24 @@
namespace KDevelop namespace KDevelop
{ {
class TestCore; class TestCore;
class IProject;
class ProjectsGenerator;
} }
class TestCustomBuildSystemPlugin : public QObject class TestCustomBuildSystemPlugin : public QObject
{ {
Q_OBJECT Q_OBJECT
private Q_SLOTS: private Q_SLOTS:
void init();
void initTestCase(); void initTestCase();
void cleanupTestCase(); void cleanupTestCase();
void cleanup();
void loadSimpleProject(); void loadSimpleProject();
void buildDirProject(); void buildDirProject();
void loadMultiPathProject(); void loadMultiPathProject();
private:
KDevelop::IProject* m_currentProject = nullptr;
KDevelop::ProjectsGenerator* m_projectGenerator = nullptr;
}; };
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment