Skip to content

Commit 50ef4fa

Browse files
Fix dotnet watch tests on Helix (#19021)
1 parent 7e094d7 commit 50ef4fa

File tree

6 files changed

+33
-21
lines changed

6 files changed

+33
-21
lines changed

src/Tools/dotnet-watch/test/AppWithDepsTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public AppWithDepsTests(ITestOutputHelper logger)
1919
_app = new AppWithDeps(logger);
2020
}
2121

22-
[Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/8267")]
22+
[Fact]
23+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
2324
public async Task ChangeFileInDependency()
2425
{
2526
await _app.StartWatcherAsync();

src/Tools/dotnet-watch/test/AwaitableProcess.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public class AwaitableProcess : IDisposable
2121
private BufferBlock<string> _source;
2222
private ITestOutputHelper _logger;
2323
private TaskCompletionSource<int> _exited;
24+
private bool _started;
2425

2526
public AwaitableProcess(ProcessSpec spec, ITestOutputHelper logger)
2627
{
@@ -72,6 +73,7 @@ public void Start()
7273
_process.Exited += OnExit;
7374

7475
_process.Start();
76+
_started = true;
7577
_process.BeginErrorReadLine();
7678
_process.BeginOutputReadLine();
7779
_logger.WriteLine($"{DateTime.Now}: process start: '{_process.StartInfo.FileName} {_process.StartInfo.Arguments}'");
@@ -150,7 +152,7 @@ public void Dispose()
150152

151153
if (_process != null)
152154
{
153-
if (!_process.HasExited)
155+
if (_started && !_process.HasExited)
154156
{
155157
_process.KillTree();
156158
}

src/Tools/dotnet-watch/test/DotNetWatcherTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ public DotNetWatcherTests(ITestOutputHelper logger)
2222
_app = new KitchenSinkApp(logger);
2323
}
2424

25-
[ConditionalFact]
26-
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/8267")]
25+
[Fact]
26+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
2727
public async Task RunsWithDotnetWatchEnvVariable()
2828
{
2929
Assert.True(string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DOTNET_WATCH")), "DOTNET_WATCH cannot be set already when this test is running");
@@ -36,7 +36,7 @@ public async Task RunsWithDotnetWatchEnvVariable()
3636
}
3737

3838
[Fact]
39-
[Flaky("https://github.com/dotnet/aspnetcore-internal/issues/1826", FlakyOn.All)]
39+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
4040
public async Task RunsWithIterationEnvVariable()
4141
{
4242
await _app.StartWatcherAsync();

src/Tools/dotnet-watch/test/GlobbingAppTests.cs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ public GlobbingAppTests(ITestOutputHelper logger)
2121
_app = new GlobbingApp(logger);
2222
}
2323

24-
[Theory(Skip = "https://github.com/dotnet/aspnetcore/issues/8267")]
24+
[Theory]
2525
[InlineData(true)]
2626
[InlineData(false)]
27+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
2728
public async Task ChangeCompiledFile(bool usePollingWatcher)
2829
{
2930
_app.UsePollingWatcher = usePollingWatcher;
@@ -41,7 +42,8 @@ public async Task ChangeCompiledFile(bool usePollingWatcher)
4142
Assert.Equal(2, types);
4243
}
4344

44-
[Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/8267")]
45+
[Fact]
46+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
4547
public async Task DeleteCompiledFile()
4648
{
4749
await _app.StartWatcherAsync();
@@ -57,7 +59,8 @@ public async Task DeleteCompiledFile()
5759
Assert.Equal(1, types);
5860
}
5961

60-
[Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/8267")]
62+
[Fact]
63+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
6164
public async Task DeleteSourceFolder()
6265
{
6366
await _app.StartWatcherAsync();
@@ -73,7 +76,8 @@ public async Task DeleteSourceFolder()
7376
Assert.Equal(1, types);
7477
}
7578

76-
[Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/8987")]
79+
[Fact]
80+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
7781
public async Task RenameCompiledFile()
7882
{
7983
await _app.StartWatcherAsync();
@@ -85,8 +89,8 @@ public async Task RenameCompiledFile()
8589
await _app.HasRestarted();
8690
}
8791

88-
[ConditionalFact]
89-
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/8267")]
92+
[Fact]
93+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
9094
public async Task ChangeExcludedFile()
9195
{
9296
await _app.StartWatcherAsync();
@@ -99,8 +103,8 @@ public async Task ChangeExcludedFile()
99103
Assert.NotSame(restart, finished);
100104
}
101105

102-
[ConditionalFact]
103-
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/8267")]
106+
[Fact]
107+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
104108
public async Task ListsFiles()
105109
{
106110
await _app.PrepareAsync();

src/Tools/dotnet-watch/test/NoDepsAppTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Diagnostics;
65
using System.IO;
76
using System.Threading.Tasks;
87
using Microsoft.AspNetCore.Testing;
@@ -24,7 +23,8 @@ public NoDepsAppTests(ITestOutputHelper logger)
2423
_output = logger;
2524
}
2625

27-
[Fact(Skip = "https://github.com/dotnet/aspnetcore/issues/8267")]
26+
[Fact]
27+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
2828
public async Task RestartProcessOnFileChange()
2929
{
3030
await _app.StartWatcherAsync(new[] { "--no-exit" });
@@ -42,8 +42,8 @@ public async Task RestartProcessOnFileChange()
4242
Assert.NotEqual(processIdentifier, processIdentifier2);
4343
}
4444

45-
[ConditionalFact]
46-
[SkipOnHelix("https://github.com/dotnet/aspnetcore/issues/8267")]
45+
[Fact]
46+
[Flaky("<No longer needed; tracked in Kusto>", FlakyOn.All)]
4747
public async Task RestartProcessThatTerminatesAfterFileChange()
4848
{
4949
await _app.StartWatcherAsync();

src/Tools/dotnet-watch/test/Scenario/WatchableApp.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Reflection;
99
using System.Runtime.CompilerServices;
1010
using System.Threading.Tasks;
11-
using Microsoft.Extensions.CommandLineUtils;
1211
using Xunit.Abstractions;
1312

1413
namespace Microsoft.DotNet.Watcher.Tools.FunctionalTests
@@ -89,9 +88,15 @@ public void Start(IEnumerable<string> arguments, [CallerMemberName] string name
8988
};
9089
args.AddRange(arguments);
9190

92-
var dotnetPath = typeof(WatchableApp).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
93-
.Single(s => s.Key == "DotnetPath").Value;
94-
91+
var dotnetPath = "dotnet";
92+
93+
// Fallback to embedded path to dotnet when not on helix
94+
if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
95+
{
96+
dotnetPath = typeof(WatchableApp).Assembly.GetCustomAttributes<AssemblyMetadataAttribute>()
97+
.Single(s => s.Key == "DotnetPath").Value;
98+
}
99+
95100
var spec = new ProcessSpec
96101
{
97102
Executable = dotnetPath,

0 commit comments

Comments
 (0)