415c675
From 562de2be781eda9a1ef7c2cee36ba71296836070 Mon Sep 17 00:00:00 2001
415c675
From: Scott K Logan <logans@cottsay.net>
415c675
Date: Sun, 14 Dec 2014 04:21:27 -0800
415c675
Subject: [PATCH] Fix test for git >= 1.8.2
415c675
415c675
The behavior of --depth changed in 1.8.2. Previously, when --depth=n was specified,
415c675
the most recent n + 1 commits were present in the clone. In 1.8.2 and newer, the most
415c675
recent n commits are.
415c675
415c675
See https://raw.githubusercontent.com/gitster/git/master/Documentation/RelNotes/1.8.2.txt
415c675
---
415c675
 test/test_git.py | 11 ++++++++---
415c675
 1 file changed, 8 insertions(+), 3 deletions(-)
415c675
415c675
diff --git a/test/test_git.py b/test/test_git.py
415c675
index b250f8f..7921627 100644
415c675
--- a/test/test_git.py
415c675
+++ b/test/test_git.py
415c675
@@ -43,6 +43,7 @@
415c675
 import threading
415c675
 import time
415c675
 
415c675
+from distutils.version import LooseVersion
415c675
 from vcstools import GitClient
415c675
 from vcstools.vcs_base import VcsError
415c675
 
415c675
@@ -236,9 +237,13 @@ def test_checkout_shallow(self):
415c675
         self.assertEqual(client.get_branch(), "master")
415c675
         self.assertEqual(client.get_branch_parent(), "master")
415c675
         po = subprocess.Popen("git log --pretty=format:%H", shell=True, cwd=self.local_path, stdout=subprocess.PIPE)
415c675
-        log = po.stdout.read().decode('UTF-8').splitlines()
415c675
-        # shallow only contains last 2 commits
415c675
-        self.assertEqual(2, len(log), log)
415c675
+        log = po.stdout.read().decode('UTF-8').strip().splitlines()
415c675
+        if LooseVersion(client.gitversion) >= LooseVersion('1.8.2'):
415c675
+            # shallow only contains last commit
415c675
+            self.assertEqual(1, len(log), log)
415c675
+        else:
415c675
+            # shallow only contains last 2 commits
415c675
+            self.assertEqual(2, len(log), log)
415c675
 
415c675
     def test_checkout_specific_version_and_update(self):
415c675
         url = self.remote_path
415c675
From c3176b498266bbb06553f67896e342c2ce62ea73 Mon Sep 17 00:00:00 2001
415c675
From: Scott K Logan <logans@cottsay.net>
415c675
Date: Sun, 14 Dec 2014 04:23:40 -0800
415c675
Subject: [PATCH] Fix race condition in testing
415c675
415c675
If the git timeout test is run on a machine which can run many threads,
415c675
the TCP server finishes the call to `handle` and resets the connection
415c675
before the timeout has occurred, and the test fails.
415c675
---
415c675
 test/test_git.py | 4 +++-
415c675
 1 file changed, 3 insertions(+), 1 deletion(-)
415c675
415c675
diff --git a/test/test_git.py b/test/test_git.py
415c675
index 7921627..d577278 100644
415c675
--- a/test/test_git.py
415c675
+++ b/test/test_git.py
415c675
@@ -774,7 +774,9 @@ class GitTimeoutTest(unittest.TestCase):
415c675
 
415c675
     class MuteHandler(BaseRequestHandler):
415c675
         def handle(self):
415c675
-            self.request.recv(1024)
415c675
+            data = True
415c675
+            while data:
415c675
+                data = self.request.recv(1024)
415c675
 
415c675
     @classmethod
415c675
     def setUpClass(self):