1 [short] skip
2
3 # Basic build error. This test also checks that the output is fully-formed JSON.
4 ! go build -json -o=$devnull ./compileerror
5 stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"# m/compileerror\\n"\}$'
6 stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"compileerror(/|\\\\)main.go:3:11: undefined: y\\n"}$'
7 stdout '^\{"ImportPath":"m/compileerror","Action":"build-fail"\}$'
8 ! stderr '.'
9
10 # Check that a build failure in an imported package is attributed correctly.
11 ! go build -json -o=$devnull ./importerror
12 stdout '"ImportPath":"m/compileerror","Action":"build-fail"'
13 ! stderr '.'
14
15 # TODO(#65335): Attributing this to "x" doesn't make much sense,
16 # especially since the reported line is the import statement.
17 ! go build -json -o=$devnull ./loaderror
18 stdout '"ImportPath":"x","Action":"build-output","Output":".*package x is not in std.*\\n"'
19 stdout '"ImportPath":"x","Action":"build-fail"'
20 ! stderr '.'
21
22 # Check that a load error in an imported package is attributed correctly.
23 ! go build -json -o=$devnull ./loadimporterror
24 stdout '"ImportPath":"x","Action":"build-output","Output":".*package x is not in std.*\\n"'
25 stdout '"ImportPath":"x","Action":"build-fail"'
26 ! stderr '.'
27
28 -- go.mod --
29 module m
30 go 1.21
31 -- compileerror/main.go --
32 package compileerror
33
34 const x = y
35 -- importerror/main.go --
36 package main
37
38 import _ "m/compileerror"
39 -- loaderror/main.go --
40 // A bad import causes a failure directly in cmd/go during import processing.
41
42 package loaderror
43
44 import _ "x"
45 -- loadimporterror/main.go --
46 package loadimporterror
47
48 import _ "m/loaderror"
49
View as plain text