From 94caff5f66cacdd21e5a93cd3de9150a22eeaa3a Mon Sep 17 00:00:00 2001 From: dec05eba Date: Sat, 16 Dec 2017 04:21:33 +0100 Subject: Add support for sub project (unit tests) --- include/Conf.hpp | 51 +++++++++++++++++++++++++++++++++++++++++++-------- include/FileUtil.hpp | 1 + 2 files changed, 44 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/Conf.hpp b/include/Conf.hpp index c792075..8da352e 100644 --- a/include/Conf.hpp +++ b/include/Conf.hpp @@ -70,6 +70,8 @@ namespace sibs class ConfigCallback { friend class Parser; + public: + virtual ~ConfigCallback(){} protected: virtual void processObject(StringView name) = 0; virtual void processField(StringView name, const ConfigValue &value) = 0; @@ -85,35 +87,68 @@ namespace sibs class SibsConfig : public ConfigCallback { public: - SibsConfig() : finishedProcessing(false), packageType((PackageType)-1) {} + SibsConfig(const std::string &_projectPath) : projectPath(_projectPath), finishedProcessing(false), packageType((PackageType)-1) {} + virtual ~SibsConfig(){} - const std::string& getPackageName() const + virtual const std::string& getPackageName() const { assert(finishedProcessing); return packageName; } - PackageType getPackageType() const + virtual PackageType getPackageType() const { assert(finishedProcessing); return packageType; } - const std::vector& getDependencies() const + virtual const std::string& getTestPath() const + { + return testPath; + } + + virtual const std::vector& getDependencies() const { return dependencies; } + + virtual const std::string& getProjectPath() const + { + return projectPath; + } + protected: + virtual void processObject(StringView name) override; + virtual void processField(StringView name, const ConfigValue &value) override; + virtual void finished() override; protected: - void processObject(StringView name) override; - void processField(StringView name, const ConfigValue &value) override; - void finished() override; - private: StringView currentObject; + std::string projectPath; std::string packageName; + std::string testPath; PackageType packageType; std::vector dependencies; bool finishedProcessing; }; + + class SibsTestConfig : public SibsConfig + { + public: + SibsTestConfig(const std::string &_projectPath) : SibsConfig(_projectPath) + { + packageName = "test"; + } + + virtual ~SibsTestConfig(){} + + PackageType getPackageType() const override + { + return PackageType::EXECUTABLE; + } + protected: + void processObject(StringView name) override; + void processField(StringView name, const ConfigValue &value) override; + void finished() override; + }; } #endif //SIBS_CONF_HPP diff --git a/include/FileUtil.hpp b/include/FileUtil.hpp index 5b91aad..5d1594a 100644 --- a/include/FileUtil.hpp +++ b/include/FileUtil.hpp @@ -27,6 +27,7 @@ namespace sibs Result getCwd(); // Note: Will not delete created directories if this operation fails for some reason Result createDirectoryRecursive(const char *path); + Result getRealPath(const char *path); } #endif //SIBS_FILEUTIL_HPP -- cgit v1.2.3