diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-11-17 20:14:06 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-17 20:14:06 +0000 |
commit | c114af0cc97ac71f5ac21e7e510eaadec37dfba0 (patch) | |
tree | e20dc5c5d555dcc52957618d537302d2a100fea5 /plumbing/transport | |
parent | 6d62dd1250a41ffe6d04794fb2e460456ebaea91 (diff) | |
parent | 2e14e3ab84edd9b0f54b355aeddfcadf1383ec67 (diff) | |
download | go-git-c114af0cc97ac71f5ac21e7e510eaadec37dfba0.tar.gz |
Merge pull request #752 from pjbgf/rt1
plumbing: transport/git, Improve tests error message
Diffstat (limited to 'plumbing/transport')
-rw-r--r-- | plumbing/transport/git/common_test.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/plumbing/transport/git/common_test.go b/plumbing/transport/git/common_test.go index 7389919..3cab933 100644 --- a/plumbing/transport/git/common_test.go +++ b/plumbing/transport/git/common_test.go @@ -1,6 +1,7 @@ package git import ( + "bytes" "fmt" "net" "os" @@ -32,7 +33,12 @@ func (s *BaseSuite) SetUpTest(c *C) { See https://github.com/git-for-windows/git/issues/907`) } - var err error + cmd := exec.Command("git", "daemon", "--help") + output, err := cmd.CombinedOutput() + if err != nil && bytes.Contains(output, []byte("'daemon' is not a git command")) { + c.Fatal("git daemon cannot be found") + } + s.port, err = freePort() c.Assert(err, IsNil) @@ -85,11 +91,15 @@ func (s *BaseSuite) prepareRepository(c *C, f *fixtures.Fixture, name string) *t } func (s *BaseSuite) TearDownTest(c *C) { - _ = s.daemon.Process.Signal(os.Kill) - _ = s.daemon.Wait() + if s.daemon != nil { + _ = s.daemon.Process.Signal(os.Kill) + _ = s.daemon.Wait() + } - err := os.RemoveAll(s.base) - c.Assert(err, IsNil) + if s.base != "" { + err := os.RemoveAll(s.base) + c.Assert(err, IsNil) + } } func freePort() (int, error) { |