Skip to content

Commit

Permalink
ported SketchWithExternC 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 5ad5f32 commit e34591b
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 @@ -108,6 +108,7 @@ func TestCompileOfProblematicSketches(t *testing.T) {
{"SketchLibraryProvidesAllIncludes", testBuilderSketchLibraryProvidesAllIncludes},
{"UserHardware", testBuilderWithUserHardware},
{"SketchWithEnumClass", testBuilderSketchWithEnumClass},
{"SketchWithExternC", testBuilderSketchWithExternC},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -661,6 +662,21 @@ func testBuilderSketchWithEnumClass(t *testing.T, env *integrationtest.Environme
})
}

func testBuilderSketchWithExternC(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 1 "{{QuoteCppString .sketchMainFile}}"
#line 1 "{{QuoteCppString .sketchMainFile}}"
void setup();
#line 6 "{{QuoteCppString .sketchMainFile}}"
void loop();
#line 11 "{{QuoteCppString .sketchMainFile}}"
extern "C" void test();
#line 1 "{{QuoteCppString .sketchMainFile}}"
void setup() {
// put your setup code here, to run once:
test();
}

void loop() {
// put your main code here, to run repeatedly:

}

extern "C" void test() {}
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 TestTryBuild037(t *testing.T) {
tryBuild(t, paths.New("sketch_with_externC", "sketch_with_externC.ino"))
}

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

0 comments on commit e34591b

Please sign in to comment.