From bcbc4f2a499749797fa94bfb038e7e6b1d889c74 Mon Sep 17 00:00:00 2001 From: "Nate McMaster (automated)" Date: Wed, 28 Mar 2018 10:41:01 -0700 Subject: [PATCH 1/3] Update dependencies.props [auto-updated: dependencies] --- build/dependencies.props | 20 ++++++++++---------- korebuild-lock.txt | 4 ++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build/dependencies.props b/build/dependencies.props index 0a3ff46de7..7537f33f0a 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -3,17 +3,17 @@ $(MSBuildAllProjects);$(MSBuildThisFileFullPath) - 2.1.0-preview2-15742 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 - 2.1.0-preview2-30355 + 2.1.0-preview2-15749 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 + 2.1.0-preview2-30478 2.0.0 - 2.1.0-preview2-26314-02 - 15.6.0 - 4.5.0-preview2-26313-01 - 4.5.0-preview2-26313-01 + 2.1.0-preview2-26326-03 + 15.6.1 + 4.5.0-preview2-26326-04 + 4.5.0-preview2-26326-04 9.0.1 2.3.1 2.4.0-beta.1.build3945 diff --git a/korebuild-lock.txt b/korebuild-lock.txt index e761020952..76d2c851ca 100644 --- a/korebuild-lock.txt +++ b/korebuild-lock.txt @@ -1,2 +1,2 @@ -version:2.1.0-preview2-15742 -commithash:21fbb0f2c3fe4a9216e2d59632b98cfd7d685962 +version:2.1.0-preview2-15749 +commithash:5544c9ab20fa5e24b9e155d8958a3c3b6f5f9df9 From 1f41b26145b5f554c67fb0e3da9a0073c9948ca3 Mon Sep 17 00:00:00 2001 From: Ryan Brandenburg Date: Thu, 29 Mar 2018 11:13:36 -0700 Subject: [PATCH 2/3] Skip broken test --- test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs b/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs index ea9ffbec03..2cbf841ae0 100644 --- a/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs +++ b/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs @@ -41,7 +41,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests Assert.Throws(() => Process.GetProcessById(pid)); } - [Fact] + [Fact(Skip="https://github.com/aspnet/DotNetTools/issues/407")] public async Task RestartProcessThatTerminatesAfterFileChange() { await _app.StartWatcherAsync(); From 6d4a632b96bfe91a91304d58d8de095a544b6f12 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Fri, 30 Mar 2018 17:44:31 -0700 Subject: [PATCH 3/3] Fix race condition in test code waiting for dotnet-watch to restart --- src/dotnet-watch/Internal/ProcessRunner.cs | 16 +++++++++++++++- .../AwaitableProcess.cs | 2 ++ .../NoDepsAppTests.cs | 2 +- .../Scenario/WatchableApp.cs | 8 ++++++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/dotnet-watch/Internal/ProcessRunner.cs b/src/dotnet-watch/Internal/ProcessRunner.cs index c866b6db14..a5f7cac8ef 100644 --- a/src/dotnet-watch/Internal/ProcessRunner.cs +++ b/src/dotnet-watch/Internal/ProcessRunner.cs @@ -105,9 +105,23 @@ namespace Microsoft.DotNet.Watcher.Internal { _process = process; _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() { diff --git a/test/dotnet-watch.FunctionalTests/AwaitableProcess.cs b/test/dotnet-watch.FunctionalTests/AwaitableProcess.cs index 25a0189315..91b53133eb 100644 --- a/test/dotnet-watch.FunctionalTests/AwaitableProcess.cs +++ b/test/dotnet-watch.FunctionalTests/AwaitableProcess.cs @@ -116,6 +116,8 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests private void OnExit(object sender, EventArgs args) { + // Wait to ensure the process has exited and all output consumed + _process.WaitForExit(); _source.Complete(); } diff --git a/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs b/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs index 2cbf841ae0..ea9ffbec03 100644 --- a/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs +++ b/test/dotnet-watch.FunctionalTests/NoDepsAppTests.cs @@ -41,7 +41,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests Assert.Throws(() => Process.GetProcessById(pid)); } - [Fact(Skip="https://github.com/aspnet/DotNetTools/issues/407")] + [Fact] public async Task RestartProcessThatTerminatesAfterFileChange() { await _app.StartWatcherAsync(); diff --git a/test/dotnet-watch.FunctionalTests/Scenario/WatchableApp.cs b/test/dotnet-watch.FunctionalTests/Scenario/WatchableApp.cs index 7725812bd6..16bfbacc8d 100644 --- a/test/dotnet-watch.FunctionalTests/Scenario/WatchableApp.cs +++ b/test/dotnet-watch.FunctionalTests/Scenario/WatchableApp.cs @@ -18,6 +18,7 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests private const string StartedMessage = "Started"; private const string ExitingMessage = "Exiting"; + private const string WatchExitedMessage = "watch : Exited"; private readonly ITestOutputHelper _logger; private string _appName; @@ -42,8 +43,11 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests public Task HasRestarted() => Process.GetOutputLineAsync(StartedMessage, DefaultMessageTimeOut); - public Task HasExited() - => Process.GetOutputLineAsync(ExitingMessage, DefaultMessageTimeOut); + public async Task HasExited() + { + await Process.GetOutputLineAsync(ExitingMessage, DefaultMessageTimeOut); + await Process.GetOutputLineAsync(WatchExitedMessage, DefaultMessageTimeOut); + } public bool UsePollingWatcher { get; set; }