Skip to content

Commit 93d62b2

Browse files
committed
Removed useless builderCtx field SketchSourceAfterArduinoPreprocessing
1 parent 8445fee commit 93d62b2

File tree

5 files changed

+67
-52
lines changed

5 files changed

+67
-52
lines changed

Diff for: legacy/builder/builder.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,11 @@ func (s *Preprocess) Run(ctx *types.Context) error {
157157
}
158158

159159
// Output arduino-preprocessed source
160-
ctx.WriteStdout([]byte(ctx.SketchSourceAfterArduinoPreprocessing))
160+
preprocessedSketch, err := ctx.SketchBuildPath.Join(ctx.Sketch.MainFile.Base() + ".cpp").ReadFile()
161+
if err != nil {
162+
return err
163+
}
164+
ctx.WriteStdout(preprocessedSketch)
161165
return nil
162166
}
163167

Diff for: legacy/builder/container_add_prototypes.go

+1-11
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,5 @@ func PreprocessSketchWithCtags(ctx *types.Context) error {
6868
if ctx.Verbose {
6969
ctx.WriteStderr(ctagsStderr)
7070
}
71-
if err != nil {
72-
return err
73-
}
74-
75-
// Save preprocesssed source in context
76-
if d, err := sketchCpp.ReadFile(); err != nil {
77-
return err
78-
} else {
79-
ctx.SketchSourceAfterArduinoPreprocessing = string(d)
80-
}
81-
return nil
71+
return err
8272
}

Diff for: legacy/builder/preprocess_sketch.go

-3
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,5 @@ func PreprocessSketchWithArduinoPreprocessor(ctx *types.Context) error {
8585
}
8686

8787
result := utils.NormalizeUTF8(buf)
88-
89-
//fmt.Printf("PREPROCESSOR OUTPUT:\n%s\n", output)
90-
ctx.SketchSourceAfterArduinoPreprocessing = string(result)
9188
return bldr.SketchSaveItemCpp(ctx.Sketch.MainFile, result, ctx.SketchBuildPath)
9289
}

Diff for: legacy/builder/test/prototypes_adder_test.go

+61-35
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ import (
2929
"github.com/stretchr/testify/require"
3030
)
3131

32+
func loadPreprocessedSketch(t *testing.T, ctx *types.Context) string {
33+
res, err := ctx.SketchBuildPath.Join(ctx.Sketch.MainFile.Base() + ".cpp").ReadFile()
34+
NoError(t, err)
35+
return string(res)
36+
}
37+
3238
func TestPrototypesAdderBridgeExample(t *testing.T) {
3339
sketchLocation := paths.New("downloaded_libraries", "Bridge", "examples", "Bridge", "Bridge.ino")
3440
quotedSketchLocation := cpp.QuoteString(Abs(t, sketchLocation).String())
@@ -53,8 +59,9 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
5359
}
5460
NoError(t, builder.PreprocessSketchWithCtags(ctx))
5561

56-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
57-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 33 "+quotedSketchLocation+"\nvoid setup();\n#line 46 "+quotedSketchLocation+"\nvoid loop();\n#line 62 "+quotedSketchLocation+"\nvoid process(BridgeClient client);\n#line 82 "+quotedSketchLocation+"\nvoid digitalCommand(BridgeClient client);\n#line 109 "+quotedSketchLocation+"\nvoid analogCommand(BridgeClient client);\n#line 149 "+quotedSketchLocation+"\nvoid modeCommand(BridgeClient client);\n#line 33 "+quotedSketchLocation+"\n")
62+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
63+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
64+
require.Contains(t, preprocessedSketch, "#line 33 "+quotedSketchLocation+"\nvoid setup();\n#line 46 "+quotedSketchLocation+"\nvoid loop();\n#line 62 "+quotedSketchLocation+"\nvoid process(BridgeClient client);\n#line 82 "+quotedSketchLocation+"\nvoid digitalCommand(BridgeClient client);\n#line 109 "+quotedSketchLocation+"\nvoid analogCommand(BridgeClient client);\n#line 149 "+quotedSketchLocation+"\nvoid modeCommand(BridgeClient client);\n#line 33 "+quotedSketchLocation+"\n")
5865
}
5966

6067
func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
@@ -79,7 +86,8 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
7986
NoError(t, builder.PreprocessSketchWithCtags(ctx))
8087

8188
preprocessed := LoadAndInterpolate(t, filepath.Join("SketchWithIfDef", "SketchWithIfDef.preprocessed.txt"), ctx)
82-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
89+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
90+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
8391
}
8492

