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)
| 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. |
| 320 | func 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. |