File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed
src/BuiltInTools/dotnet-watch/CommandLine
test/dotnet-watch.Tests/CommandLine Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -61,9 +61,8 @@ internal sealed record EnvironmentOptions(
6161 ) ;
6262
6363 public TimeSpan GetProcessCleanupTimeout ( bool isHotReloadEnabled )
64- // If Hot Reload mode is disabled the process is restarted on every file change.
65- // Waiting for graceful termination would slow down the turn around.
66- => ProcessCleanupTimeout ?? ( isHotReloadEnabled ? TimeSpan . FromSeconds ( 5 ) : TimeSpan . FromSeconds ( 0 ) ) ;
64+ // Allow sufficient time for the process to exit gracefully and release resources (e.g., network ports).
65+ => ProcessCleanupTimeout ?? TimeSpan . FromSeconds ( 5 ) ;
6766
6867 private int _uniqueLogId ;
6968
Original file line number Diff line number Diff line change 33
44namespace Microsoft . DotNet . Watch . UnitTests ;
55
6+ public class EnvironmentOptionsTests
7+ {
8+ [ Theory ]
9+ [ InlineData ( true ) ]
10+ [ InlineData ( false ) ]
11+ public void GetProcessCleanupTimeout_WithoutEnvironmentVariable_ReturnsDefaultTimeout ( bool isHotReloadEnabled )
12+ {
13+ var envOptions = new EnvironmentOptions (
14+ WorkingDirectory : "/test" ,
15+ MuxerPath : "dotnet" ,
16+ ProcessCleanupTimeout : null ) ;
17+
18+ var timeout = envOptions . GetProcessCleanupTimeout ( isHotReloadEnabled ) ;
19+
20+ Assert . Equal ( TimeSpan . FromSeconds ( 5 ) , timeout ) ;
21+ }
22+
23+ [ Theory ]
24+ [ InlineData ( true ) ]
25+ [ InlineData ( false ) ]
26+ public void GetProcessCleanupTimeout_WithEnvironmentVariable_ReturnsSpecifiedTimeout ( bool isHotReloadEnabled )
27+ {
28+ var customTimeout = TimeSpan . FromSeconds ( 10 ) ;
29+ var envOptions = new EnvironmentOptions (
30+ WorkingDirectory : "/test" ,
31+ MuxerPath : "dotnet" ,
32+ ProcessCleanupTimeout : customTimeout ) ;
33+
34+ var timeout = envOptions . GetProcessCleanupTimeout ( isHotReloadEnabled ) ;
35+
36+ Assert . Equal ( customTimeout , timeout ) ;
37+ }
38+ }
39+
640public class BuildReporterTests
741{
842 [ Fact ]
You can’t perform that action at this time.
0 commit comments