Skip to content

Commit bf2f521

Browse files
committed
Removed some ctags related fields from builder context
1 parent 48f4a2a commit bf2f521

File tree

6 files changed

+51
-62
lines changed

6 files changed

+51
-62
lines changed

legacy/builder/container_add_prototypes.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,16 @@ func PreprocessSketchWithCtags(ctx *types.Context) error {
5656
ctx.SketchSourceAfterCppPreprocessing = bldr.FilterSketchSource(ctx.Sketch, bytes.NewReader(src), false)
5757
}
5858

59-
var ctagsStderr []byte
60-
_, ctagsStderr, ctx.PrototypesLineWhereToInsert, ctx.Prototypes, err = RunCTags(
61-
ctx.Sketch, ctx.SketchSourceAfterCppPreprocessing, "sketch_merged.cpp", ctx.BuildProperties, ctx.PreprocPath)
59+
ctagsStdout, ctagsStderr, err := RunCTags(
60+
ctx.SketchSourceAfterCppPreprocessing, "sketch_merged.cpp", ctx.BuildProperties, ctx.PreprocPath)
6261
if ctx.Verbose {
6362
ctx.WriteStderr(ctagsStderr)
6463
}
6564
if err != nil {
6665
return err
6766
}
68-
ctx.SketchSourceAfterArduinoPreprocessing, ctx.PrototypesSection = PrototypesAdder(ctx.SketchSourceMerged, ctx.PrototypesLineWhereToInsert, ctx.LineOffset, ctx.Prototypes, ctx.DebugPreprocessor)
67+
ctx.SketchSourceAfterArduinoPreprocessing = PrototypesAdder(
68+
ctx.Sketch, ctx.SketchSourceMerged, ctagsStdout, ctx.LineOffset, ctx.DebugPreprocessor)
6969

