Skip to content

Commit 7b6fbf5

Browse files
committed
add test to target issue arduino#140
Signed-off-by: Martino Facchin <[email protected]>
1 parent 95d67a3 commit 7b6fbf5

File tree

2 files changed

+60
-0
lines changed

2 files changed

+60
-0
lines changed

src/arduino.cc/builder/test/ctags_to_prototypes_test.go

+52
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@
3030
package test
3131

3232
import (
33+
"arduino.cc/builder"
34+
"arduino.cc/builder/constants"
3335
"arduino.cc/builder/ctags"
3436
"arduino.cc/builder/types"
3537
"github.com/stretchr/testify/require"
3638
"io/ioutil"
39+
"os"
3740
"path/filepath"
3841
"testing"
3942
)
@@ -459,3 +462,52 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
459462

460463
require.Equal(t, 2, ctx.PrototypesLineWhereToInsert)
461464
}
465+
466+
func TestCTagsRunnerSketchWithClassFunction(t *testing.T) {
467+
DownloadCoresAndToolsAndLibraries(t)
468+
469+
sketchLocation := Abs(t, filepath.Join("sketch_with_class", "sketch_class_function.ino"))
470+
471+
ctx := &types.Context{
472+
HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"},
473+
ToolsFolders: []string{"downloaded_tools"},
474+
BuiltInLibrariesFolders: []string{"downloaded_libraries"},
475+
OtherLibrariesFolders: []string{"libraries"},
476+
SketchLocation: sketchLocation,
477+
FQBN: "arduino:avr:leonardo",
478+
ArduinoAPIVersion: "10600",
479+
Verbose: true,
480+
}
481+
482+
buildPath := SetupBuildPath(t, ctx)
483+
defer os.RemoveAll(buildPath)
484+
485+
commands := []types.Command{
486+
487+
&builder.ContainerSetupHardwareToolsLibsSketchAndProps{},
488+
489+
&builder.ContainerMergeCopySketchFiles{},
490+
491+
&builder.ContainerFindIncludes{},
492+
493+
&builder.PrintUsedLibrariesIfVerbose{},
494+
&builder.WarnAboutArchIncompatibleLibraries{},
495+
&builder.CTagsTargetFileSaver{Source: &ctx.Source, TargetFileName: constants.FILE_CTAGS_TARGET},
496+
&ctags.CTagsRunner{},
497+
&ctags.CTagsParser{},
498+
&CollectCtagsFromPreprocSource{},
499+
&ctags.CTagsToPrototypes{},
500+
}
501+
502+
for _, command := range commands {
503+
err := command.Run(ctx)
504+
NoError(t, err)
505+
}
506+
507+
prototypes := ctx.Prototypes
508+
509+
require.Equal(t, 3, len(prototypes))
510+
require.Equal(t, "void setup();", prototypes[0].Prototype)
511+
require.Equal(t, "void loop();", prototypes[1].Prototype)
512+
require.Equal(t, "void asdf();", prototypes[2].Prototype)
513+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class test {
2+
void asdf() {}
3+
};
4+
void setup() {
5+
asdf();
6+
}
7+
void loop() {}
8+
void asdf() {}

0 commit comments

Comments
 (0)