1
0
Fork 0
mirror of https://github.com/restic/restic.git synced 2024-12-23 08:16:36 +00:00

Only run minio server for Go >= 1.5.1

This commit is contained in:
Alexander Neumann 2015-12-19 18:22:57 +01:00
parent 34e8f63f77
commit d5e36bd2f0

View file

@ -8,6 +8,7 @@ import (
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
"strings"
)
@ -65,6 +66,20 @@ func (env *TravisEnvironment) Prepare() {
}
}
func goVersionAtLeast151() bool {
v := runtime.Version()
if match, _ := regexp.MatchString(`^go1\.[0-4]`, v); match {
return false
}
if v == "go1.5" {
return false
}
return true
}
func (env *TravisEnvironment) RunTests() {
// run fuse tests on darwin
if runtime.GOOS != "darwin" {
@ -85,20 +100,32 @@ func (env *TravisEnvironment) RunTests() {
// run the build script
run("go", "run", "build.go")
minioCmd, err := runMinio()
var (
testEnv map[string]string
minioCmd *exec.Cmd
err error
)
if goVersionAtLeast151() {
minioCmd, err = runMinio()
if err != nil {
fmt.Fprintf(os.Stderr, "error running minio server: %v", err)
os.Exit(8)
}
// run the tests and gather coverage information
runWithEnv(minioEnv, "gotestcover", "-coverprofile", "all.cov", "./...")
testEnv = minioEnv
}
err = minioCmd.Process.Kill()
// run the tests and gather coverage information
runWithEnv(testEnv, "gotestcover", "-coverprofile", "all.cov", "./...")
if minioCmd != nil {
err := minioCmd.Process.Kill()
if err != nil {
fmt.Fprintf(os.Stderr, "error stopping minio server: %v", err)
os.Exit(8)
}
}
runGofmt()
}
@ -261,19 +288,17 @@ func runMinio() (*exec.Cmd, error) {
return nil, err
}
// logfile, err := os.Create(filepath.Join(cfgdir, "output"))
// if err != nil {
// return nil, err
// }
logfile, err := os.Create(filepath.Join(cfgdir, "output"))
if err != nil {
return nil, err
}
cmd := exec.Command("minio",
"--config-folder", cfgdir,
"--address", "127.0.0.1:9000",
"server", dir)
// cmd.Stdout = logfile
// cmd.Stderr = logfile
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdout = logfile
cmd.Stderr = logfile
err = cmd.Start()
if err != nil {
return nil, err