From 90d14143310645a0be2714745b0920392f993053 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 18 Aug 2015 22:56:53 +0200 Subject: [PATCH 01/20] Cross-compile on windows --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 199559449..21aa363ee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,7 @@ os: - linux - osx -env: GOX_OS="linux darwin openbsd freebsd" GOX_ARCH="386 amd64 arm" +env: GOX_OS="linux darwin openbsd freebsd windows" GOX_ARCH="386 amd64 arm" notifications: irc: From f2dbdcb9e85312f482fab15c8c67b753c03de7ca Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 18 Aug 2015 23:07:24 +0200 Subject: [PATCH 02/20] Add appveyor config --- appveyor.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 000000000..ad12520cc --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,14 @@ +clone_folder: c:\gopath\src\github.com\restic\restic + +environment: + GOPATH: c:\gopath + +install: + - echo %PATH% + - echo %GOPATH% + - go version + - go env + - go get -v -t ./... + +build_script: + - go test -v From b34c53d39b4a23c7b90d262c29225f23ef85e457 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 18 Aug 2015 23:18:12 +0200 Subject: [PATCH 03/20] windows: fix nil pointer reference --- cache.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cache.go b/cache.go index 8dfd9ff84..bf3fc2d05 100644 --- a/cache.go +++ b/cache.go @@ -235,6 +235,8 @@ func getWindowsCacheDir() (string, error) { if err != nil { return "", err } + + return cachedir, nil } if err != nil { From a37431e9633d7301615a0d7cdf3dba6f3dea4b4f Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Tue, 18 Aug 2015 23:19:42 +0200 Subject: [PATCH 04/20] appveyor: run build.go, use workspace from godeps --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index ad12520cc..514b65061 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,14 +1,14 @@ clone_folder: c:\gopath\src\github.com\restic\restic environment: - GOPATH: c:\gopath + GOPATH: c:\gopath;c:\gopath\src\github.com\restic\restic\Godeps\_workspace install: - echo %PATH% - echo %GOPATH% - go version - go env - - go get -v -t ./... build_script: + - go run build.go - go test -v From 59751645be1a90f0ecf6fe3c66454a4776c55446 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:11:48 +0200 Subject: [PATCH 05/20] build.go: allow running tests in temporary GOPATH --- build.go | 62 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 53 insertions(+), 9 deletions(-) diff --git a/build.go b/build.go index 1e62384bc..f429c63d3 100644 --- a/build.go +++ b/build.go @@ -18,6 +18,7 @@ import ( var ( verbose bool keepGopath bool + runTests bool ) const timeFormat = "2006-01-02 15:04:05" @@ -32,6 +33,21 @@ func specialDir(name string) bool { return base[0] == '_' || base[0] == '.' } +// excludePath returns true if the file should not be copied to the new GOPATH. +func excludePath(name string) bool { + ext := path.Ext(name) + if ext == ".go" || ext == ".s" { + return false + } + + parentDir := filepath.Base(filepath.Dir(name)) + if parentDir == "testdata" { + return false + } + + return true +} + // updateGopath builds a valid GOPATH at dst, with all Go files in src/ copied // to dst/prefix/, so calling // @@ -60,8 +76,7 @@ func updateGopath(dst, src, prefix string) error { return nil } - ext := path.Ext(name) - if ext != ".go" && ext != ".s" { + if excludePath(name) { return nil } @@ -133,7 +148,10 @@ func showUsage(output io.Writer) { fmt.Fprintf(output, "USAGE: go run build.go OPTIONS\n") fmt.Fprintf(output, "\n") fmt.Fprintf(output, "OPTIONS:\n") - fmt.Fprintf(output, " -v --verbose output more messages\n") + fmt.Fprintf(output, " -v --verbose output more messages\n") + fmt.Fprintf(output, " -t --tags specify additional build tags\n") + fmt.Fprintf(output, " -k --keep-gopath do not remove the GOPATH after build\n") + fmt.Fprintf(output, " -T --test run tests\n") } func verbosePrintf(message string, args ...interface{}) { @@ -170,6 +188,18 @@ func build(gopath string, args ...string) error { return cmd.Run() } +// test runs "go test args..." with GOPATH set to gopath. +func test(gopath string, args ...string) error { + args = append([]string{"test"}, args...) + cmd := exec.Command("go", args...) + cmd.Env = append(cleanEnv(), "GOPATH="+gopath) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + verbosePrintf("go %s\n", args) + + return cmd.Run() +} + // getVersion returns a version string, either from the file VERSION in the // current directory or from git. func getVersion() string { @@ -218,6 +248,8 @@ func main() { case "-t", "-tags", "--tags": skipNext = true buildTags = strings.Split(params[i+1], " ") + case "-T", "--test": + runTests = true case "-h": showUsage(os.Stdout) default: @@ -258,6 +290,17 @@ func main() { die("copying files from %v to %v failed: %v\n", root, gopath, err) } + defer func() { + if !keepGopath { + verbosePrintf("remove %v\n", gopath) + if err = os.RemoveAll(gopath); err != nil { + die("remove GOPATH at %s failed: %v\n", err) + } + } else { + fmt.Printf("leaving temporary GOPATH at %v\n", gopath) + } + }() + output := "restic" if runtime.GOOS == "windows" { output = "restic.exe" @@ -277,14 +320,15 @@ func main() { err = build(gopath, args...) if err != nil { fmt.Fprintf(os.Stderr, "build failed: %v\n", err) + return } - if !keepGopath { - verbosePrintf("remove %v\n", gopath) - if err = os.RemoveAll(gopath); err != nil { - die("remove GOPATH at %s failed: %v\n", err) + if runTests { + verbosePrintf("running tests\n") + + err = test(gopath, "github.com/restic/restic/...") + if err != nil { + fmt.Fprintf(os.Stderr, "build failed: %v\n", err) } - } else { - fmt.Printf("leaving temporary GOPATH at %v\n", gopath) } } From f0c8b117934eb146a0d33f6b5c8a659789df0b3c Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:12:41 +0200 Subject: [PATCH 06/20] cleanup travis config, add run_integration_tests.go --- .travis.yml | 19 +---- run_integration_tests.go | 163 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 166 insertions(+), 16 deletions(-) create mode 100644 run_integration_tests.go diff --git a/.travis.yml b/.travis.yml index 21aa363ee..82bc079f0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,22 +25,9 @@ install: - export PATH="$PATH:$GOBIN" - export GOPATH="$GOPATH:${TRAVIS_BUILD_DIR}/Godeps/_workspace" - go env - - go get github.com/mattn/goveralls - - go get github.com/mitchellh/gox - - go version | grep -q "go1\.3" && export GOX_ARCH="386 amd64" || true - - go version | grep -q "darwin" && export GOX_OS="darwin" || true - - uname -s | grep -qi darwin && brew install caskroom/cask/brew-cask || true - - uname -s | grep -qi darwin && brew cask install osxfuse || true - - uname -s | grep -vqi darwin && export RESTIC_TEST_FUSE="0" || true - - echo "cross-compile for \"$GOX_OS\" on \"$GOX_ARCH\"" - - gox -build-toolchain -os "$GOX_OS" -arch "$GOX_ARCH" script: - - gox -verbose -os "$GOX_OS" -arch "$GOX_ARCH" -tags "release" ./cmd/restic - - gox -verbose -os "$GOX_OS" -arch "$GOX_ARCH" -tags "debug" ./cmd/restic - - go run build.go - - go run run_tests.go all.cov - - GOARCH=386 RESTIC_TEST_INTEGRATION=0 go test ./... + - go run run_integration_tests.go + +after_success: - goveralls -coverprofile=all.cov -service=travis-ci -repotoken "$COVERALLS_TOKEN" || true - - gofmt -l *.go */*.go */*/*.go - - test -z "$(gofmt -l *.go */*.go */*/*.go)" diff --git a/run_integration_tests.go b/run_integration_tests.go new file mode 100644 index 000000000..ac8ac6442 --- /dev/null +++ b/run_integration_tests.go @@ -0,0 +1,163 @@ +// +build ignore + +package main + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" + "runtime" + "strings" +) + +type CIEnvironment interface { + Prepare() + RunTests() +} + +type TravisEnvironment struct { + goxArch []string + goxOS []string +} + +func (env *TravisEnvironment) Prepare() { + fmt.Printf("preparing environment for Travis CI\n") + + run("go", "get", "github.com/mattn/goveralls") + run("go", "get", "github.com/mitchellh/gox") + + if runtime.GOOS == "darwin" { + // install the libraries necessary for fuse + run("brew", "install", "caskroom/cask/brew-cask") + run("brewcask", "install", "osxfuse") + } + + // only test cross compilation on linux with Travis + if runtime.GOOS == "linux" { + env.goxArch = []string{"386", "amd64"} + if !strings.HasPrefix(runtime.Version(), "go1.3") { + env.goxArch = append(env.goxArch, "arm") + } + + env.goxOS = []string{"linux", "darwin", "freebsd", "openbsd", "windows"} + } + + fmt.Printf("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch) + run("gox", "-build-toolchain", + "-os", strings.Join(env.goxOS, " "), + "-arch", strings.Join(env.goxArch, " ")) +} + +func (env *TravisEnvironment) RunTests() { + // run fuse tests on darwin + if runtime.GOOS != "darwin" { + fmt.Printf("skip fuse integration tests on %v\n", runtime.GOOS) + os.Setenv("RESTIC_TEST_FUSE", "0") + } + + // compile for all target architectures with tags + for _, tags := range []string{"release", "debug"} { + run("gox", "-verbose", + "-os", strings.Join(env.goxOS, " "), + "-arch", strings.Join(env.goxArch, " "), + "-tags", tags, + "./cmd/restic") + } + + // run the build script + run("go", "run", "build.go") + + // gather coverage information + run("go", "run", "run_tests.go", "all.cov") + + runGofmt() +} + +// findGoFiles returns a list of go source code file names below dir. +func findGoFiles(dir string) (list []string, err error) { + err = filepath.Walk(dir, func(name string, fi os.FileInfo, err error) error { + if filepath.Base(name) == "Godeps" { + return filepath.SkipDir + } + + if filepath.Ext(name) == ".go" { + relpath, err := filepath.Rel(dir, name) + if err != nil { + return err + } + + list = append(list, relpath) + } + + return err + }) + + return list, err +} + +func runGofmt() { + dir, err := os.Getwd() + if err != nil { + fmt.Fprintf(os.Stderr, "Getwd(): %v\n", err) + os.Exit(5) + } + + files, err := findGoFiles(dir) + if err != nil { + fmt.Fprintf(os.Stderr, "error finding Go files: %v\n", err) + os.Exit(4) + } + + fmt.Printf("runGofmt() with %d files\n", len(files)) + args := append([]string{"-l"}, files...) + cmd := exec.Command("gofmt", args...) + cmd.Stderr = os.Stderr + + buf, err := cmd.Output() + if err != nil { + fmt.Fprintf(os.Stderr, "error running gofmt: %v", err) + fmt.Fprintf(os.Stderr, "output:\n%s\n", buf) + os.Exit(3) + } + + if len(buf) > 0 { + fmt.Fprintf(os.Stderr, "not formatted with `gofmt`:\n") + fmt.Fprintln(os.Stderr, string(buf)) + os.Exit(6) + } +} + +func run(command string, args ...string) { + fmt.Printf("run %v %v\n", command, strings.Join(args, " ")) + cmd := exec.Command(command, args...) + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + err := cmd.Run() + + if err != nil { + fmt.Fprintf(os.Stderr, "error running %v %v: %v", + command, strings.Join(args, " "), err) + os.Exit(3) + } +} + +func isTravis() bool { + return os.Getenv("TRAVIS_BUILD_DIR") != "" +} + +func main() { + var env CIEnvironment + + switch { + case isTravis(): + env = &TravisEnvironment{} + default: + fmt.Fprintln(os.Stderr, "unknown CI environment") + os.Exit(1) + } + + for _, f := range []func(){env.Prepare, env.RunTests} { + f() + } +} From 2df7ed6c9be62470b071648bc7eb0c2d5b8a84dc Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:16:58 +0200 Subject: [PATCH 07/20] fix `brew cask` on darwin --- run_integration_tests.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_integration_tests.go b/run_integration_tests.go index ac8ac6442..4b3aa889b 100644 --- a/run_integration_tests.go +++ b/run_integration_tests.go @@ -30,7 +30,7 @@ func (env *TravisEnvironment) Prepare() { if runtime.GOOS == "darwin" { // install the libraries necessary for fuse run("brew", "install", "caskroom/cask/brew-cask") - run("brewcask", "install", "osxfuse") + run("brew", "cask", "install", "osxfuse") } // only test cross compilation on linux with Travis From 5b21d67a495a315344cafe6e6318febb6ba0f713 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:25:59 +0200 Subject: [PATCH 08/20] lock_test: correct merge error, use offset 500k --- lock_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lock_test.go b/lock_test.go index 8bac2362b..6890c44da 100644 --- a/lock_test.go +++ b/lock_test.go @@ -134,7 +134,7 @@ var staleLockTests = []struct { timestamp: time.Now(), stale: true, staleOnOtherHost: false, - pid: os.Getpid() + 500, + pid: os.Getpid() + 500000, }, } @@ -204,7 +204,7 @@ func TestRemoveAllLocks(t *testing.T) { id2, err := createFakeLock(repo, time.Now().Add(-time.Minute), os.Getpid()) OK(t, err) - id3, err := createFakeLock(repo, time.Now().Add(-time.Minute), os.Getpid()+500) + id3, err := createFakeLock(repo, time.Now().Add(-time.Minute), os.Getpid()+500000) OK(t, err) OK(t, restic.RemoveAllLocks(repo)) From 527593c6df6533dcdd4a142e2af310e46cf41d91 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:29:06 +0200 Subject: [PATCH 09/20] ci test: add message prefix --- run_integration_tests.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/run_integration_tests.go b/run_integration_tests.go index 4b3aa889b..22b9f6437 100644 --- a/run_integration_tests.go +++ b/run_integration_tests.go @@ -22,7 +22,7 @@ type TravisEnvironment struct { } func (env *TravisEnvironment) Prepare() { - fmt.Printf("preparing environment for Travis CI\n") + msg("preparing environment for Travis CI\n") run("go", "get", "github.com/mattn/goveralls") run("go", "get", "github.com/mitchellh/gox") @@ -43,7 +43,7 @@ func (env *TravisEnvironment) Prepare() { env.goxOS = []string{"linux", "darwin", "freebsd", "openbsd", "windows"} } - fmt.Printf("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch) + msg("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch) run("gox", "-build-toolchain", "-os", strings.Join(env.goxOS, " "), "-arch", strings.Join(env.goxArch, " ")) @@ -52,7 +52,7 @@ func (env *TravisEnvironment) Prepare() { func (env *TravisEnvironment) RunTests() { // run fuse tests on darwin if runtime.GOOS != "darwin" { - fmt.Printf("skip fuse integration tests on %v\n", runtime.GOOS) + msg("skip fuse integration tests on %v\n", runtime.GOOS) os.Setenv("RESTIC_TEST_FUSE", "0") } @@ -96,6 +96,10 @@ func findGoFiles(dir string) (list []string, err error) { return list, err } +func msg(format string, args ...interface{}) { + fmt.Printf("CI: "+format, args...) +} + func runGofmt() { dir, err := os.Getwd() if err != nil { @@ -109,7 +113,7 @@ func runGofmt() { os.Exit(4) } - fmt.Printf("runGofmt() with %d files\n", len(files)) + msg("runGofmt() with %d files\n", len(files)) args := append([]string{"-l"}, files...) cmd := exec.Command("gofmt", args...) cmd.Stderr = os.Stderr @@ -129,7 +133,7 @@ func runGofmt() { } func run(command string, args ...string) { - fmt.Printf("run %v %v\n", command, strings.Join(args, " ")) + msg("run %v %v\n", command, strings.Join(args, " ")) cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr From 23845b071b8cc3702b90f31ec2de80c1fbc32670 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:44:37 +0200 Subject: [PATCH 10/20] integration: compile on current architecture by default --- run_integration_tests.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/run_integration_tests.go b/run_integration_tests.go index 22b9f6437..43dab3fcd 100644 --- a/run_integration_tests.go +++ b/run_integration_tests.go @@ -41,6 +41,9 @@ func (env *TravisEnvironment) Prepare() { } env.goxOS = []string{"linux", "darwin", "freebsd", "openbsd", "windows"} + } else { + env.goxArch = []string{runtime.GOARCH} + env.goxOS = []string{runtime.GOOS} } msg("gox: OS %v, ARCH %v\n", env.goxOS, env.goxArch) From d21b782119aaec9a07da44588c6db4971714e753 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 20:45:54 +0200 Subject: [PATCH 11/20] appveyor: use run_integration_tests.go --- appveyor.yml | 5 +---- run_integration_tests.go | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 514b65061..77b8e5b4d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,11 +4,8 @@ environment: GOPATH: c:\gopath;c:\gopath\src\github.com\restic\restic\Godeps\_workspace install: - - echo %PATH% - - echo %GOPATH% - go version - go env build_script: - - go run build.go - - go test -v + - go run run_integration_tests.go diff --git a/run_integration_tests.go b/run_integration_tests.go index 43dab3fcd..7c4e05120 100644 --- a/run_integration_tests.go +++ b/run_integration_tests.go @@ -77,6 +77,19 @@ func (env *TravisEnvironment) RunTests() { runGofmt() } +type AppveyorEnvironment struct{} + +func (env *AppveyorEnvironment) Prepare() { + msg("preparing environment for Appveyor CI\n") + + // install tar, gzip, bzip2 +} + +func (env *AppveyorEnvironment) RunTests() { + // run the build script and the tests + run("go", "run", "build.go", "-v", "-T") +} + // findGoFiles returns a list of go source code file names below dir. func findGoFiles(dir string) (list []string, err error) { err = filepath.Walk(dir, func(name string, fi os.FileInfo, err error) error { @@ -153,12 +166,18 @@ func isTravis() bool { return os.Getenv("TRAVIS_BUILD_DIR") != "" } +func isAppveyor() bool { + return runtime.GOOS == "windows" +} + func main() { var env CIEnvironment switch { case isTravis(): env = &TravisEnvironment{} + case isAppveyor(): + env = &AppveyorEnvironment{} default: fmt.Fprintln(os.Stderr, "unknown CI environment") os.Exit(1) From 7079e4664200afe5ac34d29dea77520c1f674ce0 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 21:00:11 +0200 Subject: [PATCH 12/20] appveyor: download tar --- appveyor.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 77b8e5b4d..cc936f6f7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,9 @@ environment: install: - go version - go env + - appveyor DownloadFile http://downloads.sourceforge.net/project/gnuwin32/tar/1.13-1/tar-1.13-1-bin.zip -FileName tar.zip + - 7z x tar.zip bin/tar.exe + - set PATH=bin/;%PATH% build_script: - go run run_integration_tests.go From b8c0935f8a07a22206b87b3f959e46b9de5ebbff Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 21:00:17 +0200 Subject: [PATCH 13/20] tests: use internal bzip2/gzip implementation --- test/helpers.go | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/test/helpers.go b/test/helpers.go index 1b09b7a0e..eab73ddfb 100644 --- a/test/helpers.go +++ b/test/helpers.go @@ -2,7 +2,10 @@ package test_helper import ( "bytes" + "compress/bzip2" + "compress/gzip" "fmt" + "io" "io/ioutil" "math/rand" "os" @@ -89,14 +92,28 @@ func RandomReader(seed, size int) *bytes.Reader { // SetupTarTestFixture extracts the tarFile to outputDir. func SetupTarTestFixture(t testing.TB, outputDir, tarFile string) { - f, err := os.Open(tarFile) - defer f.Close() + input, err := os.Open(tarFile) + defer input.Close() OK(t, err) - cmd := exec.Command("tar", "xzf", "-") + var rd io.Reader + switch filepath.Ext(tarFile) { + case ".gz": + r, err := gzip.NewReader(input) + OK(t, err) + + defer r.Close() + rd = r + case ".bzip2": + rd = bzip2.NewReader(input) + default: + rd = input + } + + cmd := exec.Command("tar", "xf", "-") cmd.Dir = outputDir - cmd.Stdin = f + cmd.Stdin = rd cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr From 5d51c8ffcd87860130ba7d60c5a97a0ad03071f4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 21:14:15 +0200 Subject: [PATCH 14/20] lock: fix merge error, use processExists() --- lock.go | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lock.go b/lock.go index 6d65637c1..c305e19e2 100644 --- a/lock.go +++ b/lock.go @@ -207,17 +207,10 @@ func (l *Lock) Stale() bool { return false } - proc, err := os.FindProcess(l.PID) - defer proc.Release() - if err != nil { - debug.Log("Lock.Stale", "error searching for process %d: %v\n", l.PID, err) - return true - } - - debug.Log("Lock.Stale", "sending SIGHUP to process %d\n", l.PID) - err = proc.Signal(syscall.SIGHUP) - if err != nil { - debug.Log("Lock.Stale", "signal error: %v, lock is probably stale\n", err) + // check if we can reach the process retaining the lock + exists := l.processExists() + if !exists { + debug.Log("Lock.Stale", "could not reach process, %d, lock is probably stale\n", l.PID) return true } From 10232155ef5bcd9d911b291e234be03369d4e18b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 21:40:36 +0200 Subject: [PATCH 15/20] build.go: make sure to exit 1 on error --- build.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/build.go b/build.go index f429c63d3..05c930ae3 100644 --- a/build.go +++ b/build.go @@ -319,8 +319,7 @@ func main() { err = build(gopath, args...) if err != nil { - fmt.Fprintf(os.Stderr, "build failed: %v\n", err) - return + die("build failed: %v\n", err) } if runTests { @@ -328,7 +327,7 @@ func main() { err = test(gopath, "github.com/restic/restic/...") if err != nil { - fmt.Fprintf(os.Stderr, "build failed: %v\n", err) + die("running tests failed: %v\n", err) } } } From 264472219804ac7c62ab1f90d3cf4a156b89495b Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 22:02:47 +0200 Subject: [PATCH 16/20] Reset read-only flag before removing --- backend/local/local.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/backend/local/local.go b/backend/local/local.go index 6f5d9d976..8ba369ca3 100644 --- a/backend/local/local.go +++ b/backend/local/local.go @@ -267,6 +267,12 @@ func (b *Local) Remove(t backend.Type, name string) error { b.open[fn] = nil b.mu.Unlock() + // reset read-only flag + err := os.Chmod(fn, 0666) + if err != nil { + return err + } + return os.Remove(fn) } From 4755fff37f8e4eb3685fd90d3a4026ffbe2edd39 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 19 Aug 2015 22:20:44 +0200 Subject: [PATCH 17/20] README: Add appveyor build status --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index bdd3b3487..136e0b31d 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Stories in Ready](https://badge.waffle.io/restic/restic.png?label=ready&title=Ready)](https://waffle.io/restic/restic) [![Build Status](https://travis-ci.org/restic/restic.svg?branch=master)](https://travis-ci.org/restic/restic) +[![Build status](https://ci.appveyor.com/api/projects/status/nuy4lfbgfbytw92q/branch/master?svg=true)](https://ci.appveyor.com/project/fd0/restic/branch/master) [![sourcegraph status](https://sourcegraph.com/api/repos/github.com/restic/restic/.badges/status.png)](https://sourcegraph.com/github.com/restic/restic) [![Coverage Status](https://coveralls.io/repos/restic/restic/badge.svg)](https://coveralls.io/r/restic/restic) From 0cdbde1bd027258a8cb4311c87464341be093908 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 20 Aug 2015 18:54:24 +0200 Subject: [PATCH 18/20] Remove unneeded comments --- run_integration_tests.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/run_integration_tests.go b/run_integration_tests.go index 7c4e05120..d9a4a6cd7 100644 --- a/run_integration_tests.go +++ b/run_integration_tests.go @@ -81,12 +81,9 @@ type AppveyorEnvironment struct{} func (env *AppveyorEnvironment) Prepare() { msg("preparing environment for Appveyor CI\n") - - // install tar, gzip, bzip2 } func (env *AppveyorEnvironment) RunTests() { - // run the build script and the tests run("go", "run", "build.go", "-v", "-T") } From 7ebf5397a3fb3c179d6d2a948626ee8eac74a020 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 20 Aug 2015 19:05:19 +0200 Subject: [PATCH 19/20] clean up Makefile --- Makefile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Makefile b/Makefile index e5a11720b..9052c8d46 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,12 @@ .PHONY: all clean test -SOURCE=$(wildcard *.go) $(wildcard */*.go) $(wildcard */*/*.go) - -export GOPATH GOX_OS - all: restic restic: $(SOURCE) go run build.go -restic.debug: $(SOURCE) - go run build.go -tags debug - clean: - rm -rf restic restic.debug + rm -rf restic test: $(SOURCE) go run run_tests.go /dev/null - -all.cov: $(SOURCE) - go run run_tests.go all.cov From 3eac8061f950cfc19fcd0689130f6f2f42a4e257 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Thu, 20 Aug 2015 19:08:09 +0200 Subject: [PATCH 20/20] travis: remove unneeded GOPATH definition from --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 82bc079f0..38bef3d1b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,7 +23,6 @@ install: - go version - export GOBIN="$GOPATH/bin" - export PATH="$PATH:$GOBIN" - - export GOPATH="$GOPATH:${TRAVIS_BUILD_DIR}/Godeps/_workspace" - go env script: