From 0542939f405ce6c5cad42bd715d7ceefd573db75 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Sun, 4 Oct 2015 00:28:57 +0200 Subject: [PATCH] Update test-and-docs with TESTDIRS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit … and fix the rendering of `make test-unit` with TESTDIRS :) Signed-off-by: Vincent Demeester --- docs/project/test-and-docs.md | 23 +++++++++++++++++++++++ hack/make/test-unit | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/docs/project/test-and-docs.md b/docs/project/test-and-docs.md index 38a4274ad..ec8cd08c2 100644 --- a/docs/project/test-and-docs.md +++ b/docs/project/test-and-docs.md @@ -185,6 +185,29 @@ Most test targets require that you build these precursor targets first: ## Running individual or multiple named tests +### Unit tests + +We use golang standard [testing](https://golang.org/pkg/testing/) +package or [gocheck](https://labix.org/gocheck) for our unit tests. + +You can use the `TESTDIRS` environment variable to run unit tests for +a single package. + + $ TESTDIRS='opts' make test-unit + +You can also use the `TESTFLAGS` environment variable to run a single test. The +flag's value is passed as arguments to the `go test` command. For example, from +your local host you can run the `TestBuild` test with this command: + + $ TESTFLAGS='-test.run ^TestValidateIPAddress$' make test-unit + +On unit tests, it's better to use `TESTFLAGS` in combination with +`TESTDIRS` to make it quicker to run a specific test. + + $ TESTDIRS='opts' TESTFLAGS='-test.run ^TestValidateIPAddress$' make test-unit + +### Integration tests + We use [gocheck](https://labix.org/gocheck) for our integration-cli tests. You can use the `TESTFLAGS` environment variable to run a single test. The flag's value is passed as arguments to the `go test` command. For example, from diff --git a/hack/make/test-unit b/hack/make/test-unit index ae1d4ec41..dae56de2a 100644 --- a/hack/make/test-unit +++ b/hack/make/test-unit @@ -56,7 +56,7 @@ go_run_test_dir() { TESTS_FAILED=() while read dir; do echo - echo '+ go test' $TESTFLAGS "${DOCKER_PKG}${dir#.}" + echo '+ go test' $TESTFLAGS "${DOCKER_PKG}/${dir#./}" precompiled="$ABS_DEST/precompiled/$dir.test$(binary_extension)" if ! ( cd "$dir" && test_env "$precompiled" $TESTFLAGS ); then TESTS_FAILED+=("$dir")