@@ -107,7 +107,7 @@ func TestCompilerErrOutput(t *testing.T) {
107
107
_, _, err := cli.Run("core", "install", "arduino:avr@1.8.5")
108
108
require.NoError(t, err)
109
109
110
-
{
110
+
t.Run("Diagnostics", func(t *testing.T) {
111
111
// prepare sketch
112
112
sketch, err := paths.New("testdata", "blink_with_wrong_cpp").Abs()
113
113
require.NoError(t, err)
@@ -126,10 +126,11 @@ func TestCompilerErrOutput(t *testing.T) {
126
126
"context": [ { "message": "In function 'void wrong()':" } ]
127
127
}
128
128
]`)
129
-
}
129
+
})
130
+
131
+
t.Run("PreprocessorDiagnostics", func(t *testing.T) {
132
+
// Test the preprocessor errors are present in the diagnostics
130
133
131
-
// Test the preprocessor errors are present in the diagnostics
132
-
{
133
134
// prepare sketch
134
135
sketch, err := paths.New("testdata", "blink_with_wrong_include").Abs()
135
136
require.NoError(t, err)
@@ -148,14 +149,15 @@ func TestCompilerErrOutput(t *testing.T) {
148
149
"message": "invalid preprocessing directive #wrong\n #wrong\n ^~~~~",
149
150
}
150
151
]`)
151
-
}
152
+
})
153
+
154
+
t.Run("PreprocessorDiagnosticsWithLibErrors", func(t *testing.T) {
155
+
// Test the preprocessor errors are present in the diagnostics.
156
+
// In case we have 2 libraries:
157
+
// 1. one is missing
158
+
// 2. the other one is missing only from the first GCC run
159
+
// The diagnostics should report only 1 missing library.
152
160
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
161
// prepare sketch
160
162
sketch, err := paths.New("testdata", "using_Wire_with_missing_lib").Abs()
161
163
require.NoError(t, err)
@@ -175,11 +177,12 @@ func TestCompilerErrOutput(t *testing.T) {
175
177
"column": 10,
176
178
}
177
179
]`)
178
-
}
180
+
})
181
+
182
+
t.Run("LibraryDiscoverFalseErrors", func(t *testing.T) {
183
+
// Check that library discover do not generate false errors
184
+
// https://github.com/arduino/arduino-cli/issues/2263
179
185
180
-
// Check that library discover do not generate false errors
181
-
// https://github.com/arduino/arduino-cli/issues/2263
182
-
{
183
186
// prepare sketch
184
187
sketch, err := paths.New("testdata", "using_Wire").Abs()
185
188
require.NoError(t, err)
@@ -191,7 +194,32 @@ func TestCompilerErrOutput(t *testing.T) {
191
194
jsonOut.Query(".compiler_out").MustNotContain(`"fatal error"`)
192
195
jsonOut.Query(".compiler_err").MustNotContain(`"fatal error"`)
193
196
jsonOut.MustNotContain(`{ "diagnostics" : [] }`)
194
-
}
197
+
})
198
+
199
+
t.Run("PreprocessorErrorsOnStderr", func(t *testing.T) {
200
+
// Test the preprocessor errors are present in the diagnostics
201
+
// when they are printed on stderr
202
+
203
+
// prepare sketch
204
+
sketch, err := paths.New("testdata", "blink_with_error_directive").Abs()
205
+
require.NoError(t, err)
206
+
207
+
// Run compile and catch err stream
208
+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--json", sketch.String())
209
+
require.Error(t, err)
210
+
jsonOut := requirejson.Parse(t, out)
211
+
jsonOut.Query(".compiler_out").MustNotContain(`"error:"`)
212
+
jsonOut.Query(".compiler_err").MustContain(`"error:"`)
213
+
jsonOut.Query(`.builder_result.diagnostics`).MustContain(`
214
+
[
215
+
{
216
+
"severity": "ERROR",
217
+
"message": "#error void setup(){} void loop(){}\n #error void setup(){} void loop(){}\n ^~~~~",
218
+
"line": 1,
219
+
"column": 2
220
+
}
221
+
]`)
222
+
})
195
223
}
196
224
197
225
func TestCompileRelativeLibraryPath(t *testing.T) {
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4