Skip to content

Commit 5b897ce

Browse files
committed
Removed useless builderCtx field SketchSourceAfterArduinoPreprocessing
1 parent db9e03f commit 5b897ce

File tree

5 files changed

+67
-52
lines changed

5 files changed

+67
-52
lines changed

legacy/builder/builder.go

Lines changed: 5 additions & 1 deletion
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

legacy/builder/container_add_prototypes.go

Lines changed: 1 addition & 11 deletions
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
}

legacy/builder/preprocess_sketch.go

Lines changed: 0 additions & 3 deletions
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
}

legacy/builder/test/prototypes_adder_test.go

Lines changed: 61 additions & 35 deletions
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
DownloadCoresAndToolsAndLibraries(t)
3440

@@ -63,8 +69,9 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
6369
}
6470
NoError(t, builder.PreprocessSketchWithCtags(ctx))
6571

66-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
67-
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")
72+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
73+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
74+
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")
6875
}
6976

7077
func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
@@ -99,7 +106,8 @@ func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
99106
NoError(t, builder.PreprocessSketchWithCtags(ctx))
100107

101108
preprocessed := LoadAndInterpolate(t, filepath.Join("SketchWithIfDef", "SketchWithIfDef.preprocessed.txt"), ctx)
102-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
109+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
110+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
103111
}
104112

105113
func TestPrototypesAdderBaladuino(t *testing.T) {
@@ -134,7 +142,8 @@ func TestPrototypesAdderBaladuino(t *testing.T) {
134142
NoError(t, builder.PreprocessSketchWithCtags(ctx))
135143

136144
preprocessed := LoadAndInterpolate(t, filepath.Join("Baladuino", "Baladuino.preprocessed.txt"), ctx)
137-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
145+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
146+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
138147
}
139148

140149
func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
@@ -169,7 +178,8 @@ func TestPrototypesAdderCharWithEscapedDoubleQuote(t *testing.T) {
169178
NoError(t, builder.PreprocessSketchWithCtags(ctx))
170179

171180
preprocessed := LoadAndInterpolate(t, filepath.Join("CharWithEscapedDoubleQuote", "CharWithEscapedDoubleQuote.preprocessed.txt"), ctx)
172-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
181+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
182+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
173183
}
174184

175185
func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
@@ -204,7 +214,8 @@ func TestPrototypesAdderIncludeBetweenMultilineComment(t *testing.T) {
204214
NoError(t, builder.PreprocessSketchWithCtags(ctx))
205215

206216
preprocessed := LoadAndInterpolate(t, filepath.Join("IncludeBetweenMultilineComment", "IncludeBetweenMultilineComment.preprocessed.txt"), ctx)
207-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
217+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
218+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
208219
}
209220

210221
func TestPrototypesAdderLineContinuations(t *testing.T) {
@@ -239,7 +250,8 @@ func TestPrototypesAdderLineContinuations(t *testing.T) {
239250
NoError(t, builder.PreprocessSketchWithCtags(ctx))
240251

241252
preprocessed := LoadAndInterpolate(t, filepath.Join("LineContinuations", "LineContinuations.preprocessed.txt"), ctx)
242-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
253+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
254+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
243255
}
244256

245257
func TestPrototypesAdderStringWithComment(t *testing.T) {
@@ -274,7 +286,8 @@ func TestPrototypesAdderStringWithComment(t *testing.T) {
274286
NoError(t, builder.PreprocessSketchWithCtags(ctx))
275287

276288
preprocessed := LoadAndInterpolate(t, filepath.Join("StringWithComment", "StringWithComment.preprocessed.txt"), ctx)
277-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
289+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
290+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
278291
}
279292

280293
func TestPrototypesAdderSketchWithStruct(t *testing.T) {
@@ -309,7 +322,8 @@ func TestPrototypesAdderSketchWithStruct(t *testing.T) {
309322
NoError(t, builder.PreprocessSketchWithCtags(ctx))
310323

311324
preprocessed := LoadAndInterpolate(t, filepath.Join("SketchWithStruct", "SketchWithStruct.preprocessed.txt"), ctx)
312-
obtained := strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1)
325+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
326+
obtained := strings.Replace(preprocessedSketch, "\r\n", "\n", -1)
313327
// ctags based preprocessing removes the space after "dostuff", but this is still OK
314328
// TODO: remove this exception when moving to a more powerful parser
315329
preprocessed = strings.Replace(preprocessed, "void dostuff (A_NEW_TYPE * bar);", "void dostuff(A_NEW_TYPE * bar);", 1)
@@ -351,11 +365,12 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
351365
}
352366
NoError(t, builder.PreprocessSketchWithCtags(ctx))
353367

354-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
355-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 13 "+quotedSketchLocation+"\nvoid setup();\n#line 17 "+quotedSketchLocation+"\nvoid loop();\n#line 13 "+quotedSketchLocation+"\n")
368+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
369+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
370+
require.Contains(t, preprocessedSketch, "#line 13 "+quotedSketchLocation+"\nvoid setup();\n#line 17 "+quotedSketchLocation+"\nvoid loop();\n#line 13 "+quotedSketchLocation+"\n")
356371

357372
preprocessed := LoadAndInterpolate(t, filepath.Join("sketch_with_config", "sketch_with_config.preprocessed.txt"), ctx)
358-
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
373+
require.Equal(t, preprocessed, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
359374
}
360375

361376
func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
@@ -392,8 +407,9 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
392407
}
393408
NoError(t, builder.PreprocessSketchWithCtags(ctx))
394409

395-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
396-
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
410+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
411+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
412+
require.Equal(t, ctx.SketchSourceMerged, preprocessedSketch) // No prototypes added
397413
}
398414

399415
func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
@@ -430,8 +446,9 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
430446
}
431447
NoError(t, builder.PreprocessSketchWithCtags(ctx))
432448

