Fix and test check for MSVC setup.

This commit is contained in:
Fabio Niephaus 2024-03-12 12:30:08 +01:00 committed by Fabio Niephaus
parent b03aef7455
commit d3f9e14fc3
3 changed files with 69 additions and 9 deletions

36
__tests__/msvc.test.ts Normal file
View 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
View File

@ -94570,7 +94570,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
return result; return result;
}; };
Object.defineProperty(exports, "__esModule", ({ value: true })); Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.setUpWindowsEnvironment = void 0; exports.setUpWindowsEnvironment = exports.needsWindowsEnvironmentSetup = void 0;
const core = __importStar(__nccwpck_require__(2186)); const core = __importStar(__nccwpck_require__(2186));
const child_process_1 = __nccwpck_require__(2081); const child_process_1 = __nccwpck_require__(2081);
const fs_1 = __nccwpck_require__(7147); const fs_1 = __nccwpck_require__(7147);
@ -94595,12 +94595,19 @@ function findVcvarsallPath() {
} }
throw new Error('Failed to find vcvarsall.bat'); throw new Error('Failed to find vcvarsall.bat');
} }
function setUpWindowsEnvironment(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater) { function needsWindowsEnvironmentSetup(javaVersion, graalVMVersion, isGraalVMforJDK17OrLater) {
if (javaVersion === javaVersion || graalVMVersion === constants_1.VERSION_DEV) { if (javaVersion === constants_1.VERSION_DEV || graalVMVersion === constants_1.VERSION_DEV) {
return; // no longer required in dev builds return false; // no longer required in dev builds
} }
else if (isGraalVMforJDK17OrLater) { 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...'); core.startGroup('Updating Windows environment...');
const vcvarsallPath = findVcvarsallPath(); const vcvarsallPath = findVcvarsallPath();

View File

@ -28,15 +28,32 @@ function findVcvarsallPath(): string {
throw new Error('Failed to find vcvarsall.bat') 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( export function setUpWindowsEnvironment(
javaVersion: string, javaVersion: string,
graalVMVersion: string, graalVMVersion: string,
isGraalVMforJDK17OrLater: boolean isGraalVMforJDK17OrLater: boolean
): void { ): void {
if (javaVersion === javaVersion || graalVMVersion === VERSION_DEV) { if (
return // no longer required in dev builds !needsWindowsEnvironmentSetup(
} else if (isGraalVMforJDK17OrLater) { javaVersion,
return // no longer required in GraalVM for JDK 17 and later. graalVMVersion,
isGraalVMforJDK17OrLater
)
) {
return
} }
core.startGroup('Updating Windows environment...') core.startGroup('Updating Windows environment...')