Fix magefile compatibility with Windows (#538)

This commit is contained in:
David Zhao
2022-03-18 23:53:05 -07:00
committed by GitHub
parent f14c452f8c
commit 224dfe68b1
3 changed files with 30 additions and 19 deletions
+2 -19
View File
@@ -13,10 +13,8 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"sort"
"strings"
"syscall"
"github.com/magefile/mage/mg"
@@ -156,7 +154,7 @@ func PublishDocker() error {
// run unit tests, skipping integration
func Test() error {
mg.Deps(generateWire, macULimit)
mg.Deps(generateWire, setULimit)
cmd := exec.Command("go", "test", "-short", "./...", "-count=1")
connectStd(cmd)
return cmd.Run()
@@ -164,7 +162,7 @@ func Test() error {
// run all tests including integration
func TestAll() error {
mg.Deps(generateWire, macULimit)
mg.Deps(generateWire, setULimit)
return run("go test ./... -count=1 -timeout=4m -v")
}
@@ -269,21 +267,6 @@ func connectStd(cmd *exec.Cmd) {
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
// it's designed as a quick way to bypass
type Checksummer struct {
+20
View File
@@ -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)
}
+8
View File
@@ -0,0 +1,8 @@
//go:build mage
// +build mage
package main
func setULimit() error {
return nil
}