@@ -55,19 +55,71 @@ impl E2ETestEnvironment {
5555
5656/// Create a test script with specific content
5757fn create_script ( dir : & std:: path:: Path , name : & str , content : & str ) -> PathBuf {
58- let script_path = dir. join ( format ! ( "{}.sh" , name) ) ;
59- fs:: write ( & script_path, content) . expect ( "Failed to write test script" ) ;
60-
61- // Make script executable
62- #[ cfg( unix) ]
58+ #[ cfg( windows) ]
6359 {
60+ // On Windows, create a batch file
61+ let script_path = dir. join ( format ! ( "{}.bat" , name) ) ;
62+ // Convert bash script to batch equivalent
63+ let batch_content = convert_bash_to_batch ( content) ;
64+ fs:: write ( & script_path, batch_content) . expect ( "Failed to write test script" ) ;
65+ script_path
66+ }
67+ #[ cfg( not( windows) ) ]
68+ {
69+ let script_path = dir. join ( format ! ( "{}.sh" , name) ) ;
70+ fs:: write ( & script_path, content) . expect ( "Failed to write test script" ) ;
71+
72+ // Make script executable
6473 use std:: os:: unix:: fs:: PermissionsExt ;
6574 let mut perms = fs:: metadata ( & script_path) . unwrap ( ) . permissions ( ) ;
6675 perms. set_mode ( 0o755 ) ;
6776 fs:: set_permissions ( & script_path, perms) . unwrap ( ) ;
77+
78+ script_path
6879 }
80+ }
6981
70- script_path
82+ /// Convert basic bash script to Windows batch equivalent
83+ #[ cfg( windows) ]
84+ fn convert_bash_to_batch ( bash_content : & str ) -> String {
85+ let mut batch_content = String :: from ( "@echo off\n " ) ;
86+
87+ for line in bash_content. lines ( ) {
88+ if line. starts_with ( "#!/" ) {
89+ // Skip shebang
90+ continue ;
91+ } else if line. starts_with ( "echo " ) {
92+ // Convert echo commands
93+ batch_content. push_str ( & line. replace ( "echo " , "echo " ) ) ;
94+ batch_content. push ( '\n' ) ;
95+ } else if line. starts_with ( "sleep " ) {
96+ // Convert sleep to timeout
97+ let sleep_time = line
98+ . replace ( "sleep " , "" )
99+ . trim ( )
100+ . parse :: < u32 > ( )
101+ . unwrap_or ( 1 ) ;
102+ batch_content. push_str ( & format ! ( "timeout /t {} /nobreak >nul\n " , sleep_time) ) ;
103+ } else if line. contains ( "for i in {" ) && line. contains ( "}; do" ) {
104+ // Convert simple for loops
105+ if line. contains ( "{1..10}" ) {
106+ batch_content. push_str ( "for /l %%i in (1,1,10) do (\n " ) ;
107+ } else if line. contains ( "{1..5}" ) {
108+ batch_content. push_str ( "for /l %%i in (1,1,5) do (\n " ) ;
109+ }
110+ } else if line. trim ( ) == "done" {
111+ batch_content. push_str ( ")\n " ) ;
112+ } else if line. contains ( "exit " ) {
113+ batch_content. push_str ( line) ;
114+ batch_content. push ( '\n' ) ;
115+ } else if !line. trim ( ) . is_empty ( ) && !line. contains ( "$" ) {
116+ // Copy other simple lines
117+ batch_content. push_str ( line) ;
118+ batch_content. push ( '\n' ) ;
119+ }
120+ }
121+
122+ batch_content
71123}
72124
73125/// Create a Python script
@@ -85,6 +137,7 @@ fn create_node_script(dir: &std::path::Path, name: &str, content: &str) -> PathB
85137}
86138
87139#[ test]
140+ #[ cfg( not( windows) ) ]
88141fn test_simple_shell_script ( ) {
89142 let env = E2ETestEnvironment :: new ( ) ;
90143 let process_name = env. unique_name ( "shell-app" ) ;
@@ -127,6 +180,7 @@ echo "Shell script completed"
127180}
128181
129182#[ test]
183+ #[ cfg( not( windows) ) ]
130184fn test_python_script ( ) {
131185 let env = E2ETestEnvironment :: new ( ) ;
132186 let process_name = env. unique_name ( "python-app" ) ;
@@ -177,6 +231,7 @@ print("Python application completed")
177231}
178232
179233#[ test]
234+ #[ cfg( not( windows) ) ]
180235fn test_node_script ( ) {
181236 let env = E2ETestEnvironment :: new ( ) ;
182237 let process_name = env. unique_name ( "node-app" ) ;
@@ -239,6 +294,7 @@ process.on('SIGTERM', () => {
239294}
240295
241296#[ test]
297+ #[ cfg( not( windows) ) ]
242298fn test_clustering_mode ( ) {
243299 let env = E2ETestEnvironment :: new ( ) ;
244300 let process_name = env. unique_name ( "cluster-app" ) ;
@@ -283,6 +339,7 @@ echo "Cluster instance completed"
283339}
284340
285341#[ test]
342+ #[ cfg( not( windows) ) ]
286343fn test_port_management ( ) {
287344 let env = E2ETestEnvironment :: new ( ) ;
288345 let process_name = env. unique_name ( "port-app" ) ;
@@ -328,6 +385,7 @@ echo "Server shutting down"
328385}
329386
330387#[ test]
388+ #[ cfg( not( windows) ) ]
331389fn test_auto_restart ( ) {
332390 let env = E2ETestEnvironment :: new ( ) ;
333391 let process_name = env. unique_name ( "restart-app" ) ;
@@ -366,6 +424,7 @@ exit 1
366424}
367425
368426#[ test]
427+ #[ cfg( not( windows) ) ]
369428fn test_graceful_shutdown ( ) {
370429 let env = E2ETestEnvironment :: new ( ) ;
371430 let process_name = env. unique_name ( "graceful-app" ) ;
423482}
424483
425484#[ test]
485+ #[ cfg( not( windows) ) ]
426486fn test_resource_monitoring ( ) {
427487 let env = E2ETestEnvironment :: new ( ) ;
428488 let process_name = env. unique_name ( "monitor-app" ) ;
0 commit comments