7070
if err := bldr.SketchSaveItemCpp(ctx.Sketch.MainFile, []byte(ctx.SketchSourceAfterArduinoPreprocessing), ctx.SketchBuildPath); err != nil {
7171
return errors.WithStack(err)

legacy/builder/ctags_runner.go

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@ import (
1919
"bytes"
2020
"strings"
2121

22-
"github.com/arduino/arduino-cli/arduino/sketch"
2322
"github.com/arduino/arduino-cli/executils"
24-
"github.com/arduino/arduino-cli/legacy/builder/ctags"
2523
"github.com/arduino/go-paths-helper"
2624
properties "github.com/arduino/go-properties-orderedmap"
2725
"github.com/pkg/errors"
2826
)
2927

30-
func RunCTags(sketch *sketch.Sketch, source string, targetFileName string, buildProperties *properties.Map, preprocPath *paths.Path,
31-
) (ctagsStdout, ctagsStderr []byte, prototypesLineWhereToInsert int, prototypes []*ctags.Prototype, err error) {
32-
if err = preprocPath.MkdirAll(); err != nil {
33-
return
28+
func RunCTags(source string, targetFileName string, buildProperties *properties.Map, preprocPath *paths.Path,
29+
) ([]byte, []byte, error) {
30+
if err := preprocPath.MkdirAll(); err != nil {
31+
return nil, nil, err
3432
}
3533

3634
ctagsTargetFilePath := preprocPath.Join(targetFileName)
37-
if err = ctagsTargetFilePath.WriteFile([]byte(source)); err != nil {
38-
return
35+
if err := ctagsTargetFilePath.WriteFile([]byte(source)); err != nil {
36+
return nil, nil, err
3937
}
4038

4139
ctagsBuildProperties := properties.NewMap()
@@ -48,40 +46,25 @@ func RunCTags(sketch *sketch.Sketch, source string, targetFileName string, build
4846

4947
pattern := ctagsBuildProperties.Get("pattern")
5048
if pattern == "" {
51-
err = errors.Errorf(tr("%s pattern is missing"), "ctags")
52-
return
49+
return nil, nil, errors.Errorf(tr("%s pattern is missing"), "ctags")
5350
}
5451

5552
commandLine := ctagsBuildProperties.ExpandPropsInString(pattern)
5653
parts, err := properties.SplitQuotedString(commandLine, `"'`, false)
5754
if err != nil {
58-
return
55+
return nil, nil, err
5956
}
6057
proc, err := executils.NewProcess(nil, parts...)
6158
if err != nil {
62-
return
59+
return nil, nil, err
6360
}
6461
stdout := &bytes.Buffer{}
6562
stderr := &bytes.Buffer{}
6663
proc.RedirectStdoutTo(stdout)
6764
proc.RedirectStderrTo(stderr)
6865
if err = proc.Run(); err != nil {
69-
return
66+
return nil, nil, err
7067
}
71-
stderr.WriteString(strings.Join(parts, " "))
72-
ctagsStdout = stdout.Bytes()
73-
ctagsStderr = stderr.Bytes()
74-
if err != nil {
75-
return
76-
}
77-
78-
parser := &ctags.CTagsParser{}
79-
parser.Parse(ctagsStdout, sketch.MainFile)
80-
parser.FixCLinkageTagsDeclarations()
81-
82-
prototypes, line := parser.GeneratePrototypes()
83-
if line != -1 {
84-
prototypesLineWhereToInsert = line
85-
}
86-
return
68+
_, _ = stderr.WriteString(strings.Join(parts, " "))
69+
return stdout.Bytes(), stderr.Bytes(), err
8770
}

legacy/builder/prototypes_adder.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,33 @@ import (
2020
"strconv"
2121
"strings"
2222

23+
"github.com/arduino/arduino-cli/arduino/sketch"
2324
"github.com/arduino/arduino-cli/legacy/builder/constants"
2425
"github.com/arduino/arduino-cli/legacy/builder/ctags"
2526
"github.com/arduino/arduino-cli/legacy/builder/utils"
2627
)
2728

28-
func PrototypesAdder(source string, firstFunctionLine, lineOffset int, prototypes []*ctags.Prototype, debugOutput bool) (preprocessedSource, prototypeSection string) {
29+
func PrototypesAdder(sketch *sketch.Sketch, source string, ctagsStdout []byte, lineOffset int, debugOutput bool) string {
30+
parser := &ctags.CTagsParser{}
31+
parser.Parse(ctagsStdout, sketch.MainFile)
32+
parser.FixCLinkageTagsDeclarations()
33+
34+
prototypes, firstFunctionLine := parser.GeneratePrototypes()
35+
if firstFunctionLine == -1 {
36+
firstFunctionLine = 0
37+
}
38+
2939
source = strings.Replace(source, "\r\n", "\n", -1)
3040
source = strings.Replace(source, "\r", "\n", -1)
3141
sourceRows := strings.Split(source, "\n")
3242
if isFirstFunctionOutsideOfSource(firstFunctionLine, sourceRows) {
33-
return
43+
return ""
3444
}
3545

3646
insertionLine := firstFunctionLine + lineOffset - 1
3747
firstFunctionChar := len(strings.Join(sourceRows[:insertionLine], "\n")) + 1
38-
prototypeSection = composePrototypeSection(firstFunctionLine, prototypes)
39-
preprocessedSource = source[:firstFunctionChar] + prototypeSection + source[firstFunctionChar:]
48+
prototypeSection := composePrototypeSection(firstFunctionLine, prototypes)
49+
preprocessedSource := source[:firstFunctionChar] + prototypeSection + source[firstFunctionChar:]
4050

4151
if debugOutput {
4252
fmt.Println("#PREPROCESSED SOURCE")
@@ -53,7 +63,7 @@ func PrototypesAdder(source string, firstFunctionLine, lineOffset int, prototype
5363
}
5464
fmt.Println("#END OF PREPROCESSED SOURCE")
5565
}
56-
return
66+
return preprocessedSource
5767
}
5868

5969
func composePrototypeSection(line int, prototypes []*ctags.Prototype) string {

legacy/builder/test/ctags_runner_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestCTagsRunner(t *testing.T) {
4949
NoError(t, err)
5050
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, nil, ctx.SketchBuildPath)
5151
NoError(t, err)
52-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
52+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
5353
NoError(t, err)
5454

5555
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -85,7 +85,7 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
8585
NoError(t, err)
8686
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
8787
NoError(t, err)
88-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
88+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
8989
NoError(t, err)
9090

9191
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -119,7 +119,7 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
119119
NoError(t, err)
120120
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
121121
NoError(t, err)
122-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
122+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
123123
NoError(t, err)
124124

125125
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -152,7 +152,7 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
152152
NoError(t, err)
153153
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
154154
NoError(t, err)
155-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
155+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
156156
NoError(t, err)
157157

158158
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -184,7 +184,7 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
184184
NoError(t, err)
185185
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
186186
NoError(t, err)
187-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
187+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
188188
NoError(t, err)
189189

190190
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)

legacy/builder/test/prototypes_adder_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
6464
NoError(t, builder.PreprocessSketchWithCtags(ctx))
6565

6666
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
67-
require.Equal(t, "#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", ctx.PrototypesSection)
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")
6868
}
6969

7070
func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
@@ -352,7 +352,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
352352
NoError(t, builder.PreprocessSketchWithCtags(ctx))
353353

354354
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
355-
require.Equal(t, "#line 13 "+quotedSketchLocation+"\nvoid setup();\n#line 17 "+quotedSketchLocation+"\nvoid loop();\n#line 13 "+quotedSketchLocation+"\n", ctx.PrototypesSection)
355+
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 13 "+quotedSketchLocation+"\nvoid setup();\n#line 17 "+quotedSketchLocation+"\nvoid loop();\n#line 13 "+quotedSketchLocation+"\n")
356356

357357
preprocessed := LoadAndInterpolate(t, filepath.Join("sketch_with_config", "sketch_with_config.preprocessed.txt"), ctx)
358358
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
@@ -393,7 +393,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
393393
NoError(t, builder.PreprocessSketchWithCtags(ctx))
394394

395395
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
396-
require.Equal(t, "", ctx.PrototypesSection)
396+
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
397397
}
398398

399399
func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
@@ -431,7 +431,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
431431
NoError(t, builder.PreprocessSketchWithCtags(ctx))
432432

433433
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
434-
require.Equal(t, "", ctx.PrototypesSection)
434+
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
435435
}
436436

437437
func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
@@ -469,7 +469,7 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
469469
NoError(t, builder.PreprocessSketchWithCtags(ctx))
470470

471471
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
472-
require.Equal(t, "#line 4 "+quotedSketchLocation+"\nvoid setup();\n#line 7 "+quotedSketchLocation+"\nvoid loop();\n#line 1 "+quotedSketchLocation+"\n", ctx.PrototypesSection)
472+
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#line 4 "+quotedSketchLocation+"\nvoid setup();\n#line 7 "+quotedSketchLocation+"\nvoid loop();\n#line 1 "+quotedSketchLocation+"\n")
473473
}
474474

475475
func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
@@ -509,7 +509,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
509509
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
510510

511511
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.PrototypesSection
512+
obtained := ctx.SketchSourceAfterArduinoPreprocessing
513513
// ctags based preprocessing removes "inline" but this is still OK
514514
// TODO: remove this exception when moving to a more powerful parser
515515
expected = strings.Replace(expected, "static inline int8_t testInline();", "static int8_t testInline();", -1)
@@ -518,7 +518,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
518518
// TODO: remove this exception when moving to a more powerful parser
519519
expected = strings.Replace(expected, "__attribute__((always_inline)) uint8_t testAttribute();", "uint8_t testAttribute();", -1)
520520
obtained = strings.Replace(obtained, "__attribute__((always_inline)) uint8_t testAttribute();", "uint8_t testAttribute();", -1)
521-
require.Equal(t, expected, obtained)
521+
require.Contains(t, obtained, expected)
522522
}
523523

524524
func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
@@ -556,7 +556,7 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
556556
NoError(t, builder.PreprocessSketchWithCtags(ctx))
557557

558558
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
559-
require.Equal(t, "#line 1 "+quotedSketchLocation+"\nvoid setup();\n#line 3 "+quotedSketchLocation+"\nvoid loop();\n#line 15 "+quotedSketchLocation+"\nint8_t adalight();\n#line 1 "+quotedSketchLocation+"\n", ctx.PrototypesSection)
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")
560560
}
561561

