コード例 #1
0
ファイル: UnixUtil.cs プロジェクト: shellayers/Texas-Giant
        public async Task ExecAsync(string workingDirectory, string toolName, string argLine)
        {
            Trace.Entering();

            string toolPath = WhichUtil.Which(toolName, trace: Trace);

            Trace.Info($"Running {toolPath} {argLine}");

            var processInvoker = HostContext.CreateService <IProcessInvoker>();

            processInvoker.OutputDataReceived += OnOutputDataReceived;
            processInvoker.ErrorDataReceived  += OnErrorDataReceived;

            try
            {
                using (var cs = new CancellationTokenSource(TimeSpan.FromSeconds(45)))
                {
                    await processInvoker.ExecuteAsync(workingDirectory, toolPath, argLine, null, true, cs.Token);
                }
            }
            finally
            {
                processInvoker.OutputDataReceived -= OnOutputDataReceived;
                processInvoker.ErrorDataReceived  -= OnErrorDataReceived;
            }
        }
コード例 #2
0
ファイル: WhichUtilL0.cs プロジェクト: codedebug/vsts-agent
        public void UseWhichFindGit()
        {
            using (TestHostContext hc = new TestHostContext(this))
            {
                //Arrange
                Tracing trace = hc.GetTrace();
                var whichTool = new WhichUtil();
                whichTool.Initialize(hc);

                // Act.
                string gitPath = whichTool.Which("git");

                trace.Info($"Which(\"git\") returns: {gitPath ?? string.Empty}");

                // Assert.
                Assert.True(!string.IsNullOrEmpty(gitPath) && File.Exists(gitPath), $"Unable to find Git through: {nameof(WhichUtil.Which)}");
            }
        }