Skip to content

Commit

Permalink
ported SketchWithStaticAsserts 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 aa5451b commit 8e10e90
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 39 deletions.
86 changes: 51 additions & 35 deletions internal/integrationtest/compile_4/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,42 +70,43 @@ func TestCompileOfProblematicSketches(t *testing.T) {
require.NoError(t, customHwDir.CopyDirTo(cli.SketchbookDir().Join("hardware")))

integrationtest.CLISubtests{
//{"SketchWithInlineFunction", testBuilderSketchWithInlineFunction},
//{"SketchWithConst", testBuilderSketchWithConst},
//{"SketchWithFunctionSignatureInsideIfdef", testBuilderSketchWithFunctionSignatureInsideIfdef},
//{"SketchWithOldLibrary", testBuilderSketchWithOldLibrary},
//{"SketchWithoutFunctions", testBuilderSketchWithoutFunctions},
//{"SketchWithConfig", testBuilderSketchWithConfig},
//{"SketchWithUsbcon", testBuilderSketchWithUsbcon},
//{"SketchWithTypename", testBuilderSketchWithTypename},
//{"SketchWithMacosxGarbage", tryBuildAvrLeonardo},
//{"SketchWithNamespace", testBuilderSketchWithNamespace},
//{"SketchWithDefaultArgs", testBuilderSketchWithDefaultArgs},
//{"SketchWithClass", testBuilderSketchWithClass},
//{"SketchWithBackupFiles", testBuilderSketchWithBackupFiles},
//{"SketchWithSubfolders", testBuilderSketchWithSubfolders},
//{"SketchWithTemplatesAndShift", testBuilderSketchWithTemplatesAndShift},
//{"SketchRequiringEOLProcessing", tryBuildAvrLeonardo},
//{"SketchWithIfDef", testBuilderSketchWithIfDef},
//{"SketchWithIfDef2", testBuilderSketchWithIfDef2},
//{"SketchWithIfDef3", testBuilderSketchWithIfDef3},
//{"BridgeExample", testBuilderBridgeExample},
//{"Baladuino", testBuilderBaladuino},
//{"SketchWithEscapedDoubleQuote", testBuilderSketchWithEscapedDoubleQuote},
//{"SketchWithIncludeBetweenMultilineComment", testBuilderSketchWithIncludeBetweenMultilineComment},
//{"SketchWithLineContinuations", testBuilderSketchWithLineContinuations},
//{"SketchWithStringWithComment", testBuilderSketchWithStringWithComment},
//{"SketchWithStruct", testBuilderSketchWithStruct},
//{"SketchNoFunctionsTwoFiles", testBuilderSketchNoFunctionsTwoFiles},
//{"SketchWithClassAndMethodSubstring", testBuilderSketchWithClassAndMethodSubstring},
//{"SketchThatChecksIfSPIHasTransactions", tryBuildAvrLeonardo},
//{"SketchWithDependendLibraries", tryBuildAvrLeonardo},
//{"SketchWithFunctionPointer", tryBuildAvrLeonardo},
{"SketchWithInlineFunction", testBuilderSketchWithInlineFunction},
{"SketchWithConst", testBuilderSketchWithConst},
{"SketchWithFunctionSignatureInsideIfdef", testBuilderSketchWithFunctionSignatureInsideIfdef},
{"SketchWithOldLibrary", testBuilderSketchWithOldLibrary},
{"SketchWithoutFunctions", testBuilderSketchWithoutFunctions},
{"SketchWithConfig", testBuilderSketchWithConfig},
{"SketchWithUsbcon", testBuilderSketchWithUsbcon},
{"SketchWithTypename", testBuilderSketchWithTypename},
{"SketchWithMacosxGarbage", tryBuildAvrLeonardo},
{"SketchWithNamespace", testBuilderSketchWithNamespace},
{"SketchWithDefaultArgs", testBuilderSketchWithDefaultArgs},
{"SketchWithClass", testBuilderSketchWithClass},
{"SketchWithBackupFiles", testBuilderSketchWithBackupFiles},
{"SketchWithSubfolders", testBuilderSketchWithSubfolders},
{"SketchWithTemplatesAndShift", testBuilderSketchWithTemplatesAndShift},
{"SketchRequiringEOLProcessing", tryBuildAvrLeonardo},
{"SketchWithIfDef", testBuilderSketchWithIfDef},
{"SketchWithIfDef2", testBuilderSketchWithIfDef2},
{"SketchWithIfDef3", testBuilderSketchWithIfDef3},
{"BridgeExample", testBuilderBridgeExample},
{"Baladuino", testBuilderBaladuino},
{"SketchWithEscapedDoubleQuote", testBuilderSketchWithEscapedDoubleQuote},
{"SketchWithIncludeBetweenMultilineComment", testBuilderSketchWithIncludeBetweenMultilineComment},
{"SketchWithLineContinuations", testBuilderSketchWithLineContinuations},
{"SketchWithStringWithComment", testBuilderSketchWithStringWithComment},
{"SketchWithStruct", testBuilderSketchWithStruct},
{"SketchNoFunctionsTwoFiles", testBuilderSketchNoFunctionsTwoFiles},
{"SketchWithClassAndMethodSubstring", testBuilderSketchWithClassAndMethodSubstring},
{"SketchThatChecksIfSPIHasTransactions", tryBuildAvrLeonardo},
{"SketchWithDependendLibraries", tryBuildAvrLeonardo},
{"SketchWithFunctionPointer", tryBuildAvrLeonardo},
{"SketchThatIncludesArduinoH", testBuilderSketchThatIncludesArduinoH},
//{"USBHostExample", testBuilderUSBHostExample},
//{"SketchWithConflictingLibraries", testBuilderSketchWithConflictingLibraries},
//{"SketchLibraryProvidesAllIncludes", testBuilderSketchLibraryProvidesAllIncludes},
//{"UserHardware", testBuilderWithUserHardware},
{"SketchWithStaticAsserts", testBuilderSketchWithStaticAsserts},
{"USBHostExample", testBuilderUSBHostExample},
{"SketchWithConflictingLibraries", testBuilderSketchWithConflictingLibraries},
{"SketchLibraryProvidesAllIncludes", testBuilderSketchLibraryProvidesAllIncludes},
{"UserHardware", testBuilderWithUserHardware},
}.Run(t, env, cli)
}

Expand Down Expand Up @@ -629,6 +630,21 @@ func testBuilderSketchThatIncludesArduinoH(t *testing.T, env *integrationtest.En
})
}

func testBuilderSketchWithStaticAsserts(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,26 @@
#include <Arduino.h>
#line 1 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino"
// https://github.com/arduino/arduino-builder/issues/68

const int a = 10;
const int b = 20;

static_assert(a < b, "bar");

#line 8 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino"
void setup();
#line 12 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino"
void loop();
#line 15 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino"
void test();
#line 8 "/home/ale/arduino/arduino-cli/internal/integrationtest/compile_4/testdata/SketchWithStaticAsserts/SketchWithStaticAsserts.ino"
void setup() {
test();
}

void loop() {
}

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

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

0 comments on commit 8e10e90

Please sign in to comment.