@@ -39,6 +39,17 @@ 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 ,
47
+ '--one=true' ,
48
+ '--two=two' ,
49
+ '--three=one' ,
50
+ '--three=two' ,
51
+ '--three=three' ,
52
+ ] ;
42
53
beforeEach ( ( ) => {
43
54
originalTimeout = jasmine . DEFAULT_TIMEOUT_INTERVAL ;
44
55
jasmine . DEFAULT_TIMEOUT_INTERVAL = 10000 ;
@@ -65,26 +76,24 @@ describe('closure-compiler node bindings', () => {
65
76
expect ( hasRun ) . toBe ( true ) ;
66
77
} ) ;
67
78
68
- it ( 'should normalize an options object to an arguments array' , ( ) => {
79
+ it ( 'should normalize an options object to an arguments array' , async ( ) => {
69
80
const compiler = new Compiler ( {
70
81
one : true ,
71
82
two : 'two' ,
72
83
three : [ 'one' , 'two' , 'three' ]
73
84
} ) ;
85
+ await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
74
86
75
- const expectedArray = [ '--one=true' , '--two=two' ,
76
- '--three=one' , '--three=two' , '--three=three' ] ;
87
+ const expectedArray = compilerArgs . slice ( 1 ) ;
77
88
expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
78
89
compiler . commandArguments . forEach ( ( item , index ) => {
79
90
expect ( expectedArray [ index ] ) . toBe ( item ) ;
80
91
} ) ;
81
92
} ) ;
82
93
83
94
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 ) ) ;
95
+ const expectedArray = compilerArgs . slice ( 1 ) ;
96
+ const compiler = new Compiler ( expectedArray . slice ( 3 ) ) ;
88
97
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
89
98
90
99
expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
@@ -95,10 +104,13 @@ describe('closure-compiler node bindings', () => {
95
104
96
105
describe ( 'extra command arguments' , ( ) => {
97
106
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 ) ) ;
107
+ const args = {
108
+ one : true ,
109
+ two : 'two' ,
110
+ three : [ 'one' , 'two' , 'three' ] ,
111
+ } ;
112
+ const expectedArray = compilerArgs ;
113
+ const compiler = new Compiler ( args , compilerArgs . slice ( 0 , 1 ) ) ;
102
114
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
103
115
104
116
expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
@@ -108,10 +120,8 @@ describe('closure-compiler node bindings', () => {
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 expectedArray = compilerArgs ;
124
+ const compiler = new Compiler ( expectedArray . slice ( 4 ) , expectedArray . slice ( 0 , 1 ) ) ;
115
125
await new Promise ( ( resolve ) => compiler . run ( resolve ) ) ;
116
126
expect ( compiler . commandArguments . length ) . toBe ( expectedArray . length ) ;
117
127
compiler . commandArguments . forEach ( function ( item , index ) {
0 commit comments