Sfoglia il codice sorgente

Update test-and-docs with TESTDIRS

… and fix the rendering of `make test-unit` with TESTDIRS :)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Vincent Demeester 9 anni fa
parent
commit
0542939f40
2 ha cambiato i file con 24 aggiunte e 1 eliminazioni
  1. 23 0
      docs/project/test-and-docs.md
  2. 1 1
      hack/make/test-unit

+ 23 - 0
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

+ 1 - 1
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")