MCPcopy Create free account
hub / github.com/dim-an/cod / RunCodCmdModifiedEnv

Method RunCodCmdModifiedEnv

test/lib.go:156–178  ·  view source on GitHub ↗
(env map[string]string, args ...string)

Source from the content-addressed store, hash-verified

154}
155
156func (wb *Workbench) RunCodCmdModifiedEnv(env map[string]string, args ...string) string {
157 if env != nil {
158 oldMap := make(map[string]string)
159 for k, v := range env {
160 oldMap[k] = os.Getenv(k)
161 err := os.Setenv(k, v)
162 require.NoError(wb.t, err)
163 }
164 defer func() {
165 for k, v := range oldMap {
166 err := os.Setenv(k, v)
167 require.NoError(wb.t, err)
168 }
169 }()
170 }
171 output, err := wb.UncheckedRunCodCmd(args...)
172 if err != nil {
173 cmdString := shells.Quote(append([]string{"cod"}, args...))
174 err = fmt.Errorf("%q error: %w; output: %q", cmdString, err, output)
175 }
176 require.NoError(wb.t, err)
177 return output
178}
179
180func (wb *Workbench) NewCodCmd(args ...string) exec.Cmd {
181 cmd := exec.Cmd{}

Callers 3

RunCodCmdMethod · 0.95
TestLearnFromPATHFunction · 0.80
TestMergeLearnFunction · 0.80

Calls 2

UncheckedRunCodCmdMethod · 0.95
QuoteFunction · 0.92

Tested by 2

TestLearnFromPATHFunction · 0.64
TestMergeLearnFunction · 0.64