@@ -195,6 +195,31 @@ func TestCompilerErrOutput(t *testing.T) {
195
195
jsonOut .Query (".compiler_err" ).MustNotContain (`"fatal error"` )
196
196
jsonOut .MustNotContain (`{ "diagnostics" : [] }` )
197
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
+ })
198
223
}
199
224
200
225
func TestCompileRelativeLibraryPath (t * testing.T ) {
0 commit comments