mirror of
https://github.com/actions/setup-java.git
synced 2025-04-21 02:16:45 +00:00
Make tests work on macOS and Windows
This commit is contained in:
parent
46d790322c
commit
43a44e93dd
3 changed files with 11 additions and 21 deletions
|
@ -1,6 +1,7 @@
|
||||||
import { OracleDistribution } from '../../src/distributions/oracle/installer';
|
import { OracleDistribution } from '../../src/distributions/oracle/installer';
|
||||||
import os from 'os';
|
import os from 'os';
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
|
import { getDownloadArchiveExtension } from '../../src/util';
|
||||||
|
|
||||||
describe('findPackageForDownload', () => {
|
describe('findPackageForDownload', () => {
|
||||||
let distribution: OracleDistribution;
|
let distribution: OracleDistribution;
|
||||||
|
@ -47,23 +48,9 @@ describe('findPackageForDownload', () => {
|
||||||
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
])('version is %s -> %s', async (input, expectedVersion, expectedUrl) => {
|
||||||
const result = await distribution['findPackageForDownload'](input);
|
const result = await distribution['findPackageForDownload'](input);
|
||||||
expect(result.version).toBe(expectedVersion);
|
expect(result.version).toBe(expectedVersion);
|
||||||
let os: string;
|
const osType = distribution.getPlatform();
|
||||||
let archive: string;
|
const archiveType = getDownloadArchiveExtension();
|
||||||
switch (process.platform) {
|
const url = expectedUrl.replace('{{OS_TYPE}}', osType).replace('{{ARCHIVE_TYPE}}', archiveType);
|
||||||
case 'darwin':
|
|
||||||
os = 'macos';
|
|
||||||
archive = 'tar.gz';
|
|
||||||
break;
|
|
||||||
case 'win32':
|
|
||||||
os = 'windows';
|
|
||||||
archive = 'zip';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
os = process.platform.toString();
|
|
||||||
archive = 'tar.gz';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
const url = expectedUrl.replace('{{OS_TYPE}}', os).replace('{{ARCHIVE_TYPE}}', archive);
|
|
||||||
expect(result.url).toBe(url);
|
expect(result.url).toBe(url);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -84,8 +71,13 @@ describe('findPackageForDownload', () => {
|
||||||
checkLatest: false
|
checkLatest: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const osType = distribution.getPlatform();
|
||||||
|
if (osType === 'windows' && distroArch == 'aarch64') {
|
||||||
|
return; // skip, aarch64 is not available for Windows
|
||||||
|
}
|
||||||
|
const archiveType = getDownloadArchiveExtension();
|
||||||
const result = await distro['findPackageForDownload'](version);
|
const result = await distro['findPackageForDownload'](version);
|
||||||
const expectedUrl = `https://download.oracle.com/java/17/latest/jdk-17_linux-${distroArch}_bin.tar.gz`;
|
const expectedUrl = `https://download.oracle.com/java/17/latest/jdk-17_${osType}-${distroArch}_bin.${archiveType}`;
|
||||||
|
|
||||||
expect(result.url).toBe(expectedUrl);
|
expect(result.url).toBe(expectedUrl);
|
||||||
}
|
}
|
||||||
|
|
1
dist/setup/index.js
vendored
1
dist/setup/index.js
vendored
|
@ -104682,7 +104682,6 @@ class OracleDistribution extends base_installer_1.JavaBase {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'macos';
|
return 'macos';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
case 'cygwin':
|
|
||||||
return 'windows';
|
return 'windows';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return 'linux';
|
return 'linux';
|
||||||
|
|
|
@ -86,12 +86,11 @@ export class OracleDistribution extends JavaBase {
|
||||||
return { url: fileUrl, version: range };
|
return { url: fileUrl, version: range };
|
||||||
}
|
}
|
||||||
|
|
||||||
private getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
public getPlatform(platform: NodeJS.Platform = process.platform): OsVersions {
|
||||||
switch (platform) {
|
switch (platform) {
|
||||||
case 'darwin':
|
case 'darwin':
|
||||||
return 'macos';
|
return 'macos';
|
||||||
case 'win32':
|
case 'win32':
|
||||||
case 'cygwin':
|
|
||||||
return 'windows';
|
return 'windows';
|
||||||
case 'linux':
|
case 'linux':
|
||||||
return 'linux';
|
return 'linux';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue