mirror of
https://github.com/restic/restic.git
synced 2024-12-23 16:26:11 +00:00
Only run minio server for Go >= 1.5.1
This commit is contained in:
parent
34e8f63f77
commit
d5e36bd2f0
1 changed files with 42 additions and 17 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"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() {
|
func (env *TravisEnvironment) RunTests() {
|
||||||
// run fuse tests on darwin
|
// run fuse tests on darwin
|
||||||
if runtime.GOOS != "darwin" {
|
if runtime.GOOS != "darwin" {
|
||||||
|
@ -85,20 +100,32 @@ func (env *TravisEnvironment) RunTests() {
|
||||||
// run the build script
|
// run the build script
|
||||||
run("go", "run", "build.go")
|
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 {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error running minio server: %v", err)
|
fmt.Fprintf(os.Stderr, "error running minio server: %v", err)
|
||||||
os.Exit(8)
|
os.Exit(8)
|
||||||
}
|
}
|
||||||
|
|
||||||
// run the tests and gather coverage information
|
testEnv = minioEnv
|
||||||
runWithEnv(minioEnv, "gotestcover", "-coverprofile", "all.cov", "./...")
|
}
|
||||||
|
|
||||||
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 {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "error stopping minio server: %v", err)
|
fmt.Fprintf(os.Stderr, "error stopping minio server: %v", err)
|
||||||
os.Exit(8)
|
os.Exit(8)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
runGofmt()
|
runGofmt()
|
||||||
}
|
}
|
||||||
|
@ -261,19 +288,17 @@ func runMinio() (*exec.Cmd, error) {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// logfile, err := os.Create(filepath.Join(cfgdir, "output"))
|
logfile, err := os.Create(filepath.Join(cfgdir, "output"))
|
||||||
// if err != nil {
|
if err != nil {
|
||||||
// return nil, err
|
return nil, err
|
||||||
// }
|
}
|
||||||
|
|
||||||
cmd := exec.Command("minio",
|
cmd := exec.Command("minio",
|
||||||
"--config-folder", cfgdir,
|
"--config-folder", cfgdir,
|
||||||
"--address", "127.0.0.1:9000",
|
"--address", "127.0.0.1:9000",
|
||||||
"server", dir)
|
"server", dir)
|
||||||
// cmd.Stdout = logfile
|
cmd.Stdout = logfile
|
||||||
// cmd.Stderr = logfile
|
cmd.Stderr = logfile
|
||||||
cmd.Stdout = os.Stdout
|
|
||||||
cmd.Stderr = os.Stderr
|
|
||||||
err = cmd.Start()
|
err = cmd.Start()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in a new issue