8593
func TestPrototypesAdderBaladuino(t *testing.T) {
@@ -104,7 +112,8 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
104112
NoError(t, builder.PreprocessSketchWithCtags(ctx))
105113

106114
preprocessed := LoadAndInterpolate(t, filepath.Join("Baladuino", "Baladuino.preprocessed.txt"), ctx)
107-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
115+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
116+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
108117
}
109118

110119
func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
@@ -129,7 +138,8 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
129138
NoError(t, builder.PreprocessSketchWithCtags(ctx))
130139

131140
preprocessed := LoadAndInterpolate(t, filepath.Join("CharWithEscapedDoubleQuote", "CharWithEscapedDoubleQuote.preprocessed.txt"), ctx)
132-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
141+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
142+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
133143
}
134144

135145
func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
@@ -154,7 +164,8 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
154164
NoError(t, builder.PreprocessSketchWithCtags(ctx))
155165

156166
preprocessed := LoadAndInterpolate(t, filepath.Join("IncludeBetweenMultilineComment", "IncludeBetweenMultilineComment.preprocessed.txt"), ctx)
157-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
167+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
168+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
158169
}
159170

160171
func TestPrototypesAdderLineContinuations(t *testing.T) {
@@ -179,7 +190,8 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
179190
NoError(t, builder.PreprocessSketchWithCtags(ctx))
180191

181192
preprocessed := LoadAndInterpolate(t, filepath.Join("LineContinuations", "LineContinuations.preprocessed.txt"), ctx)
182-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
193+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
194+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
183195
}
184196

185197
func TestPrototypesAdderStringWithComment(t *testing.T) {
@@ -204,7 +216,8 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
204216
NoError(t, builder.PreprocessSketchWithCtags(ctx))
205217

206218
preprocessed := LoadAndInterpolate(t, filepath.Join("StringWithComment", "StringWithComment.preprocessed.txt"), ctx)
207-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
219+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
220+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
208221
}
209222

210223
func TestPrototypesAdderSketchWithStruct(t *testing.T) {
@@ -229,7 +242,8 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
229242
NoError(t, builder.PreprocessSketchWithCtags(ctx))
230243

231244
preprocessed := LoadAndInterpolate(t, filepath.Join("SketchWithStruct", "SketchWithStruct.preprocessed.txt"), ctx)
232-
obtained := strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1)
245+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
246+
obtained := strings.Replace(preprocessedSketch, "\r\n", "\n", -1)
233247
// ctags based preprocessing removes the space after "dostuff", but this is still OK
234248
// TODO: remove this exception when moving to a more powerful parser
235249
preprocessed = strings.Replace(preprocessed, "void dostuff (A_NEW_TYPE * bar);", "void dostuff(A_NEW_TYPE * bar);", 1)
@@ -261,11 +275,12 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
261275
}
262276
NoError(t, builder.PreprocessSketchWithCtags(ctx))
263277

264-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
265-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 13 "+quotedSketchLocation+"\nvoid setup();\n#line 17 "+quotedSketchLocation+"\nvoid loop();\n#line 13 "+quotedSketchLocation+"\n")
278+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
279+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
280+
require.Contains(t, preprocessedSketch, "#line 13 "+quotedSketchLocation+"\nvoid setup();\n#line 17 "+quotedSketchLocation+"\nvoid loop();\n#line 13 "+quotedSketchLocation+"\n")
266281

267282
preprocessed := LoadAndInterpolate(t, filepath.Join("sketch_with_config", "sketch_with_config.preprocessed.txt"), ctx)
268-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
283+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
269284
}
270285

271286
func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
@@ -292,8 +307,9 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
292307
}
293308
NoError(t, builder.PreprocessSketchWithCtags(ctx))
294309

295-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
296-
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
310+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
311+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
312+
require.Equal(t, ctx.SketchSourceMerged, preprocessedSketch) // No prototypes added
297313
}
298314

299315
func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
@@ -319,8 +335,9 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
319335
}
320336
NoError(t, builder.PreprocessSketchWithCtags(ctx))
321337

322-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
323-
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
338+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
339+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
340+
require.Equal(t, ctx.SketchSourceMerged, preprocessedSketch) // No prototypes added
324341
}
325342

326343
func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
@@ -347,8 +364,9 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
347364
}
348365
NoError(t, builder.PreprocessSketchWithCtags(ctx))
349366

