Skip to content

Commit 4c9f2b0

Browse files
committed
Added integration test
1 parent 6c4fd2a commit 4c9f2b0

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Diff for: internal/cli/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ type compileResult struct {
400400
Success bool `json:"success"`
401401
ProfileOut string `json:"profile_out,omitempty"`
402402
Error string `json:"error,omitempty"`
403-
Diagnostics []*result.CompileDiagnostic `json:"diagnostics"`
403+
Diagnostics []*result.CompileDiagnostic `json:"diagnostics,omitempty"`
404404
showPropertiesMode arguments.ShowPropertiesMode
405405
hideStats bool
406406
}

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

+13-3
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,19 @@ func TestCompilerErrOutput(t *testing.T) {
113113
require.NoError(t, err)
114114

115115
// Run compile and catch err stream
116-
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "--format", "json", sketch.String())
116+
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
117117
require.Error(t, err)
118-
compilerErr := requirejson.Parse(t, out).Query(".compiler_err")
119-
compilerErr.MustContain(`"error"`)
118+
outJson := requirejson.Parse(t, out)
119+
outJson.Query(`.compiler_err`).MustContain(`"error"`)
120+
outJson.Query(`.diagnostics`).MustContain(`
121+
[
122+
{
123+
"severity": "ERROR",
124+
"line": 1,
125+
"column": 14,
126+
"context": [ { "message": "In function 'void wrong()':" } ]
127+
}
128+
]`)
120129
}
121130

122131
// Check that library discover do not generate false errors
@@ -132,6 +141,7 @@ func TestCompilerErrOutput(t *testing.T) {
132141
jsonOut := requirejson.Parse(t, out)
133142
jsonOut.Query(".compiler_out").MustNotContain(`"fatal error"`)
134143
jsonOut.Query(".compiler_err").MustNotContain(`"fatal error"`)
144+
jsonOut.MustNotContain(`{ "diagnostics" : [] }`)
135145
}
136146
}
137147

0 commit comments

Comments
 (0)