Example #1
0
        private void FixChild(Dep currentParrentDep, string childConfiguration)
        {
            RemoveDepLine(childConfiguration, currentParrentDep, false);
            var parser           = new DepsYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName));
            var hadInSameSection = parser.GetDepsFromConfig(childConfiguration).Deps.Where(d => d.Name == patchDep.Name).ToList();

            if (!hadInSameSection.Any())
            {
                return;
            }
            if (hadInSameSection.Count > 1)
            {
                ThrowDuplicate();
            }
            var had = hadInSameSection.First();

            RemoveDepLine(childConfiguration, had, true);
            if (GetDepLine(had) == GetDepLine(currentParrentDep))
            {
                return;
            }
            if (FindLca(had, currentParrentDep).Configuration == currentParrentDep.Configuration)
            {
                return;
            }
            AddDepLine(childConfiguration, had, true);
            AddDepLine(childConfiguration, currentParrentDep, false);
        }
Example #2
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);
            }
        }
Example #3
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)));
        }
Example #4
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);
            }
        }
Example #5
0
        public void EnsureEquivalentConfigurations(string path)
        {
            var text              = pathToContentMap[path];
            var parser            = ModuleYamlParserFactory.Get();
            var depsSectionParser = new DepsYamlParser("fake", text);

            var md = parser.Parse(text);

            var oldConfigSet = depsSectionParser.GetConfigurations();
            var newConfigSet = md.AllConfigurations.Keys.ToArray();

            newConfigSet.Should().BeEquivalentTo(oldConfigSet);

            var oldDefaultConfig = depsSectionParser.GetDefaultConfigurationName();
            var newDefaultConfig = md.FindDefaultConfiguration()?.Name ?? "full-build";

            newDefaultConfig.Should().BeEquivalentTo(oldDefaultConfig);
        }
Example #6
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);
                });
            }
        }
Example #7
0
        private bool TryReplaceInSameSection(string patchConfiguration)
        {
            var parser           = new DepsYamlParser(new FileInfo(Directory.GetParent(yamlPath).FullName));
            var hadInSameSection = parser.GetDepsFromConfig(patchConfiguration).Deps.Where(d => d.Name == patchDep.Name).Distinct().ToList();

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

            ReplaceDepLine(patchConfiguration, was, shouldBe);
            FixChildren(patchConfiguration);
            return(true);
        }
Example #8
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);
        }