[Ubuntu] Migrate Toolset tests to Pester (#2339)

* migrate toolset tests to pester

* move test invocation

* minor fixes
This commit is contained in:
Dibir Magomedsaygitov
2020-12-28 15:07:00 +03:00
committed by GitHub
parent ab06a8a68f
commit f58f2c1e02
6 changed files with 69 additions and 98 deletions

View File

@@ -0,0 +1,62 @@
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"
}
}
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 {[version]$_.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
}
}
}
}
}
}
}