Skip to content

Commit fa37144

Browse files
committed
Added integration test
1 parent e22ff66 commit fa37144

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

internal/integrationtest/compile_3/compile_test.go

+25
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,31 @@ func TestCompilerErrOutput(t *testing.T) {
195195
jsonOut.Query(".compiler_err").MustNotContain(`"fatal error"`)
196196
jsonOut.MustNotContain(`{ "diagnostics" : [] }`)
197197
})
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+
})
198223
}
199224

200225
func TestCompileRelativeLibraryPath(t *testing.T) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#error void setup(){} void loop(){}

0 commit comments

Comments
 (0)