...

Text file src/cmd/go/testdata/script/build_json.txt

Documentation: cmd/go/testdata/script

     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
     5stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"# m/compileerror\\n"\}$'
     6stdout '^\{"ImportPath":"m/compileerror","Action":"build-output","Output":"compileerror(/|\\\\)main.go:3:11: undefined: y\\n"}$'
     7stdout '^\{"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
    12stdout '"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
    18stdout '"ImportPath":"x","Action":"build-output","Output":".*package x is not in std.*\\n"'
    19stdout '"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
    24stdout '"ImportPath":"x","Action":"build-output","Output":".*package x is not in std.*\\n"'
    25stdout '"ImportPath":"x","Action":"build-fail"'
    26! stderr '.'
    27
    28-- go.mod --
    29module m
    30go 1.21
    31-- compileerror/main.go --
    32package compileerror
    33
    34const x = y
    35-- importerror/main.go --
    36package main
    37
    38import _ "m/compileerror"
    39-- loaderror/main.go --
    40// A bad import causes a failure directly in cmd/go during import processing.
    41
    42package loaderror
    43
    44import _ "x"
    45-- loadimporterror/main.go --
    46package loadimporterror
    47
    48import _ "m/loaderror"

View as plain text