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; } }
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)}"); } }