зеркало из https://github.com/golang/tools.git
gopls/integration: add a first cut of govim integration tests
Govim has integration tests that we can leverage to help guard gopls against regressions. Changes have been submitted upstream to facilitate running these tests against a locally built gopls binary (https://github.com/govim/govim/pull/629) This CL adds a Dockerfile to build an image that has a version of govim available and ready for testing. This is then used to create a custom build step in a separate Cloud Build configuration, that builds gopls from source and runs the govim integration tests. A script (run_local.sh) is also added to facilitate running these tests locally. Change-Id: If68eabf9863a1689e29d9d744ff953d94a2b7681 Reviewed-on: https://go-review.googlesource.com/c/tools/+/212018 Reviewed-by: Paul Jolly <paul@myitcv.org.uk> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Родитель
8c5978f193
Коммит
d7ab245118
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2019 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
# govim requires a more recent version of vim than is available in most
|
||||
# distros, so we build from their base image.
|
||||
FROM govim/govim:go1.13.5_vim_v8.1.2414_v1
|
||||
|
||||
# Get a copy of govim in order to run its integration tests. We use a pinned
|
||||
# version so that this build is repeatable, and so that we're not sensitive to
|
||||
# test breakages in govim.
|
||||
# TODO(findleyr): Once a version of govim has been tagged containing
|
||||
# https://github.com/govim/govim/pull/629, switch this to @latest.
|
||||
ENV GOPROXY=https://proxy.golang.org GOPATH=/go VIM_FLAVOR=vim
|
||||
WORKDIR /src/mod
|
||||
RUN go mod init mod && go get -t github.com/govim/govim@v0.0.27-0.20191220164001-63ce556bb69e
|
|
@ -0,0 +1,27 @@
|
|||
# govim integration tests
|
||||
|
||||
Files in this directory configure Cloud Build to run [govim] integration tests
|
||||
against a gopls binary built from source.
|
||||
|
||||
## Running on GCP
|
||||
|
||||
To run these integration tests in Cloud Build (assuming the `gcloud` command is
|
||||
configured for a valid GCP project):
|
||||
|
||||
- `cd` to the root directory of the tools project.
|
||||
- (at least once per GCP project) Build the test harness:
|
||||
```
|
||||
$ gcloud builds submit --config=gopls/integration/govim/cloudbuild.harness.yaml
|
||||
```
|
||||
- Run the integration tests:
|
||||
```
|
||||
$ gcloud builds submit --config=gopls/integration/govim/cloudbuild.yaml
|
||||
```
|
||||
|
||||
## Running locally
|
||||
|
||||
Run `gopls/integration/govim/run_local.sh`. This may take a while the first
|
||||
time it is run, as it will require building the test harness. Currently this
|
||||
script assumes that docker may be executed without `sudo`.
|
||||
|
||||
[govim]: https://github.com/govim/govim
|
|
@ -0,0 +1,17 @@
|
|||
# Copyright 2019 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
# Build the govim test harness that will be used to run govim integration tests
|
||||
# for gopls. See README.md for instructions on how to use this.
|
||||
steps:
|
||||
- name: 'gcr.io/cloud-builders/docker'
|
||||
args: ['build', '-t', 'gcr.io/$PROJECT_ID/govim-harness',
|
||||
# It is assumed that this build is running from the root directory of the
|
||||
# tools repository.
|
||||
'-f', 'gopls/integration/govim/Dockerfile',
|
||||
# Use the integration test directory as build context: the test harness
|
||||
# doesn't actually require any local files.
|
||||
'gopls/integration/govim']
|
||||
images:
|
||||
- gcr.io/$PROJECT_ID/govim-harness
|
|
@ -0,0 +1,23 @@
|
|||
# Copyright 2019 The Go Authors. All rights reserved.
|
||||
# Use of this source code is governed by a BSD-style
|
||||
# license that can be found in the LICENSE file.
|
||||
|
||||
# Build gopls, and run the govim integration tests. See README.md for
|
||||
# instructions on how to use this.
|
||||
steps:
|
||||
- name: 'golang:1.13'
|
||||
env: ['GOPROXY=https://proxy.golang.org']
|
||||
dir: 'gopls'
|
||||
args: ['go', 'build']
|
||||
- name: 'gcr.io/$PROJECT_ID/govim-harness'
|
||||
# Work in the dummy module created in the test harness, that requires a
|
||||
# pinned version of github.com/govim/govim.
|
||||
dir: '/src/mod'
|
||||
# The below setting currently causes too much noise on STDERR.
|
||||
# TODO(findleyr): look into govim changes that make it easier to capture
|
||||
# individual logs as build artifacts.
|
||||
# env: ['GOVIM_TESTSCRIPT_STDERR=true']
|
||||
args: ['go', 'test',
|
||||
'github.com/govim/govim/cmd/govim',
|
||||
# Specify the path to the gopls binary built in step 0.
|
||||
'-gopls', '/workspace/gopls/gopls']
|
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# Run govim integration tests against a local gopls.
|
||||
# TODO(findleyr): this script assumes that docker may be run without sudo.
|
||||
# Update it to escalate privileges if and only if necessary.
|
||||
|
||||
# Find the tools root, so that this script can be run from any directory.
|
||||
script_dir=$(dirname "$(readlink -f "$0")")
|
||||
tools_dir=$(readlink -f "${script_dir}/../../..")
|
||||
|
||||
# Build gopls.
|
||||
cd "${tools_dir}/gopls"
|
||||
temp_gopls=$(mktemp -p "$PWD")
|
||||
trap "rm -f \"${temp_gopls}\"" EXIT
|
||||
go build -o "${temp_gopls}"
|
||||
|
||||
# Build the test harness. Here we are careful to pass in a very limited build
|
||||
# context so as to optimize caching.
|
||||
cd "${tools_dir}"
|
||||
docker build -t gopls-govim-harness -f gopls/integration/govim/Dockerfile \
|
||||
gopls/integration/govim
|
||||
|
||||
# Run govim integration tests.
|
||||
echo "running govim integration tests using ${temp_gopls}"
|
||||
temp_gopls_name=$(basename "${temp_gopls}")
|
||||
docker run --rm -t \
|
||||
-v "${tools_dir}:/src/tools" \
|
||||
-w "/src/mod" \
|
||||
gopls-govim-harness \
|
||||
go test github.com/govim/govim/cmd/govim \
|
||||
-gopls "/src/tools/gopls/${temp_gopls_name}"
|
Загрузка…
Ссылка в новой задаче