Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit be24dff

Browse filesBrowse files
committed
plumbing: transport/git, Improve tests error message
When running the tests in an install in which git daemon is not installed (e.g. openSUSE), all the git transport tests will fail with a connection refused error. This was due the git server not being running in the first place. The tests will now fail with "git daemon cannot be found". In such cases, the attempt to call Close() of a session that was not established, was causing a panic, which has now being fixed. Signed-off-by: Paulo Gomes <pjbgf@linux.com>
1 parent 0542a30 commit be24dff
Copy full SHA for be24dff

File tree

Expand file treeCollapse file tree

3 files changed

+13
-1
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+13
-1
lines changed

‎plumbing/transport/git/common_test.go

Copy file name to clipboardExpand all lines: plumbing/transport/git/common_test.go
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
package git
22

33
import (
4+
"bytes"
45
"fmt"
56
"io/ioutil"
67
"net"
78
"os"
89
"os/exec"
910
"path/filepath"
1011
"runtime"
12+
"strings"
1113
"testing"
1214
"time"
1315

@@ -58,11 +60,19 @@ func (s *BaseSuite) StartDaemon(c *C) {
5860
// Environment must be inherited in order to acknowledge GIT_EXEC_PATH if set.
5961
s.daemon.Env = os.Environ()
6062

63+
stdErr := bytes.NewBufferString("")
64+
s.daemon.Stderr = stdErr
65+
6166
err := s.daemon.Start()
67+
// Note that if git daemon is not installed, err may still be nil
68+
// but all transport/git tests will fail.
6269
c.Assert(err, IsNil)
6370

6471
// Connections might be refused if we start sending request too early.
6572
time.Sleep(time.Millisecond * 500)
73+
if strings.Contains(stdErr.String(), "'daemon' is not a git command") {
74+
c.Fatal("git daemon cannot be found")
75+
}
6676
}
6777

6878
func (s *BaseSuite) newEndpoint(c *C, name string) *transport.Endpoint {

‎plumbing/transport/internal/common/common.go

Copy file name to clipboardExpand all lines: plumbing/transport/internal/common/common.go
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,9 @@ func (s *session) finish() error {
360360
}
361361

362362
func (s *session) Close() (err error) {
363+
if s == nil {
364+
return
365+
}
363366
err = s.finish()
364367

365368
defer ioutil.CheckClose(s.Command, &err)

‎plumbing/transport/test/receive_pack.go

Copy file name to clipboardExpand all lines: plumbing/transport/test/receive_pack.go
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Package test implements common test suite for different transport
22
// implementations.
3-
//
43
package test
54

65
import (

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.