コード例 #1
0
        public static Task <IDisposable> Run(string baseWorkingDirectory)
        {
            var completed          = false;
            var tcs                = new TaskCompletionSource <IDisposable>();
            var cancellationSource = new CancellationTokenSource();
            var logDirectory       = Path.Combine(baseWorkingDirectory, "logs");

            if (!Directory.Exists(logDirectory))
            {
                Directory.CreateDirectory(logDirectory);
            }

            void HandleConsoleLine(string line)
            {
                if (line.Contains("listener started on 0.0.0.0:4723"))
                {
                    Logger.WriteLine(line, LogLevel.Minimal, defaultLog);

                    if (!completed)
                    {
                        tcs.SetResult(new AppiumTask(cancellationSource));
                    }
                    completed = true;
                }
                else if (line.Contains("make sure there is no other instance of this server running already") ||
                         line.Contains("listen EADDRINUSE: address already in use 0.0.0.0:4723"))
                {
                    Logger.WriteWarning(line, defaultLog);

                    if (!completed)
                    {
                        tcs.SetResult(new AppiumTask(cancellationSource));
                    }
                    completed = true;
                }
                else
                {
                    Logger.WriteLine(line, LogLevel.Verbose, defaultLog);
                }
            }

            var stdOut = PipeTarget.ToDelegate(HandleConsoleLine);
            var stdErr = PipeTarget.Merge(
                PipeTarget.ToFile(Path.Combine(logDirectory, "appium-error.log")),
                PipeTarget.ToDelegate(HandleConsoleLine));

            Logger.WriteLine("Starting Appium...", LogLevel.Minimal);

            var toolPath = EnvironmentHelper.GetToolPath("appium");
            var cmd      = Cli.Wrap(toolPath)
                           .WithStandardOutputPipe(stdOut)
                           .WithStandardErrorPipe(stdErr)
                           .WithValidation(CommandResultValidation.None)
                           .ExecuteAsync(cancellationSource.Token);

            return(tcs.Task);
        }
コード例 #2
0
        public override async Task <ExecutionResult> RunAsync(IStepExecutionContext context)
        {
            // It's important that the CHROM names match (NC_000962.3) else it will report 0
            var ouput = Session.CreateFolder();

            Output = ouput.GetFile("output");
            var errorBuilder = new StringBuilder();
            var command      = Cli
                               .Wrap("bedtools")
                               .WithArguments(args => args
                                              .Add("coverage")
                                              .Add("-a")
                                              .Add(FileA.AbsolutePath)
                                              .Add("-b")
                                              .Add(FileB.AbsolutePath))
                               .WithStandardOutputPipe(PipeTarget.ToFile(Output.AbsolutePath))
                               .WithStandardErrorPipe(PipeTarget.ToStringBuilder(errorBuilder));

            await command.ExecuteAsync();

            return(ExecutionResult.Next());
        }