433-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
434-
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
449+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
450+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
451+
require.Equal(t, ctx.SketchSourceMerged, preprocessedSketch) // No prototypes added
435452
}
436453

437454
func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
@@ -468,8 +485,9 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
468485
}
469486
NoError(t, builder.PreprocessSketchWithCtags(ctx))
470487

471-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
472-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 4 "+quotedSketchLocation+"\nvoid setup();\n#line 7 "+quotedSketchLocation+"\nvoid loop();\n#line 1 "+quotedSketchLocation+"\n")
488+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
489+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
490+
require.Contains(t, preprocessedSketch, "#line 4 "+quotedSketchLocation+"\nvoid setup();\n#line 7 "+quotedSketchLocation+"\nvoid loop();\n#line 1 "+quotedSketchLocation+"\n")
473491
}
474492

475493
func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
@@ -506,10 +524,11 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
506524
}
507525
NoError(t, builder.PreprocessSketchWithCtags(ctx))
508526

509-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
527+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
528+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
510529

511530
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"
512-
obtained := ctx.SketchSourceAfterArduinoPreprocessing
531+
obtained := preprocessedSketch
513532
// ctags based preprocessing removes "inline" but this is still OK
514533
// TODO: remove this exception when moving to a more powerful parser
515534
expected = strings.Replace(expected, "static inline int8_t testInline();", "static int8_t testInline();", -1)
@@ -555,8 +574,9 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
555574
}
556575
NoError(t, builder.PreprocessSketchWithCtags(ctx))
557576

558-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
559-
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")
577+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
578+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
579+
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")
560580
}
561581

562582
func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
@@ -593,8 +613,9 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
593613
}
594614
NoError(t, builder.PreprocessSketchWithCtags(ctx))
595615

596-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
597-
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")
616+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
617+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
618+
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")
598619
}
599620

600621
func TestPrototypesAdderSketchWithTypename(t *testing.T) {
@@ -630,9 +651,10 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
630651
}
631652
NoError(t, builder.PreprocessSketchWithCtags(ctx))
632653

633-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
654+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
655+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
634656
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"
635-
obtained := ctx.SketchSourceAfterArduinoPreprocessing
657+
obtained := preprocessedSketch
636658
// ctags based preprocessing ignores line with typename
637659
// TODO: remove this exception when moving to a more powerful parser
638660
expected = strings.Replace(expected, "#line 12 "+quotedSketchLocation+"\ntypename Foo<char>::Bar func();\n", "", -1)
@@ -674,11 +696,12 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
674696
}
675697
NoError(t, builder.PreprocessSketchWithCtags(ctx))
676698

677-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
678-
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")
699+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
700+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
701+
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")
679702

680703
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.txt"), ctx)
681-
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
704+
require.Equal(t, expectedSource, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
682705
}
683706

684707
func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
@@ -715,11 +738,12 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
715738
}
716739
NoError(t, builder.PreprocessSketchWithCtags(ctx))
717740

718-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
719-
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")
741+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
742+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
743+
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")
720744

721745
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.SAM.txt"), ctx)
722-
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
746+
require.Equal(t, expectedSource, strings.Replace(preprocessedSketch, "\r\n", "\n", -1))
723747
}
724748

725749
func TestPrototypesAdderSketchWithConst(t *testing.T) {
@@ -756,8 +780,9 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
756780
}
757781
NoError(t, builder.PreprocessSketchWithCtags(ctx))
758782

759-
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
760-
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")
783+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
784+
require.Contains(t, preprocessedSketch, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
785+
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")
761786
}
762787

763788
func TestPrototypesAdderSketchWithDosEol(t *testing.T) {
@@ -826,5 +851,6 @@ func TestPrototypesAdderSketchWithSubstringFunctionMember(t *testing.T) {
826851
}
827852
NoError(t, builder.PreprocessSketchWithCtags(ctx))
828853

829-
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();")
854+
preprocessedSketch := loadPreprocessedSketch(t, ctx)
855+
require.Contains(t, preprocessedSketch, "class Foo {\nint blooper(int x) { return x+1; }\n};\n\nFoo foo;\n\n#line 7 "+quotedSketchLocation+"\nvoid setup();")
830856
}

legacy/builder/types/context.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ type Context struct {
107107
// Arduino sketch (.ino) to C++ (.cpp) conversion steps:
108108
// 1. Concatenate *.ino files into a single merged source file -> SketchSourceMerged
109109
SketchSourceMerged string
110-
// 3. Do the Arduino preprocessing of the sketch (add missing prototypes) -> SketchSourceAfterArduinoPreprocessing
111-
SketchSourceAfterArduinoPreprocessing string
112110

113111
// Libraries handling
114112
LibrariesManager *librariesmanager.LibrariesManager

0 commit comments

Comments
 (0)