mirror of
https://github.com/actions/runner-images.git
synced 2025-12-15 14:17:22 +00:00
* Use Resolve-GithubReleaseAssetUrl more widely * Add the Get-ChecksumFromUrl function * Sort exported functions and add docs * Remove alias and fix typo * Fix kind checksum url and syntax * Fix checksums url for gh cli and msys2 * [Windows] Cleanup various scripts * Add spaces after type specifications * Rename the Take-Part function
41 lines
1.4 KiB
PowerShell
41 lines
1.4 KiB
PowerShell
Describe "Java" {
|
|
$toolsetJava = (Get-ToolsetContent).java
|
|
$defaultVersion = $toolsetJava.default
|
|
$jdkVersions = $toolsetJava.versions
|
|
|
|
[array] $testCases = $jdkVersions | ForEach-Object { @{Version = $_ } }
|
|
|
|
It "Java <DefaultJavaVersion> is default" -TestCases @(@{ DefaultJavaVersion = $defaultVersion }) {
|
|
$actualJavaPath = Get-EnvironmentVariable "JAVA_HOME"
|
|
$expectedJavaPath = Get-EnvironmentVariable "JAVA_HOME_${DefaultJavaVersion}_X64"
|
|
|
|
$actualJavaPath | Should -Not -BeNullOrEmpty
|
|
$expectedJavaPath | Should -Not -BeNullOrEmpty
|
|
$actualJavaPath | Should -Be $expectedJavaPath
|
|
}
|
|
|
|
It "<ToolName>" -TestCases @(
|
|
@{ ToolName = "java" }
|
|
@{ ToolName = "mvn" }
|
|
@{ ToolName = "ant" }
|
|
@{ ToolName = "gradle" }
|
|
) {
|
|
"$ToolName -version" | Should -ReturnZeroExitCode
|
|
}
|
|
|
|
It "Java <Version>" -TestCases $testCases {
|
|
$javaVariableValue = Get-EnvironmentVariable "JAVA_HOME_${Version}_X64"
|
|
$javaVariableValue | Should -Not -BeNullOrEmpty
|
|
$javaPath = Join-Path $javaVariableValue "bin\java"
|
|
|
|
if ($Version -eq 8) {
|
|
$Version = "1.${Version}"
|
|
}
|
|
$outputPattern = "openjdk version `"${Version}"
|
|
|
|
$outputLines = (& $env:comspec /c "`"$javaPath`" -version 2>&1") -as [string[]]
|
|
$LASTEXITCODE | Should -Be 0
|
|
$outputLines[0] | Should -Match $outputPattern
|
|
}
|
|
}
|