@@ -39,17 +39,21 @@ describe('closure-compiler node bindings', () => {
39
39
40
40
describe ( 'java version' , ( ) => {
41
41
let originalTimeout ;
42
- const compilerArgs = [
43
- '-Xms2048m' ,
44
- '--sun-misc-unsafe-memory-access=allow' ,
45
- '-jar' ,
46
- JAR_PATH ,
42
+ const baseCompilerArgs = [
47
43
'--one=true' ,
48
44
'--two=two' ,
49
45
'--three=one' ,
50
46
'--three=two' ,
51
47
'--three=three' ,
52
48
] ;
49
+ const expandedCompilerArgs = [
50
+ '-XX:+IgnoreUnrecognizedVMOptions' ,
51
+ '--sun-misc-unsafe-memory-access=allow' ,
52
+ '-jar' ,
53
+ JAR_PATH ,
54
+ ] . concat ( baseCompilerArgs ) ;
55
+ const extraCompilerArgs = [ '-Xms2048m' ] ;
56
+ const expandedPlusExtraArgs = extraCompilerArgs . concat ( expandedCompilerArgs ) ;
53
57
beforeEach ( ( ) => {
54
58
originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
55
59
jasmine . DEFAULT_TIMEOUT_INTERVAL = 10000 ;
@@ -76,29 +80,26 @@ describe('closure-compiler node bindings', () => {
76
80
expect ( hasRun ) . toBe ( true ) ;
77
81
} ) ;
78
82
79
- it ( 'should normalize an options object to an arguments array' , async ( ) => {
83
+ it ( 'should normalize an options object to an arguments array immediately' , ( ) => {
80
84
const compiler = new Compiler ( {
81
85
one : true ,
82
86
two : 'two' ,
83
87
three : [ 'one' , 'two' , 'three' ]
84
88
} ) ;
85
- await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
86
89
87
- const expectedArray = compilerArgs . slice ( 1 ) ;
88
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
90
+ expect ( compiler . commandArguments . length ) . toBe ( baseCompilerArgs . length ) ;
89
91
compiler . commandArguments . forEach ( ( item , index ) => {
90
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
92
+ expect ( baseCompilerArgs [ index ] ) . toBe ( item ) ;
91
93
} ) ;
92
94
} ) ;
93
95
94
96
it ( 'should prepend the -jar argument and compiler path when configured by array' , async ( ) => {
95
- const expectedArray = compilerArgs . slice ( 1 ) ;
96
- const compiler = new Compiler ( expectedArray . slice ( 3 ) ) ;
97
+ const compiler = new Compiler ( baseCompilerArgs ) ;
97
98
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
98
99
99
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
100
+ expect ( compiler . commandArguments . length ) . toBe ( expandedCompilerArgs . length ) ;
100
101
compiler . commandArguments . forEach ( ( item , index ) => {
101
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
102
+ expect ( expandedCompilerArgs [ index ] ) . toBe ( item ) ;
102
103
} ) ;
103
104
} ) ;
104
105
@@ -109,23 +110,21 @@ describe('closure-compiler node bindings', () => {
109
110
two : 'two' ,
110
111
three : [ 'one' , 'two' , 'three' ] ,
111
112
} ;
112
- const expectedArray = compilerArgs ;
113
- const compiler = new Compiler ( args , compilerArgs . slice ( 0 , 1 ) ) ;
113
+ const compiler = new Compiler ( args , extraCompilerArgs ) ;
114
114
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
115
115
116
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
116
+ expect ( compiler . commandArguments . length ) . toBe ( expandedPlusExtraArgs . length ) ;
117
117
compiler . commandArguments . forEach ( function ( item , index ) {
118
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
118
+ expect ( expandedPlusExtraArgs [ index ] ) . toBe ( item ) ;
119
119
} ) ;
120
120
} ) ;
121
121
122
122
it ( 'should include initial command arguments when configured by array' , async ( ) => {
123
- const expectedArray = compilerArgs ;
124
- const compiler = new Compiler ( expectedArray . slice ( 4 ) , expectedArray . slice ( 0 , 1 ) ) ;
123
+ const compiler = new Compiler ( baseCompilerArgs , extraCompilerArgs ) ;
125
124
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
126
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
125
+ expect ( compiler . commandArguments . length ) . toBe ( expandedPlusExtraArgs . length ) ;
127
126
compiler . commandArguments . forEach ( function ( item , index ) {
128
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
127
+ expect ( expandedPlusExtraArgs [ index ] ) . toBe ( item ) ;
129
128
} ) ;
130
129
} ) ;
131
130
} ) ;
0 commit comments