Skip to content

Commit a6ff664

Browse files
committed
Makefile: add 'e2e-test' target
Add a target to the Makefile that installs the end-to-end test NPM dependencies then runs the tests. By default, this will only run tests matching the "default" profile of the tests (excluding performance tests). The 'E2E_FLAGS' variable can be used to specify the profile(s) used by the tests (e.g., '--all' to include the tests excluded by default). Add documentation on how to run the end-to-end tests to 'README.md'. Signed-off-by: Victoria Dye <[email protected]>
1 parent 704f46f commit a6ff664

File tree

3 files changed

+82
-4
lines changed

3 files changed

+82
-4
lines changed

Makefile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ INSTALL_ROOT := /
1313
BINDIR := $(CURDIR)/bin
1414
DISTDIR := $(CURDIR)/_dist
1515
DOCDIR := $(CURDIR)/_docs
16+
TESTDIR := $(CURDIR)/_test
1617

1718
# Platform information
1819
GOOS := $(shell go env GOOS)
@@ -26,6 +27,7 @@ PACKAGE_ARCH := $(GOARCH)
2627
APPLE_APP_IDENTITY =
2728
APPLE_INST_IDENTITY =
2829
APPLE_KEYCHAIN_PROFILE =
30+
E2E_FLAGS=
2931

3032
# Build targets
3133
.PHONY: build
@@ -39,6 +41,14 @@ doc:
3941
@scripts/make-docs.sh --docs="$(CURDIR)/docs/man" \
4042
--output="$(DOCDIR)"
4143

44+
# Testing targets
45+
.PHONY: e2e-test
46+
e2e-test: build
47+
@echo
48+
@echo "======== Running end-to-end tests ========"
49+
$(RM) -r $(TESTDIR)
50+
@scripts/run-e2e-tests.sh $(E2E_FLAGS)
51+
4252
# Installation targets
4353
.PHONY: install
4454
install: build doc
@@ -170,3 +180,4 @@ clean:
170180
$(RM) -r $(BINDIR)
171181
$(RM) -r $(DISTDIR)
172182
$(RM) -r $(DOCDIR)
183+
$(RM) -r $(TESTDIR)

README.md

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,45 @@ $ go build -o bin/ ./...
170170

171171
### Testing and Linting
172172

173-
To run the project's unit tests, navigate to the repository root directory and
174-
run `go test -v ./...`.
173+
Unless otherwise specified, run commands from the repository root.
175174

176-
To run the project's linter, navigate to the repository root directory and run
177-
`go vet ./...`.
175+
#### Unit tests
176+
177+
```
178+
go test -v ./...
179+
```
180+
181+
#### Linter
182+
183+
```
184+
go vet ./...
185+
```
186+
187+
#### End-to-end tests
188+
189+
In order to run these tests, you need to have a recent version of
190+
[Node.js](https://nodejs.org) (current LTS version is a pretty safe bet) and NPM
191+
installed.
192+
193+
For the standard set of tests (i.e., excluding exceptionally slow tests), run:
194+
195+
```
196+
make e2e-test
197+
```
198+
199+
To configure the test execution and filtering, set the `E2E_FLAGS` build
200+
variable. The available options are:
201+
202+
* `--offline`: run all tests except those that require internet access.
203+
* `--all`: run all tests, including slow performance tests.
204+
205+
The above modes are mutually exclusive; if multiple are specified, only the last
206+
will be used. For example, `E2E_FLAGS="--offline --all"` is equivalent to
207+
`E2E_FLAGS="--all"`.
208+
209+
:warning: The performance tests that are excluded by default clone very large
210+
repos from the internet and can take anywhere from ~30 minutes to multiple hours
211+
to run, depending on internet connectivity and other system resources.
178212

179213
## License
180214

scripts/run-e2e-tests.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
THISDIR="$( cd "$(dirname "$0")" ; pwd -P )"
4+
TESTDIR="$THISDIR/../test/e2e"
5+
6+
# Defaults
7+
ARGS=()
8+
9+
# Parse script arguments
10+
for i in "$@"
11+
do
12+
case "$i" in
13+
--offline)
14+
ARGS+=("-p" "offline")
15+
shift # past argument
16+
;;
17+
--all)
18+
ARGS+=("-p" "all")
19+
shift # past argument
20+
;;
21+
*)
22+
die "unknown option '$i'"
23+
;;
24+
esac
25+
done
26+
27+
# Exit as soon as any line fails
28+
set -e
29+
30+
cd "$TESTDIR"
31+
32+
npm install
33+
npm run test -- ${ARGS:+${ARGS[*]}}

0 commit comments

Comments
 (0)