mirror of
https://github.com/graalvm/setup-graalvm.git
synced 2025-01-18 19:26:39 +08:00
Fix and test check for MSVC setup.
This commit is contained in:
parent
b03aef7455
commit
d3f9e14fc3
36
__tests__/msvc.test.ts
Normal file
36
__tests__/msvc.test.ts
Normal file
@ -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
dist/main/index.js
generated
vendored
17
dist/main/index.js
generated
vendored
@ -94570,7 +94570,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.setUpWindowsEnvironment = void 0;
|
||||
exports.setUpWindowsEnvironment = exports.needsWindowsEnvironmentSetup = void 0;
|
||||
const core = __importStar(__nccwpck_require__(2186));
|
||||
const child_process_1 = __nccwpck_require__(2081);
|
||||
const fs_1 = __nccwpck_require__(7147);
|
||||
@ -94595,12 +94595,19 @@ function findVcvarsallPath() {
|
||||
}
|
||||
throw new Error('Failed to find vcvarsall.bat');
|
||||
}
|
||||
function setUpWindowsEnvironment(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater) {
|
||||
if (javaVersion === javaVersion || graalVMVersion === constants_1.VERSION_DEV) {
|
||||
return; // no longer required in dev builds
|
||||
function needsWindowsEnvironmentSetup(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater) {
|
||||
if (javaVersion === constants_1.VERSION_DEV || graalVMVersion === constants_1.VERSION_DEV) {
|
||||
return false; // no longer required in dev builds
|
||||
}
|
||||
else if (isGraalVMforJDK17OrLater) {
|
||||
return; // no longer required in GraalVM for JDK 17 and later.
|
||||
return false; // no longer required in GraalVM for JDK 17 and later.
|
||||
}
|
||||
return true;
|
||||
}
|
||||
exports.needsWindowsEnvironmentSetup = needsWindowsEnvironmentSetup;
|
||||
function setUpWindowsEnvironment(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater) {
|
||||
if (!needsWindowsEnvironmentSetup(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater)) {
|
||||
return;
|
||||
}
|
||||
core.startGroup('Updating Windows environment...');
|
||||
const vcvarsallPath = findVcvarsallPath();
|
||||
|
25
src/msvc.ts
25
src/msvc.ts
@ -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...')
|
||||
|
Loading…
x
Reference in New Issue
Block a user