|
30 | 30 | package test
|
31 | 31 |
|
32 | 32 | import (
|
| 33 | + "arduino.cc/builder" |
| 34 | + "arduino.cc/builder/constants" |
33 | 35 | "arduino.cc/builder/ctags"
|
34 | 36 | "arduino.cc/builder/types"
|
35 | 37 | "github.com/stretchr/testify/require"
|
36 | 38 | "io/ioutil"
|
| 39 | + "os" |
37 | 40 | "path/filepath"
|
38 | 41 | "testing"
|
39 | 42 | )
|
@@ -459,3 +462,52 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
|
459 | 462 |
|
460 | 463 | require.Equal(t, 2, ctx.PrototypesLineWhereToInsert)
|
461 | 464 | }
|
| 465 | + |
| 466 | +func TestCTagsRunnerSketchWithClassFunction(t *testing.T) { |
| 467 | + DownloadCoresAndToolsAndLibraries(t) |
| 468 | + |
| 469 | + sketchLocation := Abs(t, filepath.Join("sketch_class_function", "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 | +} |
0 commit comments