| 1 |
# General |
| 2 |
WORKDIR = $(PWD) |
| 3 |
|
| 4 |
# Go parameters |
| 5 |
GOCMD = go |
| 6 |
GOTEST = $(GOCMD) test |
| 7 |
|
| 8 |
# Git config |
| 9 |
GIT_VERSION ?= |
| 10 |
GIT_DIST_PATH ?= $(PWD)/.git-dist |
| 11 |
GIT_REPOSITORY = http://github.com/git/git.git |
| 12 |
|
| 13 |
# Coverage |
| 14 |
COVERAGE_REPORT = coverage.out |
| 15 |
COVERAGE_MODE = count |
| 16 |
|
| 17 |
build-git: |
| 18 |
@if [ -f $(GIT_DIST_PATH)/git ]; then \ |
| 19 |
echo "nothing to do, using cache $(GIT_DIST_PATH)"; \ |
| 20 |
else \ |
| 21 |
git clone $(GIT_REPOSITORY) -b $(GIT_VERSION) --depth 1 --single-branch $(GIT_DIST_PATH); \ |
| 22 |
cd $(GIT_DIST_PATH); \ |
| 23 |
make configure; \ |
| 24 |
./configure; \ |
| 25 |
make all; \ |
| 26 |
fi |
| 27 |
|
| 28 |
test: |
| 29 |
@echo "running against `git version`"; \ |
| 30 |
$(GOTEST) -race ./... |
| 31 |
$(GOTEST) -v _examples/common_test.go _examples/common.go --examples |
| 32 |
|
| 33 |
TEMP_REPO := $(shell mktemp) |
| 34 |
test-sha256: |
| 35 |
$(GOCMD) run -tags sha256 _examples/sha256/main.go $(TEMP_REPO) |
| 36 |
cd $(TEMP_REPO) && git fsck |
| 37 |
rm -rf $(TEMP_REPO) |
| 38 |
|
| 39 |
test-coverage: |
| 40 |
@echo "running against `git version`"; \ |
| 41 |
echo "" > $(COVERAGE_REPORT); \ |
| 42 |
$(GOTEST) -coverprofile=$(COVERAGE_REPORT) -coverpkg=./... -covermode=$(COVERAGE_MODE) ./... |
| 43 |
|
| 44 |
clean: |
| 45 |
rm -rf $(GIT_DIST_PATH) |
| 46 |
|
| 47 |
fuzz: |
| 48 |
@go test -fuzz=FuzzParser $(PWD)/internal/revision |
| 49 |
@go test -fuzz=FuzzDecoder $(PWD)/plumbing/format/config |
| 50 |
@go test -fuzz=FuzzPatchDelta $(PWD)/plumbing/format/packfile |
| 51 |
@go test -fuzz=FuzzParseSignedBytes $(PWD)/plumbing/object |
| 52 |
@go test -fuzz=FuzzDecode $(PWD)/plumbing/object |
| 53 |
@go test -fuzz=FuzzDecoder $(PWD)/plumbing/protocol/packp |
| 54 |
@go test -fuzz=FuzzNewEndpoint $(PWD)/plumbing/transport |