diff --git a/run_python_with_restart.ps1 b/run_python_with_restart.ps1 index 838d5f3..e6410ea 100644 --- a/run_python_with_restart.ps1 +++ b/run_python_with_restart.ps1 @@ -9,6 +9,11 @@ function Run-PythonScript { return $process.ExitCode } +function Run-Tests { + $process = Start-Process -FilePath "powershell" -ArgumentList "-File run_tests.ps1" -PassThru -Wait -NoNewWindow + return $process.ExitCode +} + function Git-Pull { git pull return $LASTEXITCODE -eq 0 @@ -17,6 +22,17 @@ function Git-Pull { $waitTime = 15 while ($true) { python -m pip install -r requirements.txt + + Write-Host "Running tests..." + $testExitCode = Run-Tests + if ($testExitCode -ne 0) { + Write-Host "Tests failed. Waiting $waitTime seconds before next attempt..." + Start-Sleep -Seconds $waitTime + $waitTime *= 2 + continue + } + + Write-Host "Tests passed. Starting main Python script..." $exitCode = Run-PythonScript -ScriptPath $PythonFile if (Test-Path -Path ".\.doreboot") {