Fix magefile compatibility with Windows (#538)
This commit is contained in:
+2
-19
@@ -13,10 +13,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
|
||||||
|
|
||||||
"github.com/magefile/mage/mg"
|
"github.com/magefile/mage/mg"
|
||||||
|
|
||||||
@@ -156,7 +154,7 @@ func PublishDocker() error {
|
|||||||
|
|
||||||
// run unit tests, skipping integration
|
// run unit tests, skipping integration
|
||||||
func Test() error {
|
func Test() error {
|
||||||
mg.Deps(generateWire, macULimit)
|
mg.Deps(generateWire, setULimit)
|
||||||
cmd := exec.Command("go", "test", "-short", "./...", "-count=1")
|
cmd := exec.Command("go", "test", "-short", "./...", "-count=1")
|
||||||
connectStd(cmd)
|
connectStd(cmd)
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
@@ -164,7 +162,7 @@ func Test() error {
|
|||||||
|
|
||||||
// run all tests including integration
|
// run all tests including integration
|
||||||
func TestAll() error {
|
func TestAll() error {
|
||||||
mg.Deps(generateWire, macULimit)
|
mg.Deps(generateWire, setULimit)
|
||||||
return run("go test ./... -count=1 -timeout=4m -v")
|
return run("go test ./... -count=1 -timeout=4m -v")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,21 +267,6 @@ func connectStd(cmd *exec.Cmd) {
|
|||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
func macULimit() error {
|
|
||||||
// raise ulimit if on Mac
|
|
||||||
if runtime.GOOS != "darwin" {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
var rLimit syscall.Rlimit
|
|
||||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
rLimit.Max = 10000
|
|
||||||
rLimit.Cur = 10000
|
|
||||||
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
|
||||||
}
|
|
||||||
|
|
||||||
// A helper checksum library that generates a fast, non-portable checksum over a directory of files
|
// A helper checksum library that generates a fast, non-portable checksum over a directory of files
|
||||||
// it's designed as a quick way to bypass
|
// it's designed as a quick way to bypass
|
||||||
type Checksummer struct {
|
type Checksummer struct {
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
//go:build mage && !windows
|
||||||
|
// +build mage,!windows
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
func setULimit() error {
|
||||||
|
// raise ulimit on unix
|
||||||
|
var rLimit syscall.Rlimit
|
||||||
|
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
rLimit.Max = 10000
|
||||||
|
rLimit.Cur = 10000
|
||||||
|
return syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
//go:build mage
|
||||||
|
// +build mage
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
func setULimit() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user