From 3e4d4e028773b1e71fc2deeb99602dc6e74c32de 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 Upstream-commit: 0542939f405ce6c5cad42bd715d7ceefd573db75 Component: engine --- .../engine/docs/project/test-and-docs.md | 23 +++++++++++++++++++ components/engine/hack/make/test-unit | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/components/engine/docs/project/test-and-docs.md b/components/engine/docs/project/test-and-docs.md index 38a4274add..ec8cd08c25 100644 --- a/components/engine/docs/project/test-and-docs.md +++ b/components/engine/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/components/engine/hack/make/test-unit b/components/engine/hack/make/test-unit index ae1d4ec415..dae56de2ac 100644 --- a/components/engine/hack/make/test-unit +++ b/components/engine/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")