| 1 | // Copyright (c) Bartłomiej Płotka @bwplotka |
| 2 | // Licensed under the Apache License 2.0. |
| 3 | |
| 4 | package main_testscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/ |
| 5 | |
| 6 | import ( |
| 7 | "bytesscip-go gomod github.com/golang/go/src go1.24.9 bytes/" |
| 8 | "fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/" |
| 9 | "osscip-go gomod github.com/golang/go/src go1.24.9 os/" |
| 10 | "os/execscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/" |
| 11 | "path/filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/" |
| 12 | "stringsscip-go gomod github.com/golang/go/src go1.24.9 strings/" |
| 13 | "testingscip-go gomod github.com/golang/go/src go1.24.9 testing/" |
| 14 | |
| 15 | "github.com/efficientgo/core/errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/" |
| 16 | "github.com/efficientgo/core/testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/" |
| 17 | ) |
| 18 | |
| 19 | type testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject# struct { |
| 20 | pwdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#pwd., rootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#root. string |
| 21 | isGoProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#isGoProject. bool |
| 22 | } |
| 23 | |
| 24 | func newTestProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/newTestProject().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#, base string, target string, isGoProject bool) *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject# { |
| 25 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 26 | |
| 27 | wd, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.Getwdscip-go gomod github.com/golang/go/src go1.24.9 os/Getwd().() |
| 28 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 29 | |
| 30 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "cp", "-r", base, target) |
| 31 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 32 | |
| 33 | if isGoProject { |
| 34 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "cp", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(wd, "testdata", "main.go"), target) |
| 35 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 36 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "cp", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(wd, "testdata", "go.mod"), target) |
| 37 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 38 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "cp", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(wd, "testdata", "go.sum"), target) |
| 39 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 40 | } |
| 41 | |
| 42 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "cp", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(wd, "testdata", "Makefile"), target) |
| 43 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 44 | return &testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#{ |
| 45 | pwdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#pwd.: wd, |
| 46 | rootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#root.: target, |
| 47 | isGoProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#isGoProject.: isGoProject, |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | func (g *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#) assertNotChangedscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertNotChanged().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#, except ...string) { |
| 52 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 53 | |
| 54 | if g.isGoProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#isGoProject. { |
| 55 | g.assertGoModDidNotChangescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertGoModDidNotChange().(t).assertGoSumDidNotChangescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertGoSumDidNotChange().(t) |
| 56 | except = append(except, "main.go", "go.sum", "go.mod") |
| 57 | } |
| 58 | g.assertProjectRootIsCleanscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertProjectRootIsClean().(t, except...) |
| 59 | } |
| 60 | |
| 61 | func (g *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#) assertGoModDidNotChangescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertGoModDidNotChange().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#) *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject# { |
| 62 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 63 | |
| 64 | a, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.9 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.rootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#root., "go.mod")) |
| 65 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 66 | |
| 67 | b, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.9 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.pwdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#pwd., "testdata", "go.mod")) |
| 68 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 69 | |
| 70 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, string(b), string(a)) |
| 71 | |
| 72 | return g |
| 73 | } |
| 74 | |
| 75 | func (g *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#) assertGoSumDidNotChangescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertGoSumDidNotChange().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#) *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject# { |
| 76 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 77 | |
| 78 | a, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.9 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.rootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#root., "go.sum")) |
| 79 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 80 | |
| 81 | b, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.9 os/ReadFile().(filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.pwdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#pwd., "testdata", "go.sum")) |
| 82 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 83 | |
| 84 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, string(b), string(a)) |
| 85 | return g |
| 86 | } |
| 87 | |
| 88 | func (g *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#) assertProjectRootIsCleanscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#assertProjectRootIsClean().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#, extra ...string) *testProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject# { |
| 89 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 90 | |
| 91 | expected := map[string]struct{}{ |
| 92 | "Makefile": {}, |
| 93 | } |
| 94 | for _, e := range extra { |
| 95 | expected[e] = struct{}{} |
| 96 | } |
| 97 | if g.isGoProjectscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#isGoProject. { |
| 98 | expected["go.mod"] = struct{}{} |
| 99 | expected["go.sum"] = struct{}{} |
| 100 | expected["main.go"] = struct{}{} |
| 101 | } |
| 102 | |
| 103 | i, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadDirscip-go gomod github.com/golang/go/src go1.24.9 os/ReadDir().(g.rootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/testProject#root.) |
| 104 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 105 | got := map[string]struct{}{} |
| 106 | for _, f := range i { |
| 107 | got[f.Namescip-go gomod github.com/golang/go/src go1.24.9 `io/fs`/DirEntry#Name().()] = struct{}{} |
| 108 | } |
| 109 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Equalsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Equals().(t, expected, got) |
| 110 | |
| 111 | return g |
| 112 | } |
| 113 | |
| 114 | type goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv# struct { |
| 115 | gorootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goroot., gopathscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gopath., goproxyscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goproxy., gobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gobin., gocachescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gocache., tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir. string |
| 116 | } |
| 117 | |
| 118 | func execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(dir string, env []string, command string, args ...string) (string, error) { |
| 119 | var cmd *execscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/.Cmdscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd# |
| 120 | if env == nil { |
| 121 | cmd = execscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/.Commandscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Command().(command, args...) |
| 122 | } else { |
| 123 | // Since we want to have synthetic PATH, do not allows unspecified paths. |
| 124 | // Otherwise unit test environment PATH will be used for lookup as exec.LookPath is not parametrized. |
| 125 | // TL;DR: command has to have path separator. |
| 126 | cmd = &execscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/.Cmdscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#{ |
| 127 | Envscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Env.: env, |
| 128 | Pathscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Path.: command, |
| 129 | Argsscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Args.: append([]string{command}, args...), |
| 130 | } |
| 131 | } |
| 132 | cmd.Dirscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Dir. = dir |
| 133 | var b bytesscip-go gomod github.com/golang/go/src go1.24.9 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.9 bytes/Buffer# |
| 134 | cmd.Stdoutscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Stdout. = &b |
| 135 | cmd.Stderrscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Stderr. = &b |
| 136 | if err := cmd.Runscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#Run().(); err != nil { |
| 137 | if _, ok := err.(*execscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/.ExitErrorscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/ExitError#); ok { |
| 138 | return "", errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/.Newfscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/Newf().("error while running command %q; out: %s; err: %v", cmd.Stringscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#String().(), b.Stringscip-go gomod github.com/golang/go/src go1.24.9 bytes/Buffer#String().(), err) |
| 139 | |
| 140 | } |
| 141 | return "", errorsscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/.Newfscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/errors`/Newf().("error while running command %q; out: %s; err: %v", cmd.Stringscip-go gomod github.com/golang/go/src go1.24.9 `os/exec`/Cmd#String().(), b.Stringscip-go gomod github.com/golang/go/src go1.24.9 bytes/Buffer#String().(), err) |
| 142 | } |
| 143 | return b.Stringscip-go gomod github.com/golang/go/src go1.24.9 bytes/Buffer#String().(), nil |
| 144 | } |
| 145 | |
| 146 | func buildInitialGobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/buildInitialGobin().(t *testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.Tscip-go gomod github.com/golang/go/src go1.24.9 testing/T#, targetDir string) { |
| 147 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/common#Helper().() |
| 148 | |
| 149 | wd, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.Getwdscip-go gomod github.com/golang/go/src go1.24.9 os/Getwd().() |
| 150 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 151 | |
| 152 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, osscip-go gomod github.com/golang/go/src go1.24.9 os/.Setenvscip-go gomod github.com/golang/go/src go1.24.9 os/Setenv().("GOBIN", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(wd, ".bin"))) |
| 153 | |
| 154 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "make", "build") |
| 155 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 156 | _, err = execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(wd, nil, "cp", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(osscip-go gomod github.com/golang/go/src go1.24.9 os/.Getenvscip-go gomod github.com/golang/go/src go1.24.9 os/Getenv().("GOBIN"), bingoBinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/bingoBin.), targetDir) |
| 157 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 158 | } |
| 159 | |
| 160 | func makePathscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/makePath().(t *testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.Tscip-go gomod github.com/golang/go/src go1.24.9 testing/T#) string { |
| 161 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/common#Helper().() |
| 162 | |
| 163 | makePath, err := execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().("", nil, "which", "make") |
| 164 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 165 | return stringsscip-go gomod github.com/golang/go/src go1.24.9 strings/.TrimSuffixscip-go gomod github.com/golang/go/src go1.24.9 strings/TrimSuffix().(makePath, "\n") |
| 166 | } |
| 167 | |
| 168 | func newIsolatedGoEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/newIsolatedGoEnv().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#, goproxy string) *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv# { |
| 169 | tmpDir, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.MkdirTempscip-go gomod github.com/golang/go/src go1.24.9 os/MkdirTemp().("", "bingo-tmpgoenv") |
| 170 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 171 | |
| 172 | tmpDir, err = filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Absscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Abs().(tmpDir) |
| 173 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 174 | |
| 175 | goRoot, err := execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().("", nil, "which", "go") |
| 176 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 177 | |
| 178 | gopath := filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(tmpDir, "gopath") |
| 179 | return &goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#{ |
| 180 | tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir.: tmpDir, |
| 181 | gorootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goroot.: filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Dirscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Dir().(goRoot), |
| 182 | gopathscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gopath.: gopath, |
| 183 | // Making sure $GOBIN is actually different than standard one to test advanced stuff. |
| 184 | gobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gobin.: filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(tmpDir, "bin"), |
| 185 | gocachescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gocache.: filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(tmpDir, "gocache"), |
| 186 | goproxyscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goproxy.: goproxy, |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | // Clear clears all go env dirs but not goroot, gopath and gocache. |
| 191 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) Clearscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#Clear().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#) { |
| 192 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 193 | |
| 194 | _, err := execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().("", nil, "chmod", "-R", "777", g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir.) |
| 195 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 196 | |
| 197 | dirs, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadDirscip-go gomod github.com/golang/go/src go1.24.9 os/ReadDir().(g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir.) |
| 198 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 199 | |
| 200 | for _, d := range dirs { |
| 201 | switch filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir., d.Namescip-go gomod github.com/golang/go/src go1.24.9 `io/fs`/DirEntry#Name().()) { |
| 202 | case g.gocachescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gocache., g.gorootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goroot., g.gopathscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gopath.: |
| 203 | default: |
| 204 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, osscip-go gomod github.com/golang/go/src go1.24.9 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.24.9 os/RemoveAll().(filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir., d.Namescip-go gomod github.com/golang/go/src go1.24.9 `io/fs`/DirEntry#Name().()))) |
| 205 | } |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) TmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#TmpDir().() string { |
| 210 | return g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir. |
| 211 | } |
| 212 | |
| 213 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) syntheticEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#syntheticEnv().() []string { |
| 214 | return []string{ |
| 215 | // Make sure we don't require clang to build etc. |
| 216 | "CGO_ENABLED=0", |
| 217 | fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.9 fmt/Sprintf().("PATH=%s:%s:%s", g.gorootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goroot., g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir., g.gobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gobin.), |
| 218 | fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.9 fmt/Sprintf().("GO=%s", filepathscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.9 `path/filepath`/Join().(g.gorootscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goroot., "go")), |
| 219 | fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.9 fmt/Sprintf().("GOBIN=%s", g.gobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gobin.), |
| 220 | fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.9 fmt/Sprintf().("GOPATH=%s", g.gopathscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gopath.), |
| 221 | fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.9 fmt/Sprintf().("GOCACHE=%s", g.gocachescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gocache.), |
| 222 | fmtscip-go gomod github.com/golang/go/src go1.24.9 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.9 fmt/Sprintf().("GOPROXY=%s", g.goproxyscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#goproxy.), |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) ExecOutputscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#ExecOutput().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#, dir string, command string, args ...string) string { |
| 227 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 228 | |
| 229 | b, err := execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(dir, g.syntheticEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#syntheticEnv().(), command, args...) |
| 230 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 231 | return b |
| 232 | } |
| 233 | |
| 234 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) ExpectErrscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#ExpectErr().(dir string, command string, args ...string) error { |
| 235 | _, err := execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().(dir, g.syntheticEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#syntheticEnv().(), command, args...) |
| 236 | return err |
| 237 | } |
| 238 | |
| 239 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) existingBinariesscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#existingBinaries().(t *testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.Tscip-go gomod github.com/golang/go/src go1.24.9 testing/T#) []string { |
| 240 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/common#Helper().() |
| 241 | |
| 242 | var filenames []string |
| 243 | files, err := osscip-go gomod github.com/golang/go/src go1.24.9 os/.ReadDirscip-go gomod github.com/golang/go/src go1.24.9 os/ReadDir().(g.gobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gobin.) |
| 244 | if osscip-go gomod github.com/golang/go/src go1.24.9 os/.IsNotExistscip-go gomod github.com/golang/go/src go1.24.9 os/IsNotExist().(err) { |
| 245 | return []string{} |
| 246 | } |
| 247 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 248 | |
| 249 | for _, f := range files { |
| 250 | if f.IsDirscip-go gomod github.com/golang/go/src go1.24.9 `io/fs`/DirEntry#IsDir().() { |
| 251 | t.Fatalscip-go gomod github.com/golang/go/src go1.24.9 testing/common#Fatal().("Did not expect directory in gobin", g.gobinscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#gobin., "got", f.Namescip-go gomod github.com/golang/go/src go1.24.9 `io/fs`/DirEntry#Name().()) |
| 252 | } |
| 253 | filenames = append(filenames, f.Namescip-go gomod github.com/golang/go/src go1.24.9 `io/fs`/DirEntry#Name().()) |
| 254 | } |
| 255 | return filenames |
| 256 | } |
| 257 | |
| 258 | func (g *goEnvscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#) Closescip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#Close().(t testingscip-go gomod github.com/golang/go/src go1.24.9 testing/.TBscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#) { |
| 259 | t.Helperscip-go gomod github.com/golang/go/src go1.24.9 testing/TB#Helper().() |
| 260 | |
| 261 | _, err := execCmdscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/execCmd().("", nil, "chmod", "-R", "777", g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir.) |
| 262 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, err) |
| 263 | testutilscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/.Okscip-go gomod github.com/efficientgo/core v1.0.0-rc.3 `github.com/efficientgo/core/testutil`/Ok().(t, osscip-go gomod github.com/golang/go/src go1.24.9 os/.RemoveAllscip-go gomod github.com/golang/go/src go1.24.9 os/RemoveAll().(g.tmpDirscip-go gomod github.com/bwplotka/bingo . `github.com/bwplotka/bingo_test`/goEnv#tmpDir.)) |
| 264 | } |