Skip to content

Commit ffefb15

Browse files
committed
Improved performance of rev-parse test.
Hoping to make this significantly faster on travis. Related to #245
1 parent 66c5b33 commit ffefb15

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

Diff for: git/test/test_repo.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
from git.util import join_path_native
3535
from git.exc import BadObject
3636
from gitdb.util import bin_to_hex
37-
from git.compat import string_types
37+
from git.compat import (
38+
string_types,
39+
# PY3
40+
)
3841
from gitdb.test.lib import with_rw_directory
3942

4043
import os
@@ -555,7 +558,7 @@ def test_rev_parse(self):
555558
# start from reference
556559
num_resolved = 0
557560

558-
for ref in Reference.iter_items(self.rorepo):
561+
for ref_no, ref in enumerate(Reference.iter_items(self.rorepo)):
559562
path_tokens = ref.path.split("/")
560563
for pt in range(len(path_tokens)):
561564
path_section = '/'.join(path_tokens[-(pt + 1):])
@@ -569,6 +572,8 @@ def test_rev_parse(self):
569572
pass
570573
# END exception handling
571574
# END for each token
575+
if ref_no == 3 - 1:
576+
break
572577
# END for each reference
573578
assert num_resolved
574579

@@ -610,6 +615,7 @@ def test_rev_parse(self):
610615
# END handle multiple tokens
611616

612617
# try partial parsing
618+
# if not (PY3 and 'TRAVIS' in os.environ):
613619
max_items = 40
614620
for i, binsha in enumerate(self.rorepo.odb.sha_iter()):
615621
assert rev_parse(bin_to_hex(binsha)[:8 - (i % 2)].decode('ascii')).binsha == binsha
@@ -618,6 +624,7 @@ def test_rev_parse(self):
618624
# which requires accessing packs, it has some additional overhead
619625
break
620626
# END for each binsha in repo
627+
# end travis special handling
621628

622629
# missing closing brace commit^{tree
623630
self.failUnlessRaises(ValueError, rev_parse, '0.1.4^{tree')

0 commit comments

Comments
 (0)