Skip to content

Commit 03c9d7f

Browse files
Add integration tests
1 parent 2b457a3 commit 03c9d7f

File tree

3 files changed

+57
-1
lines changed

3 files changed

+57
-1
lines changed

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

+49-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func TestCompilerErrOutput(t *testing.T) {
117117
require.Error(t, err)
118118
outJson := requirejson.Parse(t, out)
119119
outJson.Query(`.compiler_err`).MustContain(`"error"`)
120-
outJson.Query(`.diagnostics`).MustContain(`
120+
outJson.Query(`.builder_result.diagnostics`).MustContain(`
121121
[
122122
{
123123
"severity": "ERROR",
@@ -128,6 +128,54 @@ func TestCompilerErrOutput(t *testing.T) {
128128
]`)
129129
}
130130

131+
// Test the preprocessor errors are present in the diagnostics
132+
{
133+
// prepare sketch
134+
sketch, err := paths.New("testdata", "blink_with_wrong_include").Abs()
135+
require.NoError(t, err)
136+
137+
// Run compile and catch err stream
138+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
139+
require.Error(t, err)
140+
outJson := requirejson.Parse(t, out)
141+
outJson.Query(`.success`).MustContain(`false`)
142+
outJson.Query(`.builder_result.diagnostics`).MustContain(`
143+
[
144+
{
145+
"severity": "ERROR",
146+
"line": 1,
147+
"column": 2,
148+
"message": "invalid preprocessing directive #wrong\n #wrong\n ^~~~~",
149+
}
150+
]`)
151+
}
152+
153+
// Test the preprocessor errors are present in the diagnostics.
154+
// In case we have 2 libraries:
155+
// 1. one is missing
156+
// 2. the other one is missing only from the first GCC run
157+
// The diagnostics should report only 1 missing library.
158+
{
159+
// prepare sketch
160+
sketch, err := paths.New("testdata", "using_Wire_with_missing_lib").Abs()
161+
require.NoError(t, err)
162+
163+
// Run compile and catch err stream
164+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
165+
require.Error(t, err)
166+
outJson := requirejson.Parse(t, out)
167+
outJson.Query(`.success`).MustContain(`false`)
168+
outJson.Query(`.builder_result.diagnostics`).MustContain(`
169+
[
170+
{
171+
"severity": "FATAL",
172+
"line": 2,
173+
"column": 10,
174+
"message": "MissingWire.h: No such file or directory\n #include \u003cMissingWire.h\u003e\n ^~~~~~~~~~~~~~~",
175+
}
176+
]`)
177+
}
178+
131179
// Check that library discover do not generate false errors
132180
// https://github.com/arduino/arduino-cli/issues/2263
133181
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#wrong
2+
void setup() {}
3+
void loop() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#include <Wire.h>
2+
#include <MissingWire.h>
3+
4+
void setup() {}
5+
void loop() {}

0 commit comments

Comments
 (0)