Debian Codegraph @

gopls/integration/govim/run_local.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`. -e
2
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.
6
7 # Run govim integration tests against a local gopls.
8
9 usagescip-shell shell golang-golang-x-tools 1:0.46.0+ds-1 usage().() {
10 catscip-shell system . . cat. <<EOUSAGE
11 Usage: $0 [--sudo] [--short] [--version (semver|latest)]
12
13 Args:
14 --sudo run docker with sudo
15 --short run `goscip-shell system . . go. test` with `-short`
16 --version run on the specific tagged govim version (or latest) rather
17 than the default branch
18
19 Run govim tests against HEAD using local docker.
20 EOUSAGE
21 }
22
23 SUDO_IF_NEEDED=
24 TEST_SHORT=
25 DOCKERFILE=gopls/integration/govim/Dockerfile
26 GOVIM_REF=main
27 while [[ $# -gt 0 ]]; do
28 case "$1" in
29 "-h" | "--help" | "help")
30 usagescip-shell shell golang-golang-x-tools 1:0.46.0+ds-1 usage().
31 exit 0
32 ;;
33 "--sudo")
34 SUDO_IF_NEEDED="sudo "
35 shift
36 ;;
37 "--short")
38 TEST_SHORT="-short"
39 shift
40 ;;
41 "--version")
42 if [[ -z "$2" ]]; then
43 usagescip-shell shell golang-golang-x-tools 1:0.46.0+ds-1 usage().
44 exit 1
45 fi
46 GOVIM_REF=$2
47 if [[ "${GOVIM_REF}" == "latest" ]]; then
48 TMPGOPATH=$(mktempscip-shell system . . mktemp. -d)
49 trap "GOPATH=${TMPGOPATH} go clean -modcache && rm -r ${TMPGOPATH}" EXIT
50 GOVIM_REF=$(GOPATH=${TMPGOPATH} goscip-shell system . . go. mod download -json \
51 github.com/govim/govim@latest | jq -r .Version)
52 fi
53 shift 2
54 ;;
55 *)
56 usagescip-shell shell golang-golang-x-tools 1:0.46.0+ds-1 usage().
57 exit 1
58 esac
59 done
60
61 # Find the tools root, so that this script can be run from any directory.
62 script_dir=$(dirnamescip-shell system . . dirname. "$(readlinkscip-shell system . . readlink. -f "$0")")
63 tools_dir=$(readlinkscip-shell system . . readlink. -f "${script_dir}/../../..")
64
65 # Build gopls.
66 cd "${tools_dir}/gopls"
67 temp_gopls=$(mktempscip-shell system . . 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/goplsscip-shell filesystem . . `/src/tools/gopls`." \
74 golang:rc \
75 go build -o $(basenamescip-shell system . . basename. ${temp_gopls})
76
77 # Build the test harness. Here we are careful to pass in a very limited build
78 # context so as to optimize caching.
79 echoscip-shell system . . echo. "Checking out govim@${GOVIM_REF}"
80 cd "${tools_dir}"
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
86
87 # Run govim integration tests.
88 echoscip-shell system . . echo. "running govim integration tests using ${temp_gopls}"
89 temp_gopls_name=$(basenamescip-shell system . . basename. "${temp_gopls}")
90 ${SUDO_IF_NEEDED}docker run --rm -t \
91 -v "${tools_dir}:/src/tools" \
92 -w "/src/govimscip-shell filesystem . . `/src/govim`." \
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}"