From 609942836459f866aafa8c936a575ce5d96726d9 Mon Sep 17 00:00:00 2001 From: Tomas Kral Date: Tue, 9 Aug 2016 13:48:30 +0200 Subject: [PATCH] add test targets to Makefile --- Makefile | 6 ++++++ script/test-cmd | 3 +++ script/test-unit | 25 +++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 script/test-cmd create mode 100755 script/test-unit diff --git a/Makefile b/Makefile index 7db776ab..2f431c5e 100644 --- a/Makefile +++ b/Makefile @@ -22,3 +22,9 @@ binary-cross: clean: ./script/make.sh clean + +test-unit: + ./script/make.sh test-unit + +test-cmd: + ./script/make.sh test-cmd diff --git a/script/test-cmd b/script/test-cmd new file mode 100755 index 00000000..a04691ef --- /dev/null +++ b/script/test-cmd @@ -0,0 +1,3 @@ +#!/bin/bash + +./script/test/cmd/tests.sh diff --git a/script/test-unit b/script/test-unit new file mode 100755 index 00000000..8189ce30 --- /dev/null +++ b/script/test-unit @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +find_dirs() { + ( + find . -not \( \ + \( \ + -path './vendor/*' \ + \) -prune \ + \) -name '*_test.go' -print0 | xargs -0n1 dirname | sed 's|^\./||' | sort -u + ) +} + +TEST_FLAGS="-tags experimental -cover -coverprofile=cover.out" + +if [ -z "$TEST_DIRS" ]; then + TEST_DIRS=$(find_dirs '*_test.go') +fi + +TESTS_FAILED=() + +set +e +for dir in $TEST_DIRS; do + go test ${TEST_FLAGS} "./${dir}" +done