Text file
src/cmd/go/testdata/script/list_cgo_compiled_importmap.txt
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
11 env CGO_ENABLED=1
12 env GOFLAGS=-tags=netcgo # Force net to use cgo even on Windows.
13
14
15 # "runtime/cgo [runtime.test]" appears in the test dependencies of "runtime",
16 # because "runtime/cgo" itself depends on "runtime"
17
18 go list -deps -test -compiled -f '{{if eq .ImportPath "net [runtime.test]"}}{{printf "%q" .Imports}}{{end}}' runtime
19
20 # Control case: the explicitly-imported package "sync" is a test variant,
21 # because "sync" depends on "runtime".
22 stdout '"sync \[runtime\.test\]"'
23 ! stdout '"sync"'
24
25 # Experiment: the implicitly-imported package "runtime/cgo" is also a test variant,
26 # because "runtime/cgo" also depends on "runtime".
27 stdout '"runtime/cgo \[runtime\.test\]"'
28 ! stdout '"runtime/cgo"'
29
30
31 # Because the import of "runtime/cgo" in the cgo-generated file actually refers
32 # to "runtime/cgo [runtime.test]", the latter should be listed in the ImportMap.
33 # BUG(#46462): Today, it is not.
34
35 go list -deps -test -compiled -f '{{if eq .ImportPath "net [runtime.test]"}}{{printf "%q" .ImportMap}}{{end}}' runtime
36
37 stdout '"sync":"sync \[runtime\.test\]"' # control
38 stdout '"runtime/cgo":"runtime/cgo \[runtime\.test\]"' # experiment
39
View as plain text