Avoid race in FileWatcher test Internal/1710 (#8095)

This commit is contained in:
Chris Ross 2019-03-01 15:03:21 -08:00 committed by GitHub
parent eee89a7c22
commit 1830f4f0dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 6 deletions

31
src/Tools/Tools.sln Normal file
View File

@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.0.0
MinimumVisualStudioVersion = 16.0.0.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-watch", "dotnet-watch\src\dotnet-watch.csproj", "{E16F10C8-5FC3-420B-AB33-D6E5CBE89B75}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "dotnet-watch.Tests", "dotnet-watch\test\dotnet-watch.Tests.csproj", "{63F7E822-D1E2-4C41-8ABF-60B9E3A9C54C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E16F10C8-5FC3-420B-AB33-D6E5CBE89B75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E16F10C8-5FC3-420B-AB33-D6E5CBE89B75}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E16F10C8-5FC3-420B-AB33-D6E5CBE89B75}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E16F10C8-5FC3-420B-AB33-D6E5CBE89B75}.Release|Any CPU.Build.0 = Release|Any CPU
{63F7E822-D1E2-4C41-8ABF-60B9E3A9C54C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{63F7E822-D1E2-4C41-8ABF-60B9E3A9C54C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{63F7E822-D1E2-4C41-8ABF-60B9E3A9C54C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{63F7E822-D1E2-4C41-8ABF-60B9E3A9C54C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {EC668D8E-97B9-4758-9E5C-2E5DD6B9137B}
EndGlobalSection
EndGlobal

View File

@ -246,7 +246,13 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
File.WriteAllText(Path.Combine(dir, "foo2"), string.Empty);
File.WriteAllText(Path.Combine(dir, "foo3"), string.Empty);
File.WriteAllText(Path.Combine(dir, "foo4"), string.Empty);
File.WriteAllText(Path.Combine(dir, "foo4"), string.Empty);
// On Unix the native file watcher may surface events from
// the recent past. Delay to avoid those.
// On Unix the file write time is in 1s increments;
// if we don't wait, there's a chance that the polling
// watcher will not detect the change
await Task.Delay(1250);
var testFileFullPath = Path.Combine(dir, "foo3");
@ -267,11 +273,6 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
watcher.OnFileChange += handler;
watcher.EnableRaisingEvents = true;
// On Unix the file write time is in 1s increments;
// if we don't wait, there's a chance that the polling
// watcher will not detect the change
await Task.Delay(1000);
File.WriteAllText(testFileFullPath, string.Empty);
await changedEv.Task.TimeoutAfter(DefaultTimeout);