summaryrefslogtreecommitdiffhomepage
path: root/magefile.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-08-30 12:28:29 +0200
committerBjørn Erik Pedersen <[email protected]>2018-08-30 13:36:33 +0200
commitea8ef573c6f869de95fdf4b19765d34026de6471 (patch)
tree2d45870e9e01c2ed698562bb9d67e02ed28cbf43 /magefile.go
parent293e12355dd9d9361774f5ab340cd8a03b4828a1 (diff)
downloadhugo-ea8ef573c6f869de95fdf4b19765d34026de6471.tar.gz
hugo-ea8ef573c6f869de95fdf4b19765d34026de6471.zip
mage: Init packages once
`go list ./...` fails when run in parallel on Windows. This also applies to running `go test ./...` and `go list/...` so we serialize tests.
Diffstat (limited to 'magefile.go')
-rw-r--r--magefile.go35
1 files changed, 24 insertions, 11 deletions
diff --git a/magefile.go b/magefile.go
index 91c79b1dd..b00b3bbe4 100644
--- a/magefile.go
+++ b/magefile.go
@@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strings"
+ "sync"
"time"
"github.com/magefile/mage/mg"
@@ -98,7 +99,11 @@ func Check() {
fmt.Printf("Skip Check on %s\n", runtime.Version())
return
}
- mg.Deps(Test386, Fmt, Vet)
+
+ mg.Deps(Test386)
+
+ mg.Deps(Fmt, Vet)
+
// don't run two tests in parallel, they saturate the CPUs anyway, and running two
// causes memory issues in CI.
mg.Deps(TestRace)
@@ -161,18 +166,26 @@ func Fmt() error {
return nil
}
-var pkgPrefixLen = len("github.com/gohugoio/hugo")
+var (
+ pkgPrefixLen = len("github.com/gohugoio/hugo")
+ pkgs []string
+ pkgsInit sync.Once
+)
func hugoPackages() ([]string, error) {
- s, err := sh.Output(goexe, "list", "./...")
- if err != nil {
- return nil, err
- }
- pkgs := strings.Split(s, "\n")
- for i := range pkgs {
- pkgs[i] = "." + pkgs[i][pkgPrefixLen:]
- }
- return pkgs, nil
+ var err error
+ pkgsInit.Do(func() {
+ var s string
+ s, err = sh.Output(goexe, "list", "./...")
+ if err != nil {
+ return
+ }
+ pkgs = strings.Split(s, "\n")
+ for i := range pkgs {
+ pkgs[i] = "." + pkgs[i][pkgPrefixLen:]
+ }
+ })
+ return pkgs, err
}
// Run golint linter