mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-14 16:46:25 +00:00
test: fix java skipping (#15232)
This commit is contained in:
parent
8267e77a64
commit
d9bbc18155
1 changed files with 6 additions and 14 deletions
|
@ -10,16 +10,11 @@ const gradleJavaVersionSupport = {
|
||||||
const skipJava = process.env.SKIP_JAVA_TESTS === 'true';
|
const skipJava = process.env.SKIP_JAVA_TESTS === 'true';
|
||||||
const enforceJava = process.env[failIfNoJavaEnv] === 'true' && !skipJava;
|
const enforceJava = process.env[failIfNoJavaEnv] === 'true' && !skipJava;
|
||||||
|
|
||||||
function parseJavaVersion(
|
function parseJavaVersion(javaVersionOutput: string | undefined): number {
|
||||||
javaVersionOutput: string | undefined
|
|
||||||
): number | null {
|
|
||||||
if (!javaVersionOutput) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const versionMatch = /version "(?:1\.)?(\d+)[\d._-]*"/.exec(
|
const versionMatch = /version "(?:1\.)?(\d+)[\d._-]*"/.exec(
|
||||||
javaVersionOutput
|
javaVersionOutput ?? ''
|
||||||
);
|
);
|
||||||
if (versionMatch !== null && versionMatch.length === 2) {
|
if (versionMatch?.length === 2) {
|
||||||
return parseInt(versionMatch[1], 10);
|
return parseInt(versionMatch[1], 10);
|
||||||
}
|
}
|
||||||
if (enforceJava) {
|
if (enforceJava) {
|
||||||
|
@ -30,10 +25,10 @@ ${javaVersionOutput}`);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cachedJavaVersion: number | null | undefined = undefined;
|
let cachedJavaVersion: number | null = null;
|
||||||
|
|
||||||
function determineJavaVersion(): number | null {
|
function determineJavaVersion(): number {
|
||||||
if (cachedJavaVersion === undefined) {
|
if (cachedJavaVersion === null) {
|
||||||
let javaVersionCommand: SpawnSyncReturns<string> | undefined;
|
let javaVersionCommand: SpawnSyncReturns<string> | undefined;
|
||||||
let error: Error | undefined;
|
let error: Error | undefined;
|
||||||
try {
|
try {
|
||||||
|
@ -67,9 +62,6 @@ class WithGradle {
|
||||||
|
|
||||||
constructor(gradleVersion: keyof typeof gradleJavaVersionSupport) {
|
constructor(gradleVersion: keyof typeof gradleJavaVersionSupport) {
|
||||||
const javaVersion = determineJavaVersion();
|
const javaVersion = determineJavaVersion();
|
||||||
if (!javaVersion) {
|
|
||||||
throw Error(`Unknown java version!`);
|
|
||||||
}
|
|
||||||
if (gradleJavaVersionSupport[gradleVersion] === undefined) {
|
if (gradleJavaVersionSupport[gradleVersion] === undefined) {
|
||||||
throw Error(`Unknown gradle version '${gradleVersion}'!`);
|
throw Error(`Unknown gradle version '${gradleVersion}'!`);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue