Merge branch 'release/2.1' into dev
This commit is contained in:
commit
5bec83c5c9
|
|
@ -105,9 +105,23 @@ namespace Microsoft.DotNet.Watcher.Internal
|
||||||
{
|
{
|
||||||
_process = process;
|
_process = process;
|
||||||
_process.Exited += OnExited;
|
_process.Exited += OnExited;
|
||||||
|
Task = _tcs.Task.ContinueWith(_ =>
|
||||||
|
{
|
||||||
|
// We need to use two WaitForExit calls to ensure that all of the output/events are processed. Previously
|
||||||
|
// this code used Process.Exited, which could result in us missing some output due to the ordering of
|
||||||
|
// events.
|
||||||
|
//
|
||||||
|
// See the remarks here: https://docs.microsoft.com/en-us/dotnet/api/system.diagnostics.process.waitforexit#System_Diagnostics_Process_WaitForExit_System_Int32_
|
||||||
|
if (!process.WaitForExit(Int32.MaxValue))
|
||||||
|
{
|
||||||
|
throw new TimeoutException();
|
||||||
|
}
|
||||||
|
|
||||||
|
process.WaitForExit();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task Task => _tcs.Task;
|
public Task Task { get; }
|
||||||
|
|
||||||
public void TryKill()
|
public void TryKill()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -116,6 +116,8 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
||||||
|
|
||||||
private void OnExit(object sender, EventArgs args)
|
private void OnExit(object sender, EventArgs args)
|
||||||
{
|
{
|
||||||
|
// Wait to ensure the process has exited and all output consumed
|
||||||
|
_process.WaitForExit();
|
||||||
_source.Complete();
|
_source.Complete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
||||||
|
|
||||||
private const string StartedMessage = "Started";
|
private const string StartedMessage = "Started";
|
||||||
private const string ExitingMessage = "Exiting";
|
private const string ExitingMessage = "Exiting";
|
||||||
|
private const string WatchExitedMessage = "watch : Exited";
|
||||||
|
|
||||||
private readonly ITestOutputHelper _logger;
|
private readonly ITestOutputHelper _logger;
|
||||||
private string _appName;
|
private string _appName;
|
||||||
|
|
@ -42,8 +43,11 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
||||||
public Task HasRestarted()
|
public Task HasRestarted()
|
||||||
=> Process.GetOutputLineAsync(StartedMessage, DefaultMessageTimeOut);
|
=> Process.GetOutputLineAsync(StartedMessage, DefaultMessageTimeOut);
|
||||||
|
|
||||||
public Task HasExited()
|
public async Task HasExited()
|
||||||
=> Process.GetOutputLineAsync(ExitingMessage, DefaultMessageTimeOut);
|
{
|
||||||
|
await Process.GetOutputLineAsync(ExitingMessage, DefaultMessageTimeOut);
|
||||||
|
await Process.GetOutputLineAsync(WatchExitedMessage, DefaultMessageTimeOut);
|
||||||
|
}
|
||||||
|
|
||||||
public bool UsePollingWatcher { get; set; }
|
public bool UsePollingWatcher { get; set; }
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue