in magefile.go [159:200]
func Test() error {
mg.Deps(Prepare.Dirs)
return withExecEnv(func(local, runner clitool.Executor) error {
testUseBin := envTestUseBin
if crossBuild() {
mg.Deps(Build.Test)
testUseBin = true
}
goLocal := gotool.New(local, mg.GoCmd())
goRun := gotool.New(runner, mg.GoCmd())
return ctrl.ForEachFrom(goLocal.List.ProjectPackages, failFastEach, func(pkg string) error {
fmt.Println("Test:", pkg)
if b, err := goLocal.List.HasTests(pkg); !b {
fmt.Printf("Skipping %v: No tests found\n", pkg)
return err
}
home := path.Join(buildHome, pkg)
if err := fs.MakeDirs(home); err != nil {
return err
}
tst := goRun.Test
bin := path.Join(home, path.Base(pkg))
useBinary := fs.ExistsFile(bin) && testUseBin
fmt.Printf("Run test for package '%v' (binary: %v)\n", pkg, useBinary)
return tst(
context.Background(),
tst.UseBinaryIf(bin, useBinary),
tst.WithCoverage(path.Join(home, "cover.out")),
tst.Short(envTestShort),
// tst.Out(bin), - due to bin file tests are failing on Windows, since it seems not to be used - it's disabled
tst.Package(pkg),
tst.Verbose(true),
clitool.Flag("-timeout", "30m"),
)
})
})
}