Skip to content

Commit

Permalink
ported SketchWithMultilineTemplate from legacy into integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Sep 13, 2023
1 parent 586b551 commit d9a0828
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 4 deletions.
16 changes: 16 additions & 0 deletions internal/integrationtest/compile_4/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ func TestCompileOfProblematicSketches(t *testing.T) {
{"SketchWithExternC", testBuilderSketchWithExternC},
{"SketchWithMultilinePrototypes", testBuilderSketchWithMultilinePrototypes},
{"SketchWithExternCMultiline", testBuilderSketchWithExternCMultiline},
{"SketchWithMultilineTemplate", testBuilderSketchWithMultilineTemplate},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -709,6 +710,21 @@ func testBuilderSketchWithExternCMultiline(t *testing.T, env *integrationtest.En
})
}

func testBuilderSketchWithMultilineTemplate(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) {
t.Run("Build", func(t *testing.T) {
// Build
_, err := tryBuild(t, env, cli, "arduino:avr:leonardo")
require.NoError(t, err)
})

t.Run("Preprocess", func(t *testing.T) {
// Preprocess
sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:avr:leonardo")
require.NoError(t, err)
comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch)
})
}

type builderOutput struct {
CompilerOut string `json:"compiler_out"`
CompilerErr string `json:"compiler_err"`
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <Arduino.h>
#line 0 "{{QuoteCppString .sketchMainFile}}"
template< typename T > T func(T t);
#line 6 "{{QuoteCppString .sketchMainFile}}"
void setup();
#line 10 "{{QuoteCppString .sketchMainFile}}"
void loop();
#line 0 "{{QuoteCppString .sketchMainFile}}"
#line 1 "{{QuoteCppString .sketchMainFile}}"
template< typename T >
T func(T t){
return t * t;
}

void setup() {
func( 12.34f );
}

void loop() {}

4 changes: 0 additions & 4 deletions legacy/builder/test/try_build_of_problematic_sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ import (

// TODO add them in the compile_4

func TestTryBuild041(t *testing.T) {
tryBuild(t, paths.New("sketch_with_multiline_template", "sketch_with_multiline_template.ino"))
}

func TestTryBuild042(t *testing.T) {
tryBuild(t, paths.New("sketch_with_fake_function_pointer", "sketch_with_fake_function_pointer.ino"))
}
Expand Down

0 comments on commit d9a0828

Please sign in to comment.