main: change -json flag to match upstream Go

This changes the -json flag for build/run/flash/gdb etc commands to not
print `compileopts.Config` but instead match upstream Go and print build
errors in a structured way.

For more details, see the proposal:
https://github.com/golang/go/issues/62067
This commit is contained in:
Ayke van Laethem
2025-04-18 11:49:41 +02:00
committed by Ron Evans
parent aa63f26f36
commit c2765e9eca
3 changed files with 73 additions and 29 deletions
+6 -1
View File
@@ -8,6 +8,7 @@ import (
"strings"
"testing"
"github.com/tinygo-org/tinygo/builder"
"github.com/tinygo-org/tinygo/compileopts"
"github.com/tinygo-org/tinygo/diagnostics"
)
@@ -64,7 +65,11 @@ func testErrorMessages(t *testing.T, filename string, options *compileopts.Optio
// Try to build a binary (this should fail with an error).
tmpdir := t.TempDir()
err := Build(filename, tmpdir+"/out", options)
config, err := builder.NewConfig(options)
if err != nil {
t.Fatal("expected to get a compiler error")
}
err = Build(filename, tmpdir+"/out", config)
if err == nil {
t.Fatal("expected to get a compiler error")
}