Skip to content

Commit 4c1ea05

Browse files
committed
gopls/integration/govim: improvements/fixes for run_local.sh
With the update to go1.14, run_local.sh runs into the ubuntu mlock issue. Fix this by setting memlock=unlimited. Also make it possible to run docker with sudo, and run -short tests. Change-Id: I8c9e44cd16f0a2a0d77bf28133ad4f111058b5cf Reviewed-on: https://go-review.googlesource.com/c/tools/+/225520 Reviewed-by: Rebecca Stambler <[email protected]>
1 parent 644a21f commit 4c1ea05

File tree

3 files changed

+42
-10
lines changed

3 files changed

+42
-10
lines changed

gopls/integration/govim/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# govim requires a more recent version of vim than is available in most
66
# distros, so we build from their base image.
7-
FROM govim/govim:go1.14_vim_v8.1.2056_v1
7+
FROM govim/govim:latest-vim
88

99
# We use a pinned version of govim so that this build is repeatable, and so
1010
# that we're not sensitive to test breakages in govim.

gopls/integration/govim/README.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ storage bucket owned by that project.
1414
```
1515
$ gcloud builds submit \
1616
--project="${PROJECT_ID}" \
17-
--config=gopls/integration/govim/cloudbuild.harness.yaml \
18-
--substitutions=_RESULT_BUCKET="${BUCKET}"
17+
--config=gopls/integration/govim/cloudbuild.harness.yaml
1918
```
2019
- Run the integration tests:
2120
```
@@ -39,7 +38,10 @@ evaluation id.
3938
## Running locally
4039

4140
Run `gopls/integration/govim/run_local.sh`. This may take a while the first
42-
time it is run, as it will require building the test harness. Currently this
43-
script assumes that docker may be executed without `sudo`.
41+
time it is run, as it will require building the test harness. This script
42+
accepts two flags to modify its behavior:
43+
44+
**--sudo**: run docker with `sudo`
45+
**--short**: run `go test -short`
4446

4547
[govim]: https://github.com/govim/govim

gopls/integration/govim/run_local.sh

+35-5
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,37 @@
55
# license that can be found in the LICENSE file.
66

77
# Run govim integration tests against a local gopls.
8-
# TODO(findleyr): this script assumes that docker may be run without sudo.
9-
# Update it to escalate privileges if and only if necessary.
8+
9+
usage() {
10+
cat <<EOUSAGE
11+
Usage: $0 [--sudo] [--short]
12+
13+
Run govim tests against HEAD using local docker. If --sudo is set, run docker
14+
with sudo. If --short is set, run `go test` with `-short`.
15+
EOUSAGE
16+
}
17+
18+
SUDO_IF_NEEDED=
19+
TEST_SHORT=
20+
while [[ $# -gt 0 ]]; do
21+
case "$1" in
22+
"-h" | "--help" | "help")
23+
usage
24+
exit 0
25+
;;
26+
"--sudo")
27+
SUDO_IF_NEEDED="sudo "
28+
shift
29+
;;
30+
"--short")
31+
TEST_SHORT="-short"
32+
shift
33+
;;
34+
*)
35+
usage
36+
exit 1
37+
esac
38+
done
1039

1140
# Find the tools root, so that this script can be run from any directory.
1241
script_dir=$(dirname "$(readlink -f "$0")")
@@ -21,15 +50,16 @@ go build -o "${temp_gopls}"
2150
# Build the test harness. Here we are careful to pass in a very limited build
2251
# context so as to optimize caching.
2352
cd "${tools_dir}"
24-
docker build -t gopls-govim-harness -f gopls/integration/govim/Dockerfile \
53+
${SUDO_IF_NEEDED}docker build -t gopls-govim-harness -f gopls/integration/govim/Dockerfile \
2554
gopls/integration/govim
2655

2756
# Run govim integration tests.
2857
echo "running govim integration tests using ${temp_gopls}"
2958
temp_gopls_name=$(basename "${temp_gopls}")
30-
docker run --rm -t \
59+
${SUDO_IF_NEEDED}docker run --rm -t \
3160
-v "${tools_dir}:/src/tools" \
3261
-w "/src/govim" \
62+
--ulimit memlock=-1:-1 \
3363
gopls-govim-harness \
34-
go test ./cmd/govim \
64+
go test ${TEST_SHORT} ./cmd/govim \
3565
-gopls "/src/tools/gopls/${temp_gopls_name}"

0 commit comments

Comments
 (0)