...

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

Documentation: cmd/go/testdata/script

     1# Regression test for https://golang.org/issue/46462.
     2#
     3# The "runtime/cgo" import found in synthesized .go files (reported in
     4# the CompiledGoFiles field) should have a corresponding entry in the
     5# ImportMap field when a runtime/cgo variant (such as a test variant)
     6# will be used.
     7
     8[short] skip  # -compiled can be slow (because it compiles things)
     9[!cgo] skip
    10[GOOS:darwin] skip # net package does not import "C" on Darwin
    11[GOOS:windows] skip # net package does not import "C" on Windows
    12[GOOS:plan9] skip # net package does not import "C" on Plan 9
    13
    14env CGO_ENABLED=1
    15env GOFLAGS=-tags=netcgo  # Force net to use cgo
    16
    17
    18# "runtime/cgo [runtime.test]" appears in the test dependencies of "runtime",
    19# because "runtime/cgo" itself depends on "runtime"
    20
    21go list -deps -test -compiled -f '{{if eq .ImportPath "net [runtime.test]"}}{{printf "%q" .Imports}}{{end}}' runtime
    22
    23	# Control case: the explicitly-imported package "sync" is a test variant,
    24	# because "sync" depends on "runtime".
    25stdout '"sync \[runtime\.test\]"'
    26! stdout '"sync"'
    27
    28	# Experiment: the implicitly-imported package "runtime/cgo" is also a test variant,
    29	# because "runtime/cgo" also depends on "runtime".
    30stdout '"runtime/cgo \[runtime\.test\]"'
    31! stdout '"runtime/cgo"'
    32
    33
    34# Because the import of "runtime/cgo" in the cgo-generated file actually refers
    35# to "runtime/cgo [runtime.test]", the latter should be listed in the ImportMap.
    36# BUG(#46462): Today, it is not.
    37
    38go list -deps -test -compiled -f '{{if eq .ImportPath "net [runtime.test]"}}{{printf "%q" .ImportMap}}{{end}}' runtime
    39
    40stdout '"sync":"sync \[runtime\.test\]"'                # control
    41stdout '"runtime/cgo":"runtime/cgo \[runtime\.test\]"'  # experiment

View as plain text