350-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
351-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 4 "+quotedSketchLocation+"\nvoid setup();\n#line 7 "+quotedSketchLocation+"\nvoid loop();\n#line 1 "+quotedSketchLocation+"\n")
367+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
368+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
369+
require.Contains(t, preprocessedSketch, "#line 4 "+quotedSketchLocation+"\nvoid setup();\n#line 7 "+quotedSketchLocation+"\nvoid loop();\n#line 1 "+quotedSketchLocation+"\n")
352370
}
353371

354372
func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
@@ -375,10 +393,11 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
375393
}
376394
NoError(t, builder.PreprocessSketchWithCtags(ctx))
377395

378-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
396+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
397+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
379398

380399
expected := "#line 1 " + quotedSketchLocation + "\nvoid setup();\n#line 2 " + quotedSketchLocation + "\nvoid loop();\n#line 4 " + quotedSketchLocation + "\nshort unsigned int testInt();\n#line 8 " + quotedSketchLocation + "\nstatic int8_t testInline();\n#line 12 " + quotedSketchLocation + "\n__attribute__((always_inline)) uint8_t testAttribute();\n#line 1 " + quotedSketchLocation + "\n"
381-
obtained := ctx.SketchSourceAfterArduinoPreprocessing
400+
obtained := preprocessedSketch
382401
// ctags based preprocessing removes "inline" but this is still OK
383402
// TODO: remove this exception when moving to a more powerful parser
384403
expected = strings.Replace(expected, "static inline int8_t testInline();", "static int8_t testInline();", -1)
@@ -414,8 +433,9 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
414433
}
415434
NoError(t, builder.PreprocessSketchWithCtags(ctx))
416435

417-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
418-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 1 "+quotedSketchLocation+"\nvoid setup();\n#line 3 "+quotedSketchLocation+"\nvoid loop();\n#line 15 "+quotedSketchLocation+"\nint8_t adalight();\n#line 1 "+quotedSketchLocation+"\n")
436+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
437+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
438+
require.Contains(t, preprocessedSketch, "#line 1 "+quotedSketchLocation+"\nvoid setup();\n#line 3 "+quotedSketchLocation+"\nvoid loop();\n#line 15 "+quotedSketchLocation+"\nint8_t adalight();\n#line 1 "+quotedSketchLocation+"\n")
419439
}
420440

421441
func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
@@ -447,8 +467,9 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
447467
}
448468
NoError(t, builder.PreprocessSketchWithCtags(ctx))
449469

450-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
451-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 5 "+quotedSketchLocation+"\nvoid ciao();\n#line 10 "+quotedSketchLocation+"\nvoid setup();\n#line 15 "+quotedSketchLocation+"\nvoid loop();\n#line 5 "+quotedSketchLocation+"\n")
470+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
471+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
472+
require.Contains(t, preprocessedSketch, "#line 5 "+quotedSketchLocation+"\nvoid ciao();\n#line 10 "+quotedSketchLocation+"\nvoid setup();\n#line 15 "+quotedSketchLocation+"\nvoid loop();\n#line 5 "+quotedSketchLocation+"\n")
452473
}
453474

454475
func TestPrototypesAdderSketchWithTypename(t *testing.T) {
@@ -479,9 +500,10 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
479500
}
480501
NoError(t, builder.PreprocessSketchWithCtags(ctx))
481502

482-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
503+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
504+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
483505
expected := "#line 6 " + quotedSketchLocation + "\nvoid setup();\n#line 10 " + quotedSketchLocation + "\nvoid loop();\n#line 12 " + quotedSketchLocation + "\ntypename Foo<char>::Bar func();\n#line 6 " + quotedSketchLocation + "\n"
484-
obtained := ctx.SketchSourceAfterArduinoPreprocessing
506+
obtained := preprocessedSketch
485507
// ctags based preprocessing ignores line with typename
486508
// TODO: remove this exception when moving to a more powerful parser
487509
expected = strings.Replace(expected, "#line 12 "+quotedSketchLocation+"\ntypename Foo<char>::Bar func();\n", "", -1)
@@ -513,11 +535,12 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
513535
}
514536
NoError(t, builder.PreprocessSketchWithCtags(ctx))
515537

516-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
517-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 5 "+quotedSketchLocation+"\nvoid elseBranch();\n#line 9 "+quotedSketchLocation+"\nvoid f1();\n#line 10 "+quotedSketchLocation+"\nvoid f2();\n#line 12 "+quotedSketchLocation+"\nvoid setup();\n#line 14 "+quotedSketchLocation+"\nvoid loop();\n#line 5 "+quotedSketchLocation+"\n")
538+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
539+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
540+
require.Contains(t, preprocessedSketch, "#line 5 "+quotedSketchLocation+"\nvoid elseBranch();\n#line 9 "+quotedSketchLocation+"\nvoid f1();\n#line 10 "+quotedSketchLocation+"\nvoid f2();\n#line 12 "+quotedSketchLocation+"\nvoid setup();\n#line 14 "+quotedSketchLocation+"\nvoid loop();\n#line 5 "+quotedSketchLocation+"\n")
518541

