Skip to content

Commit

Permalink
Fix and test check for MSVC setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Mar 12, 2024
1 parent 636adab commit 9023893
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 9 deletions.
36 changes: 36 additions & 0 deletions __tests__/msvc.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import * as path from 'path'
import {expect, test} from '@jest/globals'
import {needsWindowsEnvironmentSetup} from '../src/msvc'
import {VERSION_DEV, VERSION_LATEST} from '../src/constants'

process.env['RUNNER_TOOL_CACHE'] = path.join(__dirname, 'TOOL_CACHE')
process.env['RUNNER_TEMP'] = path.join(__dirname, 'TEMP')

test('decide whether Window env must be set up for GraalVM for JDK', async () => {
for (var javaVersion of [
'17',
'17.0.8',
'17.0',
'21',
'22',
'22-ea',
'23-ea',
VERSION_DEV
]) {
expect(needsWindowsEnvironmentSetup(javaVersion, '', true)).toBe(false)
}
})

test('decide whether Window env must be set up for legacy GraalVM', async () => {
for (var combination of [
['7', '22.3.0'],
['17', '22.3'],
['7', '22.3'],
['7', VERSION_DEV],
['17', VERSION_LATEST]
]) {
expect(
needsWindowsEnvironmentSetup(combination[0], combination[1], false)
).toBe(combination[1] !== VERSION_DEV)
}
})
17 changes: 12 additions & 5 deletions dist/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 21 additions & 4 deletions src/msvc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,32 @@ function findVcvarsallPath(): string {
throw new Error('Failed to find vcvarsall.bat')
}

export function needsWindowsEnvironmentSetup(
javaVersion: string,
graalVMVersion: string,
isGraalVMforJDK17OrLater: boolean
): boolean {
if (javaVersion === VERSION_DEV || graalVMVersion === VERSION_DEV) {
return false // no longer required in dev builds
} else if (isGraalVMforJDK17OrLater) {
return false // no longer required in GraalVM for JDK 17 and later.
}
return true
}

export function setUpWindowsEnvironment(
javaVersion: string,
graalVMVersion: string,
isGraalVMforJDK17OrLater: boolean
): void {
if (javaVersion === javaVersion || graalVMVersion === VERSION_DEV) {
return // no longer required in dev builds
} else if (isGraalVMforJDK17OrLater) {
return // no longer required in GraalVM for JDK 17 and later.
if (
!needsWindowsEnvironmentSetup(
javaVersion,
graalVMVersion,
isGraalVMforJDK17OrLater
)
) {
return
}

core.startGroup('Updating Windows environment...')
Expand Down

0 comments on commit 9023893

Please sign in to comment.