Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions eng/scripts/Compare-CurrentToCodegeneration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,29 @@ $generateScript = {
}

# Timeout is set to 60 seconds per script.
$timeout = 60 * $generationInformations.Count
$scriptTimeoutInSeconds = 60
$timeout = $scriptTimeoutInSeconds * $generationInformations.Count
# Ensure a minimum timeout of 5 times the script timeout
# This is for scenarios where there are only a few scripts to run. Some script with large TypeSpec source can take a few minutes.
$minimumTimeout = 5 * $scriptTimeoutInSeconds
if ($timeout -lt $minimumTimeout) {
$timeout = $minimumTimeout
}

$job = $generationInformations | ForEach-Object -Parallel $generateScript -ThrottleLimit $Parallelization -AsJob

# Out-Null to suppress output information from the job and 2>$null to suppress any error messages from Receive-Job.
$job | Wait-Job -Timeout $timeout | Out-Null
$job | Receive-Job 2>$null | Out-Null

$jobTimeout = $job.State -eq 'Running'
$jobFailed = $job.State -eq 'Failed'
if ($jobTimeout) {
Write-Host "The aggregated generate job timed out after $timeout seconds."
}

# Clean up generated code, so that next step will not be affected.
git reset --hard | Out-Null
git clean -fd . | Out-Null

exit $job.State -eq 'Failed'
exit $jobFailed -or $jobTimeout