Makefile

 1.DEFAULT_GOAL := all
 2
 3.PHONY: all
 4all: test_with_fuzz lint
 5
 6# the TEST_FLAGS env var can be set to eg run only specific tests
 7TEST_COMMAND = go test -v -count=1 -race -cover $(TEST_FLAGS)
 8
 9.PHONY: test
10test:
11	$(TEST_COMMAND)
12
13.PHONY: bench
14bench:
15	go test -bench=.
16
17FUZZ_TIME ?= 10s
18
19# see https://github.com/golang/go/issues/46312
20# and https://stackoverflow.com/a/72673487/4867444
21# if we end up having more fuzz tests
22.PHONY: test_with_fuzz
23test_with_fuzz:
24	$(TEST_COMMAND) -fuzz=FuzzRoundTripJSON -fuzztime=$(FUZZ_TIME)
25	$(TEST_COMMAND) -fuzz=FuzzRoundTripYAML -fuzztime=$(FUZZ_TIME)
26
27.PHONY: fuzz
28fuzz: test_with_fuzz
29
30.PHONY: lint
31lint:
32	golangci-lint run