@@ -1150,6 +1150,46 @@ public async Task CreateWslInstance_RepeatedTimeoutsThenSuccessNeverRepeatsInsta
11501150 Assert . Single ( commands . Calls , call => call . Arguments . Contains ( "--install" ) ) ;
11511151 }
11521152
1153+ [ Fact ]
1154+ public async Task CreateWslInstance_TimedOutProbeWithPartialOutputRetries ( )
1155+ {
1156+ var installed = false ;
1157+ var probeCalls = 0 ;
1158+ var clock = new AdvancingFreshDistroReadinessClock ( ) ;
1159+ var commands = new FakeCommandRunner ( args =>
1160+ {
1161+ if ( args . SequenceEqual ( [ "--list" , "--quiet" ] ) )
1162+ return Ok ( installed ? "OpenClawGateway\n " : "" ) ;
1163+ if ( args . Contains ( "--install" ) )
1164+ {
1165+ installed = true ;
1166+ return Ok ( ) ;
1167+ }
1168+ if ( args . SequenceEqual ( [ "--list" , "--verbose" ] ) )
1169+ return Ok ( FreshDistroVerboseOutput ) ;
1170+ if ( IsFreshDistroRootProbe ( args ) )
1171+ {
1172+ probeCalls ++ ;
1173+ if ( probeCalls == 1 )
1174+ {
1175+ clock . Advance ( TimeSpan . FromSeconds ( 30 ) ) ;
1176+ return TimedOut ( stderr : "first launch produced partial diagnostic output" ) ;
1177+ }
1178+
1179+ return Ok ( FreshDistroReadyOutput ) ;
1180+ }
1181+
1182+ return Fail ( $ "unexpected args: { string . Join ( ' ' , args ) } ") ;
1183+ } ) ;
1184+ var ctx = CreateContext ( commands : commands ) ;
1185+
1186+ var result = await new CreateWslInstanceStep ( clock ) . ExecuteAsync ( ctx , CancellationToken . None ) ;
1187+
1188+ Assert . True ( result . IsSuccess , result . Message ) ;
1189+ Assert . Equal ( 2 , probeCalls ) ;
1190+ Assert . Single ( commands . Calls , call => call . Arguments . Contains ( "--install" ) ) ;
1191+ }
1192+
11531193 [ Fact ]
11541194 public async Task CreateWslInstance_RegistrationTimeReducesPerAttemptProbeTimeout ( )
11551195 {
@@ -1324,8 +1364,10 @@ public async Task CreateWslInstance_DistroDisappearanceOrChangeFailsClosed(strin
13241364 call . Arguments . Contains ( "DifferentGateway" , StringComparer . Ordinal ) ) ;
13251365 }
13261366
1327- [ Fact ]
1328- public async Task CreateWslInstance_TerminalProbeErrorFailsWithoutRetry ( )
1367+ [ Theory ]
1368+ [ InlineData ( false ) ]
1369+ [ InlineData ( true ) ]
1370+ public async Task CreateWslInstance_TerminalProbeErrorFailsWithoutRetry ( bool timedOut )
13291371 {
13301372 var installed = false ;
13311373 var probeCalls = 0 ;
@@ -1343,9 +1385,13 @@ public async Task CreateWslInstance_TerminalProbeErrorFailsWithoutRetry()
13431385 if ( IsFreshDistroRootProbe ( args ) )
13441386 {
13451387 probeCalls ++ ;
1346- return Fail (
1388+ return new CommandResult (
1389+ - 1 ,
1390+ "" ,
13471391 "Wsl/Service/CreateInstance/WSL_E_CORRUPT_DISTRO " +
1348- string . Join ( ' ' , Enumerable . Repeat ( "diagnostic" , 100 ) ) ) ;
1392+ string . Join ( ' ' , Enumerable . Repeat ( "diagnostic" , 100 ) ) ,
1393+ TimeSpan . FromSeconds ( 30 ) ,
1394+ timedOut ) ;
13491395 }
13501396 if ( args . SequenceEqual ( [ "--terminate" , "OpenClawGateway" ] ) ||
13511397 args . SequenceEqual ( [ "--unregister" , "OpenClawGateway" ] ) )
@@ -3731,8 +3777,8 @@ private static CommandResult Fail(string stderr = "")
37313777 private static CommandResult FailWithStdout ( string stdout )
37323778 => new ( 1 , stdout , "" , TimeSpan . Zero , TimedOut : false ) ;
37333779
3734- private static CommandResult TimedOut ( )
3735- => new ( - 1 , "" , "" , TimeSpan . FromSeconds ( 30 ) , TimedOut : true ) ;
3780+ private static CommandResult TimedOut ( string stdout = "" , string stderr = "" )
3781+ => new ( - 1 , stdout , stderr , TimeSpan . FromSeconds ( 30 ) , TimedOut : true ) ;
37363782
37373783 private static bool IsFreshDistroRootProbe ( string [ ] arguments )
37383784 => arguments . SequenceEqual (
0 commit comments