diff options
author | dec05eba <dec05eba@protonmail.com> | 2018-01-01 06:42:19 +0100 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2018-01-01 06:42:25 +0100 |
commit | 0db3a23b21fe2856f64c5007b27e46a8140f10c0 (patch) | |
tree | 381affd095f2dbe54f168f04dbf7e5291f94aae2 /tests/src/confTest | |
parent | 9723d823bba90862df6de9ae8cec90cbda9e064c (diff) |
Fail build if project.conf contains invalid object or field
Diffstat (limited to 'tests/src/confTest')
-rw-r--r-- | tests/src/confTest/confTest.cpp | 18 | ||||
-rw-r--r-- | tests/src/confTest/invalidField.conf | 10 | ||||
-rw-r--r-- | tests/src/confTest/invalidObject.conf | 12 | ||||
-rw-r--r-- | tests/src/confTest/validProject.conf (renamed from tests/src/confTest/project.conf) | 0 |
4 files changed, 39 insertions, 1 deletions
diff --git a/tests/src/confTest/confTest.cpp b/tests/src/confTest/confTest.cpp index 5bab144..17b5995 100644 --- a/tests/src/confTest/confTest.cpp +++ b/tests/src/confTest/confTest.cpp @@ -6,7 +6,7 @@ using namespace sibs; TEST_CASE("parse config") { SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest")); - Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/project.conf"), sibsConfig); + Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/validProject.conf"), sibsConfig); if(result.isErr()) { fprintf(stderr, "%s", result.getErrMsg().c_str()); @@ -28,3 +28,19 @@ TEST_CASE("parse config") REQUIRE(catch2Dependency.name == "catch2"); REQUIRE(catch2Dependency.version == "1.0.0"); } + +TEST_CASE("parse config - invalid object") +{ + SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest")); + Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/invalidObject.conf"), sibsConfig); + REQUIRE(result.isErr()); + REQUIRE(result.getErrMsg() == "Invalid config object \"invalidObj\""); +} + +TEST_CASE("parse config - invalid field") +{ + SibsConfig sibsConfig(Compiler::GCC, TINYDIR_STRING("tests/src/confTest")); + Result<bool> result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/invalidField.conf"), sibsConfig); + REQUIRE(result.isErr()); + REQUIRE(result.getErrMsg() == "Invalid field \"invalidField\" under object \"package\""); +} diff --git a/tests/src/confTest/invalidField.conf b/tests/src/confTest/invalidField.conf new file mode 100644 index 0000000..c0f5892 --- /dev/null +++ b/tests/src/confTest/invalidField.conf @@ -0,0 +1,10 @@ +[package] +name = "confTest" +version = "0.1.0" +type = "library" +platforms = ["linux64", "win64"] +invalidField = "value" + +[dependencies] +xxhash = "0.1.0" +catch2 = "1.0.0" diff --git a/tests/src/confTest/invalidObject.conf b/tests/src/confTest/invalidObject.conf new file mode 100644 index 0000000..fe9fc86 --- /dev/null +++ b/tests/src/confTest/invalidObject.conf @@ -0,0 +1,12 @@ +[package] +name = "confTest" +version = "0.1.0" +type = "library" +platforms = ["linux64", "win64"] + +[dependencies] +xxhash = "0.1.0" +catch2 = "1.0.0" + +[invalidObj] +field = "value" diff --git a/tests/src/confTest/project.conf b/tests/src/confTest/validProject.conf index de5112d..de5112d 100644 --- a/tests/src/confTest/project.conf +++ b/tests/src/confTest/validProject.conf |