@@ -25,7 +25,6 @@ function retrieveParams(subpath) {
25
25
function compareTextFiles ( file1Path , file2Path ) {
26
26
const file1Content = fs . readFileSync ( file1Path , 'utf-8' )
27
27
const file2Content = fs . readFileSync ( file2Path , 'utf-8' )
28
-
29
28
return file1Content === file2Content
30
29
}
31
30
@@ -51,6 +50,8 @@ function useFixture(dir) {
51
50
52
51
describe ( 'e2e' , function ( ) {
53
52
let result = false
53
+ let code
54
+ let stdout
54
55
55
56
describe ( 'autofix tests' , ( ) => {
56
57
if ( E2E ) {
@@ -160,28 +161,32 @@ describe('e2e', function () {
160
161
}
161
162
} )
162
163
163
- it ( 'should compare Foo1 file with template BEFORE FIX file and they should match 2 ' , ( ) => {
164
+ it ( 'should compare Foo1 file with template BEFORE FIX file and they should match (2) ' , ( ) => {
164
165
result = compareTextFiles ( currentFile , beforeFixFile )
165
166
expect ( result ) . to . be . true
166
167
} )
167
168
168
- it ( 'should compare Foo1 file with template AFTER FIX file and they should match 2 ' , ( ) => {
169
- const { code, stdout } = shell . exec (
169
+ it ( 'should execute and compare Foo1 with template AFTER FIX and they should match (2) ' , ( ) => {
170
+ ( { code, stdout } = shell . exec (
170
171
`${ params . command } ${ params . param1 } -c ${ currentConfig } ${ currentFile } --fix --disc --noPrompt`
171
- )
172
+ ) )
173
+
174
+ result = compareTextFiles ( currentFile , afterFixFile )
175
+ expect ( result ) . to . be . true
176
+ } )
172
177
178
+ it ( 'should execute and exit with code 1 (2)' , ( ) => {
173
179
expect ( code ) . to . equal ( 1 )
180
+ } )
174
181
182
+ it ( 'should get the right report (2)' , ( ) => {
175
183
const reportLines = stdout . split ( '\n' )
176
184
const finalLine = '5 problems (5 errors, 0 warnings)'
177
185
expect ( reportLines [ reportLines . length - 3 ] ) . to . contain ( finalLine )
178
-
179
- result = compareTextFiles ( currentFile , afterFixFile )
180
- expect ( result ) . to . be . true
181
186
} )
182
187
} )
183
188
184
- it ( 'should check FOO1 does not change after test 2 ' , ( ) => {
189
+ it ( 'should check FOO1 does not change after test (2) ' , ( ) => {
185
190
result = compareTextFiles ( currentFile , beforeFixFile )
186
191
expect ( result ) . to . be . true
187
192
} )
@@ -202,28 +207,32 @@ describe('e2e', function () {
202
207
}
203
208
} )
204
209
205
- it ( 'should compare Foo1 file with template BEFORE FIX file and they should match 3 ' , ( ) => {
210
+ it ( 'should compare Foo1 file with template BEFORE FIX file and they should match (3) ' , ( ) => {
206
211
result = compareTextFiles ( currentFile , beforeFixFile )
207
212
expect ( result ) . to . be . true
208
213
} )
209
214
210
- it ( 'should compare Foo1 file with template AFTER FIX file and they should match 3 ' , ( ) => {
211
- const { code, stdout } = shell . exec (
215
+ it ( 'should execute and compare Foo1 with template AFTER FIX and they should match (3) ' , ( ) => {
216
+ ( { code, stdout } = shell . exec (
212
217
`${ params . command } ${ params . param1 } -c ${ currentConfig } ${ currentFile } --fix --disc --noPrompt`
213
- )
218
+ ) )
214
219
220
+ result = compareTextFiles ( currentFile , afterFixFile )
221
+ expect ( result ) . to . be . true
222
+ } )
223
+
224
+ it ( 'should execute and exit with code 1 (3)' , ( ) => {
215
225
expect ( code ) . to . equal ( 1 )
226
+ } )
216
227
228
+ it ( 'should get the right report (3)' , ( ) => {
217
229
const reportLines = stdout . split ( '\n' )
218
230
const finalLine = '9 problems (9 errors, 0 warnings)'
219
231
expect ( reportLines [ reportLines . length - 3 ] ) . to . contain ( finalLine )
220
-
221
- result = compareTextFiles ( currentFile , afterFixFile )
222
- expect ( result ) . to . be . true
223
232
} )
224
233
} )
225
234
226
- it ( 'should check FOO1 does not change after test 3 ' , ( ) => {
235
+ it ( 'should check FOO1 does not change after test (3) ' , ( ) => {
227
236
result = compareTextFiles ( currentFile , beforeFixFile )
228
237
expect ( result ) . to . be . true
229
238
} )
@@ -244,33 +253,83 @@ describe('e2e', function () {
244
253
}
245
254
} )
246
255
247
- it ( 'should compare Foo1 file with template BEFORE FIX file and they should match 4 ' , ( ) => {
256
+ it ( 'should compare Foo1 file with template BEFORE FIX file and they should match (4) ' , ( ) => {
248
257
result = compareTextFiles ( currentFile , beforeFixFile )
249
258
expect ( result ) . to . be . true
250
259
} )
251
260
252
- it ( 'should compare Foo1 file with template AFTER FIX file and they should match 4 ' , ( ) => {
253
- const { code, stdout } = shell . exec (
261
+ it ( 'should execute and compare Foo1 with template AFTER FIX and they should match (4) ' , ( ) => {
262
+ ( { code, stdout } = shell . exec (
254
263
`${ params . command } ${ params . param1 } -c ${ currentConfig } ${ currentFile } --fix --disc --noPrompt`
255
- )
264
+ ) )
256
265
266
+ result = compareTextFiles ( currentFile , afterFixFile )
267
+ expect ( result ) . to . be . true
268
+ } )
269
+
270
+ it ( 'should execute and exit with code 1 (4)' , ( ) => {
257
271
expect ( code ) . to . equal ( 1 )
272
+ } )
258
273
274
+ it ( 'should get the right report (4)' , ( ) => {
259
275
const reportLines = stdout . split ( '\n' )
260
276
const finalLine = '19 problems (19 errors, 0 warnings)'
261
277
expect ( reportLines [ reportLines . length - 3 ] ) . to . contain ( finalLine )
278
+ } )
279
+ } )
280
+
281
+ it ( 'should check FOO1 does not change after test (4)' , ( ) => {
282
+ result = compareTextFiles ( currentFile , beforeFixFile )
283
+ expect ( result ) . to . be . true
284
+ } )
285
+ } )
286
+
287
+ describe ( 'autofix rule: payable-fallback' , ( ) => {
288
+ before ( function ( ) {
289
+ params = retrieveParams ( 'payable-fallback/' )
290
+ currentConfig = `${ params . path } ${ params . subpath } .solhint.json`
291
+ currentFile = `${ params . path } ${ params . subpath } Foo1.sol`
292
+ beforeFixFile = `${ params . path } ${ params . subpath } Foo1BeforeFix.sol`
293
+ afterFixFile = `${ params . path } ${ params . subpath } Foo1AfterFix.sol`
294
+ } )
295
+ describe ( '--fix with noPrompt' , ( ) => {
296
+ after ( function ( ) {
297
+ if ( ! E2E ) {
298
+ copyFile ( beforeFixFile , currentFile )
299
+ }
300
+ } )
301
+
302
+ it ( 'should compare Foo1 file with template BEFORE FIX file and they should match (5)' , ( ) => {
303
+ result = compareTextFiles ( currentFile , beforeFixFile )
304
+ expect ( result ) . to . be . true
305
+ } )
306
+
307
+ it ( 'should execute and compare Foo1 with template AFTER FIX and they should match (5)' , ( ) => {
308
+ ( { code, stdout } = shell . exec (
309
+ `${ params . command } ${ params . param1 } -c ${ currentConfig } ${ currentFile } --fix --disc --noPrompt`
310
+ ) )
262
311
263
312
result = compareTextFiles ( currentFile , afterFixFile )
264
313
expect ( result ) . to . be . true
265
314
} )
315
+
316
+ it ( 'should execute and exit with code 1 (5)' , ( ) => {
317
+ expect ( code ) . to . equal ( 1 )
318
+ } )
319
+
320
+ it ( 'should get the right report (5)' , ( ) => {
321
+ const reportLines = stdout . split ( '\n' )
322
+ const finalLine = '11 problems (11 errors, 0 warnings)'
323
+ expect ( reportLines [ reportLines . length - 3 ] ) . to . contain ( finalLine )
324
+ } )
266
325
} )
267
- it ( 'should check FOO1 does not change after test 4' , ( ) => {
326
+
327
+ it ( 'should check FOO1 does not change after test (5)' , ( ) => {
268
328
result = compareTextFiles ( currentFile , beforeFixFile )
269
329
expect ( result ) . to . be . true
270
330
} )
271
331
} )
272
332
} )
273
333
} )
274
334
275
- // FALTA LA COMPARACION DEL FIX CON EL TEMPLATE FIX
276
335
// FALTA LA PRUEBA DEL STORE TO FILE
0 commit comments