logic: source groups for project settings
* project can not have multiple source groups with different types * language of a project is now inferred from source groups * setting global NameHierarchy delimiter of first sourceGroup in project * added project settings migrations for source groups * Add Settings Migration classes (MoveKey, DeleteKey, Lambda) * Update sample projects with migrations * added method to config to retrieve sublevel key names * implemented recursive removing of keys in settings * moved project files out of top level * removed solution parsing code as it is not used anymore fortune cookie message = The secret of getting ahead is getting started.
This commit is contained in:
@@ -17,9 +17,9 @@ public:
|
||||
sourceExtensions.push_back(".c");
|
||||
|
||||
FileManager fm;
|
||||
fm.setPaths(sourcePaths, headerPaths, excludePaths, sourceExtensions);
|
||||
FileManager::FileSets fileSets = fm.fetchFilePaths(std::vector<FileInfo>());
|
||||
fm.update(sourcePaths, excludePaths, sourceExtensions);
|
||||
std::set<FilePath> filePaths = fm.getAllSourceFilePaths();
|
||||
|
||||
TS_ASSERT_EQUALS(fileSets.addedFiles.size(), 2);
|
||||
TS_ASSERT_EQUALS(filePaths.size(), 2);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "settings/Settings.h"
|
||||
#include "settings/SettingsMigrator.h"
|
||||
#include "settings/migration/SettingsMigrator.h"
|
||||
#include "settings/migration/MigrationLambda.h"
|
||||
#include "settings/migration/MigrationMoveKey.h"
|
||||
|
||||
class SettingsMigratorTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
@@ -47,7 +49,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "int");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -73,7 +75,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "sub/int");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "sub/int"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -105,7 +107,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "values/value", "vals/value");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("values/value", "vals/value"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -137,7 +139,7 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "values/value", "values/val");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("values/value", "values/val"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -161,8 +163,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "int");
|
||||
migrator.addMigration(2, "int", "val");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int", "val"));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -187,8 +189,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "int");
|
||||
migrator.addMigration(2, "int", "val");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int", "val"));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -212,8 +214,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "int");
|
||||
migrator.addMigration(2, "int", "val");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int", "val"));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -239,8 +241,8 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "val");
|
||||
migrator.addMigration(1, "element", "ele");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "val"));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("element", "ele"));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -272,10 +274,10 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addMigration(1, "value", "int/val");
|
||||
migrator.addMigration(1, "element", "ele");
|
||||
migrator.addMigration(2, "int/val", "int");
|
||||
migrator.addMigration(3, "ele", "elements/element");
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("value", "int/val"));
|
||||
migrator.addMigration(1, std::make_shared<MigrationMoveKey>("element", "ele"));
|
||||
migrator.addMigration(2, std::make_shared<MigrationMoveKey>("int/val", "int"));
|
||||
migrator.addMigration(3, std::make_shared<MigrationMoveKey>("ele", "elements/element"));
|
||||
migrator.migrate(&settingsBefore, 3);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -299,14 +301,13 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addLambdaMigration(
|
||||
1,
|
||||
[](Settings* settings)
|
||||
migrator.addMigration(
|
||||
1, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
{
|
||||
TestSettings* test = dynamic_cast<TestSettings*>(settings);
|
||||
test->set("value", test->get("value") * 2);
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) * 2);
|
||||
}
|
||||
);
|
||||
));
|
||||
migrator.migrate(&settingsBefore, 1);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -330,22 +331,20 @@ public:
|
||||
);
|
||||
|
||||
SettingsMigrator migrator;
|
||||
migrator.addLambdaMigration(
|
||||
1,
|
||||
[](Settings* settings)
|
||||
migrator.addMigration(
|
||||
1, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
{
|
||||
TestSettings* test = dynamic_cast<TestSettings*>(settings);
|
||||
test->set("value", test->get("value") * 2);
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) * 2);
|
||||
}
|
||||
);
|
||||
migrator.addLambdaMigration(
|
||||
2,
|
||||
[](Settings* settings)
|
||||
));
|
||||
migrator.addMigration(
|
||||
2, std::make_shared<MigrationLambda>(
|
||||
[](const Migration* migration, Settings* settings)
|
||||
{
|
||||
TestSettings* test = dynamic_cast<TestSettings*>(settings);
|
||||
test->set("value", test->get("value") - 1);
|
||||
migration->setValueInSettings<int>(settings, "value", migration->getValueFromSettings<int>(settings, "value", 0) - 1);
|
||||
}
|
||||
);
|
||||
));
|
||||
migrator.migrate(&settingsBefore, 2);
|
||||
|
||||
TS_ASSERT_EQUALS(settingsBefore.getAsText(), settingsAfter.getAsText());
|
||||
@@ -372,16 +371,6 @@ private:
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
int get(const std::string& key)
|
||||
{
|
||||
return getValue<int>(key, 0);
|
||||
}
|
||||
|
||||
void set(const std::string& key, int value)
|
||||
{
|
||||
setValue<int>(key, value);
|
||||
}
|
||||
};
|
||||
|
||||
TestSettings createSettings(const std::string& text)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include <cxxtest/TestSuite.h>
|
||||
|
||||
#include "settings/ProjectSettings.h"
|
||||
#include "settings/CxxProjectSettings.h"
|
||||
#include "settings/Settings.h"
|
||||
#include "settings/SourceGroupSettingsCxx.h"
|
||||
|
||||
class SettingsTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
@@ -115,9 +115,10 @@ public:
|
||||
|
||||
void test_load_source_path_from_file()
|
||||
{
|
||||
ProjectSettings settings;
|
||||
settings.load(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
std::vector<FilePath> paths = settings.getSourcePaths();
|
||||
ProjectSettings projectSettings;
|
||||
projectSettings.load(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
std::shared_ptr<SourceGroupSettingsCxx> sourceGroupSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(projectSettings.getAllSourceGroupSettings().front());
|
||||
std::vector<FilePath> paths = sourceGroupSettings->getSourcePaths();
|
||||
|
||||
TS_ASSERT_EQUALS(paths.size(), 1);
|
||||
TS_ASSERT_EQUALS(paths[0].str(), "data");
|
||||
@@ -125,9 +126,10 @@ public:
|
||||
|
||||
void test_load_header_search_paths_from_file()
|
||||
{
|
||||
CxxProjectSettings settings;
|
||||
settings.load(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
std::vector<FilePath> paths = settings.getHeaderSearchPaths();
|
||||
ProjectSettings projectSettings;
|
||||
projectSettings.load(FilePath("data/SettingsTestSuite/settings.xml"));
|
||||
std::shared_ptr<SourceGroupSettingsCxx> sourceGroupSettings = std::dynamic_pointer_cast<SourceGroupSettingsCxx>(projectSettings.getAllSourceGroupSettings().front());
|
||||
std::vector<FilePath> paths = sourceGroupSettings->getHeaderSearchPaths();
|
||||
|
||||
TS_ASSERT_EQUALS(paths.size(), 2);
|
||||
TS_ASSERT_EQUALS(paths[0].str(), "data/");
|
||||
|
||||
Reference in New Issue
Block a user