Throw if metadata file's root is not a YAML map

Fixes #681.
This commit is contained in:
Oliver Hamlet
2016-11-03 18:02:34 +00:00
parent 874f46d4ec
commit 03fc204223
3 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -101,7 +101,7 @@ set(PSEUDOSEM_INCLUDE_DIRS "${SOURCE_DIR}/include")
ExternalProject_Add(testing-metadata
PREFIX "external"
URL "https://github.com/loot/testing-metadata/archive/1.1.0.tar.gz"
URL "https://github.com/loot/testing-metadata/archive/1.2.0.tar.gz"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
+4 -1
View File
@@ -44,13 +44,16 @@ void MetadataList::Load(const boost::filesystem::path& filepath) {
YAML::Node metadataList = YAML::Load(in);
in.close();
if (!metadataList.IsMap())
throw FileAccessError("The root of the metadata file " + filepath.string() + " is not a YAML map.");
if (metadataList["plugins"]) {
for (const auto& node : metadataList["plugins"]) {
PluginMetadata plugin(node.as<PluginMetadata>());
if (plugin.IsRegexPlugin())
regexPlugins_.push_back(plugin);
else if (!plugins_.insert(plugin).second)
throw FileAccessError("More than one entry exists for \"" + plugin.Name() + "\"");
throw FileAccessError("More than one entry exists for \"" + plugin.Name() + "\"");
}
}
if (metadataList["globals"])
+3 -1
View File
@@ -37,7 +37,9 @@ protected:
metadataPath("./testing-metadata/masterlist.yaml"),
savedMetadataPath("./testing-metadata/saved.masterlist.yaml"),
missingMetadataPath("./missing-metadata.yaml"),
invalidMetadataPaths({"./testing-metadata/invalid/non_unique.yaml"}) {}
invalidMetadataPaths({
"./testing-metadata/invalid/non_map_root.yaml",
"./testing-metadata/invalid/non_unique.yaml"}) {}
inline virtual void SetUp() {
CommonGameTestFixture::SetUp();