3 # Copyright 2019 The Go Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style
5 # license that can be found in the LICENSE file.
7 # Run govim integration tests against a local gopls.
11 Usage: $0 [--sudo] [--short] [--version (semver|latest)]
14 --sudo run docker with sudo
15 --short run `go test` with `-short`
16 --version run on the specific tagged Go version (or latest) rather
17 than the default branch
19 Run govim tests against HEAD using local docker.
25 DOCKERFILE=gopls/integration/govim/Dockerfile
27 while [[ $# -gt 0 ]]; do
29 "-h" | "--help" | "help")
34 SUDO_IF_NEEDED="sudo "
42 if [[ -z "$2" ]]; then
47 if [[ "${GOVIM_REF}" == "latest" ]]; then
48 TMPGOPATH=$(mktemp -d)
49 trap "GOPATH=${TMPGOPATH} go clean -modcache && rm -r ${TMPGOPATH}" EXIT
50 GOVIM_REF=$(GOPATH=${TMPGOPATH} go mod download -json \
51 github.com/govim/govim@latest | jq -r .Version)
61 # Find the tools root, so that this script can be run from any directory.
62 script_dir=$(dirname "$(readlink -f "$0")")
63 tools_dir=$(readlink -f "${script_dir}/../../..")
66 cd "${tools_dir}/gopls"
67 temp_gopls=$(mktemp -p "$PWD")
68 trap "rm -f \"${temp_gopls}\"" EXIT
69 # For consistency across environments, use golang docker to build rather than
70 # the local go command.
71 ${SUDO_IF_NEEDED}docker run --rm -t \
72 -v "${tools_dir}:/src/tools" \
73 -w "/src/tools/gopls" \
75 go build -o $(basename ${temp_gopls})
77 # Build the test harness. Here we are careful to pass in a very limited build
78 # context so as to optimize caching.
79 echo "Checking out govim@${GOVIM_REF}"
81 ${SUDO_IF_NEEDED}docker build \
82 --build-arg GOVIM_REF="${GOVIM_REF}" \
83 -t gopls-govim-harness:${GOVIM_REF} \
84 -f gopls/integration/govim/Dockerfile \
85 gopls/integration/govim
87 # Run govim integration tests.
88 echo "running govim integration tests using ${temp_gopls}"
89 temp_gopls_name=$(basename "${temp_gopls}")
90 ${SUDO_IF_NEEDED}docker run --rm -t \
91 -v "${tools_dir}:/src/tools" \
93 --ulimit memlock=-1:-1 \
94 gopls-govim-harness:${GOVIM_REF} \
95 go test ${TEST_SHORT} ./cmd/govim \
96 -gopls "/src/tools/gopls/${temp_gopls_name}"