Files
runner-images/images/linux/scripts/tests/Toolset.Tests.ps1
Leonid Lapshin 1ce075fe93 [ubuntu] Pester tests for dotnet sdk, cmd tools and codeql (#2335)
* dotnet cmd codeql tests

* fixed dotnet tests, added codeql to toolset

* changed codeql version to wildcard

* removed unused import and a test call

* tmp

* lowercase file name

* removed sourcing invoke-tests

Co-authored-by: Leonid Lapshin <originalnoe-nazvanie@yandex.ru>
2020-12-30 13:50:21 +03:00

66 lines
2.1 KiB
PowerShell

Describe "Toolset" {
$tools = (Get-ToolsetContent).toolcache
$toolsExecutables = @{
Python = @{
tools = @("python", "bin/pip")
command = "--version"
}
node = @{
tools = @("bin/node", "bin/npm")
command = "--version"
}
PyPy = @{
tools = @("bin/python", "bin/pip")
command = "--version"
}
go = @{
tools = @("bin/go")
command = "version"
}
Ruby = @{
tools = @("bin/ruby")
command = "--version"
}
CodeQL = @{
tools = @("codeql/codeql")
command = "version"
}
}
foreach($tool in $tools) {
$toolName = $tool.Name
Context "$toolName" {
$toolExecs = $toolsExecutables[$toolName]
foreach ($version in $tool.versions) {
# Add wildcard if missing
if ($version.Split(".").Length -lt 3) {
$version += ".*"
}
$expectedVersionPath = Join-Path $env:AGENT_TOOLSDIRECTORY $toolName $version
It "$version version folder exists" -TestCases @{ ExpectedVersionPath = $expectedVersionPath} {
$ExpectedVersionPath | Should -Exist
}
$toolExecs = $toolsExecutables[$toolName]
$foundVersion = Get-Item $expectedVersionPath `
| Sort-Object -Property {[SemVer]$_.name} -Descending `
| Select-Object -First 1
$foundVersionPath = Join-Path $foundVersion $tool.arch
if($toolExecs) {
foreach ($executable in $toolExecs["tools"]) {
$executablePath = Join-Path $foundVersionPath $executable
It "Validate $executable" -TestCases @{ExecutablePath = $executablePath} {
$ExecutablePath | Should -Exist
}
}
}
}
}
}
}