Skip to content

Commit

Permalink
Add integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alessio-perugini committed Jan 29, 2024
1 parent 033e9aa commit e37587b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
50 changes: 49 additions & 1 deletion internal/integrationtest/compile_3/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestCompilerErrOutput(t *testing.T) {
require.Error(t, err)
outJson := requirejson.Parse(t, out)
outJson.Query(`.compiler_err`).MustContain(`"error"`)
outJson.Query(`.diagnostics`).MustContain(`
outJson.Query(`.builder_result.diagnostics`).MustContain(`
[
{
"severity": "ERROR",
Expand All @@ -128,6 +128,54 @@ func TestCompilerErrOutput(t *testing.T) {
]`)
}

// Test the preprocessor errors are present in the diagnostics
{
// prepare sketch
sketch, err := paths.New("testdata", "blink_with_wrong_include").Abs()
require.NoError(t, err)

// Run compile and catch err stream
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
require.Error(t, err)
outJson := requirejson.Parse(t, out)
outJson.Query(`.success`).MustContain(`false`)
outJson.Query(`.builder_result.diagnostics`).MustContain(`
[
{
"severity": "ERROR",
"line": 1,
"column": 2,
"message": "invalid preprocessing directive #wrong\n #wrong\n ^~~~~",
}
]`)
}

// Test the preprocessor errors are present in the diagnostics.
// In case we have 2 libraries:
// 1. one is missing
// 2. the other one is missing only from the first GCC run
// The diagnostics should report only 1 missing library.
{
// prepare sketch
sketch, err := paths.New("testdata", "using_Wire_with_missing_lib").Abs()
require.NoError(t, err)

// Run compile and catch err stream
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
require.Error(t, err)
outJson := requirejson.Parse(t, out)
outJson.Query(`.success`).MustContain(`false`)
outJson.Query(`.builder_result.diagnostics`).MustContain(`
[
{
"severity": "FATAL",
"line": 2,
"column": 10,
"message": "MissingWire.h: No such file or directory\n #include \u003cMissingWire.h\u003e\n ^~~~~~~~~~~~~~~",
}
]`)
}

// Check that library discover do not generate false errors
// https://github.com/arduino/arduino-cli/issues/2263
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#wrong
void setup() {}
void loop() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include <Wire.h>
#include <MissingWire.h>

void setup() {}
void loop() {}

0 comments on commit e37587b

Please sign in to comment.