Skip to content

Commit

Permalink
Added integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Nov 8, 2023
1 parent 6c4fd2a commit 4c9f2b0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion internal/cli/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ type compileResult struct {
Success bool `json:"success"`
ProfileOut string `json:"profile_out,omitempty"`
Error string `json:"error,omitempty"`
Diagnostics []*result.CompileDiagnostic `json:"diagnostics"`
Diagnostics []*result.CompileDiagnostic `json:"diagnostics,omitempty"`
showPropertiesMode arguments.ShowPropertiesMode
hideStats bool
}
Expand Down
16 changes: 13 additions & 3 deletions internal/integrationtest/compile_3/compile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,19 @@ func TestCompilerErrOutput(t *testing.T) {
require.NoError(t, err)

// Run compile and catch err stream
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "--format", "json", sketch.String())
out, _, err := cli.Run("compile", "-b", "arduino:avr:uno", "-v", "--format", "json", sketch.String())
require.Error(t, err)
compilerErr := requirejson.Parse(t, out).Query(".compiler_err")
compilerErr.MustContain(`"error"`)
outJson := requirejson.Parse(t, out)
outJson.Query(`.compiler_err`).MustContain(`"error"`)
outJson.Query(`.diagnostics`).MustContain(`
[
{
"severity": "ERROR",
"line": 1,
"column": 14,
"context": [ { "message": "In function 'void wrong()':" } ]
}
]`)
}

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

Expand Down

0 comments on commit 4c9f2b0

Please sign in to comment.