Add timeout to all awaits in GlobbingAppTests (#23938)
This commit is contained in:
parent
7b42cf1275
commit
7f4af095f7
|
|
@ -15,7 +15,10 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
{
|
||||
public class GlobbingAppTests : IDisposable
|
||||
{
|
||||
private GlobbingApp _app;
|
||||
private static readonly TimeSpan DefaultTimeout = TimeSpan.FromSeconds(60);
|
||||
|
||||
private readonly GlobbingApp _app;
|
||||
|
||||
public GlobbingAppTests(ITestOutputHelper logger)
|
||||
{
|
||||
_app = new GlobbingApp(logger);
|
||||
|
|
@ -28,17 +31,17 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
public async Task ChangeCompiledFile(bool usePollingWatcher)
|
||||
{
|
||||
_app.UsePollingWatcher = usePollingWatcher;
|
||||
await _app.StartWatcherAsync();
|
||||
await _app.StartWatcherAsync().TimeoutAfter(DefaultTimeout);
|
||||
|
||||
var types = await _app.GetCompiledAppDefinedTypes();
|
||||
var types = await _app.GetCompiledAppDefinedTypes().TimeoutAfter(DefaultTimeout);
|
||||
Assert.Equal(2, types);
|
||||
|
||||
var fileToChange = Path.Combine(_app.SourceDirectory, "include", "Foo.cs");
|
||||
var programCs = File.ReadAllText(fileToChange);
|
||||
File.WriteAllText(fileToChange, programCs);
|
||||
|
||||
await _app.HasRestarted();
|
||||
types = await _app.GetCompiledAppDefinedTypes();
|
||||
await _app.HasRestarted().TimeoutAfter(DefaultTimeout);
|
||||
types = await _app.GetCompiledAppDefinedTypes().TimeoutAfter(DefaultTimeout);
|
||||
Assert.Equal(2, types);
|
||||
}
|
||||
|
||||
|
|
@ -46,16 +49,16 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/23360", Queues = "Debian.9.Arm64;Debian.9.Arm64.Open;(Debian.9.Arm64.Open)Ubuntu.1804.Armarch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036;(Debian.9.Arm64)Ubuntu.1804.Armarch@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036")]
|
||||
public async Task DeleteCompiledFile()
|
||||
{
|
||||
await _app.StartWatcherAsync();
|
||||
await _app.StartWatcherAsync().TimeoutAfter(DefaultTimeout);
|
||||
|
||||
var types = await _app.GetCompiledAppDefinedTypes();
|
||||
var types = await _app.GetCompiledAppDefinedTypes().TimeoutAfter(DefaultTimeout);
|
||||
Assert.Equal(2, types);
|
||||
|
||||
var fileToChange = Path.Combine(_app.SourceDirectory, "include", "Foo.cs");
|
||||
File.Delete(fileToChange);
|
||||
|
||||
await _app.HasRestarted();
|
||||
types = await _app.GetCompiledAppDefinedTypes();
|
||||
await _app.HasRestarted().TimeoutAfter(DefaultTimeout);
|
||||
types = await _app.GetCompiledAppDefinedTypes().TimeoutAfter(DefaultTimeout);
|
||||
Assert.Equal(1, types);
|
||||
}
|
||||
|
||||
|
|
@ -63,16 +66,16 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/23360", Queues = "Debian.9.Arm64;Debian.9.Arm64.Open;(Debian.9.Arm64.Open)Ubuntu.1804.Armarch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036;(Debian.9.Arm64)Ubuntu.1804.Armarch@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036")]
|
||||
public async Task DeleteSourceFolder()
|
||||
{
|
||||
await _app.StartWatcherAsync();
|
||||
await _app.StartWatcherAsync().TimeoutAfter(DefaultTimeout);
|
||||
|
||||
var types = await _app.GetCompiledAppDefinedTypes();
|
||||
var types = await _app.GetCompiledAppDefinedTypes().TimeoutAfter(DefaultTimeout);
|
||||
Assert.Equal(2, types);
|
||||
|
||||
var folderToDelete = Path.Combine(_app.SourceDirectory, "include");
|
||||
Directory.Delete(folderToDelete, recursive: true);
|
||||
|
||||
await _app.HasRestarted();
|
||||
types = await _app.GetCompiledAppDefinedTypes();
|
||||
await _app.HasRestarted().TimeoutAfter(DefaultTimeout);
|
||||
types = await _app.GetCompiledAppDefinedTypes().TimeoutAfter(DefaultTimeout);
|
||||
Assert.Equal(1, types);
|
||||
}
|
||||
|
||||
|
|
@ -80,19 +83,19 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/23360", Queues = "Debian.9.Arm64;Debian.9.Arm64.Open;(Debian.9.Arm64.Open)Ubuntu.1804.Armarch.Open@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036;(Debian.9.Arm64)Ubuntu.1804.Armarch@mcr.microsoft.com/dotnet-buildtools/prereqs:debian-9-helix-arm64v8-a12566d-20190807161036")]
|
||||
public async Task RenameCompiledFile()
|
||||
{
|
||||
await _app.StartWatcherAsync();
|
||||
await _app.StartWatcherAsync().TimeoutAfter(DefaultTimeout);
|
||||
|
||||
var oldFile = Path.Combine(_app.SourceDirectory, "include", "Foo.cs");
|
||||
var newFile = Path.Combine(_app.SourceDirectory, "include", "Foo_new.cs");
|
||||
File.Move(oldFile, newFile);
|
||||
|
||||
await _app.HasRestarted();
|
||||
await _app.HasRestarted().TimeoutAfter(DefaultTimeout);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ChangeExcludedFile()
|
||||
{
|
||||
await _app.StartWatcherAsync();
|
||||
await _app.StartWatcherAsync().TimeoutAfter(DefaultTimeout);
|
||||
|
||||
var changedFile = Path.Combine(_app.SourceDirectory, "exclude", "Baz.cs");
|
||||
File.WriteAllText(changedFile, "");
|
||||
|
|
@ -105,11 +108,11 @@ namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
|
|||
[Fact]
|
||||
public async Task ListsFiles()
|
||||
{
|
||||
await _app.PrepareAsync();
|
||||
await _app.PrepareAsync().TimeoutAfter(DefaultTimeout);
|
||||
_app.Start(new[] { "--list" });
|
||||
var cts = new CancellationTokenSource();
|
||||
cts.CancelAfter(TimeSpan.FromSeconds(30));
|
||||
var lines = await _app.Process.GetAllOutputLinesAsync(cts.Token);
|
||||
var lines = await _app.Process.GetAllOutputLinesAsync(cts.Token).TimeoutAfter(DefaultTimeout);
|
||||
var files = lines.Where(l => !l.StartsWith("watch :"));
|
||||
|
||||
AssertEx.EqualFileList(
|
||||
|
|
|
|||
Loading…
Reference in New Issue