@@ -61,12 +61,15 @@ jobs:
6161env :
6262                LD_LIBRARY_PATH : target/release 
6363            - name : test run 
64+               id : run_tests 
65+               continue-on-error : true 
6466              env :
6567                LD_LIBRARY_PATH : target/release 
6668              run : | 
6769                ./main server --json > server_output.json & 
70+                 server_pid=$! 
6871                # Wait for the server to start 
69-                 sleep 3  
72+                 sleep 10  
7073                # Read the second line of the file 
7174                line=$(sed -n '2p' server_output.json) 
7275
@@ -87,13 +90,22 @@ jobs:
8790                ./main client $node_id $relay ${addrs[@]} 
8891                sleep 10 
8992
93+                 # wait for server the shutdown 
94+                 wait $server_pid 
95+                 server_status=$? 
96+                 echo "" 
97+                 echo "Server closed with status $server_status" 
98+                 if [[ "$server_status" != "0" ]]; then 
99+                   exit 1 
100+                 fi 
101+ 
90102                # Read the 3rd line of the file 
91103                last_line=$(sed -n '3p' server_output.json) 
92104                # Parse the JSON 
93105                json_output=$(echo $last_line | jq -r '.data') 
94106                # Ensure json_output is as expected 
95107                if [[ "$json_output" != "hello world from C" ]]; then 
96-                     echo "Error: Unexpected output" 
108+                     echo "Error: Unexpected output for line 3 " 
97109                    echo "server_output.json:" 
98110                    cat server_output.json 
99111                    exit 1 
@@ -105,13 +117,22 @@ jobs:
105117                json_output=$(echo $last_line | jq -r '.data') 
106118                # Ensure json_output is as expected 
107119                if [[ "$json_output" != "hello world from C" ]]; then 
108-                     echo "Error: Unexpected output" 
120+                     echo "Error: Unexpected output for line 6 " 
109121                    echo "server_output.json:" 
110122                    cat server_output.json 
111123                    exit 1 
112124                fi 
113125
126+                 echo "" 
114127                echo "Success" 
128+                 echo "server_output.json:" 
129+                 cat server_output.json 
130+ name : Fail Job if Tests Failed 
131+               if : ${{ steps.run_tests.outcome == 'failure' }} 
132+               run : | 
133+                 echo "Tests failed, server logs are:" 
134+                 cat server_output.json 
135+                 exit 1 
115136name : check headers 
116137              shell : bash 
117138              run : | 
@@ -179,10 +200,12 @@ jobs:
179200env :
180201                LD_LIBRARY_PATH : target/release 
181202            - name : test run 
203+               id : run_tests 
204+               continue-on-error : true 
182205              run : | 
183-                 Start-Process -NoNewWindow -FilePath "./main.exe" -ArgumentList "server", "--json" -RedirectStandardOutput "server_output.json" 
206+                 $server_process =  Start-Process -PassThru  -NoNewWindow -FilePath "./main.exe" -ArgumentList "server", "--json" -RedirectStandardOutput "server_output.json" 
184207                # Wait for the server to start 
185-                 Start-Sleep -Seconds 3  
208+                 Start-Sleep -Seconds 10  
186209                # Read the second line of the file 
187210                $line = Get-Content server_output.json | Select-Object -Index 1 
188211
@@ -199,15 +222,29 @@ jobs:
199222                $relay = $json_output.relay 
200223                $addrs = $json_output.addrs 
201224                & "./main" "client" $node_id $relay $addrs 
202-                 Start-Sleep -Seconds 3 
225+                 Start-Sleep -Seconds 10 
226+ 
227+                 # wait for the server process to terminate 
228+                 Wait-Process -InputObject $server_process 
229+ 
230+                 # # ramfox: ExitCode in windows seems to not work in all environments. I've tried a few variations, but they all show the exitCode as Null. commenting this out for now. 
231+                 # $exitCode = $server_process.ExitCode 
232+ 
233+                 # Write-Output "" 
234+                 # Write-Output "Server process exited with code: $exitCode" 
235+ 
236+                 # if ($exitCode -ne 0) { 
237+                 #     exit 1 
238+                 # } 
203239
204240                # Read the 3rd line of the file 
205241                $last_line = Get-Content server_output.json | Select-Object -Index 2 
206242                # Parse the JSON 
207243                $json_output = ConvertFrom-Json $last_line 
208244                # Ensure json_output is as expected 
209245                if ($json_output.data -ne "hello world from C") { 
210-                     Write-Output "Error: Unexpected output" 
246+                     Write-Output "Error: Unexpected output for line 3" 
247+                     Write-Output $json_output 
211248                    exit 1 
212249                } 
213250
@@ -217,10 +254,20 @@ jobs:
217254                $json_output = ConvertFrom-Json $last_line 
218255                # Ensure json_output is as expected 
219256                if ($json_output.data -ne "hello world from C") { 
220-                     Write-Output "Error: Unexpected output" 
257+                     Write-Output "Error: Unexpected output for line 6" 
258+                     Write-Output $json_output 
221259                    exit 1 
222260                } 
261+                 Write-Output "" 
223262                Write-Output "Success" 
263+                 Write-Output "server_output.json:" 
264+                 Get-Content server_output.json 
265+ name : Fail Job if Tests Failed 
266+               if : ${{ steps.run_tests.outcome == 'failure' }} 
267+               run : | 
268+                 Write-Output "Tests failed, server logs are:" 
269+                 Get-Content server_output.json 
270+                 exit 1 
224271
225272android_build :
226273        name : Android Build Only 
0 commit comments