@@ -9,14 +9,15 @@ public class WslGatewayControllerTests
99 [ InlineData ( WslGatewayControlAction . Start , "start" ) ]
1010 [ InlineData ( WslGatewayControlAction . Stop , "stop" ) ]
1111 [ InlineData ( WslGatewayControlAction . Restart , "restart" ) ]
12- public void Build_UsesBashLoginShellPathPrefixAndGatewayCommand ( WslGatewayControlAction action , string verb )
12+ public void Build_UsesStdinScriptWithLinuxPathAndGatewayCommand ( WslGatewayControlAction action , string verb )
1313 {
14- var command = WslGatewayControlCommandBuilder . Build ( action ) ;
14+ var arguments = WslGatewayControlCommandBuilder . BuildArguments ( ) ;
15+ var standardInput = WslGatewayControlCommandBuilder . BuildStandardInput ( action ) ;
1516
16- Assert . Equal ( [ "bash" , "-lc " ] , command . Take ( 2 ) . ToArray ( ) ) ;
17- Assert . Equal (
18- $ " { WslGatewayControlCommandBuilder . OpenClawWslPathPrefix } && openclaw gateway { verb } ",
19- command [ 2 ] ) ;
17+ Assert . Equal ( [ "bash" , "-s " ] , arguments ) ;
18+ Assert . Contains ( WslGatewayControlCommandBuilder . OpenClawWslPathPrefix , standardInput ) ;
19+ Assert . Contains ( $ " openclaw gateway { verb } ", standardInput ) ;
20+ Assert . Contains ( "$PATH" , standardInput ) ;
2021 }
2122
2223 [ Fact ]
@@ -33,7 +34,10 @@ public async Task RunAsync_InvokesGatewayCommandInsideRegisteredDistro()
3334
3435 Assert . True ( result . Success ) ;
3536 Assert . Equal ( "OpenClawGateway" , runner . LastDistroName ) ;
36- Assert . Equal ( WslGatewayControlCommandBuilder . Build ( WslGatewayControlAction . Start ) , runner . LastDistroCommand ) ;
37+ Assert . Equal ( WslGatewayControlCommandBuilder . BuildArguments ( ) , runner . LastDistroCommand ) ;
38+ Assert . Equal (
39+ WslGatewayControlCommandBuilder . BuildStandardInput ( WslGatewayControlAction . Start ) ,
40+ runner . LastStandardInput ) ;
3741 }
3842
3943 [ Fact ]
@@ -70,7 +74,10 @@ public async Task RunAsync_AttemptsCommand_WhenDistroEnumerationIsEmpty()
7074
7175 Assert . True ( result . Success ) ;
7276 Assert . Equal ( "OpenClawGateway" , runner . LastDistroName ) ;
73- Assert . Equal ( WslGatewayControlCommandBuilder . Build ( WslGatewayControlAction . Restart ) , runner . LastDistroCommand ) ;
77+ Assert . Equal ( WslGatewayControlCommandBuilder . BuildArguments ( ) , runner . LastDistroCommand ) ;
78+ Assert . Equal (
79+ WslGatewayControlCommandBuilder . BuildStandardInput ( WslGatewayControlAction . Restart ) ,
80+ runner . LastStandardInput ) ;
7481 Assert . DoesNotContain ( "not registered" , result . StandardError ) ;
7582 }
7683
@@ -90,8 +97,11 @@ public async Task ForceRestartAsync_TerminatesDistroThenColdRestarts()
9097 Assert . Equal ( 1 , runner . TerminateCount ) ; // host-side terminate happened first
9198 Assert . Equal ( "OpenClawGateway" , runner . LastTerminatedDistro ) ;
9299 Assert . Equal ( // then a cold in-distro restart
93- WslGatewayControlCommandBuilder . Build ( WslGatewayControlAction . Restart ) ,
100+ WslGatewayControlCommandBuilder . BuildArguments ( ) ,
94101 runner . LastDistroCommand ) ;
102+ Assert . Equal (
103+ WslGatewayControlCommandBuilder . BuildStandardInput ( WslGatewayControlAction . Restart ) ,
104+ runner . LastStandardInput ) ;
95105 }
96106
97107 [ Fact ]
@@ -169,6 +179,7 @@ private sealed class FakeWslCommandRunner : IWslCommandRunner
169179 public Queue < WslCommandResult > ? InDistroResults { get ; init ; }
170180 public string ? LastDistroName { get ; private set ; }
171181 public IReadOnlyList < string > ? LastDistroCommand { get ; private set ; }
182+ public string ? LastStandardInput { get ; private set ; }
172183 public int InDistroCount { get ; private set ; }
173184 public int TerminateCount { get ; private set ; }
174185 public string ? LastTerminatedDistro { get ; private set ; }
@@ -202,10 +213,12 @@ public Task<WslCommandResult> RunInDistroAsync(
202213 string name ,
203214 IReadOnlyList < string > command ,
204215 CancellationToken cancellationToken = default ,
205- IReadOnlyDictionary < string , string > ? environment = null )
216+ IReadOnlyDictionary < string , string > ? environment = null ,
217+ string ? standardInput = null )
206218 {
207219 LastDistroName = name ;
208220 LastDistroCommand = command ;
221+ LastStandardInput = standardInput ;
209222 InDistroCount ++ ;
210223 var result = InDistroResults is { Count : > 0 } ? InDistroResults . Dequeue ( ) : Result ;
211224 return Task . FromResult ( result ) ;
0 commit comments