Skip to content

Commit 0542939

Browse files
committed
Update test-and-docs with TESTDIRS
… and fix the rendering of `make test-unit` with TESTDIRS :) Signed-off-by: Vincent Demeester <[email protected]>
1 parent 49066f6 commit 0542939

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

docs/project/test-and-docs.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,29 @@ Most test targets require that you build these precursor targets first:
185185

186186
## Running individual or multiple named tests
187187

188+
### Unit tests
189+
190+
We use golang standard [testing](https://golang.org/pkg/testing/)
191+
package or [gocheck](https://labix.org/gocheck) for our unit tests.
192+
193+
You can use the `TESTDIRS` environment variable to run unit tests for
194+
a single package.
195+
196+
$ TESTDIRS='opts' make test-unit
197+
198+
You can also use the `TESTFLAGS` environment variable to run a single test. The
199+
flag's value is passed as arguments to the `go test` command. For example, from
200+
your local host you can run the `TestBuild` test with this command:
201+
202+
$ TESTFLAGS='-test.run ^TestValidateIPAddress$' make test-unit
203+
204+
On unit tests, it's better to use `TESTFLAGS` in combination with
205+
`TESTDIRS` to make it quicker to run a specific test.
206+
207+
$ TESTDIRS='opts' TESTFLAGS='-test.run ^TestValidateIPAddress$' make test-unit
208+
209+
### Integration tests
210+
188211
We use [gocheck](https://labix.org/gocheck) for our integration-cli tests.
189212
You can use the `TESTFLAGS` environment variable to run a single test. The
190213
flag's value is passed as arguments to the `go test` command. For example, from

hack/make/test-unit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ go_run_test_dir() {
5656
TESTS_FAILED=()
5757
while read dir; do
5858
echo
59-
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}"
59+
echo '+ go test' $TESTFLAGS "${DOCKER_PKG}/${dir#./}"
6060
precompiled="$ABS_DEST/precompiled/$dir.test$(binary_extension)"
6161
if ! ( cd "$dir" && test_env "$precompiled" $TESTFLAGS ); then
6262
TESTS_FAILED+=("$dir")

0 commit comments

Comments
 (0)