Beispiel #1
0
        private LineOutColored?DotNetTest_OutputProcessor(EnumProcessOutputType type, string text)
        {
            if (text == null)
            {
                return(null);
            }
            EnumProcessOutputType processType = type;
            LineOutColored        lineOutColored;
            ReadOnlySpan <char>   textSpan = text;

            if (type == EnumProcessOutputType.ProcessErr)
            {
                return(LineOutColored.Error(text));
            }


            // Find index of the actual message part:
            // First 2 columns are blank
            if (StringExtension.SpanSearcherContains(textSpan, "Failed", 2, 9))
            {
                return(LineOutColored.LogicError(text));
            }
            if (StringExtension.SpanSearcherContains(textSpan, "Failed!", 0, 9))
            {
                return(LineOutColored.Error(text));
            }
            if (StringExtension.SpanSearcherContains(textSpan, "Passed!", 0, 9))
            {
                return(LineOutColored.Success(text));
            }
            return(LineOutColored.Normal(text));
        }
Beispiel #2
0
        /// <summary>
        /// Executes the requested Git Command AND returns the output.  Returns True on success, false otherwise
        /// </summary>
        /// <param name="cmdArguments"></param>
        /// <param name="output"></param>
        /// <returns></returns>
        private bool ExecuteGit(string cmdArguments, out List <LineOutColored> output)
        {
            string command = GIT_COMMAND;

            HasErrored = false;

            // Log it
            LineOutColored outputCmd = LineOutColored.Normal(GIT_COMMAND_MARKER + command + " " + cmdArguments);

            GitCommandOutputHistory.Add(outputCmd);

            //ProcessTasks.DefaultLogOutput = false;
            IProcess process = ProcessTasks.StartProcess(command, cmdArguments, CISession.RootDirectory, logInvocation: logInvocationLogging, logOutput: logOutputLogging);

            //,customLogger:GitProcessorLoggerNormal
            process.AssertWaitForExit();
            output = process.Output.ToList();

            // Copy output to history.
            GitCommandOutputHistory.AddRange(process.Output);

            if (process.ExitCode != 0)
            {
                HasErrored = true;
                return(false);
            }
            return(true);
        }
Beispiel #3
0
 /// <summary>
 /// Writes the given text as normal output to both BuildStage output and to the console real time.
 /// </summary>
 /// <param name="text"></param>
 protected void AOT_Normal(string text, Color textColor)
 {
     StageOutput.Add(LineOutColored.Normal(text, textColor));
     if (ShouldLogToConsoleRealTime)
     {
         Console.WriteLine(text, textColor);
     }
 }
Beispiel #4
0
        private static BlockingCollection <LineOutColored> GetOutputCollection(
            Process process,
            bool logTimestamp,
            [CanBeNull] Action <OutputType, string> logger,
            [CanBeNull] StreamWriter logFile,
            Func <string, string> outputFilter)
        {
            var output = new BlockingCollection <LineOutColored>();

            string GetProcessedOutput(string data)
            => logTimestamp
                    ? $"{DateTime.Now.ToLongTimeString()} {outputFilter.Invoke(data)}"
                    : outputFilter.Invoke(data);


            // ********************************************************************************
            process.OutputDataReceived += (_, e) =>
            {
                if (e.Data == null)
                {
                    return;
                }

                output.Add(LineOutColored.Normal(e.Data));

                var processedOutput = GetProcessedOutput(e.Data);
                logFile?.WriteLine($"[STD] {processedOutput}");
                logger?.Invoke(OutputType.Std, processedOutput);
            };


            // ********************************************************************************
            process.ErrorDataReceived += (_, e) =>
            {
                if (e.Data == null)
                {
                    return;
                }

                output.Add(LineOutColored.Error(e.Data));

                var processedOutput = GetProcessedOutput(e.Data);
                logFile?.WriteLine($"[ERR] {processedOutput}");
                logger?.Invoke(OutputType.Err, processedOutput);
            };

            process.BeginOutputReadLine();
            process.BeginErrorReadLine();

            return(output);
        }
Beispiel #5
0
        private LineOutColored?DotNetClean_OutputProcessor(EnumProcessOutputType type, string text)
        {
            if (text == null)
            {
                return(null);
            }
            EnumProcessOutputType processType = type;
            LineOutColored        lineOutColored;
            ReadOnlySpan <char>   textSpan = text;

            if (type == EnumProcessOutputType.ProcessErr)
            {
                return(LineOutColored.Error(text));
            }

            return(LineOutColored.Normal(text));
        }
Beispiel #6
0
        private LineOutColored?DotNetPack_OutputProcessor(EnumProcessOutputType type, string text)
        {
            if (text == null)
            {
                return(null);
            }
            EnumProcessOutputType processType = type;
            LineOutColored        lineOutColored;
            ReadOnlySpan <char>   textSpan = text;

            if (type == EnumProcessOutputType.ProcessErr)
            {
                return(LineOutColored.Error(text));
            }
            if (StringExtension.SpanSearcherContains(textSpan, "Successfully created package", 2, 32))
            {
                return(LineOutColored.Success(text));
            }
            return(LineOutColored.Normal(text));
        }
Beispiel #7
0
        private LineOutColored?DotNetNugetPush_OutputProcessor(EnumProcessOutputType type, string text)
        {
            if (text == null)
            {
                return(null);
            }
            EnumProcessOutputType processType = type;
            LineOutColored        lineOutColored;
            ReadOnlySpan <char>   textSpan = text;

            if (type == EnumProcessOutputType.ProcessErr)
            {
                return(LineOutColored.Error(text));
            }

            if (StringExtension.SpanSearcherContains(textSpan, "warn :", 0, 7))
            {
                return(LineOutColored.Warning(text));
            }

            return(LineOutColored.Normal(text));
        }
Beispiel #8
0
        private LineOutColored?DotNetRestore_OutputProcessor(EnumProcessOutputType type, string text)
        {
            if (text == null)
            {
                return(null);
            }
            EnumProcessOutputType processType = type;
            LineOutColored        lineOutColored;

            if (type == EnumProcessOutputType.ProcessErr)
            {
                return(LineOutColored.Error(text));
            }
            if (text.StartsWith("  Restored"))
            {
                return(LineOutColored.Success(text));
            }
            if (text.Contains("up-to-date:"))
            {
                return(LineOutColored.Success(text));
            }
            return(LineOutColored.Normal(text));
        }
Beispiel #9
0
        private LineOutColored?DotNetBuild_OutputProcessor(EnumProcessOutputType type, string text)
        {
            if (text == null)
            {
                return(null);
            }
            EnumProcessOutputType processType = type;
            LineOutColored        lineOutColored;
            ReadOnlySpan <char>   textSpan = text;

            if (type == EnumProcessOutputType.ProcessErr)
            {
                return(LineOutColored.Error(text));
            }

            // Find index of the actual message part:
            // The plus 17 is arbitrary as the src path,. still has a project path and source filename as well as line and column number entries
            int compileMsgStart = CISession.SourceDirectory.Length + 17;

            if (text.Length > compileMsgStart)
            {
                int index = text.IndexOf(": ", compileMsgStart);
                if (index > 0)
                {
                    if (StringExtension.SpanSearcherContains(textSpan, "error", index + 2, index + 10))
                    {
                        return(LineOutColored.LogicError(text));
                    }
                    if (StringExtension.SpanSearcherContains(textSpan, "warning", index + 2, index + 10 + 50))
                    {
                        return(LineOutColored.Warning(text));
                    }
                }
            }
            return(LineOutColored.Normal(text));
        }