Default to runner architecture (#376) · actions/setup-java@3617c43 (original) (raw)
`@@ -12,6 +12,8 @@ import {
`
12
12
`JavaInstallerResults
`
13
13
`} from '../../src/distributions/base-models';
`
14
14
``
``
15
`+
import os from 'os';
`
``
16
+
15
17
`class EmptyJavaBase extends JavaBase {
`
16
18
`constructor(installerOptions: JavaInstallerOptions) {
`
17
19
`super('Empty', installerOptions);
`
`@@ -192,6 +194,8 @@ describe('setupJava', () => {
`
192
194
``
193
195
`spyCoreSetOutput = jest.spyOn(core, 'setOutput');
`
194
196
`spyCoreSetOutput.mockImplementation(() => undefined);
`
``
197
+
``
198
`+
jest.spyOn(os, 'arch').mockReturnValue('x86');
`
195
199
`});
`
196
200
``
197
201
`afterEach(() => {
`
`@@ -212,6 +216,10 @@ describe('setupJava', () => {
`
212
216
`[
`
213
217
`{ version: '11.0.8', architecture: 'x86', packageType: 'jdk', checkLatest: false },
`
214
218
`{ version: installedJavaVersion, path: javaPath }
`
``
219
`+
],
`
``
220
`+
[
`
``
221
`+
{ version: '11', architecture: '', packageType: 'jdk', checkLatest: false },
`
``
222
`+
{ version: installedJavaVersion, path: javaPath }
`
215
223
`]
`
216
224
`])('should find java locally for %s', (input, expected) => {
`
217
225
`mockJavaBase = new EmptyJavaBase(input);
`
`@@ -237,6 +245,10 @@ describe('setupJava', () => {
`
237
245
`[
`
238
246
`{ version: '11', architecture: 'x64', packageType: 'jre', checkLatest: false },
`
239
247
`{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x64'), version: '11.0.9' }
`
``
248
`+
],
`
``
249
`+
[
`
``
250
`+
{ version: '11', architecture: '', packageType: 'jre', checkLatest: false },
`
``
251
`+
{ path: path.join('toolcache', 'Java_Empty_jre', '11.0.9', 'x86'), version: '11.0.9' }
`
240
252
`]
`
241
253
`])('download java with configuration %s', async (input, expected) => {
`
242
254
`mockJavaBase = new EmptyJavaBase(input);
`
`@@ -245,7 +257,7 @@ describe('setupJava', () => {
`
245
257
`expect(spyCoreAddPath).toHaveBeenCalled();
`
246
258
`expect(spyCoreExportVariable).toHaveBeenCalled();
`
247
259
`expect(spyCoreExportVariable).toHaveBeenCalledWith(
`
248
``
`` -
JAVA_HOME_${input.version}_${input.architecture.toLocaleUpperCase()},
``
``
260
`` +
JAVA_HOME_${input.version}_${(input.architecture || 'x86').toLocaleUpperCase()},
``
249
261
`expected.path
`
250
262
`);
`
251
263
`expect(spyCoreSetOutput).toHaveBeenCalled();
`
`@@ -260,6 +272,10 @@ describe('setupJava', () => {
`
260
272
`[
`
261
273
`{ version: '11.0.9', architecture: 'x86', packageType: 'jdk', checkLatest: true },
`
262
274
`{ version: '11.0.9', path: javaPathInstalled }
`
``
275
`+
],
`
``
276
`+
[
`
``
277
`+
{ version: '11.0.9', architecture: '', packageType: 'jdk', checkLatest: true },
`
``
278
`+
{ version: '11.0.9', path: javaPathInstalled }
`
263
279
`]
`
264
280
`])('should check the latest java version for %s and resolve locally', async (input, expected) => {
`
265
281
`mockJavaBase = new EmptyJavaBase(input);
`
`@@ -283,6 +299,10 @@ describe('setupJava', () => {
`
283
299
`[
`
284
300
`{ version: '11.0.x', architecture: 'x86', packageType: 'jdk', checkLatest: true },
`
285
301
`{ version: actualJavaVersion, path: javaPathInstalled }
`
``
302
`+
],
`
``
303
`+
[
`
``
304
`+
{ version: '11', architecture: '', packageType: 'jdk', checkLatest: true },
`
``
305
`+
{ version: actualJavaVersion, path: javaPathInstalled }
`
286
306
`]
`
287
307
`])('should check the latest java version for %s and download', async (input, expected) => {
`
288
308
`mockJavaBase = new EmptyJavaBase(input);
`