diff options
author | dec05eba <dec05eba@protonmail.com> | 2017-12-16 04:21:33 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2017-12-16 04:21:44 +0100 |
commit | 94caff5f66cacdd21e5a93cd3de9150a22eeaa3a (patch) | |
tree | b3b7689e5a25c908369bb5fad5a59e085253b76e /include | |
parent | 28d6b571139998915bce147abb58617884431192 (diff) |
Add support for sub project (unit tests)
Diffstat (limited to 'include')
-rw-r--r-- | include/Conf.hpp | 51 | ||||
-rw-r--r-- | include/FileUtil.hpp | 1 |
2 files changed, 44 insertions, 8 deletions
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<Dependency>& getDependencies() const + virtual const std::string& getTestPath() const + { + return testPath; + } + + virtual const std::vector<Dependency>& 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<Dependency> 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<std::string> getCwd(); // Note: Will not delete created directories if this operation fails for some reason Result<bool> createDirectoryRecursive(const char *path); + Result<std::string> getRealPath(const char *path); } #endif //SIBS_FILEUTIL_HPP |