Skip to content

added '.tpp' file ext to known list #1316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 22, 2021
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
32 changes: 32 additions & 0 deletions arduino/builder/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,3 +289,35 @@ func TestSketchWithMarkdownAsciidocJson(t *testing.T) {
require.Equal(t, "foo.json", filepath.Base(sketch.RootFolderFiles[1].Path))
require.Equal(t, "foo.md", filepath.Base(sketch.RootFolderFiles[2].Path))
}

func TestSketchWithTppFile(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, 1)
require.Equal(t, "template.tpp", filepath.Base(sketch.AdditionalFiles[0].Path))
require.Len(t, sketch.RootFolderFiles, 1)
require.Equal(t, "template.tpp", filepath.Base(sketch.RootFolderFiles[0].Path))
}

func TestSketchWithIppFile(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, 1)
require.Equal(t, "template.ipp", filepath.Base(sketch.AdditionalFiles[0].Path))
require.Len(t, sketch.RootFolderFiles, 1)
require.Equal(t, "template.ipp", filepath.Base(sketch.RootFolderFiles[0].Path))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "template.ipp"

void setup() {}
void loop() {}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "template.tpp"

void setup() {}
void loop() {}
Empty file.
2 changes: 2 additions & 0 deletions arduino/globals/globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var (
".adoc": empty,
".md": empty,
".json": empty,
".tpp": empty,
".ipp": empty,
}

// SourceFilesValidExtensions lists valid extensions for source files (no headers)
Expand Down
34 changes: 34 additions & 0 deletions arduino/sketch/sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,37 @@ func TestSketchWithMarkdownAsciidocJson(t *testing.T) {
require.Equal(t, "foo.json", filepath.Base(sketch.RootFolderFiles[1].Path))
require.Equal(t, "foo.md", filepath.Base(sketch.RootFolderFiles[2].Path))
}

func TestSketchWithTppFile(t *testing.T) {
sketchPath := paths.New("testdata", "SketchWithTppFile")
mainFilePath := sketchPath.Join("SketchWithTppFile.ino").String()
templateFile := sketchPath.Join("template.tpp").String()

sketch, err := New(sketchPath.String(), mainFilePath, "", []string{mainFilePath, templateFile})
require.NotNil(t, sketch)
require.NoError(t, err)
require.Equal(t, sketchPath.String(), sketch.LocationPath)
require.Equal(t, mainFilePath, sketch.MainFile.Path)
require.Len(t, sketch.OtherSketchFiles, 0)
require.Len(t, sketch.AdditionalFiles, 1)
require.Equal(t, "template.tpp", filepath.Base(sketch.AdditionalFiles[0].Path))
require.Len(t, sketch.RootFolderFiles, 1)
require.Equal(t, "template.tpp", filepath.Base(sketch.RootFolderFiles[0].Path))
}

func TestSketchWithIppFile(t *testing.T) {
sketchPath := paths.New("testdata", "SketchWithIppFile")
mainFilePath := sketchPath.Join("SketchWithIppFile.ino").String()
templateFile := sketchPath.Join("template.ipp").String()

sketch, err := New(sketchPath.String(), mainFilePath, "", []string{mainFilePath, templateFile})
require.NotNil(t, sketch)
require.NoError(t, err)
require.Equal(t, sketchPath.String(), sketch.LocationPath)
require.Equal(t, mainFilePath, sketch.MainFile.Path)
require.Len(t, sketch.OtherSketchFiles, 0)
require.Len(t, sketch.AdditionalFiles, 1)
require.Equal(t, "template.ipp", filepath.Base(sketch.AdditionalFiles[0].Path))
require.Len(t, sketch.RootFolderFiles, 1)
require.Equal(t, "template.ipp", filepath.Base(sketch.RootFolderFiles[0].Path))
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "template.ipp"

void setup() {}
void loop() {}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "template.tpp"

void setup() {}
void loop() {}
Empty file.
26 changes: 26 additions & 0 deletions test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,3 +1129,29 @@ def test_compile_with_esp8266_bundled_libraries(run_command, data_dir, copy_sket
f" Not used: {cli_installed_lib_path}",
]
assert "\n".join(expected_output) not in res.stdout


def test_compile_sketch_with_tpp_file_include(run_command, copy_sketch):
assert run_command("update")

# Download latest AVR
run_command("core install arduino:avr")

sketch_name = "sketch_with_tpp_file_include"
sketch_path = copy_sketch(sketch_name)
fqbn = "arduino:avr:uno"

assert run_command(f"compile -b {fqbn} {sketch_path} --verbose")


def test_compile_sketch_with_ipp_file_include(run_command, copy_sketch):
assert run_command("update")

# Download latest AVR
run_command("core install arduino:avr")

sketch_name = "sketch_with_ipp_file_include"
sketch_path = copy_sketch(sketch_name)
fqbn = "arduino:avr:uno"

assert run_command(f"compile -b {fqbn} {sketch_path} --verbose")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "template.ipp"

void setup() {}
void loop() {}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#include "template.tpp"

void setup() {}
void loop() {}
Empty file.