1# General
2WORKDIR = $(PWD)
3
4# Go parameters
5GOCMD = go
6GOTEST = $(GOCMD) test
7
8# Git config
9GIT_VERSION ?=
10GIT_DIST_PATH ?= $(PWD)/.git-dist
11GIT_REPOSITORY = http://github.com/git/git.git
12
13# Coverage
14COVERAGE_REPORT = coverage.out
15COVERAGE_MODE = count
16
17# Defines the maximum time each fuzz target will be executed for.
18FUZZ_TIME ?= 10s
19FUZZ_PKGS = $(shell grep -r --include='**_test.go' --files-with-matches 'func Fuzz' . | xargs -I{} dirname {})
20
21build-git:
22 @if [ -f $(GIT_DIST_PATH)/git ]; then \
23 echo "nothing to do, using cache $(GIT_DIST_PATH)"; \
24 else \
25 git clone $(GIT_REPOSITORY) -b $(GIT_VERSION) --depth 1 --single-branch $(GIT_DIST_PATH); \
26 cd $(GIT_DIST_PATH); \
27 make configure; \
28 ./configure; \
29 make all; \
30 fi
31
32test:
33 @echo "running against `git version`"; \
34 $(GOTEST) -race ./...
35 $(GOTEST) -v _examples/common_test.go _examples/common.go --examples
36
37TEMP_REPO := $(shell mktemp)
38test-sha256:
39 $(GOCMD) run -tags sha256 _examples/sha256/main.go $(TEMP_REPO)
40 cd $(TEMP_REPO) && git fsck
41 rm -rf $(TEMP_REPO)
42
43test-coverage:
44 @echo "running against `git version`"; \
45 echo "" > $(COVERAGE_REPORT); \
46 $(GOTEST) -coverprofile=$(COVERAGE_REPORT) -coverpkg=./... -covermode=$(COVERAGE_MODE) ./...
47
48clean:
49 rm -rf $(GIT_DIST_PATH)
50
51fuzz:
52 @for path in $(FUZZ_PKGS); do \
53 go test -fuzz=Fuzz -fuzztime=$(FUZZ_TIME) $$path; \
54 done