aboutsummaryrefslogtreecommitdiff
path: root/src/Conf.cpp
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2017-12-16 04:21:33 +0100
committerdec05eba <dec05eba@protonmail.com>2017-12-16 04:21:44 +0100
commit94caff5f66cacdd21e5a93cd3de9150a22eeaa3a (patch)
treeb3b7689e5a25c908369bb5fad5a59e085253b76e /src/Conf.cpp
parent28d6b571139998915bce147abb58617884431192 (diff)
Add support for sub project (unit tests)
Diffstat (limited to 'src/Conf.cpp')
-rw-r--r--src/Conf.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/Conf.cpp b/src/Conf.cpp
index 1f439cd..b1e05bb 100644
--- a/src/Conf.cpp
+++ b/src/Conf.cpp
@@ -394,6 +394,25 @@ namespace sibs
else
throw ParserException("Expected package.type to be a single value, was a list");
}
+ else if(name.equals("tests"))
+ {
+ if (value.isSingle())
+ {
+ testPath = projectPath;
+ testPath += "/";
+ testPath += string(value.asSingle().data, value.asSingle().size);
+ Result<string> testRealPathResult = getRealPath(testPath.c_str());
+ if(!testRealPathResult)
+ {
+ string errMsg = "Failed to resolve package.tests path: ";
+ errMsg += testRealPathResult.getErrMsg();
+ throw ParserException(errMsg);
+ }
+ testPath = testRealPathResult.unwrap();
+ }
+ else
+ throw ParserException("Expected package.tests to be a single value, was a list");
+ }
}
else if(currentObject.equals("dependencies"))
{
@@ -416,4 +435,38 @@ namespace sibs
throw ParserException("Missing required config package.type. Expected to be one either 'executable', 'static', 'dynamic' or 'library'");
finishedProcessing = true;
}
+
+ void SibsTestConfig::processObject(StringView name)
+ {
+ currentObject = name;
+ }
+
+ void SibsTestConfig::processField(StringView name, const ConfigValue &value)
+ {
+ if(currentObject.equals("dependencies"))
+ {
+ if(value.isSingle())
+ {
+ // TODO: Validate version is number in correct format
+ Dependency dependency;
+ dependency.name = string(name.data, name.size);
+ dependency.version = string(value.asSingle().data, value.asSingle().size);
+ dependencies.emplace_back(dependency);
+ }
+ else
+ throw ParserException("Expected field under dependencies to be a single value, was a list");
+ }
+ else
+ {
+ string errMsg = "project.conf: Expected category to be 'dependencies', was: '";
+ errMsg += string(currentObject.data, currentObject.size);
+ errMsg += "'";
+ throw ParserException(errMsg);
+ }
+ }
+
+ void SibsTestConfig::finished()
+ {
+ finishedProcessing = true;
+ }
} \ No newline at end of file