Skip to content

Re-enable DotNet.Watcher.Tests #49642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions test/dotnet-watch.Tests/TestUtilities/WatchableApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public async Task<string> AssertOutputLineStartsWith(string expectedPrefix, Pred
{
Logger.Log($"Test waiting for output: '{expectedPrefix}'", testPath, testLine);

var line = await Process.GetOutputLineAsync(
success: line => line.StartsWith(expectedPrefix, StringComparison.Ordinal),
failure: failure ?? new Predicate<string>(line => line.Contains(WatchErrorOutputEmoji, StringComparison.Ordinal)));
var line = await TryGetOutputLineWithDelayAsync(
expectedPrefix,
failure ?? new Predicate<string>(line => line.Contains(WatchErrorOutputEmoji, StringComparison.Ordinal)));

if (line == null)
{
Expand Down Expand Up @@ -171,5 +171,28 @@ public void SendKey(char c)
Process.Process.StandardInput.Write(c);
Process.Process.StandardInput.Flush();
}

private async Task<string> TryGetOutputLineWithDelayAsync(string expectedPrefix, Predicate<string> failure, int maxAttempts = 2)
{
for (int attempt = 0; attempt < maxAttempts; attempt++)
{
if (attempt > 0)
{
Logger.Log($"Retrying to find output with prefix: '{expectedPrefix}' (attempt {attempt + 1}/{maxAttempts})");
await Task.Delay(TimeSpan.FromSeconds(1));
}

var line = await Process.GetOutputLineAsync(
success: line => line.StartsWith(expectedPrefix, StringComparison.Ordinal),
failure: failure);

if (line is not null)
{
return line;
}
}

return null;
}
}
}
10 changes: 5 additions & 5 deletions test/dotnet-watch.Tests/Watch/GlobbingAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public GlobbingAppTests(ITestOutputHelper logger)
{
}

[ConditionalTheory(Skip = "https://github.com/dotnet/sdk/issues/42921")]
[ConditionalTheory]
[InlineData(true)]
[InlineData(false)]
public async Task ChangeCompiledFile(bool usePollingWatcher)
Expand All @@ -34,7 +34,7 @@ public async Task ChangeCompiledFile(bool usePollingWatcher)
await AssertCompiledAppDefinedTypes(expected: 2);
}

[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
[Fact]
public async Task DeleteCompiledFile()
{
var testAsset = TestAssets.CopyTestAsset(AppName)
Expand All @@ -51,7 +51,7 @@ public async Task DeleteCompiledFile()
await AssertCompiledAppDefinedTypes(expected: 1);
}

[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
[Fact]
public async Task DeleteSourceFolder()
{
var testAsset = TestAssets.CopyTestAsset(AppName)
Expand All @@ -68,7 +68,7 @@ public async Task DeleteSourceFolder()
await AssertCompiledAppDefinedTypes(expected: 1);
}

[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
[Fact]
public async Task RenameCompiledFile()
{
var testAsset = TestAssets.CopyTestAsset(AppName)
Expand All @@ -85,7 +85,7 @@ public async Task RenameCompiledFile()
await App.AssertStarted();
}

[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
[Fact]
public async Task ChangeExcludedFile()
{
var testAsset = TestAssets.CopyTestAsset(AppName)
Expand Down
2 changes: 1 addition & 1 deletion test/dotnet-watch.Tests/Watch/NoDepsAppTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class NoDepsAppTests(ITestOutputHelper logger) : DotNetWatchTestBase(logg
{
private const string AppName = "WatchNoDepsApp";

[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
[Fact]
public async Task RestartProcessOnFileChange()
{
var testAsset = TestAssets.CopyTestAsset(AppName)
Expand Down
Loading