From 0db3a23b21fe2856f64c5007b27e46a8140f10c0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Mon, 1 Jan 2018 06:42:19 +0100 Subject: Fail build if project.conf contains invalid object or field --- tests/src/confTest/confTest.cpp | 18 +++++++++++++++++- tests/src/confTest/invalidField.conf | 10 ++++++++++ tests/src/confTest/invalidObject.conf | 12 ++++++++++++ tests/src/confTest/project.conf | 9 --------- tests/src/confTest/validProject.conf | 9 +++++++++ 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 tests/src/confTest/invalidField.conf create mode 100644 tests/src/confTest/invalidObject.conf delete mode 100644 tests/src/confTest/project.conf create mode 100644 tests/src/confTest/validProject.conf (limited to 'tests/src') 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 result = Config::readFromFile(TINYDIR_STRING("tests/src/confTest/project.conf"), sibsConfig); + Result 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 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 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/project.conf deleted file mode 100644 index de5112d..0000000 --- a/tests/src/confTest/project.conf +++ /dev/null @@ -1,9 +0,0 @@ -[package] -name = "confTest" -version = "0.1.0" -type = "library" -platforms = ["linux64", "win64"] - -[dependencies] -xxhash = "0.1.0" -catch2 = "1.0.0" diff --git a/tests/src/confTest/validProject.conf b/tests/src/confTest/validProject.conf new file mode 100644 index 0000000..de5112d --- /dev/null +++ b/tests/src/confTest/validProject.conf @@ -0,0 +1,9 @@ +[package] +name = "confTest" +version = "0.1.0" +type = "library" +platforms = ["linux64", "win64"] + +[dependencies] +xxhash = "0.1.0" +catch2 = "1.0.0" -- cgit v1.2.3