/// <summary>
        /// Reports the summary of this pass, including a sumamry for each test
        /// </summary>
        /// <param name="CurrentPass"></param>
        /// <param name="NumPasses"></param>
        /// <param name="Duration"></param>
        /// <param name="AllInfo"></param>
        /// <returns></returns>
        void ReportMasterSummary(int CurrentPass, int NumPasses, TimeSpan Duration, IEnumerable <TestExecutionInfo> AllInfo)
        {
            MarkdownBuilder MB = new MarkdownBuilder();

            int TestCount    = AllInfo.Count();
            int FailedCount  = AllInfo.Where(T => T.FinalResult != TestResult.Passed).Count();
            int WarningCount = AllInfo.Where(T => T.TestNode.GetWarnings().Any()).Count();

            var SortedInfo = AllInfo;

            // sort our tests by failed/warning/ok
            if (FailedCount > 0 || WarningCount > 0)
            {
                SortedInfo = AllInfo.OrderByDescending(T =>
                {
                    if (T.FinalResult != TestResult.Passed)
                    {
                        return(10);
                    }

                    if (T.TestNode.GetWarnings().Any())
                    {
                        return(5);
                    }

                    return(0);
                });
            }

            Log.Info("Completed test pass {0} of {1}.", CurrentPass, NumPasses);

            MB.H2(string.Format("{0} of {1} Tests Passed in {2:mm\\:ss}. ({3} Failed, {4} Passed with Warnings)",
                                TestCount - FailedCount, TestCount, Duration, FailedCount, WarningCount));

            // write out a list of tests and results
            List <string> TestResults = new List <string>();

            foreach (TestExecutionInfo Info in SortedInfo)
            {
                string WarningString = Info.TestNode.GetWarnings().Any() ? " With Warnings" : "";
                TestResults.Add(string.Format("\t{0} result={1}{2}", Info, Info.FinalResult, WarningString));
            }

            MB.UnorderedList(TestResults);

            // write the markdown out with each line indented
            MB.ToString().Split('\n').ToList().ForEach(L => Log.Info("  " + L));

            if (Options.DeferReports)
            {
                // write each tests full summary
                foreach (TestExecutionInfo Info in SortedInfo)
                {
                    ReportTestSummary(Info);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Parses the output of an application to try and determine a failure cause (if one exists). Returns
        /// 0 for graceful shutdown
        /// </summary>
        /// <param name="Prefix"></param>
        /// <param name="App"></param>
        /// <returns></returns>
        protected virtual int GetRoleSummary(UnrealRoleArtifacts InArtifacts, out string Summary)
        {
            const int MaxLogLines       = 10;
            const int MaxCallstackLines = 20;

            UnrealLogParser.LogSummary LogSummary = InArtifacts.LogSummary;

            string ExitReason = "Unknown";
            int    ExitCode   = GetExitCodeAndReason(InArtifacts, out ExitReason);

            MarkdownBuilder MB = new MarkdownBuilder();

            MB.H3(string.Format("Role: {0} ({1} {2})", InArtifacts.SessionRole.RoleType, InArtifacts.SessionRole.Platform, InArtifacts.SessionRole.Configuration));

            if (ExitCode != 0)
            {
                MB.H4(string.Format("Result: Abnormal Exit: {0}", ExitReason));
            }
            else
            {
                MB.H4(string.Format("Result: {0}", ExitReason));
            }

            int FatalErrors = LogSummary.FatalError != null ? 1 : 0;

            if (LogSummary.FatalError != null)
            {
                MB.H4(string.Format("Fatal Error: {0}", LogSummary.FatalError.Message));
                MB.UnorderedList(InArtifacts.LogSummary.FatalError.Callstack.Take(MaxCallstackLines));

                if (InArtifacts.LogSummary.FatalError.Callstack.Count() > MaxCallstackLines)
                {
                    MB.Paragraph("See log for full callstack");
                }
            }

            if (LogSummary.Ensures.Count() > 0)
            {
                foreach (var Ensure in LogSummary.Ensures)
                {
                    MB.H4(string.Format("Ensure: {0}", Ensure.Message));
                    MB.UnorderedList(Ensure.Callstack.Take(MaxCallstackLines));

                    if (Ensure.Callstack.Count() > MaxCallstackLines)
                    {
                        MB.Paragraph("See log for full callstack");
                    }
                }
            }

            MB.Paragraph(string.Format("FatalErrors: {0}, Ensures: {1}, Errors: {2}, Warnings: {3}",
                                       FatalErrors, LogSummary.Ensures.Count(), LogSummary.Errors.Count(), LogSummary.Warnings.Count()));

            if (GetConfiguration().ShowErrorsInSummary&& InArtifacts.LogSummary.Errors.Count() > 0)
            {
                MB.H4("Errors");
                MB.UnorderedList(LogSummary.Errors.Take(MaxLogLines));

                if (LogSummary.Errors.Count() > MaxLogLines)
                {
                    MB.Paragraph(string.Format("(First {0} of {1} errors)", MaxLogLines, LogSummary.Errors.Count()));
                }
            }

            if (GetConfiguration().ShowWarningsInSummary&& InArtifacts.LogSummary.Warnings.Count() > 0)
            {
                MB.H4("Warnings");
                MB.UnorderedList(LogSummary.Warnings.Take(MaxLogLines));

                if (LogSummary.Warnings.Count() > MaxLogLines)
                {
                    MB.Paragraph(string.Format("(First {0} of {1} warnings)", MaxLogLines, LogSummary.Warnings.Count()));
                }
            }

            MB.H4("Artifacts");
            MB.Paragraph(string.Format("Log: {0}", InArtifacts.LogPath));
            MB.Paragraph(string.Format("Commandline: {0}", InArtifacts.AppInstance.CommandLine));
            MB.Paragraph(InArtifacts.ArtifactPath);

            Summary = MB.ToString();
            return(ExitCode);
        }