diff options
author | Sebastian Thiel <byronimo@gmail.com> | 2015-01-03 20:25:01 +0100 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2015-01-03 20:31:18 +0100 |
commit | f2840c626d2eb712055ccb5dcbad25d040f17ce1 (patch) | |
tree | 15b771106a507fe284ab610bf0d141fa9255f4f2 | |
parent | 342a0276dbf11366ae91ce28dcceddc332c97eaf (diff) | |
download | gitpython-f2840c626d2eb712055ccb5dcbad25d040f17ce1.tar.gz |
Auto-skip performance tests more quietly on travis
... and be able to run performance tests independently of the chosen performance test repo
Now all tests run fine locally
-rw-r--r-- | .travis.yml | 7 | ||||
-rw-r--r-- | git/test/lib/helper.py | 3 | ||||
-rw-r--r-- | git/test/performance/lib.py | 10 | ||||
-rw-r--r-- | git/test/performance/test_commit.py | 13 | ||||
-rw-r--r-- | git/test/performance/test_odb.py | 4 | ||||
-rw-r--r-- | git/test/performance/test_streams.py | 2 | ||||
-rw-r--r-- | git/test/performance/test_utils.py | 7 |
7 files changed, 21 insertions, 25 deletions
diff --git a/.travis.yml b/.travis.yml index 92842941..7a21ad94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,10 @@ install: - git submodule update --init --recursive - git fetch --tags - pip install coveralls + # for now we have to make sure there is a master branch - at some point we should just have it by default - git branch master 0.3 + # generate some reflog as git-python tests need it - git reset --hard HEAD~1 - git reset --hard HEAD~1 @@ -21,8 +23,13 @@ install: - git checkout master - git reset --hard HEAD~1 - git reset --hard HEAD~1 + - git reset --hard HEAD~1 - git reset --hard origin/0.3 - git checkout 0.3 + + # as commits are performed with the default user, it needs to be set for travis too + - git config --global user.email "travis@ci.com" + - git config --global user.name "Travis Runner" script: - nosetests -v --with-coverage after_success: diff --git a/git/test/lib/helper.py b/git/test/lib/helper.py index 40e34fe0..df94abde 100644 --- a/git/test/lib/helper.py +++ b/git/test/lib/helper.py @@ -8,6 +8,7 @@ import os import sys from git import Repo, Remote, GitCommandError, Git from unittest import TestCase +import time import tempfile import shutil import cStringIO @@ -191,6 +192,8 @@ def with_rw_and_rw_remote_repo(working_tree_ref): # On windows, this will fail ... we deal with failures anyway and default to telling the user to do it try: gd = Git().daemon(temp_dir, as_process=True) + # yes, I know ... fortunately, this is always going to work if sleep time is just large enough + time.sleep(0.5) except Exception as err: gd = None # end diff --git a/git/test/performance/lib.py b/git/test/performance/lib.py index 985e3637..9b6f45bf 100644 --- a/git/test/performance/lib.py +++ b/git/test/performance/lib.py @@ -1,6 +1,7 @@ """Contains library functions""" import os from git.test.lib import * +from gitdb.test.lib import skip_on_travis_ci import shutil import tempfile import logging @@ -36,11 +37,11 @@ class TestBigRepoR(TestBase): """ #{ Invariants - head_sha_2k = '235d521da60e4699e5bd59ac658b5b48bd76ddca' - head_sha_50 = '32347c375250fd470973a5d76185cac718955fd5' #} END invariants def setUp(self): + # This will raise on travis, which is what we want to happen early as to prevent us to do any work + skip_on_travis_ci(lambda *args: None)(self) try: super(TestBigRepoR, self).setUp() except AttributeError: @@ -54,7 +55,6 @@ class TestBigRepoR(TestBase): self.gitrorepo = Repo(repo_path, odbt=GitCmdObjectDB) self.puregitrorepo = Repo(repo_path, odbt=GitDB) - class TestBigRepoRW(TestBigRepoR): """As above, but provides a big repository that we can write to. @@ -62,6 +62,7 @@ class TestBigRepoRW(TestBigRepoR): Provides ``self.gitrwrepo`` and ``self.puregitrwrepo``""" def setUp(self): + self.gitrwrepo = None try: super(TestBigRepoRW, self).setUp() except AttributeError: @@ -72,6 +73,7 @@ class TestBigRepoRW(TestBigRepoR): self.puregitrwrepo = Repo(dirname, odbt=GitDB) def tearDown(self): - shutil.rmtree(self.gitrwrepo.working_dir) + if self.gitrwrepo is not None: + shutil.rmtree(self.gitrwrepo.working_dir) #} END base classes diff --git a/git/test/performance/test_commit.py b/git/test/performance/test_commit.py index a8f63f95..c256a75c 100644 --- a/git/test/performance/test_commit.py +++ b/git/test/performance/test_commit.py @@ -8,7 +8,6 @@ from lib import * from git import * from gitdb import IStream from git.test.test_commit import assert_commit_serialization -from gitdb.test.lib import skip_on_travis_ci from cStringIO import StringIO from time import time import sys @@ -29,7 +28,6 @@ class TestPerformance(TestBigRepoRW): c.message c.parents - @skip_on_travis_ci def test_iteration(self): no = 0 nc = 0 @@ -51,39 +49,36 @@ class TestPerformance(TestBigRepoRW): print >> sys.stderr, "Traversed %i Trees and a total of %i unchached objects in %s [s] ( %f objs/s )" % ( nc, no, elapsed_time, no / elapsed_time) - @skip_on_travis_ci def test_commit_traversal(self): # bound to cat-file parsing performance nc = 0 st = time() - for c in self.gitrorepo.commit(self.head_sha_2k).traverse(branch_first=False): + for c in self.gitrorepo.commit().traverse(branch_first=False): nc += 1 self._query_commit_info(c) # END for each traversed commit elapsed_time = time() - st print >> sys.stderr, "Traversed %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time) - @skip_on_travis_ci def test_commit_iteration(self): # bound to stream parsing performance nc = 0 st = time() - for c in Commit.iter_items(self.gitrorepo, self.head_sha_2k): + for c in Commit.iter_items(self.gitrorepo, self.gitrorepo.head): nc += 1 self._query_commit_info(c) # END for each traversed commit elapsed_time = time() - st print >> sys.stderr, "Iterated %i Commits in %s [s] ( %f commits/s )" % (nc, elapsed_time, nc / elapsed_time) - @skip_on_travis_ci def test_commit_serialization(self): - assert_commit_serialization(self.gitrwrepo, self.head_sha_2k, True) + assert_commit_serialization(self.gitrwrepo, self.gitrwrepo.head, True) rwrepo = self.gitrwrepo make_object = rwrepo.odb.store # direct serialization - deserialization can be tested afterwards # serialization is probably limited on IO - hc = rwrepo.commit(self.head_sha_2k) + hc = rwrepo.commit(rwrepo.head) nc = 5000 st = time() diff --git a/git/test/performance/test_odb.py b/git/test/performance/test_odb.py index 1c4bd9ed..9d857260 100644 --- a/git/test/performance/test_odb.py +++ b/git/test/performance/test_odb.py @@ -2,7 +2,6 @@ from time import time import sys -from gitdb.test.lib import skip_on_travis_ci from lib import ( TestBigRepoR @@ -11,13 +10,12 @@ from lib import ( class TestObjDBPerformance(TestBigRepoR): - @skip_on_travis_ci def test_random_access(self): results = [["Iterate Commits"], ["Iterate Blobs"], ["Retrieve Blob Data"]] for repo in (self.gitrorepo, self.puregitrorepo): # GET COMMITS st = time() - root_commit = repo.commit(self.head_sha_2k) + root_commit = repo.commit(repo.head) commits = list(root_commit.traverse()) nc = len(commits) elapsed = time() - st diff --git a/git/test/performance/test_streams.py b/git/test/performance/test_streams.py index a2bca94c..facf9eed 100644 --- a/git/test/performance/test_streams.py +++ b/git/test/performance/test_streams.py @@ -3,7 +3,6 @@ from git.test.lib import * from gitdb import * from gitdb.util import bin_to_hex -from gitdb.test.lib import skip_on_travis_ci from time import time import os @@ -22,7 +21,6 @@ class TestObjDBPerformance(TestBigRepoR): large_data_size_bytes = 1000 * 1000 * 10 # some MiB should do it moderate_data_size_bytes = 1000 * 1000 * 1 # just 1 MiB - @skip_on_travis_ci @with_rw_repo('HEAD', bare=True) def test_large_data_streaming(self, rwrepo): # TODO: This part overlaps with the same file in gitdb.test.performance.test_stream diff --git a/git/test/performance/test_utils.py b/git/test/performance/test_utils.py index b0d6fa48..e7c33aa2 100644 --- a/git/test/performance/test_utils.py +++ b/git/test/performance/test_utils.py @@ -2,8 +2,6 @@ from time import time import sys -from gitdb.test.lib import skip_on_travis_ci - from lib import ( TestBigRepoR ) @@ -11,7 +9,6 @@ from lib import ( class TestUtilPerformance(TestBigRepoR): - @skip_on_travis_ci def test_access(self): # compare dict vs. slot access class Slotty(object): @@ -66,7 +63,6 @@ class TestUtilPerformance(TestBigRepoR): cls.__name__, na, elapsed, na / elapsed) # END for each sequence - @skip_on_travis_ci def test_instantiation(self): ni = 100000 max_num_items = 4 @@ -109,7 +105,6 @@ class TestUtilPerformance(TestBigRepoR): elapsed = time() - st print >> sys.stderr, "Created %i tuples tuple((1,2,3,4)) in %f s ( %f tuples / s)" % (ni, elapsed, ni / elapsed) - @skip_on_travis_ci def test_unpacking_vs_indexing(self): ni = 1000000 list_items = [1, 2, 3, 4] @@ -141,7 +136,6 @@ class TestUtilPerformance(TestBigRepoR): ni, type(sequence).__name__, len(sequence), elapsed, ni / elapsed) # END for each sequence - @skip_on_travis_ci def test_large_list_vs_iteration(self): # what costs more: alloc/realloc of lists, or the cpu strain of iterators ? def slow_iter(ni): @@ -166,7 +160,6 @@ class TestUtilPerformance(TestBigRepoR): print >> sys.stderr, "Iterated %i items from iterator in %f s ( %f acc / s)" % (ni, elapsed, ni / elapsed) # END for each number of iterations - @skip_on_travis_ci def test_type_vs_inst_class(self): class NewType(object): pass |