env GO111MODULE=off

# Disable systemcrypto while evaluating test dependencies to avoid importing
# vendored crypto module dependencies like golang-fips/openssl. This test script
# is not set up to handle any vendored libraries being imported other than
# golang.org/x/net/http2/hpack, so we must make sure it is the only one.
#
# See https://github.com/microsoft/go/issues/481 for more details, such as the
# dependency chain that would cause the failure if the gocrypt tag isn't used.
env GOEXPERIMENT=none

[!compiler:gc] skip

go list -f '{{.Dir}}' vendor/golang.org/x/net/http2/hpack
stdout $GOPATH[/\\]src[/\\]vendor

# A package importing 'net/http' should resolve its dependencies
# to the package 'vendor/golang.org/x/net/http2/hpack' within GOROOT.
cd importnethttp
go list -deps -f '{{.ImportPath}} {{.Dir}}'
stdout ^vendor/golang.org/x/net/http2/hpack
stdout $GOROOT[/\\]src[/\\]vendor[/\\]golang.org[/\\]x[/\\]net[/\\]http2[/\\]hpack
! stdout $GOPATH[/\\]src[/\\]vendor

# In the presence of $GOPATH/src/vendor/golang.org/x/net/http2/hpack,
# a package in GOPATH importing 'golang.org/x/net/http2/hpack' should
# resolve its dependencies in GOPATH/src.
cd ../issue16333
go build .

go list -deps -f '{{.ImportPath}} {{.Dir}}' .
stdout $GOPATH[/\\]src[/\\]vendor[/\\]golang.org[/\\]x[/\\]net[/\\]http2[/\\]hpack
! stdout $GOROOT[/\\]src[/\\]vendor

go list -test -deps -f '{{.ImportPath}} {{.Dir}}' .
stdout $GOPATH[/\\]src[/\\]vendor[/\\]golang.org[/\\]x[/\\]net[/\\]http2[/\\]hpack
! stdout $GOROOT[/\\]src[/\\]vendor

-- issue16333/issue16333.go --
package vendoring17

import _ "golang.org/x/net/http2/hpack"
-- issue16333/issue16333_test.go --
package vendoring17

import _ "testing"
import _ "golang.org/x/net/http2/hpack"
-- importnethttp/http.go --
package importnethttp

import _ "net/http"
-- $GOPATH/src/vendor/golang.org/x/net/http2/hpack/hpack.go --
package hpack
