protected override void AssertPipGraphContent(PipGraph pipGraph, SimpleGraph file2file, StringTable stringTable)
        {
            AssertPipGraphCounts(pipGraph, new Dictionary <PipType, int>
            {
                [PipType.Process]       = file2file.NodeCount,
                [PipType.SealDirectory] = file2file.NodeCount,
            });
            var processPips = pipGraph.RetrievePipsOfType(PipType.Process).ToList();

            // assert edges exist
            Assert.All(
                file2file.Edges,
                edge =>
            {
                var errPrefix = $"Edge ({edge.Src})->({edge.Dest}) not found: ";
                var srcPip    = FindPipByTag(processPips, GetProcTag(edge.Src), stringTable);
                var destPip   = FindPipByTag(processPips, GetProcTag(edge.Dest), stringTable);
                var producedSealDirectoryPips = pipGraph.RetrievePipImmediateDependents(destPip).Where(pip => pip.PipType == PipType.SealDirectory).ToList();
                XAssert.AreEqual(1, producedSealDirectoryPips.Count, $"{errPrefix} expected to find exactly one SealDirectory dependency of Process Pip {destPip}");
                var producedSealDirectoryPip = producedSealDirectoryPips.First();
                var deps = pipGraph.RetrievePipImmediateDependents(producedSealDirectoryPip);
                if (!deps.Contains(srcPip))
                {
                    XAssert.Fail($"{errPrefix} expected edges between {srcPip} <-- {producedSealDirectoryPip} <-- {destPip}; dependencies of Pip {producedSealDirectoryPip} are: {XAssert.SetToString(deps)}");
                }
            });
        }
Ejemplo n.º 2
0
        private void TopSortInternal(List <Pip> pips, List <List <Pip> > sortedPipGroups)
        {
            var childrenLeftToVisit = new Dictionary <Pip, int>();

            sortedPipGroups.Add(new List <Pip>());
            int totalAdded = 0;

            foreach (var pip in pips)
            {
                childrenLeftToVisit[pip] = 0;
            }

            foreach (var pip in pips)
            {
                foreach (var dependent in (PipGraph.RetrievePipImmediateDependents(pip) ?? Enumerable.Empty <Pip>()))
                {
                    childrenLeftToVisit[dependent]++;
                }
            }

            foreach (var pip in pips)
            {
                if (childrenLeftToVisit[pip] == 0)
                {
                    totalAdded++;
                    sortedPipGroups[sortedPipGroups.Count - 1].Add(pip);
                }
            }

            int currentLevel = sortedPipGroups.Count - 1;

            while (totalAdded < pips.Count)
            {
                sortedPipGroups.Add(new List <Pip>());
                foreach (var pip in sortedPipGroups[currentLevel])
                {
                    foreach (var dependent in PipGraph.RetrievePipImmediateDependents(pip) ?? Enumerable.Empty <Pip>())
                    {
                        if (--childrenLeftToVisit[dependent] == 0)
                        {
                            totalAdded++;
                            sortedPipGroups[currentLevel + 1].Add(dependent);
                        }
                    }
                }

                currentLevel++;
            }
        }
Ejemplo n.º 3
0
        private static void SetCommonPipDetails(Pip p, PipDetails result)
        {
            IVisualizationInformation visualizationInformation = EngineModel.VisualizationInformation;
            PipGraph pipGraph    = visualizationInformation.PipGraph.Value;
            var      scheduler   = visualizationInformation.Scheduler.Value;
            var      context     = visualizationInformation.Context.Value;
            var      pathTable   = context.PathTable;
            var      symbolTable = context.SymbolTable;

            result.Id   = p.PipId.Value;
            result.Hash = p.SemiStableHash.ToString("X16", CultureInfo.InvariantCulture);
            result.QualifierAsString = p.Provenance != null?context.QualifierTable.GetCanonicalDisplayString(p.Provenance.QualifierId) : "";

            result.Description = p.GetDescription(context);
            result.State       = scheduler.GetPipState(p.PipId);

            result.Tags = p.Tags.IsValid ? p.Tags.Select(tag => pathTable.StringTable.GetString(tag)).ToList() : new List <string>();

            IEnumerable <Pip> dependents = pipGraph.RetrievePipImmediateDependents(p);

            result.DependantOf = dependents
                                 .Where(d => d.PipType != PipType.HashSourceFile)
                                 .Select(f => FromPip(f))
                                 .ToList();

            IEnumerable <Pip> dependencies = pipGraph.RetrievePipImmediateDependencies(p);

            result.DependsOn = dependencies
                               .Where(d => d.PipType != PipType.HashSourceFile)
                               .Select(f => FromPip(f))
                               .ToList();

            IEnumerable <ValuePip> valuePips = dependents.Where(pipId => pipId.PipType == PipType.Value).Cast <ValuePip>();

            result.Values = valuePips.Select(valuePip => ValueReference.Create(symbolTable, pathTable, valuePip));
        }