From 4d20d6d38bfcff05e417911e7067004dff99e0f3 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 9 Feb 2016 11:56:33 +0100 Subject: [PATCH] add test for sketch with malformed EOL --- .../builder/test/eol_processing/sketch.ino | 1 + .../builder/test/prototypes_adder_test.go | 41 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/arduino.cc/builder/test/eol_processing/sketch.ino diff --git a/src/arduino.cc/builder/test/eol_processing/sketch.ino b/src/arduino.cc/builder/test/eol_processing/sketch.ino new file mode 100644 index 00000000..9037a7fa --- /dev/null +++ b/src/arduino.cc/builder/test/eol_processing/sketch.ino @@ -0,0 +1 @@ +int led = 7; void setup() { } void loop() { } \ No newline at end of file diff --git a/src/arduino.cc/builder/test/prototypes_adder_test.go b/src/arduino.cc/builder/test/prototypes_adder_test.go index 0771ebaa..b3d95a9c 100644 --- a/src/arduino.cc/builder/test/prototypes_adder_test.go +++ b/src/arduino.cc/builder/test/prototypes_adder_test.go @@ -880,3 +880,44 @@ func TestPrototypesAdderSketchWithConst(t *testing.T) { require.Equal(t, "#include \n#line 1\n", context[constants.CTX_INCLUDE_SECTION].(string)) require.Equal(t, "#line 1 \""+absoluteSketchLocation+"\"\nvoid setup();\n#line 2 \""+absoluteSketchLocation+"\"\nvoid loop();\n#line 4 \""+absoluteSketchLocation+"\"\nconst __FlashStringHelper* test();\n#line 6 \""+absoluteSketchLocation+"\"\nconst int test3();\n#line 8 \""+absoluteSketchLocation+"\"\nvolatile __FlashStringHelper* test2();\n#line 10 \""+absoluteSketchLocation+"\"\nvolatile int test4();\n#line 1\n", context[constants.CTX_PROTOTYPE_SECTION].(string)) } + +func TestPrototypesAdderSketchWithDosEol(t *testing.T) { + DownloadCoresAndToolsAndLibraries(t) + + context := make(map[string]interface{}) + + buildPath := SetupBuildPath(t, context) + defer os.RemoveAll(buildPath) + + sketchLocation := filepath.Join("eol_processing", "sketch.ino") + + 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:uno" + 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.ContainerAddPrototypes{}, + } + + for _, command := range commands { + err := command.Run(context) + NoError(t, err) + } + // only requires no error as result +}