Makefile improvements

Make watcher more robust by appending || exit 0
Revert back to GOTEST variable to allow use of other go-test utilities, like
  rakyll/gotest
This commit is contained in:
Denis Arh
2019-09-09 13:04:12 +02:00
parent 437127448a
commit 18191b28aa
2 changed files with 39 additions and 11 deletions
+11 -8
View File
@@ -2,7 +2,7 @@
GO = go
GOGET = $(GO) get -u
GOTEST = go test
GOTEST ?= go test
BASEPKGS = system compose messaging
IMAGES = corteza-server-system corteza-server-compose corteza-server-messaging corteza-server
@@ -12,8 +12,11 @@ IMAGES = corteza-server-system corteza-server-compose corteza-server-messaging
WATCH_DELAY ?= 1s
# Run go test cmd with flags, eg:
# $> TEST_FLAGS=-v make test.integration
TEST_FLAGS ?=
# $> TEST_FLAGS="-v" make test.integration
# $> TEST_FLAGS="-v -run SpecialTest" make test.integration
TEST_FLAGS ?=
TEST_INTEGRATION_COVER_PROFILE_OUT ?= .integration.cover.out
########################################################################################################################
# Tool bins
@@ -77,12 +80,12 @@ mailhog.up:
watch.test.integration: $(NODEMON)
# Development helper - watches for file
# changes & reruns integration tests
$(WATCHER) "make test.integration"
$(WATCHER) "make test.integration || exit 0"
watch.test.integration.coverage: $(NODEMON)
# Development helper - watches for file
# changes & reruns integration tests
$(WATCHER) "make test.integration.coverage"
$(WATCHER) "make test.integration.coverage || exit 0"
########################################################################################################################
# QA
@@ -90,16 +93,16 @@ watch.test.integration.coverage: $(NODEMON)
## refactored
test.integration:
$(GO) test $(TEST_FLAGS) ./tests/...
$(GOTEST) $(TEST_FLAGS) ./tests/...
test.integration.coverage:
$(GO) test $(TEST_FLAGS) -covermode=count -coverprofile=.integration.cover.out -coverpkg=./... ./tests/...
$(GOTEST) $(TEST_FLAGS) -covermode=count -coverprofile=$(TEST_INTEGRATION_COVER_PROFILE_OUT) -coverpkg=./... ./tests/...
## old:
test:
# Run basic unit tests
$(GO) test ./pkg/... ./internal/... ./compose/... ./messaging/... ./system/...
$(GOTEST) ./pkg/... ./internal/... ./compose/... ./messaging/... ./system/...
test-coverage:
overalls -project=github.com/cortezaproject/corteza-server -covermode=count -- -coverpkg=./... --tags=integration -p 1
+28 -3
View File
@@ -19,18 +19,17 @@ What, how and why we test:
Are we handling access control and log events (audit log) properly?
All services and data should be protected to prevent unwanted access
and modifications
and modifications.
- Scenarios:
Are complex scenarios executed as designed (e.g. is password recovery email
sent and can link from the email be used)
- Integration with external services
All external services (with exception to database) are mocked but we do test
if communication to these services take place and if
- Database schema & data migrations
@@ -41,3 +40,29 @@ What, how and why we test:
that occurred while testing
# Running tests
To run integration tests once:
```shell script
make test.integration
```
For development, you can watch file-system changes (with `nodemon` utility) and rerun-tests everytime:
```shell script
make watch.test.integration
```
## Environmental variables you can sue:
### Change test utility wih `GOTEST`
If you want some colors in your CLI, you can use [rakyll/gotest](https://github.com/rakyll/gotest).
```shell script
GOTEST=$GOPATH/bin/gotest make watch.test.integration
```
### Finetune test execution with `TEST_FLAGS`
Examples:
- `TEST_FLAGS="-v" make ....`
- `TEST_FLAGS="-v -run testName" make ....`