From dbb10c67ba99d3e85b255c0cebaa55e76aad6fae Mon Sep 17 00:00:00 2001 From: Shamil Mubarakshin <127750046+shamil-mubarakshin@users.noreply.github.com> Date: Thu, 14 Dec 2023 17:33:34 +0100 Subject: [PATCH] [ubuntu] Refactor pester tests (#9006) * [ubuntu] Refactor pester tests * Fix key name and add BeforeAll * Fix ActionArchiveCache test --- .../tests/ActionArchiveCache.Tests.ps1 | 13 ++-- images/ubuntu/scripts/tests/Android.Tests.ps1 | 36 ++-------- images/ubuntu/scripts/tests/Apt.Tests.ps1 | 66 ++++--------------- .../ubuntu/scripts/tests/CLI.Tools.Tests.ps1 | 1 - images/ubuntu/scripts/tests/Common.Tests.ps1 | 15 ++--- .../ubuntu/scripts/tests/Databases.Tests.ps1 | 2 +- .../ubuntu/scripts/tests/DotnetSDK.Tests.ps1 | 10 ++- images/ubuntu/scripts/tests/Haskell.Tests.ps1 | 4 +- images/ubuntu/scripts/tests/Helpers.psm1 | 6 +- images/ubuntu/scripts/tests/Java.Tests.ps1 | 4 +- images/ubuntu/scripts/tests/Node.Tests.ps1 | 5 -- .../scripts/tests/PowerShellModules.Tests.ps1 | 14 ++-- .../scripts/tests/RunnerCache.Tests.ps1 | 4 +- images/ubuntu/scripts/tests/Tools.Tests.ps1 | 60 +++++------------ images/ubuntu/scripts/tests/Toolset.Tests.ps1 | 9 ++- 15 files changed, 70 insertions(+), 179 deletions(-) diff --git a/images/ubuntu/scripts/tests/ActionArchiveCache.Tests.ps1 b/images/ubuntu/scripts/tests/ActionArchiveCache.Tests.ps1 index 6da1eb934..df4add65e 100644 --- a/images/ubuntu/scripts/tests/ActionArchiveCache.Tests.ps1 +++ b/images/ubuntu/scripts/tests/ActionArchiveCache.Tests.ps1 @@ -1,14 +1,17 @@ Describe "ActionArchiveCache" { + BeforeDiscovery { + $actionArchiveCachePath = "/opt/actionarchivecache" + $tarballTestCases = Get-ChildItem -Path "$actionArchiveCachePath/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } } + } + Context "Action archive cache directory not empty" { - It "/opt/actionarchivecache not empty" { - (Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0 + It " not empty" -TestCases @{ ActionArchiveCachepath = $actionArchiveCachePath } { + (Get-ChildItem -Path "$ActionArchiveCachepath/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0 } } Context "Action tarball not empty" { - $testCases = Get-ChildItem -Path "/opt/actionarchivecache/*.tar.gz" -Recurse | ForEach-Object { @{ ActionTarball = $_.FullName } } - It "" -TestCases $testCases { - param ([string] $ActionTarball) + It "" -TestCases $tarballTestCases { (Get-Item "$ActionTarball").Length | Should -BeGreaterThan 0 } } diff --git a/images/ubuntu/scripts/tests/Android.Tests.ps1 b/images/ubuntu/scripts/tests/Android.Tests.ps1 index 840d65205..aef895716 100644 --- a/images/ubuntu/scripts/tests/Android.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Android.Tests.ps1 @@ -1,34 +1,4 @@ Describe "Android" { - BeforeAll { - function Test-AndroidPackage { - <# - .SYNOPSIS - This function tests existance of an Android package. - - .DESCRIPTION - The Test-AndroidPackage function is used to test an existance of Android package in ANDROID_HOME path. - - .PARAMETER PackageName - The name of the Android package to test. - - .EXAMPLE - Test-AndroidPackage - - This command tests the Android package. - - #> - param ( - [Parameter(Mandatory=$true)] - [string] $PackageName - ) - - # Convert 'cmake;3.6.4111459' -> 'cmake/3.6.4111459' - $PackageName = $PackageName.Replace(";", "/") - $targetPath = Join-Path $env:ANDROID_HOME $PackageName - $targetPath | Should -Exist - } - } - function Get-AndroidPackages { <# .SYNOPSIS @@ -130,8 +100,10 @@ Describe "Android" { $testCases = $androidPackages | ForEach-Object { @{ PackageName = $_ } } It "" -TestCases $testCases { - param ([string] $PackageName) - Test-AndroidPackage $PackageName + # Convert 'cmake;3.6.4111459' -> 'cmake/3.6.4111459' + $PackageName = $PackageName.Replace(";", "/") + $targetPath = Join-Path $env:ANDROID_HOME $PackageName + $targetPath | Should -Exist } } } diff --git a/images/ubuntu/scripts/tests/Apt.Tests.ps1 b/images/ubuntu/scripts/tests/Apt.Tests.ps1 index 18b48063d..d0596137d 100644 --- a/images/ubuntu/scripts/tests/Apt.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Apt.Tests.ps1 @@ -1,63 +1,23 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" -$cmd = (Get-ToolsetContent).apt.cmd_packages + (Get-ToolsetContent).apt.vital_packages - Describe "Apt" { - - $testCases = $cmd | ForEach-Object { - @{ toolName = $_ } - } + $packages = (Get-ToolsetContent).apt.cmd_packages + (Get-ToolsetContent).apt.vital_packages + $testCases = $packages | ForEach-Object { @{ toolName = $_ } } It " is available" -TestCases $testCases { - if ($toolName -eq "acl") - { - $toolName = "getfacl" + switch ($toolName) { + "acl" { $toolName = "getfacl"; break } + "aria2" { $toolName = "aria2c"; break } + "p7zip-full" { $toolName = "p7zip"; break } + "subversion" { $toolName = "svn"; break } + "sphinxsearch" { $toolName = "searchd"; break } + "binutils" { $toolName = "strings"; break } + "coreutils" { $toolName = "tr"; break } + "net-tools" { $toolName = "netstat"; break } + "mercurial" { $toolName = "hg"; break } + "findutils" { $toolName = "find"; break } } - if ($toolName -eq "aria2") - { - $toolName = "aria2c" - } - - if ($toolName -eq "p7zip-full") - { - $toolName = "p7zip" - } - - if ($toolName -eq "subversion") - { - $toolName = "svn" - } - - if ($toolName -eq "sphinxsearch") - { - $toolName = "searchd" - } - - if ($toolName -eq "binutils") - { - $toolName = "strings" - } - - if ($toolName -eq "coreutils") - { - $toolName = "tr" - } - - if ($toolName -eq "net-tools") - { - $toolName = "netstat" - } - - if ($toolName -eq "mercurial") - { - $toolName = "hg" - } - - if ($toolName -eq "findutils") - { - $toolName = "find" - } (Get-Command -Name $toolName).CommandType | Should -BeExactly "Application" } } diff --git a/images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1 b/images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1 index 2cd42df7b..0951afdfc 100644 --- a/images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1 +++ b/images/ubuntu/scripts/tests/CLI.Tools.Tests.ps1 @@ -1,4 +1,3 @@ - Describe "Azure CLI" { It "Azure CLI" { "az --version" | Should -ReturnZeroExitCode diff --git a/images/ubuntu/scripts/tests/Common.Tests.ps1 b/images/ubuntu/scripts/tests/Common.Tests.ps1 index 593fd1be3..38eaeb2b9 100644 --- a/images/ubuntu/scripts/tests/Common.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Common.Tests.ps1 @@ -1,15 +1,10 @@ Describe "PHP" { - - [array]$testCases = (Get-ToolsetContent).php.versions | ForEach-Object { @{phpVersion = $_} } + $testCases = (Get-ToolsetContent).php.versions | ForEach-Object { @{PhpVersion = $_} } It "php " -TestCases $testCases { - param ( - [string] $phpVersion - ) - - "php$phpVersion --version" | Should -ReturnZeroExitCode - "php-config$phpVersion --version" | Should -ReturnZeroExitCode - "phpize$phpVersion --version" | Should -ReturnZeroExitCode + "php${PhpVersion} --version" | Should -ReturnZeroExitCode + "php-config${PhpVersion} --version" | Should -ReturnZeroExitCode + "phpize${PhpVersion} --version" | Should -ReturnZeroExitCode } It "PHPUnit" { @@ -44,7 +39,7 @@ Describe "Swift" { } Describe "PipxPackages" { - [array]$testCases = (Get-ToolsetContent).pipx | ForEach-Object { @{package=$_.package; cmd = $_.cmd} } + $testCases = (Get-ToolsetContent).pipx | ForEach-Object { @{package=$_.package; cmd = $_.cmd} } It "" -TestCases $testCases { "$cmd --version" | Should -ReturnZeroExitCode diff --git a/images/ubuntu/scripts/tests/Databases.Tests.ps1 b/images/ubuntu/scripts/tests/Databases.Tests.ps1 index f39a46076..6eec8d1bd 100644 --- a/images/ubuntu/scripts/tests/Databases.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Databases.Tests.ps1 @@ -4,7 +4,7 @@ Describe "MongoDB" -Skip:(Test-IsUbuntu22) { @{ ToolName = "mongod" } ) { $toolsetVersion = (Get-ToolsetContent).mongodb.version - (&$ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*" + (& $ToolName --version)[2].Split('"')[-2] | Should -BeLike "$toolsetVersion*" } } diff --git a/images/ubuntu/scripts/tests/DotnetSDK.Tests.ps1 b/images/ubuntu/scripts/tests/DotnetSDK.Tests.ps1 index d2d90dadd..e3d06df40 100644 --- a/images/ubuntu/scripts/tests/DotnetSDK.Tests.ps1 +++ b/images/ubuntu/scripts/tests/DotnetSDK.Tests.ps1 @@ -1,13 +1,12 @@ Import-Module "$PSScriptRoot/../helpers/Common.Helpers.psm1" Describe "Dotnet and tools" { - BeforeAll { $env:PATH = "/etc/skel/.dotnet/tools:$($env:PATH)" $dotnetSDKs = dotnet --list-sdks | ConvertTo-Json $dotnetRuntimes = dotnet --list-runtimes | ConvertTo-Json } - + $dotnetVersions = (Get-ToolsetContent).dotnet.versions Context "Default" { @@ -20,11 +19,11 @@ Describe "Dotnet and tools" { Context "Dotnet $version" { $dotnet = @{ dotnetVersion = $version } - It "SDK $version is available" -TestCases $dotnet { + It "SDK is available" -TestCases $dotnet { $dotnetSDKs | Should -Match "$dotnetVersion.[1-9]*" } - It "Runtime $version is available" -TestCases $dotnet { + It "Runtime is available" -TestCases $dotnet { $dotnetRuntimes | Should -Match "$dotnetVersion.[1-9]*" } } @@ -38,5 +37,4 @@ Describe "Dotnet and tools" { "$TestInstance" | Should -ReturnZeroExitCode } } - -} \ No newline at end of file +} diff --git a/images/ubuntu/scripts/tests/Haskell.Tests.ps1 b/images/ubuntu/scripts/tests/Haskell.Tests.ps1 index af05f9839..a620df5c3 100644 --- a/images/ubuntu/scripts/tests/Haskell.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Haskell.Tests.ps1 @@ -5,15 +5,13 @@ Describe "Haskell" { $testCase = @{ GHCVersions = $GHCVersions } It "GHC directory contains two version of GHC" -TestCases $testCase { - param ([object] $GHCVersions) $GHCVersions.Count | Should -Be 2 } $testCases = $GHCVersions | ForEach-Object { @{ GHCPath = "${_}/bin/ghc"} } It "GHC version " -TestCases $testCases { - param ([string] $GHCPath) - "$GHCPath --version" | Should -ReturnZeroExitCode + "$GHCPath --version" | Should -ReturnZeroExitCode } It "GHCup" { diff --git a/images/ubuntu/scripts/tests/Helpers.psm1 b/images/ubuntu/scripts/tests/Helpers.psm1 index 7236ae33f..31ad52700 100644 --- a/images/ubuntu/scripts/tests/Helpers.psm1 +++ b/images/ubuntu/scripts/tests/Helpers.psm1 @@ -96,8 +96,7 @@ function ShouldReturnZeroExitCode { [bool] $succeeded = $result.ExitCode -eq 0 if ($Negate) { $succeeded = -not $succeeded } - if (-not $succeeded) - { + if (-not $succeeded) { $commandOutputIndent = " " * 4 $commandOutput = ($result.Output | ForEach-Object { "${commandOutputIndent}${_}" }) -join "`n" $failureMessage = "Command '${ActualValue}' has finished with exit code`n${commandOutput}" @@ -149,8 +148,7 @@ function ShouldOutputTextMatchingRegex { if (-not $succeeded) { if ($Negate) { $failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to not match '$output', but it did match." - } - else { + } else { $failureMessage = "Expected regular expression '$RegularExpression' for '$ActualValue' command to match '$output', but it did not match." } } diff --git a/images/ubuntu/scripts/tests/Java.Tests.ps1 b/images/ubuntu/scripts/tests/Java.Tests.ps1 index ba63bcfad..dff9cf399 100644 --- a/images/ubuntu/scripts/tests/Java.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Java.Tests.ps1 @@ -5,8 +5,6 @@ Describe "Java" { $defaultVersion = $toolsetJava.default $jdkVersions = $toolsetJava.versions - [array]$testCases = $jdkVersions | ForEach-Object { @{Version = $_ } } - It "Java is default" -TestCases @{ DefaultJavaVersion = $defaultVersion } { $actualJavaPath = [System.Environment]::GetEnvironmentVariable("JAVA_HOME") $expectedJavaPath = [System.Environment]::GetEnvironmentVariable("JAVA_HOME_${DefaultJavaVersion}_X64") @@ -35,6 +33,8 @@ Describe "Java" { "`"$GradlePath`" -version" | Should -ReturnZeroExitCode } + $testCases = $jdkVersions | ForEach-Object { @{Version = $_ } } + It "Java " -TestCases $testCases { $javaVariableValue = [System.Environment]::GetEnvironmentVariable("JAVA_HOME_${Version}_X64") $javaVariableValue | Should -Not -BeNullOrEmpty diff --git a/images/ubuntu/scripts/tests/Node.Tests.ps1 b/images/ubuntu/scripts/tests/Node.Tests.ps1 index 10d8e35d6..3ae9761e4 100644 --- a/images/ubuntu/scripts/tests/Node.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Node.Tests.ps1 @@ -4,10 +4,6 @@ Describe "Node.js" { $testCases = $binaries + $module_commands | ForEach-Object { @{NodeCommand = $_} } It "" -TestCases $testCases { - param ( - [string] $NodeCommand - ) - "$NodeCommand --version" | Should -ReturnZeroExitCode } @@ -15,4 +11,3 @@ Describe "Node.js" { node --version | Should -BeLike "v$((Get-ToolsetContent).node.default).*" } } - diff --git a/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 b/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 index cd4f4b469..9a1079ece 100644 --- a/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 +++ b/images/ubuntu/scripts/tests/PowerShellModules.Tests.ps1 @@ -1,22 +1,22 @@ Describe "PowerShellModules" { $modules = (Get-ToolsetContent).powershellModules - $withoutVersionsModules = $modules | Where-Object {-not $_.versions} | ForEach-Object { + $modulesWithoutVersions = $modules | Where-Object { -not $_.versions } | ForEach-Object { @{moduleName = $_.name} } - $withVersionsModules = $modules | Where-Object {$_.versions} | ForEach-Object { + $modulesWithVersions = $modules | Where-Object { $_.versions } | ForEach-Object { $moduleName = $_.name $_.versions | ForEach-Object { @{moduleName = $moduleName; expectedVersion = $_} } } - It " is installed" -TestCases $withoutVersionsModules { + It " is installed" -TestCases $modulesWithoutVersions { Get-Module -Name $moduleName -ListAvailable | Should -BeTrue } - if ($withVersionsModules) { - It " with is installed" -TestCases $withVersionsModules { + if ($modulesWithVersions) { + It " with is installed" -TestCases $modulesWithVersions { (Get-Module -Name $moduleName -ListAvailable).Version -contains $expectedVersion | Should -BeTrue } } @@ -33,6 +33,7 @@ Describe "AzureModules" { foreach ($version in $module.versions) { $modulePath = Join-Path -Path $modulesRootPath -ChildPath "${moduleName}_${version}" $moduleInfo = @{ moduleName = $moduleName; modulePath = $modulePath; expectedVersion = $version } + It " exists in modules directory" -TestCases $moduleInfo { $testJob = Start-Job -ScriptBlock { param ( @@ -52,6 +53,7 @@ Describe "AzureModules" { if ($module.default) { $moduleInfo = @{ moduleName = $moduleName; moduleDefault = $module.default } + It " set as default" -TestCases $moduleInfo { $moduleVersion = (Get-Module -ListAvailable -Name $moduleName).Version.ToString() $moduleVersion | Should -Match $moduleDefault @@ -59,4 +61,4 @@ Describe "AzureModules" { } } } -} \ No newline at end of file +} diff --git a/images/ubuntu/scripts/tests/RunnerCache.Tests.ps1 b/images/ubuntu/scripts/tests/RunnerCache.Tests.ps1 index 76c1a7278..8c8109ef0 100644 --- a/images/ubuntu/scripts/tests/RunnerCache.Tests.ps1 +++ b/images/ubuntu/scripts/tests/RunnerCache.Tests.ps1 @@ -1,7 +1,7 @@ Describe "RunnerCache" { Context "runner cache directory not empty" { - It "/opt/runner-cache not empty" { - (Get-ChildItem -Path "/opt/runner-cache/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0 + It " not empty" -TestCases @{ RunnerCachePath = "/opt/runner-cache" } { + (Get-ChildItem -Path "$RunnerCachePath/*.tar.gz" -Recurse).Count | Should -BeGreaterThan 0 } } } diff --git a/images/ubuntu/scripts/tests/Tools.Tests.ps1 b/images/ubuntu/scripts/tests/Tools.Tests.ps1 index 4071e3984..3e42763fc 100644 --- a/images/ubuntu/scripts/tests/Tools.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Tools.Tests.ps1 @@ -63,6 +63,7 @@ Describe "Rust" { } } } + Describe "Docker" { It "docker" { "docker --version" | Should -ReturnZeroExitCode @@ -111,13 +112,9 @@ Describe "Bazel" { } Describe "clang" { - [array]$testCases = (Get-ToolsetContent).clang.Versions | ForEach-Object { @{ClangVersion = $_} } + $testCases = (Get-ToolsetContent).clang.Versions | ForEach-Object { @{ClangVersion = $_} } It "clang " -TestCases $testCases { - param ( - [string] $ClangVersion - ) - "clang-$ClangVersion --version" | Should -ReturnZeroExitCode "clang++-$ClangVersion --version" | Should -ReturnZeroExitCode "clang-format-$ClangVersion --version" | Should -ReturnZeroExitCode @@ -136,34 +133,22 @@ Describe "erlang" -Skip:(Test-IsUbuntu22) { $testCases = @("erl -version", "erlc -v", "rebar3 -v") | ForEach-Object { @{ErlangCommand = $_} } It "erlang " -TestCases $testCases { - param ( - [string] $ErlangCommand - ) - "$ErlangCommand" | Should -ReturnZeroExitCode } } Describe "gcc" { - [array]$testCases = (Get-ToolsetContent).gcc.Versions | ForEach-Object { @{GccVersion = $_} } + $testCases = (Get-ToolsetContent).gcc.Versions | ForEach-Object { @{GccVersion = $_} } It "gcc " -TestCases $testCases { - param ( - [string] $GccVersion - ) - "$GccVersion --version" | Should -ReturnZeroExitCode } } Describe "gfortran" { - [array]$testCases = (Get-ToolsetContent).gfortran.Versions | ForEach-Object { @{GfortranVersion = $_} } + $testCases = (Get-ToolsetContent).gfortran.Versions | ForEach-Object { @{GfortranVersion = $_} } It "gfortran " -TestCases $testCases { - param ( - [string] $GfortranVersion - ) - "$GfortranVersion --version" | Should -ReturnZeroExitCode } } @@ -323,7 +308,7 @@ Describe "Pulumi" { Describe "Phantomjs" -Skip:(Test-IsUbuntu22) { It "phantomjs" { - $env:OPENSSL_CONF="/etc/ssl"; phantomjs --version + $env:OPENSSL_CONF="/etc/ssl" "phantomjs --version" | Should -ReturnZeroExitCode } } @@ -332,16 +317,14 @@ Describe "Containers" { $testCases = @("podman", "buildah", "skopeo") | ForEach-Object { @{ContainerCommand = $_} } It "" -TestCases $testCases { - param ( - [string] $ContainerCommand - ) - "$ContainerCommand -v" | Should -ReturnZeroExitCode } # https://github.com/actions/runner-images/issues/7753 It "podman networking" -TestCases "podman CNI plugins" { - "podman network create -d bridge test-net && podman network ls" | Should -Not -OutputTextMatchingRegex "Error" + "podman network create -d bridge test-net" | Should -ReturnZeroExitCode + "podman network ls" | Should -Not -OutputTextMatchingRegex "Error" + "podman network rm test-net" | Should -ReturnZeroExitCode } } @@ -356,31 +339,20 @@ Describe "Python" { $testCases = @("python", "pip", "python3", "pip3") | ForEach-Object { @{PythonCommand = $_} } It "" -TestCases $testCases { - param ( - [string] $PythonCommand - ) - "$PythonCommand --version" | Should -ReturnZeroExitCode - } + } } Describe "Ruby" { $testCases = @("ruby", "gem") | ForEach-Object { @{RubyCommand = $_} } It "" -TestCases $testCases { - param ( - [string] $RubyCommand - ) - "$RubyCommand --version" | Should -ReturnZeroExitCode } - $gemTestCases = (Get-ToolsetContent).rubygems | ForEach-Object { - @{gemName = $_.name} - } + $gemTestCases = (Get-ToolsetContent).rubygems | ForEach-Object { @{gemName = $_.name} } - if ($gemTestCases) - { + if ($gemTestCases) { It "Gem is installed" -TestCases $gemTestCases { "gem list -i '^$gemName$'" | Should -OutputTextMatchingRegex "true" } @@ -395,22 +367,22 @@ Describe "yq" { Describe "Kotlin" { It "kapt" { - "kapt -version"| Should -ReturnZeroExitCode + "kapt -version" | Should -ReturnZeroExitCode } It "kotlin" { - "kotlin -version"| Should -ReturnZeroExitCode + "kotlin -version" | Should -ReturnZeroExitCode } It "kotlinc" { - "kotlinc -version"| Should -ReturnZeroExitCode + "kotlinc -version" | Should -ReturnZeroExitCode } It "kotlinc-jvm" { - "kotlinc-jvm -version"| Should -ReturnZeroExitCode + "kotlinc-jvm -version" | Should -ReturnZeroExitCode } It "kotlin-dce-js" { - "kotlin-dce-js -version"| Should -ReturnZeroExitCode + "kotlin-dce-js -version" | Should -ReturnZeroExitCode } } diff --git a/images/ubuntu/scripts/tests/Toolset.Tests.ps1 b/images/ubuntu/scripts/tests/Toolset.Tests.ps1 index 2ac3e12bc..488bb42ae 100644 --- a/images/ubuntu/scripts/tests/Toolset.Tests.ps1 +++ b/images/ubuntu/scripts/tests/Toolset.Tests.ps1 @@ -28,7 +28,7 @@ Describe "Toolset" { } } - foreach($tool in $tools) { + foreach ($tool in $tools) { $toolName = $tool.Name Context "$toolName" { $toolExecs = $toolsExecutables[$toolName] @@ -45,16 +45,15 @@ Describe "Toolset" { $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) { + if ($toolExecs) { foreach ($executable in $toolExecs["tools"]) { - $executablePath = Join-Path $foundVersionPath $executable - + $executablePath = Join-Path $foundVersionPath $executable + It "Validate $executable" -TestCases @{ExecutablePath = $executablePath} { $ExecutablePath | Should -Exist }