/// <summary> /// Process an already loaded <c>YamlDocument</c> and returns the loaded suite model. /// </summary> /// <param name="yaml">The yaml document to process.</param> /// <returns>Returns a loaded model if succeeds. On error it throws an exception, never /// returns <c>null</c>.</returns> protected Suite LoadYaml(YamlDocument yaml) { Contract.Requires(yaml != null); Contract.Requires(yaml.RootNode != null); Contract.Ensures(Contract.Result <Suite>() != null); log.Debug("Processing YAML document..."); foreach (var pluginUri in LoadPlugins(yaml.RootNode)) { pluginLoader.Load(pluginUri); } var goals = LoadGoals(yaml.RootNode); var defaultGoal = LoadDefaultGoal(goals, yaml.RootNode) ?? Suite.DebugGoal; var suite = suiteFactory.CreateSuite(new HashSet <Goal>(goals.Values), defaultGoal); parser.SetActiveGoal(suite.ActiveGoal); suite.Name = parser.GetScalarValue(yaml.RootNode, "suite", "Error reading the name of the suite"); suite.Version = ParseVersion(parser.GetOptionalScalarValue(yaml.RootNode, "version", null)); suite.Copyright = parser.GetOptionalScalarValue(yaml.RootNode, "copyright", null); LoadParameters(suite, suite, yaml.RootNode); foreach (KeyValuePair <string, YamlNode> item in parser.EnumerateNamedNodesOf(yaml.RootNode, "modules")) { var module = suite.GetModule(item.Key); if (item.Value != null) { LoadModule(module, item.Value); } } foreach (KeyValuePair <string, YamlNode> item in parser.EnumerateNamedNodesOf(yaml.RootNode, "products")) { var product = suite.GetProduct(item.Key); if (item.Value != null) { LoadProduct(suite, product, item.Value); } } LoadSourceSetIgnoreLists(suite.SourceSetIgnoreLists, yaml.RootNode); validator.Validate(suite); log.Debug("Finished processing YAML document."); return(suite); }
/// <summary> /// Process an already loaded <c>YamlDocument</c> and returns the loaded suite model. /// </summary> /// <param name="yaml">The yaml document to process.</param> /// <returns>Returns a loaded model if succeeds. On error it throws an exception, never /// returns <c>null</c>.</returns> protected Suite LoadYaml(YamlDocument yaml) { Contract.Requires(yaml != null); Contract.Requires(yaml.RootNode != null); Contract.Ensures(Contract.Result <Suite>() != null); log.Debug("Processing YAML document..."); var goals = new HashSet <Goal>(LoadGoals(yaml.RootNode)); var suite = suiteFactory.CreateSuite(goals); parser.SetActiveGoal(suite.ActiveGoal); suite.Name = parser.GetScalarValue(yaml.RootNode, "suite", "Error reading the name of the suite"); suite.Version = parser.GetOptionalScalarValue(yaml.RootNode, "version", null); suite.Copyright = parser.GetOptionalScalarValue(yaml.RootNode, "copyright", null); foreach (KeyValuePair <string, YamlNode> item in parser.EnumerateNamedNodesOf(yaml.RootNode, "modules")) { var module = suite.GetModule(item.Key); if (item.Value != null) { LoadModule(module, item.Value); } } foreach (KeyValuePair <string, YamlNode> item in parser.EnumerateNamedNodesOf(yaml.RootNode, "products")) { var product = suite.GetProduct(item.Key); if (item.Value != null) { LoadProduct(suite, product, item.Value); } } LoadParameters(suite, suite, yaml.RootNode); log.Debug("Finished processing YAML document."); return(suite); }