562562
func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
@@ -594,7 +594,7 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
594594
NoError(t, builder.PreprocessSketchWithCtags(ctx))
595595

596596
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
597-
require.Equal(t, "#line 5 "+quotedSketchLocation+"\nvoid ciao();\n#line 10 "+quotedSketchLocation+"\nvoid setup();\n#line 15 "+quotedSketchLocation+"\nvoid loop();\n#line 5 "+quotedSketchLocation+"\n", ctx.PrototypesSection)
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")
598598
}
599599

600600
func TestPrototypesAdderSketchWithTypename(t *testing.T) {
@@ -632,12 +632,12 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
632632

633633
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
634634
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.PrototypesSection
635+
obtained := ctx.SketchSourceAfterArduinoPreprocessing
636636
// ctags based preprocessing ignores line with typename
637637
// TODO: remove this exception when moving to a more powerful parser
638638
expected = strings.Replace(expected, "#line 12 "+quotedSketchLocation+"\ntypename Foo<char>::Bar func();\n", "", -1)
639639
obtained = strings.Replace(obtained, "#line 12 "+quotedSketchLocation+"\ntypename Foo<char>::Bar func();\n", "", -1)
640-
require.Equal(t, expected, obtained)
640+
require.Contains(t, obtained, expected)
641641
}
642642

643643
func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
@@ -675,7 +675,7 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
675675
NoError(t, builder.PreprocessSketchWithCtags(ctx))
676676

677677
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
678-
require.Equal(t, "#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", ctx.PrototypesSection)
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")
679679

680680
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.txt"), ctx)
681681
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
@@ -716,7 +716,7 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
716716
NoError(t, builder.PreprocessSketchWithCtags(ctx))
717717

718718
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
719-
require.Equal(t, "#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", ctx.PrototypesSection)
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")
720720

721721
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.SAM.txt"), ctx)
722722
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
@@ -757,7 +757,7 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) {
757757
NoError(t, builder.PreprocessSketchWithCtags(ctx))
758758

759759
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
760-
require.Equal(t, "#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", ctx.PrototypesSection)
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")
761761
}
762762

763763
func TestPrototypesAdderSketchWithDosEol(t *testing.T) {

0 commit comments

Comments
 (0)