MCPcopy
hub / github.com/tinygo-org/tinygo / TestErrors

Function TestErrors

errors_test.go:17–58  ·  view source on GitHub ↗

Test the error messages of the TinyGo compiler.

(t *testing.T)

Source from the content-addressed store, hash-verified

15
16// Test the error messages of the TinyGo compiler.
17func TestErrors(t *testing.T) {
18 // TODO: nicely formatted error messages for:
19 // - duplicate symbols in ld.lld (currently only prints bitcode file)
20 type errorTest struct {
21 name string
22 target string
23 }
24 for _, tc := range []errorTest{
25 {name: "cgo"},
26 {name: "compiler"},
27 {name: "interp"},
28 {name: "invalidmain"},
29 {name: "invalidname"},
30 {name: "linker-flashoverflow", target: "cortex-m-qemu"},
31 {name: "linker-ramoverflow", target: "cortex-m-qemu"},
32 {name: "linker-undefined", target: "darwin/arm64"},
33 {name: "linker-undefined", target: "linux/amd64"},
34 //{name: "linker-undefined", target: "windows/amd64"}, // TODO: no source location
35 {name: "linker-undefined", target: "cortex-m-qemu"},
36 //{name: "linker-undefined", target: "wasip1"}, // TODO: no source location
37 {name: "loader-importcycle"},
38 {name: "loader-invaliddep"},
39 {name: "loader-invalidpackage"},
40 {name: "loader-nopackage"},
41 {name: "optimizer"},
42 {name: "syntax"},
43 {name: "types"},
44 } {
45 name := tc.name
46 if tc.target != "" {
47 name += "#" + tc.target
48 }
49 target := tc.target
50 if target == "" {
51 target = "wasip1"
52 }
53 t.Run(name, func(t *testing.T) {
54 options := optionsFromTarget(target, sema)
55 testErrorMessages(t, "./testdata/errors/"+tc.name+".go", &options)
56 })
57 }
58}
59
60func testErrorMessages(t *testing.T, filename string, options *compileopts.Options) {
61 t.Parallel()

Callers

nothing calls this directly

Calls 3

optionsFromTargetFunction · 0.85
testErrorMessagesFunction · 0.85
RunMethod · 0.45

Tested by

no test coverage detected