Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
| ... | ... |
@@ -1,4 +1,4 @@ |
| 1 |
-.PHONY: all binary build cross default docs docs-build docs-shell shell test test-integration test-integration-cli validate |
|
| 1 |
+.PHONY: all binary build cross default docs docs-build docs-shell shell test test-unit test-integration test-integration-cli validate |
|
| 2 | 2 |
|
| 3 | 3 |
# to allow `make BINDDIR=. shell` or `make BINDDIR= test` |
| 4 | 4 |
BINDDIR := bundles |
| ... | ... |
@@ -35,7 +35,10 @@ docs-release: docs-build |
| 35 | 35 |
$(DOCKER_RUN_DOCS) "$(DOCKER_DOCS_IMAGE)" ./release.sh |
| 36 | 36 |
|
| 37 | 37 |
test: build |
| 38 |
- $(DOCKER_RUN_DOCKER) hack/make.sh binary test test-integration test-integration-cli |
|
| 38 |
+ $(DOCKER_RUN_DOCKER) hack/make.sh binary test-unit test-integration test-integration-cli |
|
| 39 |
+ |
|
| 40 |
+test-unit: build |
|
| 41 |
+ $(DOCKER_RUN_DOCKER) hack/make.sh test-unit |
|
| 39 | 42 |
|
| 40 | 43 |
test-integration: build |
| 41 | 44 |
$(DOCKER_RUN_DOCKER) hack/make.sh test-integration |
| 52 | 52 |
deleted file mode 100644 |
| ... | ... |
@@ -1,55 +0,0 @@ |
| 1 |
-#!/bin/bash |
|
| 2 |
-set -e |
|
| 3 |
- |
|
| 4 |
-DEST=$1 |
|
| 5 |
- |
|
| 6 |
-RED=$'\033[31m' |
|
| 7 |
-GREEN=$'\033[32m' |
|
| 8 |
-TEXTRESET=$'\033[0m' # reset the foreground colour |
|
| 9 |
- |
|
| 10 |
-# Run Docker's test suite, including sub-packages, and store their output as a bundle |
|
| 11 |
-# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. |
|
| 12 |
-# You can use this to select certain tests to run, eg. |
|
| 13 |
-# |
|
| 14 |
-# TESTFLAGS='-run ^TestBuild$' ./hack/make.sh test |
|
| 15 |
-# |
|
| 16 |
-bundle_test() {
|
|
| 17 |
- {
|
|
| 18 |
- date |
|
| 19 |
- |
|
| 20 |
- # Run all the tests if no TESTDIRS were specified. |
|
| 21 |
- if [ -z "$TESTDIRS" ]; then |
|
| 22 |
- TESTDIRS=$(find_dirs '*_test.go') |
|
| 23 |
- fi |
|
| 24 |
- |
|
| 25 |
- TESTS_FAILED=() |
|
| 26 |
- for test_dir in $TESTDIRS; do |
|
| 27 |
- echo |
|
| 28 |
- |
|
| 29 |
- if ! LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" go_test_dir "$test_dir"; then |
|
| 30 |
- TESTS_FAILED+=("$test_dir")
|
|
| 31 |
- echo |
|
| 32 |
- echo "${RED}Tests failed: $test_dir${TEXTRESET}"
|
|
| 33 |
- sleep 1 # give it a second, so observers watching can take note |
|
| 34 |
- fi |
|
| 35 |
- done |
|
| 36 |
- |
|
| 37 |
- echo |
|
| 38 |
- echo |
|
| 39 |
- echo |
|
| 40 |
- |
|
| 41 |
- # if some tests fail, we want the bundlescript to fail, but we want to |
|
| 42 |
- # try running ALL the tests first, hence TESTS_FAILED |
|
| 43 |
- if [ "${#TESTS_FAILED[@]}" -gt 0 ]; then
|
|
| 44 |
- echo "${RED}Test failures in: ${TESTS_FAILED[@]}${TEXTRESET}"
|
|
| 45 |
- echo |
|
| 46 |
- false |
|
| 47 |
- else |
|
| 48 |
- echo "${GREEN}Test success${TEXTRESET}"
|
|
| 49 |
- echo |
|
| 50 |
- true |
|
| 51 |
- fi |
|
| 52 |
- } 2>&1 | tee $DEST/test.log |
|
| 53 |
-} |
|
| 54 |
- |
|
| 55 |
-bundle_test |
| 56 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,55 @@ |
| 0 |
+#!/bin/bash |
|
| 1 |
+set -e |
|
| 2 |
+ |
|
| 3 |
+DEST=$1 |
|
| 4 |
+ |
|
| 5 |
+RED=$'\033[31m' |
|
| 6 |
+GREEN=$'\033[32m' |
|
| 7 |
+TEXTRESET=$'\033[0m' # reset the foreground colour |
|
| 8 |
+ |
|
| 9 |
+# Run Docker's test suite, including sub-packages, and store their output as a bundle |
|
| 10 |
+# If $TESTFLAGS is set in the environment, it is passed as extra arguments to 'go test'. |
|
| 11 |
+# You can use this to select certain tests to run, eg. |
|
| 12 |
+# |
|
| 13 |
+# TESTFLAGS='-run ^TestBuild$' ./hack/make.sh test-unit |
|
| 14 |
+# |
|
| 15 |
+bundle_test_unit() {
|
|
| 16 |
+ {
|
|
| 17 |
+ date |
|
| 18 |
+ |
|
| 19 |
+ # Run all the tests if no TESTDIRS were specified. |
|
| 20 |
+ if [ -z "$TESTDIRS" ]; then |
|
| 21 |
+ TESTDIRS=$(find_dirs '*_test.go') |
|
| 22 |
+ fi |
|
| 23 |
+ |
|
| 24 |
+ TESTS_FAILED=() |
|
| 25 |
+ for test_dir in $TESTDIRS; do |
|
| 26 |
+ echo |
|
| 27 |
+ |
|
| 28 |
+ if ! LDFLAGS="$LDFLAGS $LDFLAGS_STATIC_DOCKER" go_test_dir "$test_dir"; then |
|
| 29 |
+ TESTS_FAILED+=("$test_dir")
|
|
| 30 |
+ echo |
|
| 31 |
+ echo "${RED}Tests failed: $test_dir${TEXTRESET}"
|
|
| 32 |
+ sleep 1 # give it a second, so observers watching can take note |
|
| 33 |
+ fi |
|
| 34 |
+ done |
|
| 35 |
+ |
|
| 36 |
+ echo |
|
| 37 |
+ echo |
|
| 38 |
+ echo |
|
| 39 |
+ |
|
| 40 |
+ # if some tests fail, we want the bundlescript to fail, but we want to |
|
| 41 |
+ # try running ALL the tests first, hence TESTS_FAILED |
|
| 42 |
+ if [ "${#TESTS_FAILED[@]}" -gt 0 ]; then
|
|
| 43 |
+ echo "${RED}Test failures in: ${TESTS_FAILED[@]}${TEXTRESET}"
|
|
| 44 |
+ echo |
|
| 45 |
+ false |
|
| 46 |
+ else |
|
| 47 |
+ echo "${GREEN}Test success${TEXTRESET}"
|
|
| 48 |
+ echo |
|
| 49 |
+ true |
|
| 50 |
+ fi |
|
| 51 |
+ } 2>&1 | tee $DEST/test.log |
|
| 52 |
+} |
|
| 53 |
+ |
|
| 54 |
+bundle_test_unit |