Skip to content

Commit

Permalink
Merge 1300d1e into 894fd62
Browse files Browse the repository at this point in the history
  • Loading branch information
zimmski committed Jun 22, 2016
2 parents 894fd62 + 1300d1e commit 739a860
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 62 deletions.
24 changes: 7 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
language: go

go:
- 1.4
- 1.6

install:
# tools
- make tools
sudo: false

# project
- make dependencies
install:
- make install-tools
- make install-dependencies
- make install

script:
# linting
- $(exit $(gofmt -l . | wc -l))
- errcheck github.com/zimmski/go-mutesting/...
- $(exit $(go tool vet -all=true -v=true . 2>&1 | grep --invert-match -P "(Checking file|\%p of wrong type|can't check non-constant format|not compatible with reflect.StructTag.Get)" | wc -l))
- $(exit $(golint ./... | grep --invert-match -P "(_string.go:)" | wc -l))

# project
- make testverbose

# code coverage
- ginkgo -r -cover -skipPackage="testdata"
- make lint
- make test-with-coverage
- gover
- if [ "$TRAVIS_SECURE_ENV_VARS" = "true" ]; then goveralls -coverprofile=gover.coverprofile -service=travis-ci -repotoken $COVERALLS_TOKEN; fi

Expand Down
74 changes: 33 additions & 41 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,52 +1,44 @@
.PHONY: all clean coverage debug-install dependencies fmt install lint markdown test testverbose tools
.PHONY: all clean clean-coverage generate install install-dependencies install-tools lint test test-verbose test-with-coverage

ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
export ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
export PKG := github.com/zimmski/go-mutesting
export ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

all: tools dependencies install test
$(eval $(ARGS):;@:) # turn arguments into do-nothing targets
export ARGS

all: install-tools install-dependencies install lint test

clean:
go clean -i ./...
go clean -i -race ./...
coverage:
go test -coverprofile=coverage.out
go tool cover -html=coverage.out
crosscompile:
gox -os="linux" ./...
debug-install: generate
go install -race -v ./...
dependencies:
go get -t -v ./...
go build -v ./...
fmt:
gofmt -l -w $(ROOT_DIR)/
go clean -i $(PKG)/...
go clean -i -race $(PKG)/...
clean-coverage:
find $(ROOT_DIR) | grep .coverprofile | xargs rm
generate: clean
go install -v ./...
go generate ./...
go generate $(PKG)/...
install: generate
go install -v ./...
lint: install fmt
errcheck github.com/zimmski/go-mutesting/... || true
golint ./... | grep --invert-match -P "(_string.go:)" || true
go tool vet -all=true -v=true $(ROOT_DIR)/ 2>&1 | grep --invert-match -P "(Checking file|\%p of wrong type|can't check non-constant format|not compatible with reflect.StructTag.Get)" || true
markdown:
orange
test:
go test -race ./...
testverbose:
go test -race -v ./...
tools:
go install -v $(PKG)/...
install-dependencies:
go get -t -v $(PKG)/...
go build -v $(PKG)/...
install-tools:
# generation
go get -u golang.org/x/tools/cmd/godoc
go get -u golang.org/x/tools/cmd/stringer
go get -u -v golang.org/x/tools/cmd/stringer

# linting
go get -u golang.org/x/tools/cmd/vet
go get -u github.com/golang/lint
go install github.com/golang/lint/golint
go get -u github.com/kisielk/errcheck
go get -u -v github.com/golang/lint/...
go get -u -v github.com/kisielk/errcheck/...

# code coverage
go get -u golang.org/x/tools/cmd/cover
go get github.com/onsi/ginkgo/ginkgo
go get github.com/modocache/gover
go get github.com/mattn/goveralls
go get -u -v golang.org/x/tools/cmd/cover
go get -u -v github.com/onsi/ginkgo/ginkgo/...
go get -u -v github.com/modocache/gover/...
go get -u -v github.com/mattn/goveralls/...
lint:
$(ROOT_DIR)/scripts/lint.sh
test:
go test -race -test.timeout 60s $(PKG)/...
test-verbose:
go test -race -test.timeout 60s -v $(PKG)/...
test-with-coverage:
ginkgo -r -cover -race -skipPackage="testdata"
8 changes: 4 additions & 4 deletions cmd/go-mutesting/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,26 @@ func TestMain(t *testing.T) {

os.Stderr = w
os.Stdout = w
os.Chdir("../../example")
assert.Nil(t, os.Chdir("../../example"))

bufChannel := make(chan string)

go func() {
buf := new(bytes.Buffer)
_, err = io.Copy(buf, r)
r.Close()
assert.Nil(t, err)
assert.Nil(t, r.Close())

bufChannel <- buf.String()
}()

exitCode := mainCmd([]string{"--exec", "../scripts/simple.sh", "--exec-timeout", "1", "./..."})

w.Close()
assert.Nil(t, w.Close())

os.Stderr = saveStderr
os.Stdout = saveStdout
os.Chdir(saveCwd)
assert.Nil(t, os.Chdir(saveCwd))

out := <-bufChannel

Expand Down
22 changes: 22 additions & 0 deletions scripts/lint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh

if [ -z ${PKG+x} ]; then echo "PKG is not set"; exit 1; fi
if [ -z ${ROOT_DIR+x} ]; then echo "ROOT_DIR is not set"; exit 1; fi

echo "gofmt:"
OUT=$(gofmt -l $ROOT_DIR)
if [ $($OUT | wc -l) -ne 0 ]; then echo $OUT; PROBLEM=1; fi

echo "errcheck:"
OUT=$(errcheck $PKG/...)
if [ $($OUT | wc -l) -ne 0 ]; then echo $OUT; PROBLEM=1; fi

echo "go vet:"
OUT=$(go tool vet -all=true -v=true $ROOT_DIR 2>&1 | grep --invert-match -P "(Checking file|\%p of wrong type|can't check non-constant format|not compatible with reflect.StructTag.Get)")
if [ $($OUT | wc -l) -ne 0 ]; then echo $OUT; PROBLEM=1; fi

echo "golint:"
OUT=$(golint $PKG/... | grep --invert-match -P "(_string.go:)")
if [ $($OUT | wc -l) -ne 0 ]; then echo $OUT; PROBLEM=1; fi

if [ -n "$PROBLEM" ]; then exit 1; fi

0 comments on commit 739a860

Please sign in to comment.