Exemple #1
0
        private void FixChildren(string patchConfiguration)
        {
            var parser = new DepsYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName));
            var hadDepsInThisSectionAndParrents = parser.Get(patchConfiguration).Deps.Where(d => d.Name == patchDep.Name).ToList();

            if (!hadDepsInThisSectionAndParrents.Any())
            {
                return;
            }
            if (hadDepsInThisSectionAndParrents.Count > 1)
            {
                ThrowDuplicate();
            }
            var currentSectionDep   = hadDepsInThisSectionAndParrents.First();
            var childConfigurations = new ConfigurationYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName))
                                      .GetConfigurationsHierarchy()[patchConfiguration];

            foreach (var child in childConfigurations)
            {
                FixChild(currentSectionDep, child);
            }
            foreach (var child in childConfigurations)
            {
                FixChildren(child);
            }
        }
Exemple #2
0
        public Dictionary <string, DepsData> OldDepsParser()
        {
            var parser  = new DepsYamlParser("fakename", Content);
            var configs = parser.GetConfigurations();

            return(configs.ToDictionary(c => c, c => parser.Get(c)));
        }
Exemple #3
0
        public void EnsureEquivalentDeps(string path)
        {
            var text              = pathToContentMap[path];
            var parser            = ModuleYamlParserFactory.Get();
            var depsSectionParser = new DepsYamlParser("fake", text);

            var md      = parser.Parse(text);
            var configs = md.AllConfigurations.Keys.ToArray();

            foreach (var config in configs)
            {
                var newDeps = md[config].Deps;
                var oldDeps = depsSectionParser.Get(config);

                newDeps.Should().BeEquivalentTo(oldDeps);
            }
        }
Exemple #4
0
        public void OldYamlParsersDoNotThrow(string path)
        {
            var text = pathToContentMap[path];

            var depsSectionParser    = new DepsYamlParser("fake", text);
            var installSectionParser = new InstallYamlParser("fake", text);
            var buildSectionParser   = new BuildYamlParser("fake", text);

            var configs = depsSectionParser.GetConfigurations();

            foreach (var config in configs)
            {
                Assert.DoesNotThrow(() =>
                {
                    depsSectionParser.Get(config);
                    installSectionParser.Get(config);
                    buildSectionParser.Get(config);
                });
            }
        }
Exemple #5
0
        private bool TryReplaceFromParent(string patchConfiguration)
        {
            var parser = new DepsYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName));
            var had    = parser.Get(patchConfiguration).Deps.Where(d => d.Name == patchDep.Name).ToList();

            if (!had.Any())
            {
                return(false);
            }
            if (had.Count > 1)
            {
                ThrowDuplicate();
            }
            var shouldBe = FindLca(patchDep, had.First());

            if (GetDepLine(had.First()) == GetDepLine(shouldBe))
            {
                return(true);
            }
            AddDepLine(patchConfiguration, shouldBe, true);
            AddDepLine(patchConfiguration, had.First(), false);
            FixChildren(patchConfiguration);
            return(true);
        }