diff --git a/windows/tests/Assert-IsoStructure.ps1 b/windows/tests/Assert-IsoStructure.ps1 index 37d9329..b7b749b 100644 --- a/windows/tests/Assert-IsoStructure.ps1 +++ b/windows/tests/Assert-IsoStructure.ps1 @@ -17,8 +17,16 @@ function Assert { param([string]$Name,[bool]$Cond) if (-not (([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator))) { throw 'must run elevated (WIM mount).' } +# Discard any stale WIM mounts from a prior aborted run (CI reuses the runner) and +# use a fresh, unique mount dir — a leftover mount makes Mount-WindowsImage fail with +# "attempted to mount to a directory that is not empty." Mirrors build.ps1 Stage 0. +Get-WindowsImage -Mounted -EA SilentlyContinue | ForEach-Object { + Dismount-WindowsImage -Path $_.MountPath -Discard -EA SilentlyContinue | Out-Null +} +Clear-WindowsCorruptMountPoint -EA SilentlyContinue | Out-Null + $img = Mount-DiskImage -ImagePath $IsoPath -PassThru -$mount = Join-Path $env:TEMP 'sm-assert-wim' +$mount = Join-Path $env:TEMP ('sm-assert-wim-' + [guid]::NewGuid().ToString('N')) $null = New-Item -ItemType Directory -Force $mount try { $drive = ($img | Get-Volume).DriveLetter + ':' @@ -43,10 +51,15 @@ try { Assert 'Welcome exe baked into WIM' (Test-Path $welcomeExe) $welcomeFlavours = Get-ChildItem (Join-Path $mount 'Program Files\SilverOS\Welcome\flavours') -Filter '*.json' -EA SilentlyContinue Assert 'Welcome flavours baked (>=1 .json)' ($welcomeFlavours.Count -ge 1) + $welcomeCatalog = Join-Path $mount 'Program Files\SilverOS\Welcome\apps\catalog.json' + Assert 'Welcome app catalog baked' (Test-Path $welcomeCatalog) } } finally { Dismount-WindowsImage -Path $mount -Discard | Out-Null } } -} finally { Dismount-DiskImage -ImagePath $IsoPath | Out-Null } +} finally { + Dismount-DiskImage -ImagePath $IsoPath | Out-Null + Remove-Item $mount -Recurse -Force -EA SilentlyContinue +} Write-Host "`n$($fail) assertion(s) failed." exit $fail