-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
38 lines (29 loc) · 1.29 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
.DEFAULT_GOAL := build
BIN ?= ansitags
.PHONY: test
test: ### Run tests with some verbose information filtered out and some minor styling
@CGO_ENABLED=1 go test -v -race \
-coverprofile=testdata/coverage_tests.out \
. \
| grep -v "=== RUN\|\d: PASS:" \
| sed -E "s/^coverage: ([0-9\.%]*) of statements/`printf "\033[97;1mcoverage: \033[93;1m"`\1`printf "\033[0m \033[97;1mof statements\033[0m"`/" \
| sed -E "s/^([[:space:]]*)--- PASS: (.*)/`printf "\033[96m"`\1--- PASS: \2`printf "\033[0m"`/" \
| sed -E "s/^([[:space:]]*)([-]*)([[:space:]]*)FAIL(.*)/`printf "\033[91m"`\1\2\3FAIL\4`printf "\033[0m"`/"
.PHONY: coverage-html
coverage-html: ### Saves a coverage html file
@go tool cover -html=testdata/coverage_tests.out -o testdata/coverage_tests.html
.PHONY: view-coverage
view-coverage: coverage-html # Opens/views coverage report in browser
@open testdata/coverage_tests.html
.PHONY: build
build:
CGO_ENABLED=0 go build -trimpath -a -o example/bin/$(BIN) ./example
.PHONY: stream-test
stream-test: build
cat testdata/ansitags_test_streaming.yaml | ./example/bin/$(BIN)
.PHONY: stream-test-256
stream-test-256: build
cat testdata/ansitags_test_streaming-256.yaml | COLOR_MODE=256 ./example/bin/$(BIN)
.PHONY: profile
profile:
go test -cpuprofile cpu.prof -memprofile mem.prof -bench .