File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4444 go generate main.go
4545 go mod tidy
4646
47- - name : Run the Program
47+ - name : Run the Program (Unix)
48+ if : runner.os != 'Windows'
4849 shell : bash
4950 run : |
5051 go run main.go > output.log 2>&1 &
5758 fi
5859 sleep 1
5960 done
60- if [[ "$RUNNER_OS" == "Windows" ]]; then
61- taskkill //F //T //PID $PID 2>/dev/null || true
62- else
63- kill $PID 2>/dev/null || true
64- wait $PID 2>/dev/null || true
65- fi
61+ kill $PID 2>/dev/null || true
62+ wait $PID 2>/dev/null || true
63+ echo ""
6664 echo "Run log:"
6765 cat output.log
6866 echo ""
7371 echo "Failure: Timeout after 60s without finding target output"
7472 exit 1
7573 fi
74+
75+ - name : Run the Program (Windows)
76+ if : runner.os == 'Windows'
77+ shell : pwsh
78+ run : |
79+ $proc = Start-Process -FilePath "go" -ArgumentList "run", "main.go" -NoNewWindow -PassThru -RedirectStandardOutput "stdout.log" -RedirectStandardError "stderr.log"
80+ $found = $false
81+ for ($i = 0; $i -lt 60; $i++) {
82+ Start-Sleep -Seconds 1
83+ $content = ""
84+ if (Test-Path "stdout.log") { $content += Get-Content "stdout.log" -Raw -ErrorAction SilentlyContinue }
85+ if (Test-Path "stderr.log") { $content += Get-Content "stderr.log" -Raw -ErrorAction SilentlyContinue }
86+ if ($content -match '\[ws\] 连接到Websocket服务器') {
87+ $found = $true
88+ break
89+ }
90+ }
91+ taskkill /F /T /PID $proc.Id 2>$null
92+ Write-Host ""
93+ Write-Host "Run log:"
94+ if (Test-Path "stdout.log") { Get-Content "stdout.log" }
95+ if (Test-Path "stderr.log") { Get-Content "stderr.log" }
96+ Write-Host ""
97+ if ($found) {
98+ Write-Host "Success: Found target output"
99+ exit 0
100+ } else {
101+ Write-Host "Failure: Timeout after 60s without finding target output"
102+ exit 1
103+ }
You can’t perform that action at this time.
0 commit comments