Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
20 changes: 20 additions & 0 deletions arduino/builder/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,23 @@ func TestLoadSketchCaseMismatch(t *testing.T) {
require.Nil(t, s)
require.Error(t, err)
}

func TestSketchWithMarkdownAsciidocJson(t *testing.T) {
sketchPath := filepath.Join("testdata", t.Name())
mainFilePath := filepath.Join(sketchPath, t.Name()+".ino")

sketch, err := builder.SketchLoad(sketchPath, "")
require.NotNil(t, sketch)
require.NoError(t, err)
require.Equal(t, sketchPath, sketch.LocationPath)
require.Equal(t, mainFilePath, sketch.MainFile.Path)
require.Len(t, sketch.OtherSketchFiles, 0)
require.Len(t, sketch.AdditionalFiles, 3)
require.Equal(t, "foo.adoc", filepath.Base(sketch.AdditionalFiles[0].Path))
require.Equal(t, "foo.json", filepath.Base(sketch.AdditionalFiles[1].Path))
require.Equal(t, "foo.md", filepath.Base(sketch.AdditionalFiles[2].Path))
require.Len(t, sketch.RootFolderFiles, 3)
require.Equal(t, "foo.adoc", filepath.Base(sketch.RootFolderFiles[0].Path))
require.Equal(t, "foo.json", filepath.Base(sketch.RootFolderFiles[1].Path))
require.Equal(t, "foo.md", filepath.Base(sketch.RootFolderFiles[2].Path))
}
Empty file.
Empty file.
Empty file.
15 changes: 9 additions & 6 deletions arduino/globals/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ var (

// AdditionalFileValidExtensions lists any file extension the builder considers as valid
AdditionalFileValidExtensions = map[string]struct{}{
".h": empty,
".c": empty,
".hpp": empty,
".hh": empty,
".cpp": empty,
".S": empty,
".h": empty,
".c": empty,
".hpp": empty,
".hh": empty,
".cpp": empty,
".S": empty,
".adoc": empty,
".md": empty,
".json": empty,
}

// SourceFilesValidExtensions lists valid extensions for source files (no headers)
Expand Down
33 changes: 28 additions & 5 deletions arduino/sketch/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func TestNew(t *testing.T) {

func TestNewSketchCasingWrong(t *testing.T) {
sketchPath := paths.New("testdata", "SketchCasingWrong")
mainFilePath := paths.New("testadata", "sketchcasingwrong.ino").String()
mainFilePath := sketchPath.Join("sketchcasingwrong.ino").String()
sketch, err := New(sketchPath.String(), mainFilePath, "", []string{mainFilePath})
assert.Nil(t, sketch)
assert.Error(t, err)
Expand All @@ -91,12 +91,12 @@ func TestNewSketchCasingWrong(t *testing.T) {
}

func TestNewSketchCasingCorrect(t *testing.T) {
sketchPath := paths.New("testdata", "SketchCasingCorrect").String()
mainFilePath := paths.New("testadata", "SketchCasingCorrect.ino").String()
sketch, err := New(sketchPath, mainFilePath, "", []string{mainFilePath})
sketchPath := paths.New("testdata", "SketchCasingCorrect")
mainFilePath := sketchPath.Join("SketchCasingCorrect.ino").String()
sketch, err := New(sketchPath.String(), mainFilePath, "", []string{mainFilePath})
assert.NotNil(t, sketch)
assert.NoError(t, err)
assert.Equal(t, sketchPath, sketch.LocationPath)
assert.Equal(t, sketchPath.String(), sketch.LocationPath)
assert.Equal(t, mainFilePath, sketch.MainFile.Path)
assert.Len(t, sketch.OtherSketchFiles, 0)
assert.Len(t, sketch.AdditionalFiles, 0)
Expand All @@ -115,3 +115,26 @@ func TestCheckSketchCasingCorrect(t *testing.T) {
err := CheckSketchCasing(sketchFolder)
require.NoError(t, err)
}

func TestSketchWithMarkdownAsciidocJson(t *testing.T) {
sketchPath := paths.New("testdata", "SketchWithMarkdownAsciidocJson")
mainFilePath := sketchPath.Join("SketchWithMarkdownAsciidocJson.ino").String()
adocFilePath := sketchPath.Join("foo.adoc").String()
jsonFilePath := sketchPath.Join("foo.json").String()
mdFilePath := sketchPath.Join("foo.md").String()

sketch, err := New(sketchPath.String(), mainFilePath, "", []string{mainFilePath, adocFilePath, jsonFilePath, mdFilePath})
assert.NotNil(t, sketch)
assert.NoError(t, err)
assert.Equal(t, sketchPath.String(), sketch.LocationPath)
assert.Equal(t, mainFilePath, sketch.MainFile.Path)
assert.Len(t, sketch.OtherSketchFiles, 0)
require.Len(t, sketch.AdditionalFiles, 3)
require.Equal(t, "foo.adoc", filepath.Base(sketch.AdditionalFiles[0].Path))
require.Equal(t, "foo.json", filepath.Base(sketch.AdditionalFiles[1].Path))
require.Equal(t, "foo.md", filepath.Base(sketch.AdditionalFiles[2].Path))
assert.Len(t, sketch.RootFolderFiles, 3)
require.Equal(t, "foo.adoc", filepath.Base(sketch.RootFolderFiles[0].Path))
require.Equal(t, "foo.json", filepath.Base(sketch.RootFolderFiles[1].Path))
require.Equal(t, "foo.md", filepath.Base(sketch.RootFolderFiles[2].Path))
}
Empty file.
Empty file.
Empty file.