MCPcopy Index your code
hub / github.com/ddev/ddev / Chdir

Function Chdir

pkg/testcommon/testcommon.go:320–333  ·  view source on GitHub ↗

Chdir will change to the directory for the site specified by TestSite. It returns an anonymous function which will return to the original working directory when called.

(dirPath string)

Source from the content-addressed store, hash-verified

318// Chdir will change to the directory for the site specified by TestSite.
319// It returns an anonymous function which will return to the original working directory when called.
320func Chdir(dirPath string) func() {
321 curDir, _ := os.Getwd()
322 err := os.Chdir(dirPath)
323 if err != nil {
324 output.UserErr.Errorf("Could not change to directory %s: %v\n", dirPath, err)
325 }
326
327 return func() {
328 err := os.Chdir(curDir)
329 if err != nil {
330 output.UserErr.Errorf("Failed to change directory to original dir=%s, err=%v", curDir, err)
331 }
332 }
333}
334
335// ClearDockerEnv unsets env vars set in platform DockerEnv() so that
336// they can be set by another test run.

Calls 2

ChdirMethod · 0.80
ErrorfMethod · 0.80