From 1aa3a37a28f9ad0fd85f69bae66ee1dc8e40b780 Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Thu, 13 Jun 2024 17:20:27 +0100 Subject: [PATCH] gitannex: make tests run more quietly - use go test -v for more info These tests were generating 1000s of lines of logs and making it difficult to figure out what was failing in other tests. --- cmd/gitannex/e2e_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/gitannex/e2e_test.go b/cmd/gitannex/e2e_test.go index bff6ed890..eae2b8e94 100644 --- a/cmd/gitannex/e2e_test.go +++ b/cmd/gitannex/e2e_test.go @@ -93,6 +93,7 @@ func findFileWithContents(t *testing.T, dir string, wantContents []byte) bool { } type e2eTestingContext struct { + t *testing.T tempDir string binDir string homeDir string @@ -126,7 +127,7 @@ func makeE2eTestingContext(t *testing.T) e2eTestingContext { require.NoError(t, os.Mkdir(dir, 0700)) } - return e2eTestingContext{tempDir, binDir, homeDir, configDir, rcloneConfigDir, ephemeralRepoDir} + return e2eTestingContext{t, tempDir, binDir, homeDir, configDir, rcloneConfigDir, ephemeralRepoDir} } // Install the symlink that enables git-annex to invoke "rclone gitannex" @@ -154,16 +155,17 @@ func (e *e2eTestingContext) installRcloneConfig(t *testing.T) { // 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. func (e *e2eTestingContext) runInRepo(t *testing.T, command string, args ...string) { - fmt.Printf("+ %s %v\n", command, args) + if testing.Verbose() { + t.Logf("Running %s %v\n", command, args) + } cmd := exec.Command(command, args...) cmd.Dir = e.ephemeralRepoDir cmd.Env = []string{ "HOME=" + e.homeDir, "PATH=" + os.Getenv("PATH") + ":" + e.binDir, } - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - require.NoError(t, cmd.Run()) + buf, err := cmd.CombinedOutput() + require.NoError(t, err, fmt.Sprintf("+ %s %v failed:\n%s\n", command, args, buf)) } // createGitRepo creates an empty git repository in the ephemeral repo