From 158c62617ec24d0e7718bd29f3eb89379b97c7f0 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 23 Feb 2016 12:25:00 +0100 Subject: [PATCH 1/3] add test for templates containing shifts Signed-off-by: Martino Facchin --- .../builder/test/ctags_runner_test.go | 44 +++++++++++++++++++ .../template_and_shift.cpp | 10 +++++ 2 files changed, 54 insertions(+) create mode 100644 src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp diff --git a/src/arduino.cc/builder/test/ctags_runner_test.go b/src/arduino.cc/builder/test/ctags_runner_test.go index ab75fed3..59209bc0 100644 --- a/src/arduino.cc/builder/test/ctags_runner_test.go +++ b/src/arduino.cc/builder/test/ctags_runner_test.go @@ -231,3 +231,47 @@ func TestCTagsRunnerSketchWithNamespace(t *testing.T) { require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1)) } + +func TestCTagsRunnerSketchWithTemplates(t *testing.T) { + DownloadCoresAndToolsAndLibraries(t) + + context := make(map[string]interface{}) + + buildPath := SetupBuildPath(t, context) + defer os.RemoveAll(buildPath) + + sketchLocation := Abs(t, filepath.Join("sketch_with_templates_and_shift", "template_and_shift.cpp")) + context[constants.CTX_HARDWARE_FOLDERS] = []string{filepath.Join("..", "hardware"), "hardware", "downloaded_hardware"} + context[constants.CTX_TOOLS_FOLDERS] = []string{"downloaded_tools"} + context[constants.CTX_FQBN] = "arduino:avr:leonardo" + context[constants.CTX_SKETCH_LOCATION] = sketchLocation + context[constants.CTX_BUILD_PROPERTIES_RUNTIME_IDE_VERSION] = "10600" + context[constants.CTX_BUILT_IN_LIBRARIES_FOLDERS] = []string{"downloaded_libraries"} + context[constants.CTX_OTHER_LIBRARIES_FOLDERS] = []string{"libraries"} + context[constants.CTX_VERBOSE] = true + + commands := []types.Command{ + &builder.SetupHumanLoggerIfMissing{}, + + &builder.ContainerSetupHardwareToolsLibsSketchAndProps{}, + + &builder.ContainerMergeCopySketchFiles{}, + + &builder.ContainerFindIncludes{}, + + &builder.PrintUsedLibrariesIfVerbose{}, + &builder.WarnAboutArchIncompatibleLibraries{}, + &builder.CTagsTargetFileSaver{SourceField: constants.CTX_SOURCE, TargetFileName: constants.FILE_CTAGS_TARGET}, + &ctags.CTagsRunner{}, + } + + for _, command := range commands { + err := command.Run(context) + NoError(t, err) + } + + sketchLocation = strings.Replace(sketchLocation, "\\", "\\\\", -1) + expectedOutput := "printGyro\t" + sketchLocation + "\t/^void printGyro()$/;\"\tkind:function\tline:8\tsignature:()\treturntype:void\n" + + require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1)) +} diff --git a/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp b/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp new file mode 100644 index 00000000..67566f22 --- /dev/null +++ b/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp @@ -0,0 +1,10 @@ +template<> class FastPin<0> : public _ARMPIN<0, 10, 1 << 10, 0> {};; + +template class OtherType> class NestedTemplateClass +{ + OtherType f; +}; + +void printGyro() +{ +} From 28ab01826f683eaa4e5000f88975b9aa03ac5c5d Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 23 Feb 2016 13:01:46 +0100 Subject: [PATCH 2/3] also test for expression in generics --- src/arduino.cc/builder/test/ctags_runner_test.go | 2 +- .../test/sketch_with_templates_and_shift/template_and_shift.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/arduino.cc/builder/test/ctags_runner_test.go b/src/arduino.cc/builder/test/ctags_runner_test.go index 59209bc0..d5a26a6d 100644 --- a/src/arduino.cc/builder/test/ctags_runner_test.go +++ b/src/arduino.cc/builder/test/ctags_runner_test.go @@ -271,7 +271,7 @@ func TestCTagsRunnerSketchWithTemplates(t *testing.T) { } sketchLocation = strings.Replace(sketchLocation, "\\", "\\\\", -1) - expectedOutput := "printGyro\t" + sketchLocation + "\t/^void printGyro()$/;\"\tkind:function\tline:8\tsignature:()\treturntype:void\n" + expectedOutput := "printGyro\t" + sketchLocation + "\t/^void printGyro()$/;\"\tkind:function\tline:10\tsignature:()\treturntype:void\n" require.Equal(t, expectedOutput, strings.Replace(context[constants.CTX_CTAGS_OUTPUT].(string), "\r\n", "\n", -1)) } diff --git a/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp b/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp index 67566f22..ce9bb444 100644 --- a/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp +++ b/src/arduino.cc/builder/test/sketch_with_templates_and_shift/template_and_shift.cpp @@ -1,5 +1,7 @@ template<> class FastPin<0> : public _ARMPIN<0, 10, 1 << 10, 0> {};; +template<> class FastPin<0> : public _ARMPIN<0, 10, 1 < 10, 0> {};; + template class OtherType> class NestedTemplateClass { OtherType f; From d3374b17ee131dbc9270a584007ad7ad2126126b Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 23 Feb 2016 13:23:25 +0100 Subject: [PATCH 3/3] add FastLED problematic sketch on samd --- .../builder/test/helper_tools_downloader.go | 1 + .../builder/test/sketch11/sketch_fastleds.ino | 27 +++++++++++++++++++ .../try_build_of_problematic_sketch_test.go | 6 +++++ 3 files changed, 34 insertions(+) create mode 100644 src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino diff --git a/src/arduino.cc/builder/test/helper_tools_downloader.go b/src/arduino.cc/builder/test/helper_tools_downloader.go index 1e449e41..e8df4e20 100644 --- a/src/arduino.cc/builder/test/helper_tools_downloader.go +++ b/src/arduino.cc/builder/test/helper_tools_downloader.go @@ -138,6 +138,7 @@ func DownloadCoresAndToolsAndLibraries(t *testing.T) { Library{Name: "CapacitiveSensor", Version: "0.5.0", VersionInLibProperties: "0.5"}, Library{Name: "Ethernet", Version: "1.1.1"}, Library{Name: "Robot IR Remote", Version: "1.0.2"}, + Library{Name: "FastLED", Version: "3.1.0"}, } download(t, cores, boardsManagerCores, boardsManagerRedBearCores, tools, toolsMultipleVersions, boardsManagerTools, boardsManagerRFduinoTools, libraries) diff --git a/src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino b/src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino new file mode 100644 index 00000000..eba4f526 --- /dev/null +++ b/src/arduino.cc/builder/test/sketch11/sketch_fastleds.ino @@ -0,0 +1,27 @@ +#include "FastLED.h" + +#define DATA_PIN 7 +#define CLK_PIN 6 +#define LED_TYPE APA102 +#define COLOR_ORDER GRB +#define NUM_LEDS 79 +CRGB leds[NUM_LEDS]; + +#define BRIGHTNESS 96 +#define FRAMES_PER_SECOND 120 +void setup() { + + FastLED.addLeds(leds, NUM_LEDS).setCorrection(TypicalLEDStrip); +} + +void loop() { + +} + +typedef void (*SimplePatternList[])(); +//SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm }; +SimplePatternList gPatterns = {sinelon}; + +void sinelon() +{ +} \ No newline at end of file diff --git a/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go b/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go index 83f5bddc..08eccaf1 100644 --- a/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go +++ b/src/arduino.cc/builder/test/try_build_of_problematic_sketch_test.go @@ -185,6 +185,12 @@ func TestTryBuild035(t *testing.T) { tryBuild(t, "sketch_with_enum_class", "sketch_with_enum_class.ino") } +func TestTryBuild036(t *testing.T) { + context := makeDefaultContext(t) + context[constants.CTX_FQBN] = "arduino:samd:arduino_zero_native" + tryBuildWithContext(t, context, "sketch11", "sketch_fastleds.ino") +} + func makeDefaultContext(t *testing.T) map[string]interface{} { DownloadCoresAndToolsAndLibraries(t)