Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,8 @@ internal sealed record EnvironmentOptions(
);

public TimeSpan GetProcessCleanupTimeout(bool isHotReloadEnabled)
// If Hot Reload mode is disabled the process is restarted on every file change.
// Waiting for graceful termination would slow down the turn around.
=> ProcessCleanupTimeout ?? (isHotReloadEnabled ? TimeSpan.FromSeconds(5) : TimeSpan.FromSeconds(0));
// Allow sufficient time for the process to exit gracefully and release resources (e.g., network ports).
=> ProcessCleanupTimeout ?? TimeSpan.FromSeconds(5);

private int _uniqueLogId;

Expand Down
34 changes: 34 additions & 0 deletions test/dotnet-watch.Tests/CommandLine/EnvironmentOptionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@

namespace Microsoft.DotNet.Watch.UnitTests;

public class EnvironmentOptionsTests
{
[Theory]
[InlineData(true)]
[InlineData(false)]
public void GetProcessCleanupTimeout_WithoutEnvironmentVariable_ReturnsDefaultTimeout(bool isHotReloadEnabled)
{
var envOptions = new EnvironmentOptions(
WorkingDirectory: "/test",
MuxerPath: "dotnet",
ProcessCleanupTimeout: null);

var timeout = envOptions.GetProcessCleanupTimeout(isHotReloadEnabled);

Assert.Equal(TimeSpan.FromSeconds(5), timeout);
}

[Theory]
[InlineData(true)]
[InlineData(false)]
public void GetProcessCleanupTimeout_WithEnvironmentVariable_ReturnsSpecifiedTimeout(bool isHotReloadEnabled)
{
var customTimeout = TimeSpan.FromSeconds(10);
var envOptions = new EnvironmentOptions(
WorkingDirectory: "/test",
MuxerPath: "dotnet",
ProcessCleanupTimeout: customTimeout);

var timeout = envOptions.GetProcessCleanupTimeout(isHotReloadEnabled);

Assert.Equal(customTimeout, timeout);
}
}

public class BuildReporterTests
{
[Fact]
Expand Down
4 changes: 2 additions & 2 deletions test/dotnet-watch.Tests/HotReload/ApplyDeltaTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ public async Task BlazorWasmHosted()
App.AssertOutputContains($"dotnet watch ⌚ [blazorhosted ({tfm})] Capabilities: 'Baseline AddMethodToExistingType AddStaticFieldToExistingType AddInstanceFieldToExistingType NewTypeDefinition ChangeCustomAttributes UpdateParameters GenericUpdateMethod GenericAddMethodToExistingType GenericAddFieldToExistingType AddFieldRva'");
}

[PlatformSpecificFact(TestPlatforms.Windows)] // https://github.com/dotnet/aspnetcore/issues/63759
[Fact]
public async Task Razor_Component_ScopedCssAndStaticAssets()
{
var testAsset = TestAssets.CopyTestAsset("WatchRazorWithDeps")
Expand Down Expand Up @@ -1017,7 +1017,7 @@ public async Task Razor_Component_ScopedCssAndStaticAssets()
/// Currently only works on Windows.
/// Add TestPlatforms.OSX once https://github.com/dotnet/sdk/issues/45521 is fixed.
/// </summary>
[PlatformSpecificFact(TestPlatforms.Windows, Skip = "https://github.com/dotnet/sdk/issues/40006")]
[PlatformSpecificFact(TestPlatforms.Windows)]
public async Task MauiBlazor()
{
var testAsset = TestAssets.CopyTestAsset("WatchMauiBlazor")
Expand Down
Loading