1
0
mirror of https://github.com/magefile/mage.git synced 2025-04-19 06:22:14 +03:00
mage/install_test.go
Horacio Duran 2385abb49a
Correct test input code to support older go versions (#490)
Samples used for testing need to have build tags for new and old style:

```
//go:build tag
// +build tag
```

The particular problem here seems to be that 1.16 was actually importing the package referred in the `TestGoModules` test (`import "golang.org/x/text/unicode/norm"`) which, in the CI system's version lacks an old style go tag comment. Hence go complaining of a `//go:build` without a `// +build`. I made all files bi-tagged for consistency.
2023-11-18 18:05:41 +01:00

41 lines
671 B
Go

//go:build CI
// +build CI
package main
import (
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"testing"
)
func TestBootstrap(t *testing.T) {
dir, err := ioutil.TempDir("", "")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(dir)
s, err := run("go", "run", "bootstrap.go")
if err != nil {
t.Fatal(s)
}
name := "mage"
if runtime.GOOS == "windows" {
name += ".exe"
}
if _, err := os.Stat(filepath.Join(os.Getenv("GOPATH"), "bin", name)); err != nil {
t.Fatal(err)
}
}
func run(cmd string, args ...string) (string, error) {
c := exec.Command(cmd, args...)
c.Env = os.Environ()
b, err := c.CombinedOutput()
return string(b), err
}