Пример #1
0
        public BaseliningSummary RunSeries(string seriesPath, string reportingName, int debugLogIndex = -1, int debugResultIndex = -1)
        {
            string            outputLogPath = Path.ChangeExtension(seriesPath.Replace($"\\{InputFolderName}\\", $"\\{OutputFolderName}\\"), ".log");
            BaseliningSummary seriesSummary = new BaseliningSummary(Path.GetFileName(seriesPath));

            Directory.CreateDirectory(Path.GetDirectoryName(outputLogPath));

            using (Stream outputStream = File.Create(outputLogPath))
                using (BaseliningDetailLogger logger = new BaseliningDetailLogger(seriesPath, outputStream))
                {
                    // Load the original baseline
                    SarifLog baseline = LoadBaseline(seriesPath);

                    // Baseline each log in order
                    foreach (LogInSeries current in LoadSeriesLogs(seriesPath))
                    {
                        if (debugLogIndex == current.LogIndex && Debugger.IsAttached)
                        {
                            Debugger.Break();
                            DebugResultComparison(baseline, current.Log, $"{debugLogIndex:d3} {debugResultIndex:d3}");
                        }

                        SarifLog newBaseline = Baseline(baseline, current.Log);

                        if (debugLogIndex == current.LogIndex)
                        {
                            List <Result> absentResults = newBaseline.EnumerateResults().Where((r) => r.BaselineState == BaselineState.Absent).ToList();
                            List <Result> newResults    = newBaseline.EnumerateResults().Where((r) => r.BaselineState == BaselineState.New).ToList();
                        }

                        BaseliningSummary fileSummary = new BaseliningSummary(Path.GetFileNameWithoutExtension(current.FilePath));
                        fileSummary.Add(newBaseline, baseline, current.Log);
                        seriesSummary.AddCounts(fileSummary);
                        logger.Write(newBaseline, baseline, fileSummary);

                        baseline = newBaseline;
                    }
                }

            EnrichSeries(seriesPath);

            string comparisonResult = CompareToExpected(outputLogPath);

            Console.WriteLine($" - {comparisonResult}{seriesSummary.ToString(reportingName)}");
            return(seriesSummary);
        }
Пример #2
0
        public BaseliningSummary RunUnder(string folderPath, string reportingName)
        {
            BaseliningSummary folderSummary = new BaseliningSummary(Path.GetFileName(folderPath));

            // Recurse on subfolders, if found
            foreach (string subfolder in Directory.EnumerateDirectories(folderPath, "*", SearchOption.TopDirectoryOnly))
            {
                BaseliningSummary part = RunUnder(subfolder, Path.Combine(reportingName, Path.GetFileName(subfolder)));
                folderSummary.AddComponent(part);
            }

            // Run series for leaf folders
            if (Directory.EnumerateFiles(folderPath).Any())
            {
                BaseliningSummary seriesSummary = RunSeries(folderPath, reportingName);
                folderSummary.AddCounts(seriesSummary);
            }

            return(folderSummary);
        }
Пример #3
0
        public BaseliningSummary RunUnder(string folderPath)
        {
            BaseliningSummary folderSummary = new BaseliningSummary(Path.GetFileName(folderPath));

            // Recurse on subfolders, if found
            foreach (string subfolder in Directory.EnumerateDirectories(folderPath, "*", SearchOption.TopDirectoryOnly))
            {
                BaseliningSummary part = RunUnder(subfolder);
                folderSummary.AddComponent(part);
            }

            // Look for logs and sort in Ordinal order
            if (Directory.EnumerateFiles(folderPath).Any())
            {
                BaseliningSummary seriesSummary = RunSeries(folderPath);
                folderSummary.AddCounts(seriesSummary);
            }

            return(folderSummary);
        }