@@ -34,7 +34,6 @@ import (
34
34
"arduino.cc/builder/constants"
35
35
"arduino.cc/builder/types"
36
36
"github.com/stretchr/testify/require"
37
- "io/ioutil"
38
37
"os"
39
38
"path/filepath"
40
39
"strings"
@@ -117,11 +116,7 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
117
116
NoError (t , err )
118
117
}
119
118
120
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch2" , "SketchWithIfDef.preprocessed.txt" ))
121
- NoError (t , err )
122
-
123
- preprocessed := string (bytes )
124
-
119
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch2" , "SketchWithIfDef.preprocessed.txt" ), context )
125
120
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
126
121
}
127
122
@@ -161,11 +156,7 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
161
156
NoError (t , err )
162
157
}
163
158
164
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch3" , "Baladuino.preprocessed.txt" ))
165
- NoError (t , err )
166
-
167
- preprocessed := string (bytes )
168
-
159
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch3" , "Baladuino.preprocessed.txt" ), context )
169
160
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
170
161
}
171
162
@@ -205,11 +196,7 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
205
196
NoError (t , err )
206
197
}
207
198
208
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch4" , "CharWithEscapedDoubleQuote.preprocessed.txt" ))
209
- NoError (t , err )
210
-
211
- preprocessed := string (bytes )
212
-
199
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch4" , "CharWithEscapedDoubleQuote.preprocessed.txt" ), context )
213
200
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
214
201
}
215
202
@@ -249,11 +236,7 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
249
236
NoError (t , err )
250
237
}
251
238
252
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch5" , "IncludeBetweenMultilineComment.preprocessed.txt" ))
253
- NoError (t , err )
254
-
255
- preprocessed := string (bytes )
256
-
239
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch5" , "IncludeBetweenMultilineComment.preprocessed.txt" ), context )
257
240
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
258
241
}
259
242
@@ -293,11 +276,7 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
293
276
NoError (t , err )
294
277
}
295
278
296
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch6" , "LineContinuations.preprocessed.txt" ))
297
- NoError (t , err )
298
-
299
- preprocessed := string (bytes )
300
-
279
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch6" , "LineContinuations.preprocessed.txt" ), context )
301
280
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
302
281
}
303
282
@@ -337,11 +316,7 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
337
316
NoError (t , err )
338
317
}
339
318
340
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch7" , "StringWithComment.preprocessed.txt" ))
341
- NoError (t , err )
342
-
343
- preprocessed := string (bytes )
344
-
319
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch7" , "StringWithComment.preprocessed.txt" ), context )
345
320
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
346
321
}
347
322
@@ -381,11 +356,7 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
381
356
NoError (t , err )
382
357
}
383
358
384
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch8" , "SketchWithStruct.preprocessed.txt" ))
385
- NoError (t , err )
386
-
387
- preprocessed := string (bytes )
388
-
359
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch8" , "SketchWithStruct.preprocessed.txt" ), context )
389
360
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
390
361
}
391
362
@@ -428,11 +399,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
428
399
require .Equal (t , "#include <Arduino.h>\n #line 1\n " , context [constants .CTX_INCLUDE_SECTION ].(string ))
429
400
require .Equal (t , "void setup();\n void loop();\n #line 13\n " , context [constants .CTX_PROTOTYPE_SECTION ].(string ))
430
401
431
- bytes , err := ioutil .ReadFile (filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ))
432
- NoError (t , err )
433
-
434
- preprocessed := string (bytes )
435
-
402
+ preprocessed := LoadAndInterpolate (t , filepath .Join ("sketch_with_config" , "sketch_with_config.preprocessed.txt" ), context )
436
403
require .Equal (t , preprocessed , strings .Replace (context [constants .CTX_SOURCE ].(string ), "\r \n " , "\n " , - 1 ))
437
404
}
438
405
0 commit comments