-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain_test.go
More file actions
48 lines (37 loc) · 949 Bytes
/
Copy pathmain_test.go
File metadata and controls
48 lines (37 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package main
import (
"encoding/json"
"path/filepath"
"testing"
"github.com/rogpeppe/go-internal/gotooltest"
"github.com/rogpeppe/go-internal/testscript"
"github.com/stretchr/testify/require"
exec "golang.org/x/sys/execabs"
)
func TestMain(m *testing.M) {
testscript.Main(m, map[string]func(){
"allowtags": main,
})
}
func TestScripts(t *testing.T) {
t.Parallel()
var goEnv struct {
GOCACHE string
GOMODCACHE string
GOMOD string
}
out, err := exec.Command("go", "env", "-json").CombinedOutput()
require.NoError(t, err)
require.NoError(t, json.Unmarshal(out, &goEnv))
p := testscript.Params{
Dir: filepath.Join("testdata", "script"),
Setup: func(env *testscript.Env) error {
env.Setenv("GOCACHE", goEnv.GOCACHE)
env.Setenv("GOMODCACHE", goEnv.GOMODCACHE)
env.Setenv("GOMOD_DIR", filepath.Dir(goEnv.GOMOD))
return nil
},
}
require.NoError(t, gotooltest.Setup(&p))
testscript.Run(t, p)
}