Skip to content
Myr

Makefile

This file

Path

Makefile

110 lines · 2.9 KiB

Last changed by

test(make): modify test folder and test command in Makefile (#4465)HolynnChenbefore adoptioncb2b764

History of this file

Take it

The walk stopped after 200 commits: lines older than cf32d2d point at it.

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

lines 1–6why, one step back
1GO ?= go
2GOFMT ?= gofmt "-s"3GO_VERSION=$(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2)4PACKAGES ?= $(shell $(GO) list ./...)5VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /examples/)6GOFILES := $(shell find . -name "*.go")

test(make): modify test folder and test command in Makefile (#4465)HolynnChenbefore adoptioncb2b764

line 7why, one step back
7TESTFOLDER := $(shell $(GO) list ./... | grep -E 'gin$$|ginS$$|binding$$|render$$' | grep -v examples)

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

lines 8–14why, one step back
8TESTTAGS ?= ""
910.PHONY: test11# Run tests to verify code functionality.12test:13 echo "mode: count" > coverage.out14 for d in $(TESTFOLDER); do \

test(make): modify test folder and test command in Makefile (#4465)HolynnChenbefore adoptioncb2b764

lines 15–19why, one step back
15 if [ -n "$(TESTTAGS)" ]; then \
16 $(GO) test $(TESTTAGS) -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \17 else \18 $(GO) test -v -covermode=count -coverprofile=profile.out $$d > tmp.out; \19 fi; \

chore(deps): bump github.com/pelletier/go-toml/v2 from 2.2.2 to 2.2.4 (#4212)dependabot[bot]before adoptioncf32d2d

lines 20–110why, one step back
20 cat tmp.out; \
21 if grep -q "^--- FAIL" tmp.out; then \22 rm tmp.out; \23 exit 1; \24 elif grep -q "build failed" tmp.out; then \25 rm tmp.out; \26 exit 1; \27 elif grep -q "setup failed" tmp.out; then \28 rm tmp.out; \29 exit 1; \30 fi; \31 if [ -f profile.out ]; then \32 cat profile.out | grep -v "mode:" >> coverage.out; \33 rm profile.out; \34 fi; \35 done3637.PHONY: fmt38# Ensure consistent code formatting.39fmt:40 $(GOFMT) -w $(GOFILES)4142.PHONY: fmt-check43# format (check only).44fmt-check:45 @diff=$$($(GOFMT) -d $(GOFILES)); \46 if [ -n "$$diff" ]; then \47 echo "Please run 'make fmt' and commit the result:"; \48 echo "$${diff}"; \49 exit 1; \50 fi;5152.PHONY: vet53# Examine packages and report suspicious constructs if any.54vet:55 $(GO) vet $(VETPACKAGES)5657.PHONY: lint58# Inspect source code for stylistic errors or potential bugs.59lint:60 @hash golint > /dev/null 2>&1; if [ $$? -ne 0 ]; then \61 $(GO) get -u golang.org/x/lint/golint; \62 fi63 for PKG in $(PACKAGES); do golint -set_exit_status $$PKG || exit 1; done;6465.PHONY: misspell66# Correct commonly misspelled English words in source code.67misspell:68 @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \69 $(GO) get -u github.com/client9/misspell/cmd/misspell; \70 fi71 misspell -w $(GOFILES)7273.PHONY: misspell-check74# misspell (check only).75misspell-check:76 @hash misspell > /dev/null 2>&1; if [ $$? -ne 0 ]; then \77 $(GO) get -u github.com/client9/misspell/cmd/misspell; \78 fi79 misspell -error $(GOFILES)8081.PHONY: tools82# Install tools (golint and misspell).83tools:84 @if [ $(GO_VERSION) -gt 15 ]; then \85 $(GO) install golang.org/x/lint/golint@latest; \86 $(GO) install github.com/client9/misspell/cmd/misspell@latest; \87 elif [ $(GO_VERSION) -lt 16 ]; then \88 $(GO) install golang.org/x/lint/golint; \89 $(GO) install github.com/client9/misspell/cmd/misspell; \90 fi9192.PHONY: help93# Help.94help:95 @echo ''96 @echo 'Usage:'97 @echo ' make [target]'98 @echo ''99 @echo 'Targets:'100 @awk '/^[a-zA-Z\-\0-9]+:/ { \101 helpMessage = match(lastLine, /^# (.*)/); \102 if (helpMessage) { \103 helpCommand = substr($$1, 0, index($$1, ":")-1); \104 helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \105 printf " - \033[36m%-20s\033[0m %s\n", helpCommand, helpMessage; \106 } \107 } \108 { lastLine = $$0 }' $(MAKEFILE_LIST)109110.DEFAULT_GOAL := help