Skip to content

Commit 5875f09

Browse files
committed
Removed some ctags related fields from builder context
The last piece in RunCTags: parser := &ctags.CTagsParser{} parser.Parse(ctagsStdout, sketch.MainFile) parser.FixCLinkageTagsDeclarations() prototypes, line := parser.GeneratePrototypes() if line != -1 { prototypesLineWhereToInsert = line } has been moved at the beginning of PrototypesAdder. RunCTags now returns the output of ctags instead of `prototypes` and `line`. This also allows to remove the context variables that keeps those information.
1 parent aa9e438 commit 5875f09

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
@@ -62,16 +62,16 @@ func PreprocessSketchWithCtags(ctx *types.Context) error {
6262
ctx.SketchSourceAfterCppPreprocessing = filterSketchSource(ctx.Sketch, bytes.NewReader(src), false)
6363
}
6464

65-
var ctagsStderr []byte
66-
_, ctagsStderr, ctx.PrototypesLineWhereToInsert, ctx.Prototypes, err = RunCTags(
67-
ctx.Sketch, ctx.SketchSourceAfterCppPreprocessing, "sketch_merged.cpp", ctx.BuildProperties, ctx.PreprocPath)
65+
ctagsStdout, ctagsStderr, err := RunCTags(
66+
ctx.SketchSourceAfterCppPreprocessing, "sketch_merged.cpp", ctx.BuildProperties, ctx.PreprocPath)
6867
if ctx.Verbose {
6968
ctx.WriteStderr(ctagsStderr)
7069
}
7170
if err != nil {
7271
return err
7372
}
74-
ctx.SketchSourceAfterArduinoPreprocessing, ctx.PrototypesSection = PrototypesAdder(ctx.SketchSourceMerged, ctx.PrototypesLineWhereToInsert, ctx.LineOffset, ctx.Prototypes, ctx.DebugPreprocessor)
73+
ctx.SketchSourceAfterArduinoPreprocessing = PrototypesAdder(
74+
ctx.Sketch, ctx.SketchSourceMerged, ctagsStdout, ctx.LineOffset, ctx.DebugPreprocessor)
7575

