Fix Windows build test midnight race (#15616)

This commit is contained in:
TheLegendTubaGuy
2026-09-09 12:18:21 -05:00
committed by GitHub
parent f18eb21b82
commit dbeef900cc

View File

@@ -22,6 +22,7 @@
Match regexes; each must match at least one output line Match regexes; each must match at least one output line
NotMatch regexes; none may match any output line NotMatch regexes; none may match any output line
NotExists paths that must not exist after the case runs NotExists paths that must not exist after the case runs
DateStampedZip require a bundle date from during this case's invocation
.PARAMETER Name .PARAMETER Name
Run only the cases whose name matches this regex. Headings with no Run only the cases whose name matches this regex. Headings with no
@@ -109,12 +110,6 @@ $slnDir = Join-Path $fixtures 'sln'
New-Item -ItemType Directory -Force -Path $slnDir | Out-Null New-Item -ItemType Directory -Force -Path $slnDir | Out-Null
Set-Content -Path (Join-Path $slnDir 'OrcaSlicer.sln') -Value '' -Encoding ascii Set-Content -Path (Join-Path $slnDir 'OrcaSlicer.sln') -Value '' -Encoding ascii
# The pack stamp is checked against real dates, so a locale-dependent parse
# in the script cannot pass by looking date-shaped. Yesterday is accepted too,
# so a run that crosses midnight does not flake.
$dateStamps = @((Get-Date -Format 'yyyyMMdd'), (Get-Date).AddDays(-1).ToString('yyyyMMdd'))
$stampPattern = '_(' + ($dateStamps -join '|') + ')\.zip$'
$cases = @( $cases = @(
'argument handling' 'argument handling'
@{ Name = 'no arguments prints help'; Args = @(); DryRun = $false @{ Name = 'no arguments prints help'; Args = @(); DryRun = $false
@@ -326,12 +321,12 @@ $cases = @(
Contains = @('OrcaSlicer_dep_win-x64_') Contains = @('OrcaSlicer_dep_win-x64_')
NotContains = @('-clang', '-Release') } NotContains = @('-clang', '-Release') }
@{ Name = 'the bundle is stamped with today, not a shuffled date'; Args = @('-p') @{ Name = 'the bundle is stamped with today, not a shuffled date'; Args = @('-p')
Match = @($stampPattern) } DateStampedZip = $true }
# powershell.exe is not in System32 itself, so a trimmed PATH used to # powershell.exe is not in System32 itself, so a trimmed PATH used to
# leave the stamp empty and the bundle named OrcaSlicer_dep_win-x64_.zip. # leave the stamp empty and the bundle named OrcaSlicer_dep_win-x64_.zip.
@{ Name = 'the bundle is stamped even with a bare PATH'; Args = @('-p') @{ Name = 'the bundle is stamped even with a bare PATH'; Args = @('-p')
Env = @{ PATH = 'C:\Windows\system32;C:\Windows' } Env = @{ PATH = 'C:\Windows\system32;C:\Windows' }
Match = @($stampPattern) } DateStampedZip = $true }
@{ Name = '-p packs without rebuilding'; Args = @('-p') @{ Name = '-p packs without rebuilding'; Args = @('-p')
Match = @('^\+ .*(7z\.exe a|tar\.exe -a -c -f) ') Match = @('^\+ .*(7z\.exe a|tar\.exe -a -c -f) ')
NotContains = @('cmake -S deps') } NotContains = @('cmake -S deps') }
@@ -861,7 +856,7 @@ function Invoke-BuildScript {
$knownFields = @( $knownFields = @(
'Name', 'Args', 'ExpectExit', 'DryRun', 'First', 'Env', 'Name', 'Args', 'ExpectExit', 'DryRun', 'First', 'Env',
'Contains', 'NotContains', 'Match', 'NotMatch', 'NotExists' 'Contains', 'NotContains', 'Match', 'NotMatch', 'NotExists', 'DateStampedZip'
) )
function Test-Case { function Test-Case {
@@ -876,7 +871,9 @@ function Test-Case {
$expect = 0 $expect = 0
if ($Case.ContainsKey('ExpectExit')) { $expect = $Case['ExpectExit'] } if ($Case.ContainsKey('ExpectExit')) { $expect = $Case['ExpectExit'] }
$started = Get-Date
$result = Invoke-BuildScript -Arguments $argv -Environment $Case['Env'] $result = Invoke-BuildScript -Arguments $argv -Environment $Case['Env']
$finished = Get-Date
$problems = @() $problems = @()
@@ -902,6 +899,15 @@ function Test-Case {
$problems += "no line matching /$pattern/" $problems += "no line matching /$pattern/"
} }
} }
if ($Case['DateStampedZip']) {
# Bound the accepted dates to this invocation so crossing midnight is
# valid without allowing an unrelated past or future date.
$dateStamps = @($started.ToString('yyyyMMdd'), $finished.ToString('yyyyMMdd')) | Select-Object -Unique
$pattern = '_(' + ($dateStamps -join '|') + ')\.zip$'
if (@($lines | Where-Object { $_ -match $pattern }).Count -eq 0) {
$problems += "no line matching /$pattern/"
}
}
foreach ($pattern in $Case['NotMatch']) { foreach ($pattern in $Case['NotMatch']) {
foreach ($line in @($lines | Where-Object { $_ -match $pattern })) { foreach ($line in @($lines | Where-Object { $_ -match $pattern })) {
$problems += "line matches /$pattern/: $line" $problems += "line matches /$pattern/: $line"