519542
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.txt"), ctx)
520-
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
543+
require.Equal(t, expectedSource, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
521544
}
522545

523546
func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
@@ -544,11 +567,12 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
544567
}
545568
NoError(t, builder.PreprocessSketchWithCtags(ctx))
546569

547-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
548-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 2 "+quotedSketchLocation+"\nvoid ifBranch();\n#line 9 "+quotedSketchLocation+"\nvoid f1();\n#line 10 "+quotedSketchLocation+"\nvoid f2();\n#line 12 "+quotedSketchLocation+"\nvoid setup();\n#line 14 "+quotedSketchLocation+"\nvoid loop();\n#line 2 "+quotedSketchLocation+"\n")
570+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
571+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
572+
require.Contains(t, preprocessedSketch, "#line 2 "+quotedSketchLocation+"\nvoid ifBranch();\n#line 9 "+quotedSketchLocation+"\nvoid f1();\n#line 10 "+quotedSketchLocation+"\nvoid f2();\n#line 12 "+quotedSketchLocation+"\nvoid setup();\n#line 14 "+quotedSketchLocation+"\nvoid loop();\n#line 2 "+quotedSketchLocation+"\n")
549573

550574
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.SAM.txt"), ctx)
551-
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
575+
require.Equal(t, expectedSource, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
552576
}
553577

554578
func TestPrototypesAdderSketchWithConst(t *testing.T) {
@@ -575,8 +599,9 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
575599
}
576600
NoError(t, builder.PreprocessSketchWithCtags(ctx))
577601

578-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
579-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 1 "+quotedSketchLocation+"\nvoid setup();\n#line 2 "+quotedSketchLocation+"\nvoid loop();\n#line 4 "+quotedSketchLocation+"\nconst __FlashStringHelper* test();\n#line 6 "+quotedSketchLocation+"\nconst int test3();\n#line 8 "+quotedSketchLocation+"\nvolatile __FlashStringHelper* test2();\n#line 10 "+quotedSketchLocation+"\nvolatile int test4();\n#line 1 "+quotedSketchLocation+"\n")
602+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
603+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
604+
require.Contains(t, preprocessedSketch, "#line 1 "+quotedSketchLocation+"\nvoid setup();\n#line 2 "+quotedSketchLocation+"\nvoid loop();\n#line 4 "+quotedSketchLocation+"\nconst __FlashStringHelper* test();\n#line 6 "+quotedSketchLocation+"\nconst int test3();\n#line 8 "+quotedSketchLocation+"\nvolatile __FlashStringHelper* test2();\n#line 10 "+quotedSketchLocation+"\nvolatile int test4();\n#line 1 "+quotedSketchLocation+"\n")
580605
}
581606

582607
func TestPrototypesAdderSketchWithDosEol(t *testing.T) {
@@ -626,5 +651,6 @@ func TestPrototypesAdderSketchWithSubstringFunctionMember(t *testing.T) {
626651
}
627652
NoError(t, builder.PreprocessSketchWithCtags(ctx))
628653

629-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "class Foo {\nint blooper(int x) { return x+1; }\n};\n\nFoo foo;\n\n#line 7 "+quotedSketchLocation+"\nvoid setup();")
654+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
655+
require.Contains(t, preprocessedSketch, "class Foo {\nint blooper(int x) { return x+1; }\n};\n\nFoo foo;\n\n#line 7 "+quotedSketchLocation+"\nvoid setup();")
630656
}

Diff for: legacy/builder/types/context.go

-2
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,6 @@ type Context struct {
104104
// Arduino sketch (.ino) to C++ (.cpp) conversion steps:
105105
// 1. Concatenate *.ino files into a single merged source file -> SketchSourceMerged
106106
SketchSourceMerged string
107-
// 3. Do the Arduino preprocessing of the sketch (add missing prototypes) -> SketchSourceAfterArduinoPreprocessing
108-
SketchSourceAfterArduinoPreprocessing string
109107

110108
// Libraries handling
111109
LibrariesManager *librariesmanager.LibrariesManager

0 commit comments

Comments
 (0)