mirror of
https://github.com/restic/restic.git
synced 2024-12-23 16:26:11 +00:00
Add error handling
This commit is contained in:
parent
aa43b69651
commit
b2846ea49d
1 changed files with 41 additions and 15 deletions
|
@ -138,21 +138,39 @@ func (env *TravisEnvironment) Prepare() error {
|
||||||
|
|
||||||
msg("preparing environment for Travis CI\n")
|
msg("preparing environment for Travis CI\n")
|
||||||
|
|
||||||
run("go", "get", "golang.org/x/tools/cmd/cover")
|
for _, pkg := range []string{
|
||||||
run("go", "get", "github.com/mattn/goveralls")
|
"golang.org/x/tools/cmd/cover",
|
||||||
run("go", "get", "github.com/pierrre/gotestcover")
|
"github.com/mattn/goveralls",
|
||||||
env.getMinio()
|
"github.com/pierrre/gotestcover",
|
||||||
env.runMinio()
|
} {
|
||||||
|
err := run("go", "get", pkg)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := env.getMinio(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := env.runMinio(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
// install the libraries necessary for fuse
|
// install the libraries necessary for fuse
|
||||||
run("brew", "update")
|
if err := run("brew", "update"); err != nil {
|
||||||
run("brew", "cask", "install", "osxfuse")
|
return err
|
||||||
|
}
|
||||||
|
if err := run("brew", "cask", "install", "osxfuse"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *runCrossCompile {
|
if *runCrossCompile {
|
||||||
// only test cross compilation on linux with Travis
|
// only test cross compilation on linux with Travis
|
||||||
run("go", "get", "github.com/mitchellh/gox")
|
if err := run("go", "get", "github.com/mitchellh/gox"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
if runtime.GOOS == "linux" {
|
if runtime.GOOS == "linux" {
|
||||||
env.goxArch = []string{"386", "amd64"}
|
env.goxArch = []string{"386", "amd64"}
|
||||||
if !strings.HasPrefix(runtime.Version(), "go1.3") {
|
if !strings.HasPrefix(runtime.Version(), "go1.3") {
|
||||||
|
@ -169,9 +187,13 @@ func (env *TravisEnvironment) Prepare() error {
|
||||||
|
|
||||||
v := runtime.Version()
|
v := runtime.Version()
|
||||||
if !strings.HasPrefix(v, "go1.5") && !strings.HasPrefix(v, "go1.6") {
|
if !strings.HasPrefix(v, "go1.5") && !strings.HasPrefix(v, "go1.6") {
|
||||||
run("gox", "-build-toolchain",
|
err := run("gox", "-build-toolchain",
|
||||||
"-os", strings.Join(env.goxOS, " "),
|
"-os", strings.Join(env.goxOS, " "),
|
||||||
"-arch", strings.Join(env.goxArch, " "))
|
"-arch", strings.Join(env.goxArch, " "))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,10 +321,15 @@ func (env *TravisEnvironment) RunTests() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the build script
|
// run the build script
|
||||||
run("go", "run", "build.go")
|
if err := run("go", "run", "build.go"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// run the tests and gather coverage information
|
// run the tests and gather coverage information
|
||||||
runWithEnv(env.env, "gotestcover", "-coverprofile", "all.cov", "cmds/...", "restic/...")
|
err = runWithEnv(env.env, "gotestcover", "-coverprofile", "all.cov", "cmds/...", "restic/...")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return runGofmt()
|
return runGofmt()
|
||||||
}
|
}
|
||||||
|
@ -315,8 +342,7 @@ func (env *AppveyorEnvironment) Prepare() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *AppveyorEnvironment) RunTests() error {
|
func (env *AppveyorEnvironment) RunTests() error {
|
||||||
run("go", "run", "build.go", "-v", "-T")
|
return run("go", "run", "build.go", "-v", "-T")
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *AppveyorEnvironment) Teardown() error {
|
func (env *AppveyorEnvironment) Teardown() error {
|
||||||
|
@ -397,9 +423,9 @@ func runGofmt() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func run(command string, args ...string) {
|
func run(command string, args ...string) error {
|
||||||
msg("run %v %v\n", command, strings.Join(args, " "))
|
msg("run %v %v\n", command, strings.Join(args, " "))
|
||||||
runWithEnv(nil, command, args...)
|
return runWithEnv(nil, command, args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
// runWithEnv calls a command with the current environment, except the entries
|
// runWithEnv calls a command with the current environment, except the entries
|
||||||
|
|
Loading…
Reference in a new issue