Skip to content

Commit f3ef21e

Browse files
ported SketchWithMinMaxDefinitions from legacy into integration test
1 parent 614e981 commit f3ef21e

File tree

4 files changed

+42
-9
lines changed

4 files changed

+42
-9
lines changed

Diff for: internal/integrationtest/compile_4/compile_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func TestCompileOfProblematicSketches(t *testing.T) {
113113
{"SketchWithExternCMultiline", testBuilderSketchWithExternCMultiline},
114114
{"SketchWithMultilineTemplate", testBuilderSketchWithMultilineTemplate},
115115
{"SketchWithFakeFunctionPointer", testBuilderSketchWithFakeFunctionPointer},
116+
{"SketchWithMinMaxDefinitions", testBuilderSketchWithMinMaxDefinitions},
116117
}.Run(t, env, cli)
117118
}
118119

@@ -741,6 +742,21 @@ func testBuilderSketchWithFakeFunctionPointer(t *testing.T, env *integrationtest
741742
})
742743
}
743744

745+
func testBuilderSketchWithMinMaxDefinitions(t *testing.T, env *integrationtest.Environment, cli *integrationtest.ArduinoCLI) {
746+
t.Run("Build", func(t *testing.T) {
747+
// Build
748+
_, err := tryBuild(t, env, cli, "arduino:samd:arduino_zero_native")
749+
require.NoError(t, err)
750+
})
751+
752+
t.Run("Preprocess", func(t *testing.T) {
753+
// Preprocess
754+
sketchPath, preprocessedSketch, err := tryPreprocess(t, env, cli, "arduino:samd:arduino_zero_native")
755+
require.NoError(t, err)
756+
comparePreprocessGoldenFile(t, sketchPath, preprocessedSketch)
757+
})
758+
}
759+
744760
type builderOutput struct {
745761
CompilerOut string `json:"compiler_out"`
746762
CompilerErr string `json:"compiler_err"`
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include <Arduino.h>
2+
#line 1 {{QuoteCppString .sketchMainFile}}
3+
// See: https://github.com/arduino/arduino-builder/issues/68
4+
5+
// The following avoid duplicate definitions of min and max
6+
#undef min
7+
#undef max
8+
9+
#include <memory>
10+
11+
#line 9 {{QuoteCppString .sketchMainFile}}
12+
void setup();
13+
#line 13 {{QuoteCppString .sketchMainFile}}
14+
void loop();
15+
#line 15 {{QuoteCppString .sketchMainFile}}
16+
void test();
17+
#line 9 {{QuoteCppString .sketchMainFile}}
18+
void setup() {
19+
test();
20+
}
21+
22+
void loop() {}
23+
24+
void test() {}
25+
26+

Diff for: legacy/builder/test/try_build_of_problematic_sketch_test.go

-9
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,6 @@ func TestTryBuild036(t *testing.T) {
3434
tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch_fastleds", "sketch_fastleds.ino"))
3535
}
3636

37-
func TestTryBuild039(t *testing.T) {
38-
ctx := makeDefaultContext()
39-
tryBuildWithContext(t, ctx, "arduino:samd:arduino_zero_native", paths.New("sketch12", "sketch12.ino"))
40-
}
41-
4237
func makeDefaultContext() *types.Context {
4338
preprocessor.DebugPreprocessor = true
4439
return &types.Context{
@@ -49,10 +44,6 @@ func makeDefaultContext() *types.Context {
4944
}
5045
}
5146

52-
func tryBuild(t *testing.T, sketchLocation *paths.Path) {
53-
tryBuildWithContext(t, makeDefaultContext(), "arduino:avr:leonardo", sketchLocation)
54-
}
55-
5647
func tryBuildWithContext(t *testing.T, ctx *types.Context, fqbn string, sketchLocation *paths.Path) {
5748
ctx = prepareBuilderTestContext(t, ctx, sketchLocation, fqbn)
5849
defer cleanUpBuilderTestContext(t, ctx)

0 commit comments

Comments
 (0)