summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorhorus_arch2015-03-31 00:27:34 +0200
committerhorus_arch2015-03-31 00:27:34 +0200
commit9d3a4de291f7c7bb06ec2a956f23c07a67fcc7f9 (patch)
tree465d24b239f9f415a14eda0d0b64e6ebd6fbf99f /Makefile
parentc735f33c37f4982492c363d3c7a23c38effd2b41 (diff)
downloadfreemail-9d3a4de291f7c7bb06ec2a956f23c07a67fcc7f9.tar.gz
Changed make test to test only code which was recently changed.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile22
1 files changed, 19 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index ecf974f..f3ee5e1 100644
--- a/Makefile
+++ b/Makefile
@@ -37,6 +37,8 @@ ifndef VAGRANT_DIR
VAGRANT_DIR:=/vagrant
endif
+_TEST_FILES = $(wildcard *_test.go)
+FILTER_TEST= grep -v "import" | grep -oE '^func Test.+\(' | sed 's/(//g' | sed s'/func //g' | tr '\n' '|' | sed 's/|$$//'
# Start targets
all: kill build run
@@ -98,9 +100,23 @@ pack: gen_config
echo "\n/$(APP).tar.gz is ready." || \
(echo "Run \"make build\" first." && exit 1)
-test: import
- FREEMAIL_SMTP_MAILER_MX=localhost FREEMAIL_DB_CREDENTIALS=":memory:" go test $(RACE) $(VERBOSE) $(EXTERNAL)
- @(rm $(IMPORT_FILE) 2>/dev/null && echo "Removing import file..." ) || true
+test: import _info_test _run_test
+
+_info_test:
+ @echo "Please note: We are testing only changes."
+ @echo "To run the complete test suite run 'make test_all'."
+ @echo ""
+
+_run_test: $(_TEST_FILES)
+ @echo Testing $?
+ @echo ""
+ @FREEMAIL_SMTP_MAILER_MX=localhost FREEMAIL_DB_CREDENTIALS=':memory:' \
+ go test $(RACE) $(VERBOSE) $(EXTERNAL) \
+ -run="$$(gofmt $? | $(FILTER_TEST))" && \
+ touch $@
+
+test_all: import
+ @FREEMAIL_SMTP_MAILER_MX=localhost FREEMAIL_DB_CREDENTIALS=':memory:' go test $(RACE) $(VERBOSE) $(EXTERNAL)
benchmark: import
DB_FREEMAIL_LOG=false FREEMAIL_DB_CREDENTIALS=":memory:" go test $(VERBOSE) -bench=".*"