예제 #1
0
 private void ReportExecBegin()
 {
     if (!_quietBuildReporter)
     {
         BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo, includeWorkingDirectory: false));
     }
 }
예제 #2
0
파일: Command.cs 프로젝트: schellap/cli
 private void ReportExecBegin()
 {
     if (!_quietBuildReporter)
     {
         BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo));
     }
 }
예제 #3
0
 private void ReportExecWaitOnExit()
 {
     if (!_quietBuildReporter)
     {
         BuildReporter.SectionComment("EXEC", $"Waiting for process {Process.Id} to exit...");
     }
 }
예제 #4
0
        public CommandResult Execute()
        {
            ThrowIfRunning();
            _running = true;

            if (_process.StartInfo.RedirectStandardOutput)
            {
                _process.OutputDataReceived += (sender, args) =>
                {
                    ProcessData(args.Data, _stdOutCapture, _stdOutForward, _stdOutHandler);
                };
            }

            if (_process.StartInfo.RedirectStandardError)
            {
                _process.ErrorDataReceived += (sender, args) =>
                {
                    ProcessData(args.Data, _stdErrCapture, _stdErrForward, _stdErrHandler);
                };
            }

            _process.EnableRaisingEvents = true;

            var sw = Stopwatch.StartNew();

            BuildReporter.BeginSection("EXEC", FormatProcessInfo(_process.StartInfo));

            _process.Start();

            if (_process.StartInfo.RedirectStandardOutput)
            {
                _process.BeginOutputReadLine();
            }

            if (_process.StartInfo.RedirectStandardError)
            {
                _process.BeginErrorReadLine();
            }

            _process.WaitForExit();

            var exitCode = _process.ExitCode;

            var message = $"{FormatProcessInfo(_process.StartInfo)} exited with {exitCode}";

            if (exitCode == 0)
            {
                BuildReporter.EndSection("EXEC", message.Green(), success: true);
            }
            else
            {
                BuildReporter.EndSection("EXEC", message.Red().Bold(), success: false);
            }

            return(new CommandResult(
                       _process.StartInfo,
                       exitCode,
                       _stdOutCapture?.GetStringBuilder()?.ToString(),
                       _stdErrCapture?.GetStringBuilder()?.ToString()));
        }
예제 #5
0
        private BuildTargetResult ExecTarget(BuildTarget target)
        {
            var sectionName = $"{target.Name.PadRight(_maxTargetLen + 2).Yellow()} ({target.Source.White()})";

            BuildReporter.BeginSection("TARGET", sectionName);

            BuildTargetResult result;

            // Run the dependencies
            var dependencyResults      = new Dictionary <string, BuildTargetResult>();
            var failedDependencyResult = RunDependencies(target, dependencyResults);

            if (failedDependencyResult != null)
            {
                result = failedDependencyResult;
            }
            else if (target.Body != null)
            {
                try
                {
                    result = target.Body(new BuildTargetContext(this, target, dependencyResults));
                }
                catch (Exception ex)
                {
                    result = new BuildTargetResult(target, success: false, exception: ex);
                }
            }
            else
            {
                result = new BuildTargetResult(target, success: true);
            }
            BuildReporter.EndSection("TARGET", sectionName, result.Success);

            return(result);
        }
예제 #6
0
        private void ReportExecEnd(int exitCode)
        {
            if (!_quietBuildReporter)
            {
                bool success = exitCode == 0;

                var message = $"{FormatProcessInfo(_process.StartInfo, includeWorkingDirectory: !success)} exited with {exitCode}";

                BuildReporter.EndSection(
                    "EXEC",
                    success ? message.Green() : message.Red().Bold(),
                    success);
            }
        }
예제 #7
0
파일: Command.cs 프로젝트: schellap/cli
 private void ReportExecEnd(int exitCode)
 {
     if (!_quietBuildReporter)
     {
         var message = $"{FormatProcessInfo(_process.StartInfo)} exited with {exitCode}";
         if (exitCode == 0)
         {
             BuildReporter.EndSection("EXEC", message.Green(), success: true);
         }
         else
         {
             BuildReporter.EndSection("EXEC", message.Red().Bold(), success: false);
         }
     }
 }
예제 #8
0
        private void ReportExecEnd(int exitCode, bool fExpectedToFail)
        {
            bool   success           = exitCode == 0;
            string msgExpectedToFail = "";

            if (fExpectedToFail)
            {
                success           = !success;
                msgExpectedToFail = "failed as expected and ";
            }

            var message = $"{FormatProcessInfo(Process.StartInfo, includeWorkingDirectory: !success)} {msgExpectedToFail}exited with {exitCode}";

            BuildReporter.EndSection(
                "EXEC",
                success ? message.Green() : message.Red().Bold(),
                success);
        }