|
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 | )
|
@@ -438,3 +441,52 @@ func TestCTagsToPrototypesFunctionPointers(t *testing.T) {
|
438 | 441 |
|
439 | 442 | require.Equal(t, 2, ctx.PrototypesLineWhereToInsert)
|
440 | 443 | }
|
| 444 | + |
| 445 | +func TestCTagsRunnerSketchWithClassFunction(t *testing.T) { |
| 446 | + DownloadCoresAndToolsAndLibraries(t) |
| 447 | + |
| 448 | + sketchLocation := Abs(t, filepath.Join("sketch_class_function", "sketch_class_function.ino")) |
| 449 | + |
| 450 | + ctx := &types.Context{ |
| 451 | + HardwareFolders: []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"}, |
| 452 | + ToolsFolders: []string{"downloaded_tools"}, |
| 453 | + BuiltInLibrariesFolders: []string{"downloaded_libraries"}, |
| 454 | + OtherLibrariesFolders: []string{"libraries"}, |
| 455 | + SketchLocation: sketchLocation, |
| 456 | + FQBN: "arduino:avr:leonardo", |
| 457 | + ArduinoAPIVersion: "10600", |
| 458 | + Verbose: true, |
| 459 | + } |
| 460 | + |
| 461 | + buildPath := SetupBuildPath(t, ctx) |
| 462 | + defer os.RemoveAll(buildPath) |
| 463 | + |
| 464 | + commands := []types.Command{ |
| 465 | + |
| 466 | + &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, |
| 467 | + |
| 468 | + &builder.ContainerMergeCopySketchFiles{}, |
| 469 | + |
| 470 | + &builder.ContainerFindIncludes{}, |
| 471 | + |
| 472 | + &builder.PrintUsedLibrariesIfVerbose{}, |
| 473 | + &builder.WarnAboutArchIncompatibleLibraries{}, |
| 474 | + &builder.CTagsTargetFileSaver{Source: &ctx.Source, TargetFileName: constants.FILE_CTAGS_TARGET}, |
| 475 | + &ctags.CTagsRunner{}, |
| 476 | + &ctags.CTagsParser{}, |
| 477 | + &CollectCtagsFromPreprocSource{}, |
| 478 | + &ctags.CTagsToPrototypes{}, |
| 479 | + } |
| 480 | + |
| 481 | + for _, command := range commands { |
| 482 | + err := command.Run(ctx) |
| 483 | + NoError(t, err) |
| 484 | + } |
| 485 | + |
| 486 | + prototypes := ctx.Prototypes |
| 487 | + |
| 488 | + require.Equal(t, 3, len(prototypes)) |
| 489 | + require.Equal(t, "void setup();", prototypes[0].Prototype) |
| 490 | + require.Equal(t, "void loop();", prototypes[1].Prototype) |
| 491 | + require.Equal(t, "void asdf();", prototypes[2].Prototype) |
| 492 | +} |
0 commit comments