mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
[Windows] Implement new directories hierarchy (#8616)
This commit is contained in:
committed by
GitHub
parent
84a7deae24
commit
d1f2c9a3be
89
images/windows/scripts/tests/Toolset.Tests.ps1
Normal file
89
images/windows/scripts/tests/Toolset.Tests.ps1
Normal file
@@ -0,0 +1,89 @@
|
||||
$toolsExecutables = @{
|
||||
Python = @(
|
||||
@{ Binary = "python.exe"; Arguments = "--version" },
|
||||
@{ Binary = "Scripts\pip.exe"; Arguments = "--version" }
|
||||
)
|
||||
PyPy = @(
|
||||
@{ Binary = "python.exe"; Arguments = "--version" },
|
||||
@{ Binary = "Scripts\pip.exe"; Arguments = "--version" }
|
||||
)
|
||||
Node = @(
|
||||
@{ Binary = "node.exe"; Arguments = "--version" },
|
||||
@{ Binary = "npm"; Arguments = "--version" }
|
||||
)
|
||||
Go = @(
|
||||
@{ Binary = "bin\go.exe"; Arguments = "version" }
|
||||
)
|
||||
Ruby = @(
|
||||
@{ Binary = "bin\ruby.exe"; Arguments = "--version" }
|
||||
)
|
||||
}
|
||||
|
||||
function Get-ToolExecutables {
|
||||
Param ([String] $Name)
|
||||
if ($toolsExecutables.ContainsKey($Name)) { $toolsExecutables[$Name] } else { @() }
|
||||
}
|
||||
|
||||
function Test-Binaries {
|
||||
Param (
|
||||
[String] $Name,
|
||||
[String] $Version,
|
||||
[String] $Arch,
|
||||
[Array] $ToolExecs
|
||||
)
|
||||
$testCases = $ToolExecs | ForEach-Object {
|
||||
@{ Name = $Name; Version = $Version; Arch = $Arch; Binary = $_.Binary; Arguments = $_.Arguments }
|
||||
}
|
||||
It "<Binary> <Arguments>" -TestCases $testCases {
|
||||
$binaryFullPath = Join-Path (Get-ToolsetToolFullPath -Name $Name -Version $Version -Arch $Arch) $Binary
|
||||
"$binaryFullPath $Arguments" | Should -ReturnZeroExitCode
|
||||
}
|
||||
}
|
||||
|
||||
function Test-DefaultVersion {
|
||||
Param (
|
||||
[String] $Name,
|
||||
[String] $ExpectedVersion,
|
||||
[Array] $ToolExecs
|
||||
)
|
||||
$binaryName = [IO.Path]::GetFileNameWithoutExtension($ToolExecs[0].Binary)
|
||||
$testCase = @{ Binary = $binaryName; Arguments = $ToolExecs[0].Arguments; ExpectedVersion = $ExpectedVersion }
|
||||
It "<ExpectedVersion> is default version" -TestCases $testCase {
|
||||
$commandResult = Get-CommandResult "$Binary $Arguments"
|
||||
$commandResult.ExitCode | Should -Be 0
|
||||
$commandResult.Output | Should -Match $ExpectedVersion
|
||||
}
|
||||
|
||||
It "default version is located in tool-cache" -TestCases $testCase {
|
||||
$binaryFullPath = Get-WhichTool $Binary
|
||||
$toolcacheDirectory = Get-ToolcacheToolDirectory -ToolName $Name
|
||||
$binaryFullPath | Should -Match ([Regex]::Escape($toolcacheDirectory))
|
||||
}
|
||||
}
|
||||
|
||||
$tools = Get-ToolsetContent | Select-Object -ExpandProperty toolcache
|
||||
foreach ($tool in $tools) {
|
||||
Describe "$($tool.name) [$($tool.arch)]" {
|
||||
$toolExecs = Get-ToolExecutables -Name $tool.name
|
||||
|
||||
foreach ($version in $tool.versions) {
|
||||
Context "$version" {
|
||||
$toolInfo = @{ Name = $tool.name; Version = $version; Arch = $tool.arch }
|
||||
It "tool-cache directory exists" -TestCases $toolInfo {
|
||||
$toolFullPath = Get-ToolsetToolFullPath -Name $Name -Version $Version -Arch $Arch
|
||||
$toolFullPath | Should -Exist
|
||||
}
|
||||
|
||||
if ($toolExecs) {
|
||||
Test-Binaries -Name $tool.name -Version $version -Arch $tool.arch -ToolExecs $toolExecs
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($tool.default -and $toolExecs) {
|
||||
Context "Default" {
|
||||
Test-DefaultVersion -Name $tool.name -ExpectedVersion $tool.default -ToolExecs $toolExecs
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user