Skip to content

Commit

Permalink
ported SketchWithEnumClass 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 8e10e90 commit 5ad5f32
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 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 @@ -107,6 +107,7 @@ func TestCompileOfProblematicSketches(t *testing.T) {
{"SketchWithConflictingLibraries", testBuilderSketchWithConflictingLibraries},
{"SketchLibraryProvidesAllIncludes", testBuilderSketchLibraryProvidesAllIncludes},
{"UserHardware", testBuilderWithUserHardware},
{"SketchWithEnumClass", testBuilderSketchWithEnumClass},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -645,6 +646,21 @@ func testBuilderSketchWithStaticAsserts(t *testing.T, env *integrationtest.Envir
})
}

func testBuilderSketchWithEnumClass(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,31 @@
#include <Arduino.h>
#line 1 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino"
#line 1 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino"
void test();
#line 11 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino"
void test2();
#line 14 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino"
void setup();
#line 17 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino"
void loop();
#line 1 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithEnumClass/SketchWithEnumClass.ino"
void test() {
test2();
}

enum class MyEnum
{
AValue = 0,
AnotherValue = 1
};

void test2() {
}

void setup() {
}

void loop() {
}


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

// TODO add them in the compile_4

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

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

func TestTryBuild037(t *testing.T) {
tryBuild(t, paths.New("sketch_with_externC", "sketch_with_externC.ino"))
}
Expand All @@ -46,11 +37,6 @@ func TestTryBuild038(t *testing.T) {
tryBuild(t, paths.New("sketch_with_multiline_prototypes", "sketch_with_multiline_prototypes.ino"))
}

func TestTryBuild039(t *testing.T) {
ctx := makeDefaultContext()
tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch12", "sketch12.ino"))
}

func TestTryBuild040(t *testing.T) {
tryBuild(t, paths.New("sketch_with_externC_multiline", "sketch_with_externC_multiline.ino"))
}
Expand All @@ -63,6 +49,16 @@ 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"))
}

func TestTryBuild039(t *testing.T) {
ctx := makeDefaultContext()
tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch12", "sketch12.ino"))
}

func makeDefaultContext() *types.Context {
preprocessor.DebugPreprocessor = true
return &types.Context{
Expand Down

0 comments on commit 5ad5f32

Please sign in to comment.