Skip to content

Commit

Permalink
ported SketchWithFakeFunctionPointer 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 d9a0828 commit 574ed7e
Show file tree
Hide file tree
Showing 4 changed files with 43 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 @@ -112,6 +112,7 @@ func TestCompileOfProblematicSketches(t *testing.T) {
{"SketchWithMultilinePrototypes", testBuilderSketchWithMultilinePrototypes},
{"SketchWithExternCMultiline", testBuilderSketchWithExternCMultiline},
{"SketchWithMultilineTemplate", testBuilderSketchWithMultilineTemplate},
{"SketchWithFakeFunctionPointer", testBuilderSketchWithFakeFunctionPointer},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -725,6 +726,21 @@ func testBuilderSketchWithMultilineTemplate(t *testing.T, env *integrationtest.E
})
}

func testBuilderSketchWithFakeFunctionPointer(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,27 @@
#include <Arduino.h>
#line 1 "{{QuoteCppString .sketchMainFile}}"
template< uint16_t nBuffSize >
class Foo{
public:

template< uint16_t N >
Foo &operator +=( const Foo<N> &ref ){
//...
return *this;
}
};

Foo<64> a;
Foo<32> b;

#line 15 "{{QuoteCppString .sketchMainFile}}"
void setup();
#line 19 "{{QuoteCppString .sketchMainFile}}"
void loop();
#line 15 "{{QuoteCppString .sketchMainFile}}"
void setup(){
a += b;
}

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 TestTryBuild042(t *testing.T) {
tryBuild(t, paths.New("sketch_with_fake_function_pointer", "sketch_with_fake_function_pointer.ino"))
}

func TestTryBuild036(t *testing.T) {
ctx := makeDefaultContext()
tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch_fastleds", "sketch_fastleds.ino"))
Expand Down

0 comments on commit 574ed7e

Please sign in to comment.