aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/list_cgo_compiled_importmap.txt
blob: 3d68ef3055972e5310191f86942248817685d7d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# Regression test for https://golang.org/issue/46462.
#
# The "runtime/cgo" import found in synthesized .go files (reported in
# the CompiledGoFiles field) should have a corresponding entry in the
# ImportMap field when a runtime/cgo variant (such as a test variant)
# will be used.

[short] skip  # -compiled can be slow (because it compiles things)
[!cgo] skip

env CGO_ENABLED=1
env GOFLAGS=-tags=netcgo  # Force net to use cgo even on Windows.


# "runtime/cgo [runtime.test]" appears in the the test dependencies of "runtime",
# because "runtime/cgo" itself depends on "runtime"

go list -deps -test -compiled -f '{{if eq .ImportPath "net [runtime.test]"}}{{printf "%q" .Imports}}{{end}}' runtime

	# Control case: the explicitly-imported package "sync" is a test variant,
	# because "sync" depends on "runtime".
stdout '"sync \[runtime\.test\]"'
! stdout '"sync"'

	# Experiment: the implicitly-imported package "runtime/cgo" is also a test variant,
	# because "runtime/cgo" also depends on "runtime".
stdout '"runtime/cgo \[runtime\.test\]"'
! stdout '"runtime/cgo"'


# Because the import of "runtime/cgo" in the cgo-generated file actually refers
# to "runtime/cgo [runtime.test]", the latter should be listed in the ImportMap.
# BUG(#46462): Today, it is not.

go list -deps -test -compiled -f '{{if eq .ImportPath "net [runtime.test]"}}{{printf "%q" .ImportMap}}{{end}}' runtime

stdout '"sync":"sync \[runtime\.test\]"'                # control
stdout '"runtime/cgo":"runtime/cgo \[runtime\.test\]"'  # experiment