summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--morphlib/artifactresolver_tests.py37
-rw-r--r--morphlib/buildsystem.py6
-rw-r--r--morphlib/cachekeycomputer_tests.py10
-rw-r--r--morphlib/morphloader_tests.py4
-rw-r--r--morphlib/morphologyfactory_tests.py38
-rw-r--r--morphlib/morphset_tests.py27
-rw-r--r--morphlib/plugins/branch_and_merge_new_plugin.py8
7 files changed, 52 insertions, 78 deletions
diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py
index 6f62b4d1..a679726e 100644
--- a/morphlib/artifactresolver_tests.py
+++ b/morphlib/artifactresolver_tests.py
@@ -171,7 +171,7 @@ class ArtifactResolverTests(unittest.TestCase):
pool.add(chunk)
morph = FakeStratumMorphology(
- 'stratum', chunks=[('chunk', 'chunk', 'repo', 'ref')])
+ 'stratum', chunks=[('chunk', 'chunk.morph', 'repo', 'ref')])
stratum = morphlib.source.Source(
'repo', 'ref', 'sha1', 'tree', morph, 'stratum.morph')
pool.add(stratum)
@@ -207,7 +207,7 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeStratumMorphology(
'stratum',
chunks=[
- ('chunk', 'chunk', 'repo', 'ref'),
+ ('chunk', 'chunk.morph', 'repo', 'ref'),
])
stratum = morphlib.source.Source(
'repo', 'ref', 'sha1', 'tree', morph, 'stratum.morph')
@@ -243,7 +243,8 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeStratumMorphology(
'stratum1',
- chunks=[('chunk1', 'chunk1', 'repo', 'original/ref')])
+ chunks=[
+ ('chunk1', 'chunk1.morph', 'repo', 'original/ref')])
stratum1 = morphlib.source.Source(
'repo', 'ref', 'sha1', 'tree', morph, 'stratum1.morph')
pool.add(stratum1)
@@ -257,12 +258,12 @@ class ArtifactResolverTests(unittest.TestCase):
{
"repo": "repo",
"ref": "ref",
- "morph": "stratum1"
+ "morph": "stratum1.morph"
},
{
"repo": "repo",
"ref": "ref",
- "morph": "stratum2"
+ "morph": "stratum2.morph"
}
]
}
@@ -279,8 +280,8 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeStratumMorphology(
'stratum2',
- chunks=[('chunk2', 'chunk2', 'repo', 'original/ref')],
- build_depends=[('stratum1', 'repo', 'ref')])
+ chunks=[('chunk2', 'chunk2.morph', 'repo', 'original/ref')],
+ build_depends=[('stratum1.morph', 'repo', 'ref')])
stratum2 = morphlib.source.Source(
'repo', 'ref', 'sha1', 'tree', morph, 'stratum2.morph')
pool.add(stratum2)
@@ -344,24 +345,24 @@ class ArtifactResolverTests(unittest.TestCase):
"kind": "stratum",
"chunks": [
{
- "name": "chunk1",
+ "name": "chunk1.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": []
},
{
- "name": "chunk2",
+ "name": "chunk2.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": []
},
{
- "name": "chunk3",
+ "name": "chunk3.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": [
- "chunk1",
- "chunk2"
+ "chunk1.morph",
+ "chunk2.morph"
]
}
]
@@ -423,7 +424,7 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeStratumMorphology(
'stratum1',
chunks=[],
- build_depends=[('stratum2', 'repo', 'original/ref')])
+ build_depends=[('stratum2.morph', 'repo', 'original/ref')])
stratum1 = morphlib.source.Source(
'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum1.morph')
pool.add(stratum1)
@@ -431,7 +432,7 @@ class ArtifactResolverTests(unittest.TestCase):
morph = FakeStratumMorphology(
'stratum2',
chunks=[],
- build_depends=[('stratum1', 'repo', 'original/ref')])
+ build_depends=[('stratum1.morph', 'repo', 'original/ref')])
stratum2 = morphlib.source.Source(
'repo', 'original/ref', 'sha1', 'tree', morph, 'stratum2.morph')
pool.add(stratum2)
@@ -449,15 +450,15 @@ class ArtifactResolverTests(unittest.TestCase):
"kind": "stratum",
"chunks": [
{
- "name": "chunk1",
+ "name": "chunk1.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": [
- "chunk2"
+ "chunk2.morph"
]
},
{
- "name": "chunk2",
+ "name": "chunk2.morph",
"repo": "repo",
"ref": "original/ref"
}
@@ -492,7 +493,7 @@ class ArtifactResolverTests(unittest.TestCase):
"kind": "stratum",
"chunks": [
{
- "name": "chunk",
+ "name": "chunk.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": "whatever"
diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py
index 1a330568..40188056 100644
--- a/morphlib/buildsystem.py
+++ b/morphlib/buildsystem.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2012-2013 Codethink Limited
+# Copyright (C) 2012-2014 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -15,6 +15,7 @@
import os
+import yaml
class BuildSystem(object):
@@ -52,6 +53,9 @@ class BuildSystem(object):
def get_morphology_text(self, name):
'''Return the text of an autodetected chunk morphology.'''
+ return yaml.dump({'name': name,
+ 'kind': 'chunk',
+ 'build-system': self.name}, default_flow_style=False)
return '''
name: %(name)s
kind: chunk
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py
index dd10307f..2b963142 100644
--- a/morphlib/cachekeycomputer_tests.py
+++ b/morphlib/cachekeycomputer_tests.py
@@ -51,7 +51,7 @@ class CacheKeyComputerTests(unittest.TestCase):
"kind": "stratum",
"chunks": [
{
- "name": "chunk",
+ "name": "chunk.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": []
@@ -63,13 +63,13 @@ class CacheKeyComputerTests(unittest.TestCase):
"kind": "stratum",
"chunks": [
{
- "name": "chunk2",
+ "name": "chunk2.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": []
},
{
- "name": "chunk3",
+ "name": "chunk3.morph",
"repo": "repo",
"ref": "original/ref",
"build-depends": []
@@ -81,12 +81,12 @@ class CacheKeyComputerTests(unittest.TestCase):
"kind": "system",
"strata": [
{
- "morph": "stratum",
+ "morph": "stratum.morph",
"repo": "repo",
"ref": "original/ref"
},
{
- "morph": "stratum2",
+ "morph": "stratum2.morph",
"repo": "repo",
"ref": "original/ref"
}
diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py
index a050e10b..b9530fa2 100644
--- a/morphlib/morphloader_tests.py
+++ b/morphlib/morphloader_tests.py
@@ -551,6 +551,10 @@ build-system: dummy
'name': 'foo',
'description': '',
'build-system': 'manual',
+ 'repo': '',
+ 'ref': '',
+ 'unpetrify-ref': '',
+ 'comments': '',
'configure-commands': [],
'pre-configure-commands': [],
diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py
index 39092857..e72f512d 100644
--- a/morphlib/morphologyfactory_tests.py
+++ b/morphlib/morphologyfactory_tests.py
@@ -219,50 +219,12 @@ class MorphologyFactoryTests(unittest.TestCase):
'remote-chunk.morph')
self.assertEqual('remote-chunk', morph['name'])
- 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')
- 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'])
-
- def test_raises_error_when_fails_detect_locally(self):
- self.lr.cat = self.nolocalfile
- self.assertRaises(AutodetectError, self.mf.get_morphology,
- 'reponame', 'sha1', 'unreached.morph')
-
- def test_raises_error_when_fails_detect_remotely(self):
- self.lrc.has_repo = self.doesnothaverepo
- self.rrc.cat_file = self.noremotefile
-# self.mf.get_morphology('reponame', 'sha1', 'unreached.morph')
- self.assertRaises(AutodetectError, self.mf.get_morphology,
- 'reponame', 'sha1', 'unreached.morph')
-
- def test_raises_error_when_name_mismatches(self):
- self.assertRaises(morphlib.Error, self.mf.get_morphology,
- 'reponame', 'sha1', 'name-mismatch.morph')
-
def test_looks_locally_with_no_remote(self):
self.lr.ls_tree = self.localmorph
morph = self.lmf.get_morphology('reponame', 'sha1',
'chunk.morph')
self.assertEqual('chunk', morph['name'])
- def test_autodetects_locally_with_no_remote(self):
- self.lr.cat = self.nolocalmorph
- self.lr.ls_tree = self.autotoolsbuildsystem
- morph = self.mf.get_morphology('reponame', 'sha1',
- 'assumed-local.morph')
- self.assertEqual('assumed-local', morph['name'])
-
def test_fails_when_local_not_cached_and_no_remote(self):
self.lrc.has_repo = self.doesnothaverepo
self.assertRaises(NotcachedError, self.lmf.get_morphology,
diff --git a/morphlib/morphset_tests.py b/morphlib/morphset_tests.py
index d6908844..429003ea 100644
--- a/morphlib/morphset_tests.py
+++ b/morphlib/morphset_tests.py
@@ -33,7 +33,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:morphs',
'ref': 'master',
- 'morph': 'foo-stratum',
+ 'morph': 'foo-stratum.morph',
},
],
})
@@ -48,7 +48,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:foo-chunk',
'ref': 'master',
- 'morph': 'foo-chunk',
+ 'morph': 'foo-chunk.morph',
},
],
'build-depends': [],
@@ -85,7 +85,7 @@ class MorphologySetTests(unittest.TestCase):
self.morphs.add_morphology(self.stratum)
self.assertEqual(
self.morphs.get_stratum_in_system(
- self.system, self.stratum['name']),
+ self.system, self.stratum.filename),
self.stratum)
def test_raises_stratum_not_in_system_error(self):
@@ -99,14 +99,15 @@ class MorphologySetTests(unittest.TestCase):
self.morphs.add_morphology(self.system)
self.assertRaises(
morphlib.morphset.StratumNotInSetError,
- self.morphs.get_stratum_in_system, self.system, 'foo-stratum')
+ self.morphs.get_stratum_in_system,
+ self.system, 'foo-stratum.morph')
def test_get_chunk_triplet(self):
self.morphs.add_morphology(self.system)
self.morphs.add_morphology(self.stratum)
self.assertEqual(
- self.morphs.get_chunk_triplet(self.stratum, 'foo-chunk'),
- ('test:foo-chunk', 'master', 'foo-chunk'))
+ self.morphs.get_chunk_triplet(self.stratum, 'foo-chunk.morph'),
+ ('test:foo-chunk', 'master', 'foo-chunk.morph'))
def test_raises_chunk_not_in_stratum_error(self):
self.assertRaises(
@@ -127,7 +128,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:morphs',
'ref': 'new-ref',
- 'morph': 'foo-stratum',
+ 'morph': 'foo-stratum.morph',
'unpetrify-ref': 'master',
})
@@ -140,7 +141,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': self.stratum.repo_url,
'ref': self.stratum.ref,
- 'morph': self.stratum['name'],
+ 'morph': self.stratum.filename,
'unpetrify-ref': 'master',
},
]
@@ -162,7 +163,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:morphs',
'ref': 'new-ref',
- 'morph': 'foo-stratum',
+ 'morph': 'foo-stratum.morph',
'unpetrify-ref': 'master',
})
@@ -180,7 +181,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:foo-chunk',
'ref': 'new-ref',
- 'morph': 'foo-chunk',
+ 'morph': 'foo-chunk.morph',
'unpetrify-ref': 'master',
}
])
@@ -199,7 +200,7 @@ class MorphologySetTests(unittest.TestCase):
self.assertEqual(self.system['strata'],
[
{
- 'morph': 'foo-stratum',
+ 'morph': 'foo-stratum.morph',
'ref': 'test',
'repo': 'test:morphs',
'unpetrify-ref': 'master',
@@ -217,7 +218,7 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:foo-chunk',
'ref': '0'*40,
- 'morph': 'foo-chunk',
+ 'morph': 'foo-chunk.morph',
'unpetrify-ref': 'master',
}
])
@@ -233,6 +234,6 @@ class MorphologySetTests(unittest.TestCase):
{
'repo': 'test:foo-chunk',
'ref': 'master',
- 'morph': 'foo-chunk',
+ 'morph': 'foo-chunk.morph',
}
])
diff --git a/morphlib/plugins/branch_and_merge_new_plugin.py b/morphlib/plugins/branch_and_merge_new_plugin.py
index 03467fd4..1205fbc1 100644
--- a/morphlib/plugins/branch_and_merge_new_plugin.py
+++ b/morphlib/plugins/branch_and_merge_new_plugin.py
@@ -375,7 +375,8 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
For example:
- morph edit systems/devel-system-x86-64-generic.morph strata/devel.morph
+ morph edit systems/devel-system-x86-64-generic.morph \
+ strata/devel.morph
The above command will mark the `devel` stratum as being
modified in the current system branch. In this case, the stratum's
@@ -400,7 +401,8 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
Another example:
- morph edit systems/devel-system-x86_64-generic.morph strata/devel.morph chunks/gcc.morph
+ morph edit systems/devel-system-x86_64-generic.morph \
+ strata/devel.morph chunks/gcc.morph
The above command will mark the `gcc` chunk as being edited in
the current system branch. Morph will clone the `gcc` repository
@@ -465,7 +467,7 @@ class SimpleBranchAndMergePlugin(cliapp.Plugin):
# relevant git branch checked out. This also invents the new branch
# name.
- if chunk_name:
+ if chunk_filename:
logging.debug('Editing chunk %s' % chunk_filename)
chunk_url, chunk_ref, chunk_morph = morphs.get_chunk_triplet(