Skip to content

Commit 6dd5fa4

Browse files
author
Simon Zhao (BEYONDSOFT CONSULTING INC)
committed
Re-enable DotNet.Watcher.Tests
1 parent 2ed2664 commit 6dd5fa4

File tree

3 files changed

+32
-9
lines changed

3 files changed

+32
-9
lines changed

test/dotnet-watch.Tests/TestUtilities/WatchableApp.cs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ public async Task<string> AssertOutputLineStartsWith(string expectedPrefix, Pred
6565
{
6666
Logger.Log($"Test waiting for output: '{expectedPrefix}'", testPath, testLine);
6767

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

7272
if (line == null)
7373
{
@@ -171,5 +171,28 @@ public void SendKey(char c)
171171
Process.Process.StandardInput.Write(c);
172172
Process.Process.StandardInput.Flush();
173173
}
174+
175+
private async Task<string> TryGetOutputLineWithDelayAsync(string expectedPrefix, Predicate<string> failure, int maxAttempts = 2)
176+
{
177+
for (int attempt = 0; attempt < maxAttempts; attempt++)
178+
{
179+
if (attempt > 0)
180+
{
181+
Logger.Log($"Retrying to find output with prefix: '{expectedPrefix}' (attempt {attempt + 1}/{maxAttempts})");
182+
await Task.Delay(TimeSpan.FromSeconds(1));
183+
}
184+
185+
var line = await Process.GetOutputLineAsync(
186+
success: line => line.StartsWith(expectedPrefix, StringComparison.Ordinal),
187+
failure: failure);
188+
189+
if (line is not null)
190+
{
191+
return line;
192+
}
193+
}
194+
195+
return null;
196+
}
174197
}
175198
}

test/dotnet-watch.Tests/Watch/GlobbingAppTests.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public GlobbingAppTests(ITestOutputHelper logger)
1212
{
1313
}
1414

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

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

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

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

88-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
88+
[Fact]
8989
public async Task ChangeExcludedFile()
9090
{
9191
var testAsset = TestAssets.CopyTestAsset(AppName)

test/dotnet-watch.Tests/Watch/NoDepsAppTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class NoDepsAppTests(ITestOutputHelper logger) : DotNetWatchTestBase(logg
77
{
88
private const string AppName = "WatchNoDepsApp";
99

10-
[Fact(Skip = "https://github.com/dotnet/sdk/issues/42921")]
10+
[Fact]
1111
public async Task RestartProcessOnFileChange()
1212
{
1313
var testAsset = TestAssets.CopyTestAsset(AppName)

0 commit comments

Comments
 (0)