diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 17:58:42 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-08-24 17:58:42 +0100 |
commit | 98b802e36b2a291b39dbdb83b55546b1acae1573 (patch) | |
tree | a6579f891f29f15a7b8b7c94ea3847cc66ad5428 /morphlib/morphologyfactory_tests.py | |
parent | 975b3f30605c36a714bf5b9619817a897cb6a4a3 (diff) | |
download | morph-98b802e36b2a291b39dbdb83b55546b1acae1573.tar.gz |
Use git ls-tree to autodetect build system
The cost of one git ls-tree call is roughly the same as one
git cat-file call. Therefore, when autodetecting the build system,
it is much faster to list the tree once and then search for the
required files than to call git cat-file for every possible one.
Diffstat (limited to 'morphlib/morphologyfactory_tests.py')
-rw-r--r-- | morphlib/morphologyfactory_tests.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 39331262..9d6900d7 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -35,6 +35,8 @@ class FakeRemoteRepoCache(object): }''' return 'text' + def ls_tree(self, reponame, sha1): + return [] class FakeLocalRepo(object): @@ -87,6 +89,8 @@ class FakeLocalRepo(object): }''' return 'text' + def ls_tree(self, sha1): + return [] class FakeLocalRepoCache(object): @@ -120,6 +124,9 @@ class MorphologyFactoryTests(unittest.TestCase): raise IOError('File not found') return 'text' + def autotoolsbuildsystem(self, *args): + return ['configure.in'] + def noremotemorph(self, *args): if args[-1].endswith('.morph'): raise CatFileError('reponame', 'ref', 'filename') @@ -141,13 +148,15 @@ class MorphologyFactoryTests(unittest.TestCase): def test_autodetects_local_morphology(self): self.lr.cat = self.nolocalmorph + self.lr.ls_tree = self.autotoolsbuildsystem morph = self.mf.get_morphology('reponame', 'sha1', - 'assumed-local.morph') + 'assumed-local.morph') self.assertEqual('assumed-local', morph['name']) def test_autodetects_remote_morphology(self): self.lrc.has_repo = self.doesnothaverepo self.rrc.cat_file = self.noremotemorph + self.rrc.ls_tree = self.autotoolsbuildsystem morph = self.mf.get_morphology('reponame', 'sha1', 'assumed-remote.morph') self.assertEqual('assumed-remote', morph['name']) @@ -171,7 +180,8 @@ class MorphologyFactoryTests(unittest.TestCase): def test_autodetects_locally_with_no_remote(self): self.lr.cat = self.nolocalmorph - morph = self.lmf.get_morphology('reponame', 'sha1', + self.lr.ls_tree = self.autotoolsbuildsystem + morph = self.mf.get_morphology('reponame', 'sha1', 'assumed-local.morph') self.assertEqual('assumed-local', morph['name']) |