runInRepo runs the given command from within the ephemeral repo directory. To prevent accidental changes in the real home directory, it sets the HOME variable to a subdirectory of the temp directory. It also ensures that the git-annex-remote-rclone-builtin symlink will be found by extending the PATH
(t *testing.T, command string, args ...string)
| 154 | // variable to a subdirectory of the temp directory. It also ensures that the |
| 155 | // git-annex-remote-rclone-builtin symlink will be found by extending the PATH. |
| 156 | func (e *e2eTestingContext) runInRepo(t *testing.T, command string, args ...string) { |
| 157 | if testing.Verbose() { |
| 158 | t.Logf("Running %s %v\n", command, args) |
| 159 | } |
| 160 | cmd := exec.Command(command, args...) |
| 161 | cmd.Dir = e.ephemeralRepoDir |
| 162 | cmd.Env = []string{ |
| 163 | "HOME=" + e.homeDir, |
| 164 | "PATH=" + os.Getenv("PATH") + ":" + e.binDir, |
| 165 | } |
| 166 | buf, err := cmd.CombinedOutput() |
| 167 | require.NoError(t, err, fmt.Sprintf("+ %s %v failed:\n%s\n", command, args, buf)) |
| 168 | } |
| 169 | |
| 170 | // createGitRepo creates an empty git repository in the ephemeral repo |
| 171 | // directory. It makes "global" config changes that are ultimately scoped to the |
no test coverage detected