diff --git a/.gitignore b/.gitignore index 859d7d08f..0173fa4f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /.gopath +/restic cmd/dirdiff/dirdiff cmd/gentestdata/gentestdata cmd/restic/restic diff --git a/.travis.yml b/.travis.yml index 94af0113d..db800b730 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,9 @@ os: - linux - osx +env: + - SFTP_PATH="/usr/lib/openssh/sftp-server" + notifications: irc: channels: @@ -15,23 +18,17 @@ notifications: on_success: change on_failure: change -env: GOX_OS="linux darwin openbsd freebsd" - install: - go get github.com/mattn/goveralls - go get github.com/mitchellh/gox - gox -build-toolchain -os "$GOX_OS" - - go get -v -t ./... script: - - go build -ldflags "-s" ./... - - go build -ldflags "-s" -o restic ./cmd/restic - - sh -c 'cd cmd/restic && gox -verbose -os "$GOX_OS" && ls -al' - - go test -v ./... - - ./testsuite.sh - - sh -c "cd backend && go test -v -test.sftppath /usr/lib/openssh/sftp-server ./..." - - go list ./... | while read pkg; do go test -covermode=count -coverprofile=$(base64 <<< $pkg).cov $pkg; done - - 'echo "mode: count" > all.cov; tail -q -n +2 *.cov >> all.cov' + - make restic + - make gox + - make test + - make test-integration + - make all.cov - goveralls -coverprofile=all.cov -service=travis-ci -repotoken "$COVERALLS_TOKEN" - gofmt -l *.go */*.go */*/*.go - test -z "$(gofmt -l *.go */*.go */*/*.go)" diff --git a/Makefile b/Makefile index 7ae540e78..114d7a30f 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,59 @@ -.PHONY: clean all debug test +.PHONY: all clean env test bench gox test-integration -all: - for dir in ./cmd/* ; do \ - (echo "$$dir"; cd "$$dir"; go build) \ - done +TMPGOPATH=$(PWD)/.gopath +VENDORPATH=$(PWD)/Godeps/_workspace +BASE=github.com/restic/restic +BASEPATH=$(TMPGOPATH)/src/$(BASE) -debug: - (cd cmd/restic; go build -a -tags debug) +GOPATH=$(TMPGOPATH):$(VENDORPATH) -test: - ./testsuite.sh +GOTESTFLAGS ?= -v +GOX_OS ?= linux darwin openbsd freebsd +SFTP_PATH ?= /usr/lib/ssh/sftp-server + +export GOPATH GOX_OS + +all: restic + +.gopath: + mkdir -p .gopath/src/github.com/restic + ln -sf ../../../.. .gopath/src/github.com/restic/restic + +restic: .gopath + cd $(BASEPATH) && \ + go build -a -ldflags "-s" -o restic ./cmd/restic + +restic.debug: .gopath + cd $(BASEPATH) && \ + go build -a -tags debug -o restic ./cmd/restic clean: + rm -rf .gopath restic *.cov restic_* go clean ./... + +test: .gopath + cd $(BASEPATH) && \ + go test $(GOTESTFLAGS) ./... + +bench: .gopath + cd $(BASEPATH) && \ + go test GOTESTFLAGS) bench ./... + +gox: .gopath + cd $(BASEPATH) && \ + gox -verbose -os "$(GOX_OS)" ./cmd/restic + +test-integration: + cd $(BASEPATH)/backend && \ + go test $(GOTESTFLAGS) -test.sftppath $(SFTP_PATH) ./... + +all.cov: + cd $(BASEPATH) && \ + go list ./... | \ + while read pkg; do \ + go test -covermode=count -coverprofile=$$(base64 <<< $$pkg).cov $$pkg; \ + done + echo "mode: count" > all.cov; tail -q -n +2 *.cov >> all.cov + +env: + @echo export GOPATH=\"$(GOPATH)\"