-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathManifest.Tests.ps1
More file actions
104 lines (88 loc) · 4.66 KB
/
Copy pathManifest.Tests.ps1
File metadata and controls
104 lines (88 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<#
.SYNOPSIS
Manifest tests.
#>
[CmdletBinding()]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseDeclaredVarsMoreThanAssignments", "", Justification = "This OK for the tests files.")]
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSAvoidUsingWriteHost", "", Justification = "Outputs to log host.")]
param ()
BeforeDiscovery {
$ValidateReleasesAmd64 = @("2017", "2019", "14")
$ValidateReleasesArm64 = @("14")
if ($env:PROCESSOR_ARCHITECTURE -eq "AMD64") {
$SkipAmd = $false
}
else {
$SkipAmd = $true
}
if ($env:PROCESSOR_ARCHITECTURE -eq "ARM64") {
$SkipArm = $false
}
else {
$SkipArm = $true
}
}
Describe -Name "AMD64 specific tests" -Skip:$SkipAmd {
Describe -Name "VcRedist manifest tests" -ForEach $ValidateReleasesAmd64 {
BeforeAll {
Get-InstalledVcRedist | Uninstall-VcRedist -Confirm:$false
}
Context "Validate manifest" {
BeforeAll {
$VcManifest = "$env:GITHUB_WORKSPACE\VcRedist\VisualCRedistributables.json"
Write-Host -ForegroundColor "Cyan" "`tGetting manifest from: $VcManifest."
$CurrentManifest = Get-Content -Path $VcManifest | ConvertFrom-Json
$VcRedist = $_
$Path = $([System.IO.Path]::Combine($env:RUNNER_TEMP, "Downloads"))
New-Item -Path $Path -ItemType "Directory" -ErrorAction "SilentlyContinue" > $null
Save-VcRedist -VcList (Get-VcList -Release $VcRedist) -Path $Path
$Architectures = @("x86", "x64")
}
Context "Compare manifest version against installed version for <VcRedist>" -ForEach $Architectures {
BeforeEach {
$VcList = Get-VcList -Release $VcRedist | Save-VcRedist -Path $([System.IO.Path]::Combine($env:RUNNER_TEMP, "Downloads"))
Install-VcRedist -VcList $VcList -Silent
$InstalledVcRedists = Get-InstalledVcRedist
$ManifestVcRedist = $CurrentManifest.Supported | Where-Object { $_.Release -eq $VcRedist }
$InstalledItem = $InstalledVcRedists | Where-Object { ($VcRedist -eq $ManifestVcRedist.Release) -and ($_ -eq $ManifestVcRedist.Architecture) }
}
# If the manifest version of the VcRedist is lower than the installed version, the manifest is out of date
It "$($ManifestVcRedist.Release) $($ManifestVcRedist.Architecture) version should be current" {
[System.Version]$InstalledItem.Version -gt [System.Version]$ManifestVcRedist.Version | Should -Be $false
}
}
}
}
}
Describe -Name "ARM64 specific tests" -Skip:$SkipArm {
Describe -Name "VcRedist manifest tests" -ForEach $ValidateReleasesArm64 {
BeforeAll {
Get-InstalledVcRedist | Uninstall-VcRedist -Confirm:$false
}
Context "Validate manifest" {
BeforeAll {
$VcManifest = "$env:GITHUB_WORKSPACE\VcRedist\VisualCRedistributables.json"
Write-Host -ForegroundColor "Cyan" "`tGetting manifest from: $VcManifest."
$CurrentManifest = Get-Content -Path $VcManifest | ConvertFrom-Json
$VcRedist = $_
$Path = $([System.IO.Path]::Combine($env:RUNNER_TEMP, "Downloads"))
New-Item -Path $Path -ItemType "Directory" -ErrorAction "SilentlyContinue" > $null
Save-VcRedist -VcList (Get-VcList -Release $VcRedist) -Path $Path
$Architectures = @("arm64")
}
Context "Compare manifest version against installed version for <VcRedist>" -ForEach $Architectures {
BeforeEach {
$VcList = Get-VcList -Release $VcRedist | Save-VcRedist -Path $([System.IO.Path]::Combine($env:RUNNER_TEMP, "Downloads"))
Install-VcRedist -VcList $VcList -Silent
$InstalledVcRedists = Get-InstalledVcRedist
$ManifestVcRedist = $CurrentManifest.Supported | Where-Object { $_.Release -eq $VcRedist }
$InstalledItem = $InstalledVcRedists | Where-Object { ($VcRedist -eq $ManifestVcRedist.Release) -and ($_ -eq $ManifestVcRedist.Architecture) }
}
# If the manifest version of the VcRedist is lower than the installed version, the manifest is out of date
It "$($ManifestVcRedist.Release) $($ManifestVcRedist.Architecture) version should be current" {
[System.Version]$InstalledItem.Version -gt [System.Version]$ManifestVcRedist.Version | Should -Be $false
}
}
}
}
}