Colorize go test output using kyoh86/richgo

This commit is contained in:
Michael Mayer 2019-06-03 16:31:15 +02:00
parent ac435f7cd7
commit a38fe29953
3 changed files with 16 additions and 14 deletions

View file

@ -5,6 +5,13 @@ DOCKER_TAG=`date -u +%Y%m%d`
TIDB_VERSION=2.1.8
DARKTABLE_VERSION="$(awk '$2 == "DARKTABLE_VERSION" { print $3; exit }' docker/darktable/Dockerfile)"
HASRICHGO := $(shell which richgo)
ifdef HASRICHGO
GOTEST=richgo test
else
GOTEST=go test
endif
all: dep build
dep: dep-tensorflow dep-js dep-go
build: build-js build-go
@ -49,11 +56,13 @@ test-chromium:
test-firefox:
(cd frontend && npm run test-firefox)
test-go:
go test -tags=slow -timeout 20m -v ./internal/... | scripts/colorize-tests.sh
$(GOTEST) -tags=slow -timeout 20m ./internal/...
test-debug:
$(GOTEST) -tags=slow -timeout 20m -v ./internal/...
test-short:
go test -short -timeout 5m -v ./internal/... | scripts/colorize-tests.sh
$(GOTEST) -short -timeout 5m -v ./internal/...
test-race:
go test -tags=slow -race -timeout 60m -v ./internal/... | scripts/colorize-tests.sh
$(GOTEST) -tags=slow -race -timeout 60m -v ./internal/...
test-codecov:
go test -tags=slow -timeout 30m -coverprofile=coverage.txt -covermode=atomic -v ./internal/...
scripts/codecov.sh

View file

@ -100,8 +100,10 @@ RUN rm -rf /tmp/* && mkdir -p /tmp/photoprism
RUN wget "https://dl.photoprism.org/tensorflow/nasnet.zip?${BUILD_TAG}" -O /tmp/photoprism/nasnet.zip
RUN wget "https://dl.photoprism.org/fixtures/testdata.zip?${BUILD_TAG}" -O /tmp/photoprism/testdata.zip
# Install goimports
RUN env GO111MODULE=off /usr/local/go/bin/go get golang.org/x/tools/cmd/goimports
# Install goimports & richgo (colorizes "go test" output)
RUN env GO111MODULE=off /usr/local/go/bin/go get -u golang.org/x/tools/cmd/goimports
RUN env GO111MODULE=off /usr/local/go/bin/go get -u github.com/kyoh86/richgo
RUN echo "alias go=richgo" > /root/.bash_aliases
# Configure broadwayd (HTML5 display server)
# Command: broadwayd -p 8080 -a 0.0.0.0 :5

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
if (( $# == 0 )) ; then
sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' < /dev/stdin | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
else
sed ''/PASS/s//$(printf "\033[32mPASS\033[0m")/'' <<< "$1" | sed ''/FAIL/s//$(printf "\033[31mFAIL\033[0m")/''
fi
echo "Code that cannot be tested is flawed :-)"