@@ -39,6 +39,21 @@ describe('closure-compiler node bindings', () => {
39
39
40
40
describe ( 'java version' , ( ) => {
41
41
let originalTimeout ;
42
+ const baseCompilerArgs = [
43
+ '--one=true' ,
44
+ '--two=two' ,
45
+ '--three=one' ,
46
+ '--three=two' ,
47
+ '--three=three' ,
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 ) ;
42
57
beforeEach ( ( ) => {
43
58
originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
44
59
jasmine . DEFAULT_TIMEOUT_INTERVAL = 10000 ;
@@ -65,57 +80,51 @@ describe('closure-compiler node bindings', () => {
65
80
expect ( hasRun ) . toBe ( true ) ;
66
81
} ) ;
67
82
68
- it ( 'should normalize an options object to an arguments array' , ( ) => {
83
+ it ( 'should normalize an options object to an arguments array immediately ' , ( ) => {
69
84
const compiler = new Compiler ( {
70
85
one : true ,
71
86
two : 'two' ,
72
87
three : [ 'one' , 'two' , 'three' ]
73
88
} ) ;
74
89
75
- const expectedArray = [ '--one=true' , '--two=two' ,
76
- '--three=one' , '--three=two' , '--three=three' ] ;
77
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
90
+ expect ( compiler . commandArguments . length ) . toBe ( baseCompilerArgs . length ) ;
78
91
compiler . commandArguments . forEach ( ( item , index ) => {
79
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
92
+ expect ( baseCompilerArgs [ index ] ) . toBe ( item ) ;
80
93
} ) ;
81
94
} ) ;
82
95
83
96
it ( 'should prepend the -jar argument and compiler path when configured by array' , async ( ) => {
84
- const expectedArray = [ '-jar' , JAR_PATH , '--one=true' , '--two=two' ,
85
- '--three=one' , '--three=two' , '--three=three' ] ;
86
-
87
- const compiler = new Compiler ( expectedArray . slice ( 2 ) ) ;
97
+ const compiler = new Compiler ( baseCompilerArgs ) ;
88
98
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
89
99
90
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
100
+ expect ( compiler . commandArguments . length ) . toBe ( expandedCompilerArgs . length ) ;
91
101
compiler . commandArguments . forEach ( ( item , index ) => {
92
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
102
+ expect ( expandedCompilerArgs [ index ] ) . toBe ( item ) ;
93
103
} ) ;
94
104
} ) ;
95
105
96
106
describe ( 'extra command arguments' , ( ) => {
97
107
it ( 'should include initial command arguments when configured by an options object' , async ( ) => {
98
- const expectedArray = [ '-Xms2048m' , '-jar' , JAR_PATH , '--one=true' , '--two=two' ,
99
- '--three=one' , '--three=two' , '--three=three' ] ;
100
-
101
- const compiler = new Compiler ( expectedArray . slice ( 3 ) , expectedArray . slice ( 0 , 1 ) ) ;
108
+ const args = {
109
+ one : true ,
110
+ two : 'two' ,
111
+ three : [ 'one' , 'two' , 'three' ] ,
112
+ } ;
113
+ const compiler = new Compiler ( args , extraCompilerArgs ) ;
102
114
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
103
115
104
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
116
+ expect ( compiler . commandArguments . length ) . toBe ( expandedPlusExtraArgs . length ) ;
105
117
compiler . commandArguments . forEach ( function ( item , index ) {
106
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
118
+ expect ( expandedPlusExtraArgs [ index ] ) . toBe ( item ) ;
107
119
} ) ;
108
120
} ) ;
109
121
110
122
it ( 'should include initial command arguments when configured by array' , async ( ) => {
111
- const expectedArray = [ '-Xms2048m' , '-jar' , JAR_PATH , '--one=true' , '--two=two' ,
112
- '--three=one' , '--three=two' , '--three=three' ] ;
113
-
114
- const compiler = new Compiler ( expectedArray . slice ( 3 ) , expectedArray . slice ( 0 , 1 ) ) ;
123
+ const compiler = new Compiler ( baseCompilerArgs , extraCompilerArgs ) ;
115
124
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
116
- expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
125
+ expect ( compiler . commandArguments . length ) . toBe ( expandedPlusExtraArgs . length ) ;
117
126
compiler . commandArguments . forEach ( function ( item , index ) {
118
- expect ( expectedArray [ index ] ) . toBe ( item ) ;
127
+ expect ( expandedPlusExtraArgs [ index ] ) . toBe ( item ) ;
119
128
} ) ;
120
129
} ) ;
121
130
} ) ;
0 commit comments