7676
if err := bldr.SketchSaveItemCpp(ctx.Sketch.MainFile, []byte(ctx.SketchSourceAfterArduinoPreprocessing), ctx.SketchBuildPath); err != nil {
7777
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
@@ -36,7 +36,7 @@ func TestCTagsRunner(t *testing.T) {
3636
NoError(t, err)
3737
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, nil, ctx.SketchBuildPath)
3838
NoError(t, err)
39-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
39+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
4040
NoError(t, err)
4141

4242
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -60,7 +60,7 @@ func TestCTagsRunnerSketchWithClass(t *testing.T) {
6060
NoError(t, err)
6161
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
6262
NoError(t, err)
63-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
63+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
6464
NoError(t, err)
6565

6666
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -82,7 +82,7 @@ func TestCTagsRunnerSketchWithTypename(t *testing.T) {
8282
NoError(t, err)
8383
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
8484
NoError(t, err)
85-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
85+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
8686
NoError(t, err)
8787

8888
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -103,7 +103,7 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) {
103103
NoError(t, err)
104104
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
105105
NoError(t, err)
106-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
106+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
107107
NoError(t, err)
108108

109109
quotedSketchLocation := strings.Replace(sketchLocation.String(), "\\", "\\\\", -1)
@@ -123,7 +123,7 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) {
123123
NoError(t, err)
124124
_, source, err := bldr.PrepareSketchBuildPath(ctx.Sketch, ctx.SourceOverride, ctx.SketchBuildPath)
125125
NoError(t, err)
126-
ctagsOutput, _, _, _, err := builder.RunCTags(ctx.Sketch, source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
126+
ctagsOutput, _, err := builder.RunCTags(source, "ctags_target.cpp", ctx.BuildProperties, ctx.PreprocPath)
127127
NoError(t, err)
128128

129129
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
@@ -54,7 +54,7 @@ func TestPrototypesAdderBridgeExample(t *testing.T) {
5454
NoError(t, builder.PreprocessSketchWithCtags(ctx))
5555

5656
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
57-
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)
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")
5858
}
5959

6060
func TestPrototypesAdderSketchWithIfDef(t *testing.T) {
@@ -262,7 +262,7 @@ func TestPrototypesAdderSketchWithConfig(t *testing.T) {
262262
NoError(t, builder.PreprocessSketchWithCtags(ctx))
263263

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

267267
preprocessed := LoadAndInterpolate(t, filepath.Join("sketch_with_config", "sketch_with_config.preprocessed.txt"), ctx)
268268
require.Equal(t, preprocessed, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
@@ -293,7 +293,7 @@ func TestPrototypesAdderSketchNoFunctionsTwoFiles(t *testing.T) {
293293
NoError(t, builder.PreprocessSketchWithCtags(ctx))
294294

295295
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
296-
require.Equal(t, "", ctx.PrototypesSection)
296+
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
297297
}
298298

299299
func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
@@ -320,7 +320,7 @@ func TestPrototypesAdderSketchNoFunctions(t *testing.T) {
320320
NoError(t, builder.PreprocessSketchWithCtags(ctx))
321321

322322
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
323-
require.Equal(t, "", ctx.PrototypesSection)
323+
require.Equal(t, ctx.SketchSourceMerged, ctx.SketchSourceAfterArduinoPreprocessing) // No prototypes added
324324
}
325325

326326
func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
@@ -348,7 +348,7 @@ func TestPrototypesAdderSketchWithDefaultArgs(t *testing.T) {
348348
NoError(t, builder.PreprocessSketchWithCtags(ctx))
349349

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

354354
func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
@@ -378,7 +378,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
378378
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
379379

380380
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.PrototypesSection
381+
obtained := ctx.SketchSourceAfterArduinoPreprocessing
382382
// ctags based preprocessing removes "inline" but this is still OK
383383
// TODO: remove this exception when moving to a more powerful parser
384384
expected = strings.Replace(expected, "static inline int8_t testInline();", "static int8_t testInline();", -1)
@@ -387,7 +387,7 @@ func TestPrototypesAdderSketchWithInlineFunction(t *testing.T) {
387387
// TODO: remove this exception when moving to a more powerful parser
388388
expected = strings.Replace(expected, "__attribute__((always_inline)) uint8_t testAttribute();", "uint8_t testAttribute();", -1)
389389
obtained = strings.Replace(obtained, "__attribute__((always_inline)) uint8_t testAttribute();", "uint8_t testAttribute();", -1)
390-
require.Equal(t, expected, obtained)
390+
require.Contains(t, obtained, expected)
391391
}
392392

393393
func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
@@ -415,7 +415,7 @@ func TestPrototypesAdderSketchWithFunctionSignatureInsideIFDEF(t *testing.T) {
415415
NoError(t, builder.PreprocessSketchWithCtags(ctx))
416416

417417
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
418-
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)
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")
419419
}
420420

421421
func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
@@ -448,7 +448,7 @@ func TestPrototypesAdderSketchWithUSBCON(t *testing.T) {
448448
NoError(t, builder.PreprocessSketchWithCtags(ctx))
449449

450450
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
451-
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)
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")
452452
}
453453

454454
func TestPrototypesAdderSketchWithTypename(t *testing.T) {
@@ -481,12 +481,12 @@ func TestPrototypesAdderSketchWithTypename(t *testing.T) {
481481

482482
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
483483
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.PrototypesSection
484+
obtained := ctx.SketchSourceAfterArduinoPreprocessing
485485
// ctags based preprocessing ignores line with typename
486486
// TODO: remove this exception when moving to a more powerful parser
487487
expected = strings.Replace(expected, "#line 12 "+quotedSketchLocation+"\ntypename Foo<char>::Bar func();\n", "", -1)
488488
obtained = strings.Replace(obtained, "#line 12 "+quotedSketchLocation+"\ntypename Foo<char>::Bar func();\n", "", -1)
489-
require.Equal(t, expected, obtained)
489+
require.Contains(t, obtained, expected)
490490
}
491491

492492
func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
@@ -514,7 +514,7 @@ func TestPrototypesAdderSketchWithIfDef2(t *testing.T) {
514514
NoError(t, builder.PreprocessSketchWithCtags(ctx))
515515

516516
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
517-
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)
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")
518518

519519
expectedSource := LoadAndInterpolate(t, filepath.Join("sketch_with_ifdef", "sketch.preprocessed.txt"), ctx)
520520
require.Equal(t, expectedSource, strings.Replace(ctx.SketchSourceAfterArduinoPreprocessing, "\r\n", "\n", -1))
@@ -545,7 +545,7 @@ func TestPrototypesAdderSketchWithIfDef2SAM(t *testing.T) {
545545
NoError(t, builder.PreprocessSketchWithCtags(ctx))
546546

547547
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
548-
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)
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")
549549

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

578578
require.Contains(t, ctx.SketchSourceAfterArduinoPreprocessing, "#include <Arduino.h>\n#line 1 "+quotedSketchLocation+"\n")
579-
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)
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")
580580
}
581581

582582
func TestPrototypesAdderSketchWithDosEol(t *testing.T) {

0 commit comments

Comments
 (0)