Skip to content

Commit

Permalink
ported SketchWithMinMaxDefinitions 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 614e981 commit 5a73abd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 9 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 @@ -113,6 +113,7 @@ func TestCompileOfProblematicSketches(t *testing.T) {
{"SketchWithExternCMultiline", testBuilderSketchWithExternCMultiline},
{"SketchWithMultilineTemplate", testBuilderSketchWithMultilineTemplate},
{"SketchWithFakeFunctionPointer", testBuilderSketchWithFakeFunctionPointer},
{"SketchWithMinMaxDefinitions", testBuilderSketchWithMinMaxDefinitions},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -741,6 +742,21 @@ func testBuilderSketchWithFakeFunctionPointer(t *testing.T, env *integrationtest
})
}

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

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

type builderOutput struct {
CompilerOut string `json:"compiler_out"`
CompilerErr string `json:"compiler_err"`
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include <Arduino.h>
#line 1 {{QuoteCppString .sketchMainFile}}
// See: https://github.com/arduino/arduino-builder/issues/68

// The following avoid duplicate definitions of min and max
#undef min
#undef max

#include <memory>

#line 9 {{QuoteCppString .sketchMainFile}}
void setup();
#line 13 {{QuoteCppString .sketchMainFile}}
void loop();
#line 15 {{QuoteCppString .sketchMainFile}}
void test();
#line 9 {{QuoteCppString .sketchMainFile}}
void setup() {
test();
}

void loop() {}

void test() {}
9 changes: 0 additions & 9 deletions legacy/builder/test/try_build_of_problematic_sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ func TestTryBuild036(t *testing.T) {
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 All @@ -49,10 +44,6 @@ func makeDefaultContext() *types.Context {
}
}

func tryBuild(t *testing.T, sketchLocation *paths.Path) {
tryBuildWithContext(t, makeDefaultContext(), "arduino:avr:leonardo", sketchLocation)
}

func tryBuildWithContext(t *testing.T, ctx *types.Context, fqbn string, sketchLocation *paths.Path) {
ctx = prepareBuilderTestContext(t, ctx, sketchLocation, fqbn)
defer cleanUpBuilderTestContext(t, ctx)
Expand Down

0 comments on commit 5a73abd

Please sign in to comment.