Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add testcases to cover #358 (Symbolic link as sketch directory) and #424
 (folder with .ino extension)
  • Loading branch information
Roberto Sora committed Oct 29, 2019
commit ebca955cebd75e1e3506865da4af2de0c6ce1c60
40 changes: 40 additions & 0 deletions arduino/builder/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,46 @@ func TestLoadSketchFolder(t *testing.T) {
require.Equal(t, "helper.h", filepath.Base(s.AdditionalFiles[2].Path))
}

func TestLoadSketchFolderSymlink(t *testing.T) {
// pass the path to the sketch folder
sketchPath := filepath.Join("testdata", t.Name())
mainFilePath := filepath.Join(sketchPath, t.Name()+".ino")
s, err := builder.SketchLoad(sketchPath, "")
require.Nil(t, err)
require.NotNil(t, s)
require.Equal(t, mainFilePath, s.MainFile.Path)
require.Equal(t, sketchPath, s.LocationPath)
require.Len(t, s.OtherSketchFiles, 2)
require.Equal(t, "old.pde", filepath.Base(s.OtherSketchFiles[0].Path))
require.Equal(t, "other.ino", filepath.Base(s.OtherSketchFiles[1].Path))
require.Len(t, s.AdditionalFiles, 3)
require.Equal(t, "header.h", filepath.Base(s.AdditionalFiles[0].Path))
require.Equal(t, "s_file.S", filepath.Base(s.AdditionalFiles[1].Path))
require.Equal(t, "helper.h", filepath.Base(s.AdditionalFiles[2].Path))

// pass the path to the main file
sketchPath = mainFilePath
s, err = builder.SketchLoad(sketchPath, "")
require.Nil(t, err)
require.NotNil(t, s)
require.Equal(t, mainFilePath, s.MainFile.Path)
require.Len(t, s.OtherSketchFiles, 2)
require.Equal(t, "old.pde", filepath.Base(s.OtherSketchFiles[0].Path))
require.Equal(t, "other.ino", filepath.Base(s.OtherSketchFiles[1].Path))
require.Len(t, s.AdditionalFiles, 3)
require.Equal(t, "header.h", filepath.Base(s.AdditionalFiles[0].Path))
require.Equal(t, "s_file.S", filepath.Base(s.AdditionalFiles[1].Path))
require.Equal(t, "helper.h", filepath.Base(s.AdditionalFiles[2].Path))
}

func TestLoadSketchFolderIno(t *testing.T) {
// pass the path to the sketch folder
sketchPath := filepath.Join("testdata", t.Name())
_, err := builder.SketchLoad(sketchPath, "")
require.Error(t, err)
require.Contains(t, err.Error(), "sketch must not be a directory")
}

func TestLoadSketchFolderWrongMain(t *testing.T) {
sketchPath := filepath.Join("testdata", t.Name())
_, err := builder.SketchLoad(sketchPath, "")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void setup() {

}

void loop() {

}
1 change: 1 addition & 0 deletions arduino/builder/testdata/TestLoadSketchFolderSymlink
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
void setup()
void loop) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
void setup() {

}

void loop() {

}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define FOO "BAR"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
String hello() {
return "world";
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include <testlib4.h>
#error "Whattya looking at?"
Empty file.