@@ -12,6 +12,8 @@ import {
1212 JavaInstallerResults
1313} from '../../src/distributions/base-models' ;
1414
15+ import os from 'os' ;
16+
1517class EmptyJavaBase extends JavaBase {
1618 constructor ( installerOptions : JavaInstallerOptions ) {
1719 super ( 'Empty' , installerOptions ) ;
@@ -192,6 +194,8 @@ describe('setupJava', () => {
192194
193195 spyCoreSetOutput = jest . spyOn ( core , 'setOutput' ) ;
194196 spyCoreSetOutput . mockImplementation ( ( ) => undefined ) ;
197+
198+ jest . spyOn ( os , 'arch' ) . mockReturnValue ( 'x86' ) ;
195199 } ) ;
196200
197201 afterEach ( ( ) => {
@@ -212,6 +216,10 @@ describe('setupJava', () => {
212216 [
213217 { version : '11.0.8' , architecture : 'x86' , packageType : 'jdk' , checkLatest : false } ,
214218 { version : installedJavaVersion , path : javaPath }
219+ ] ,
220+ [
221+ { version : '11' , architecture : '' , packageType : 'jdk' , checkLatest : false } ,
222+ { version : installedJavaVersion , path : javaPath }
215223 ]
216224 ] ) ( 'should find java locally for %s' , ( input , expected ) => {
217225 mockJavaBase = new EmptyJavaBase ( input ) ;
@@ -237,6 +245,10 @@ describe('setupJava', () => {
237245 [
238246 { version : '11' , architecture : 'x64' , packageType : 'jre' , checkLatest : false } ,
239247 { 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' }
240252 ]
241253 ] ) ( 'download java with configuration %s' , async ( input , expected ) => {
242254 mockJavaBase = new EmptyJavaBase ( input ) ;
@@ -245,7 +257,7 @@ describe('setupJava', () => {
245257 expect ( spyCoreAddPath ) . toHaveBeenCalled ( ) ;
246258 expect ( spyCoreExportVariable ) . toHaveBeenCalled ( ) ;
247259 expect ( spyCoreExportVariable ) . toHaveBeenCalledWith (
248- `JAVA_HOME_${ input . version } _${ input . architecture . toLocaleUpperCase ( ) } ` ,
260+ `JAVA_HOME_${ input . version } _${ ( input . architecture || 'x86' ) . toLocaleUpperCase ( ) } ` ,
249261 expected . path
250262 ) ;
251263 expect ( spyCoreSetOutput ) . toHaveBeenCalled ( ) ;
@@ -260,6 +272,10 @@ describe('setupJava', () => {
260272 [
261273 { version : '11.0.9' , architecture : 'x86' , packageType : 'jdk' , checkLatest : true } ,
262274 { 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 }
263279 ]
264280 ] ) ( 'should check the latest java version for %s and resolve locally' , async ( input , expected ) => {
265281 mockJavaBase = new EmptyJavaBase ( input ) ;
@@ -283,6 +299,10 @@ describe('setupJava', () => {
283299 [
284300 { version : '11.0.x' , architecture : 'x86' , packageType : 'jdk' , checkLatest : true } ,
285301 { version : actualJavaVersion , path : javaPathInstalled }
302+ ] ,
303+ [
304+ { version : '11' , architecture : '' , packageType : 'jdk' , checkLatest : true } ,
305+ { version : actualJavaVersion , path : javaPathInstalled }
286306 ]
287307 ] ) ( 'should check the latest java version for %s and download' , async ( input , expected ) => {
288308 mockJavaBase = new EmptyJavaBase ( input ) ;
0 commit comments