gump-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From leosim...@apache.org
Subject svn commit: r209850 - in /gump/branches/Gump3/pygump/python/gump: engine/modeller.py engine/objectifier.py model/__init__.py test/testEngineLoader.py test/testEngineModeller.py test/testEngineObjectifier.py
Date Fri, 08 Jul 2005 17:52:33 GMT
Author: leosimons
Date: Fri Jul  8 10:52:32 2005
New Revision: 209850

URL: http://svn.apache.org/viewcvs?rev=209850&view=rev
Log:
Fix a nasty bug with dependency management right within the model.

 * pygump/python/gump/model/__init__.py: Dependency up until now had an argument in __init__
that had a default value of []. That default value is created once, on subsequent invocations
of __init__, the same list would be used. This effectively meant that all dependencies shared
one global array of DependencyInfo, which of course is wrong, wrong, wrong.

Modified:
    gump/branches/Gump3/pygump/python/gump/engine/modeller.py
    gump/branches/Gump3/pygump/python/gump/engine/objectifier.py
    gump/branches/Gump3/pygump/python/gump/model/__init__.py
    gump/branches/Gump3/pygump/python/gump/test/testEngineLoader.py
    gump/branches/Gump3/pygump/python/gump/test/testEngineModeller.py
    gump/branches/Gump3/pygump/python/gump/test/testEngineObjectifier.py

Modified: gump/branches/Gump3/pygump/python/gump/engine/modeller.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/modeller.py?rev=209850&r1=209849&r2=209850&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/modeller.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/modeller.py Fri Jul  8 10:52:32 2005
@@ -14,7 +14,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-"""This module reads, merges and converts gump xml metadata."""
+"""This module has common support utilities for reading, merging and converting gump xml
metadata."""
 
 __copyright__ = "Copyright (c) 2004-2005 The Apache Software Foundation"
 __license__   = "http://www.apache.org/licenses/LICENSE-2.0"
@@ -34,11 +34,13 @@
 ###
 def _find_element_text(parent, element_name):
     """Retrieves the text contents of an element like <blah>text</blah>."""
-    elem = parent.getElementsByTagName(element_name).item(0).firstChild
-    if elem:
-        return elem.data
-    else:
-        return ""
+    item = parent.getElementsByTagName(element_name).item(0)
+    if not item: return None
+    
+    child = item.firstChild
+    if not child: return None
+
+    return child.data
 
 
 def _do_drop(to_remove, dropped_nodes=None):
@@ -143,13 +145,3 @@
             return True
         
         return False
-
-##
-## These at bottom to closely mimick old format of this file where they were
-## defined right here
-##
-#TODO remove these
-#from gump.engine.loader import Loader
-#from gump.engine.normalizer import Normalizer
-#from gump.engine.objectifier import Objectifier
-#from gump.engine.verifier import Verifier

Modified: gump/branches/Gump3/pygump/python/gump/engine/objectifier.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/engine/objectifier.py?rev=209850&r1=209849&r2=209850&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/engine/objectifier.py (original)
+++ gump/branches/Gump3/pygump/python/gump/engine/objectifier.py Fri Jul  8 10:52:32 2005
@@ -32,6 +32,8 @@
 from gump.engine import EngineError
 from gump.engine.modeller import _find_element_text
 
+DEFAULT_GUMP_LOCAL_REPOSITORY_NAME = "DEFAULT_GUMP_LOCAL_REPOSITORY"
+DEFAULT_GUMP_LOCAL_MODULE_NAME = "DEFAULT_GUMP_LOCAL_MODULE"
 ###
 ### Utility
 ###
@@ -41,14 +43,12 @@
     parent = element.getAttribute("parent")
     nested = element.getAttribute("nested")
     
-    path = None
     if parent:
-        path = os.path.join(get_module_directory(workdir, project.module), parent)
+        return os.path.join(get_module_directory(workdir, project.module), parent)
     elif nested:
-        path = os.path.join(get_project_directory(workdir, project), nested)
+        return os.path.join(get_project_directory(workdir, project), nested)
     else:
         raise Error, "Unknown relative path entry (no parent or nested): %s" % (element)
-    return path
 
 
 ###
@@ -62,55 +62,33 @@
     name = repository_definition.getAttribute("name")
     
     # parse the attributes and elements common to all repositories
-    title = None
-    try: title = _find_element_text(repository_definition, "title")
-    except: pass #TODO don't catch everything
-    
-    home_page = None
-    try: home_page = _find_element_text(repository_definition, "home-page")
-    except: pass #TODO don't catch everything
-    
-    cvsweb = None
-    try: cvsweb = _find_element_text(repository_definition, "cvsweb")
-    except:
-        try: cvsweb = _find_element_text(repository_definition, "web")
-        except: pass #TODO don't catch everything
-    
-    redistributable = False
-    if repository_definition.getElementsByTagName("redistributable").length > 0:
-        redistributable = True
+    title = _find_element_text(repository_definition, "title")
+    home_page = _find_element_text(repository_definition, "home-page")
+    cvsweb = _find_element_text(repository_definition, "cvsweb")
+    if cvsweb == None:
+        cvsweb = _find_element_text(repository_definition, "web")
+    redistributable = repository_definition.getElementsByTagName("redistributable").length
> 0
         
     # now delegate to _create methods for specific repositories to do the rest
-    repository = None
     type = repository_definition.getAttribute("type").upper()
     if type == "CVS":
-        repository = _create_cvs_repository(workspace, name, title, home_page, \
-                                            cvsweb, redistributable, repository_definition)
+        return _create_cvs_repository(workspace, name, title, home_page, \
+                                      cvsweb, redistributable, repository_definition)
     elif type == "SVN":
-        repository = _create_svn_repository(workspace, name, title, home_page, \
-                                            cvsweb, redistributable, repository_definition)
+        return _create_svn_repository(workspace, name, title, home_page, \
+                                      cvsweb, redistributable, repository_definition)
     else:
         raise EngineError, "Unknown repository type '%s' for repository '%s'" % (type, name)
     #TODO perforce support
-    
-    return repository
 
 
-def _create_cvs_repository(workspace, name, title, home_page, cvsweb, redistributable, repository_definition):
+def _create_cvs_repository(workspace, name, title, home_page, cvsweb, \
+                           redistributable, repository_definition):
     hostname = _find_element_text(repository_definition, "hostname")
     path = _find_element_text(repository_definition, "path")
-
-    method = CVS_METHOD_PSERVER
-    try: method = _find_element_text(repository_definition, "method")
-    except: pass
-    
-    user = None
-    try: user = _find_element_text(repository_definition, "user")
-    except: pass
-
-    password = None
-    try: password = _find_element_text(repository_definition, "password")
-    except: pass
+    method = _find_element_text(repository_definition, "method") or CVS_METHOD_PSERVER
+    user = _find_element_text(repository_definition, "user")
+    password = _find_element_text(repository_definition, "password")
     
     repository = CvsRepository(workspace,
                                name,
@@ -128,14 +106,8 @@
 
 def _create_svn_repository(workspace, name, title, home_page, cvsweb, redistributable, repository_definition):
     url = _find_element_text(repository_definition, "url")
-
-    user = None
-    try: user = _find_element_text(repository_definition, "user")
-    except: pass
-
-    password = None
-    try: password = _find_element_text(repository_definition, "password")
-    except: pass
+    user = _find_element_text(repository_definition, "user")
+    password = _find_element_text(repository_definition, "password")
     
     repository = SvnRepository(workspace,
                                name,
@@ -153,24 +125,20 @@
     name = module_definition.getAttribute("name")
     
     # parse the attributes and elements common to all modules
-    url = None
-    try: url = _find_element_text(module_definition, "url")
-    except: pass
-    
-    description = None
-    try: description = _find_element_text(module_definition, "description")
-    except: pass
+    url = _find_element_text(module_definition, "url")
+    description = _find_element_text(module_definition, "description")
     
     # now delegate to _create methods for specific modules to do the rest
-    module = None
     if isinstance(repository, CvsRepository):
-        module = _create_cvs_module(repository, name, url, description, module_definition)
+        return _create_cvs_module(repository, name, url, description, module_definition)
     elif isinstance(repository, SvnRepository):
-        module = _create_svn_module(repository, name, url, description, module_definition)
+        return _create_svn_module(repository, name, url, description, module_definition)
     elif isinstance(repository, LocalRepository):
-        module = _create_local_module(repository, name, url, description, module_definition)
+        return _create_local_module(repository, name, url, description, module_definition)
     else:
-        raise EngineError, "Unknown repository type '%s' referenced by module '%s'" % (repository.__class__,name)
+        raise EngineError, \
+              "Unknown repository type '%s' referenced by module '%s'" % \
+              (repository.__class__,name)
     #TODO perforce support
     return module
 
@@ -295,43 +263,37 @@
         ids=[]
     
     relationship = project.get_dependency_on_project(dependency_project)
-    relationship.add_dependency_info(DependencyInfo(relationship,optional,runtime,inherit,ids))
+    info = DependencyInfo(relationship,optional,runtime,inherit,ids)
+    relationship.add_dependency_info(info)
 
 ###
 ### Searching
 ###
-def _find_repository_definitions(root):
-    """Retrieves a list of <repository/> elements."""
+def _find_child_definitions(root, parent_element_name):
+    """Retrieves a list of elements that have a particular parent."""
     children = root.childNodes
 
-    for child in children:
-        if not child.nodeType == dom.Node.ELEMENT_NODE: continue
-        if child.tagName == "repositories":
+    for child in [c for c in children \
+            if c.nodeType == dom.Node.ELEMENT_NODE]:
+        if child.tagName == parent_element_name:
             return child.childNodes
         
-    raise EngineError, "No <repository/> found!"
+    raise EngineError, "No <%s/> found!" % parent_element_name
+    
+
+def _find_repository_definitions(root):
+    """Retrieves a list of <repository/> elements."""
+    return _find_child_definitions(root, "repositories")
 
 
 def _find_module_definitions(root):
     """Retrieve a list of <module/> elements."""
-    children = root.childNodes
-    for child in children:
-        if not child.nodeType == dom.Node.ELEMENT_NODE: continue
-        if child.tagName == "modules":
-            return child.childNodes
-    
-    raise EngineError, "No <module/> found!"
+    return _find_child_definitions(root, "modules")
 
 
 def _find_project_definitions(root):
     """Retrieve a list of <project/> elements."""
-    children = root.childNodes
-    for child in children:
-        if not child.nodeType == dom.Node.ELEMENT_NODE: continue
-        if child.tagName == "projects":
-            return child.childNodes
-
-    raise EngineError, "No <project/> found!"
+    return _find_child_definitions(root, "projects")
 
 
 ###
@@ -346,7 +308,6 @@
     def __str__(self):
         return "Dependency '%s' specified by '%s' cannot be found!" % (self.dependency_name,
self.project)
 
-DEFAULT_GUMP_LOCAL_REPOSITORY_NAME = "DEFAULT_GUMP_LOCAL_REPOSITORY"
 
 class Objectifier:
     """Turns a *normalized* gump DOM workspace into a pythonified workspace.
@@ -370,10 +331,9 @@
 
     def get_workspace(self, domtree):
         """Transforms a workspace xml document into object form."""
-        
         root = domtree.documentElement
-
         workspace = _create_workspace(root)
+
         self._create_repositories(workspace, _find_repository_definitions(root))
         self._create_modules(workspace, _find_module_definitions(root))
         self._create_projects(workspace, _find_project_definitions(root))
@@ -388,17 +348,16 @@
         repository = LocalRepository(workspace, DEFAULT_GUMP_LOCAL_REPOSITORY_NAME)
         workspace.repositories[repository.name] = repository
 
-        for repository_definition in repository_definitions:
-            if not repository_definition.nodeType == dom.Node.ELEMENT_NODE: continue
+        for repository_definition in [r for r in repository_definitions \
+                if r.nodeType == dom.Node.ELEMENT_NODE]:
             name = repository_definition.getAttribute("name")
             self.log.debug("Converting repository definition '%s' into object form." % name)
             try:
                 repository = _create_repository(workspace, repository_definition)
                 workspace.repositories[repository.name] = repository
             except:
-                # TODO: the name of the failing element and ideally the source xml file should
be
-                #       reported somewhere and e.g. e-mailed to the gump admins
-                self.log.exception("Failed to convert repository definition '%s' into object
form." % name)
+                self.log.exception(
+                    "Failed to convert repository definition '%s' into object form." % name)
     
     def _find_repository_for_module(self, workspace, module_definition):
         try:
@@ -413,8 +372,15 @@
             return workspace.repositories[DEFAULT_GUMP_LOCAL_REPOSITORY_NAME]
 
     def _create_modules(self, workspace, module_definitions):
-        for module_definition in module_definitions:
-            if not module_definition.nodeType == dom.Node.ELEMENT_NODE: continue
+        # Create a "default module" for projects that don't actually live in
+        # version control (aka installed packages)
+        repository = workspace.repositories[DEFAULT_GUMP_LOCAL_REPOSITORY_NAME]
+        module = LocalModule(repository, DEFAULT_GUMP_LOCAL_MODULE_NAME)
+        repository.add_module(module)
+        workspace.modules[module.name] = module
+
+        for module_definition in [m for m in module_definitions \
+                if m.nodeType == dom.Node.ELEMENT_NODE]:
             name = module_definition.getAttribute("name")
             self.log.debug("Converting module definition '%s' into object form." % name)
             try:
@@ -423,22 +389,30 @@
                 module.repository.modules[module.name] = module
                 workspace.modules[module.name] = module
             except:
-                # TODO: the name of the failing element and ideally the source xml file should
be
-                #       reported somewhere and e.g. e-mailed to the gump admins
                 self.log.exception("Failed to convert module definition '%s' into object
form." % name)
         
     def _find_module_for_project(self, workspace, project_definition):
-        name = project_definition.getAttribute("name")
-        module_name = project_definition.getElementsByTagName("module").item(0).getAttribute("name")
-        module = workspace.modules[module_name]
-        return module
+        try:
+            name = project_definition.getAttribute("name")
+            module_name = project_definition.getElementsByTagName("module").item(0).getAttribute("name")
+            module = workspace.modules[module_name]
+            return module
+        except:
+            # If we can't find a module, then we're dealing with an installed
+            # package
+            self.log.debug("It seems that the project '%s' is an installed package" % name)
+            return workspace.modules[DEFAULT_GUMP_LOCAL_MODULE_NAME]
 
     def _create_projects(self, workspace, project_definitions):
-        problems = []
+        project_definitions = [p for p in project_definitions \
+                if p.nodeType == dom.Node.ELEMENT_NODE]
         
         for project_definition in project_definitions:
-            if not project_definition.nodeType == dom.Node.ELEMENT_NODE: continue
             name = project_definition.getAttribute("name")
+            if not name:
+                self.log.error("Can't convert project definition because it does not have
a name!")
+                project_definitions.remove(project_definition)
+                continue
             self.log.debug("Converting project definition '%s' into object form." % name)
             try:
                 module = self._find_module_for_project(workspace, project_definition)
@@ -450,11 +424,10 @@
                 _create_outputs(project, project_definition, self.workdir)
             except:
                 self.log.exception("Failed to convert project definition '%s' into object
form." % name)
-                problems.append(name)
+                project_definitions.remove(project_definition)
 
         # wire up dependencies only after projects have been created
         for project_definition in project_definitions:
-            if not project_definition.nodeType == dom.Node.ELEMENT_NODE: continue
             try:
                 _create_dependencies(project_definition, workspace.projects)
             except:
@@ -464,6 +437,5 @@
                 cause = ExceptionInfo(type, value, traceback)
                 self.log.error(cause)
                 name = project_definition.getAttribute("name")
-                if name and not name in problems:
-                    project = workspace.projects[name]
-                    mark_failure(project, cause)
+                project = workspace.projects[name]
+                mark_failure(project, cause)

Modified: gump/branches/Gump3/pygump/python/gump/model/__init__.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/model/__init__.py?rev=209850&r1=209849&r2=209850&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/model/__init__.py (original)
+++ gump/branches/Gump3/pygump/python/gump/model/__init__.py Fri Jul  8 10:52:32 2005
@@ -350,12 +350,10 @@
         # Project A is a dependee of Project B
         self.module.repository.workspace.dependencies.append(relationship)
         self.dependencies.append(relationship)
-        #print "%s is told %s depends on %s" % (self.name, self.name, relationship.dependency.name)
         
         # register Project A as a dependee of Project B
         # relationship.dependency is Project B
         # relationship.dependency.add_dependee() registers A with B
-        #print "%s is telling %s that %s depends on %s" % (self.name, relationship.dependency.name,
self.name, relationship.dependency.name)
         if isinstance(relationship.dependency, Project): # might be a string for a bad
                                                             # dependency
             relationship.dependency.add_dependee(relationship)
@@ -377,7 +375,6 @@
         return new_relationship
     
     def add_dependee(self, relationship):
-        #print "%s is told that %s is a dependee of %s" % (self.name, relationship.dependee.name,
self.name)
         self.dependees.append(relationship)
     
     def add_command(self, command):
@@ -417,15 +414,13 @@
     """
     def __init__(self,
                  dependency,
-                 dependee,
-                 dependencyInfo = []):
+                 dependee):
         assert isinstance(dependency, Project)
         assert isinstance(dependee, Project)
-        for info in dependencyInfo:
-            assert isinstance(info, DependencyInfo)
+
         self.dependency         = dependency
         self.dependee           = dependee
-        self.dependencyInfo     = dependencyInfo
+        self.dependencyInfo     = []
     
     def add_dependency_info(self, info):
         assert isinstance(info, DependencyInfo)

Modified: gump/branches/Gump3/pygump/python/gump/test/testEngineLoader.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testEngineLoader.py?rev=209850&r1=209849&r2=209850&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testEngineLoader.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testEngineLoader.py Fri Jul  8 10:52:32 2005
@@ -22,12 +22,63 @@
 import unittest
 from pmock import *
 
-from gump.engine.loader import *
+from xml.dom import minidom
+import StringIO
+
+from gump.engine.loader import Loader
+from gump.engine import EngineError
 
 class EngineLoaderTestCase(MockTestCase):
     def setUp(self):
-        pass
+        self.sampleworkspacestring = """<?xml version="1.0"?>
+
+<workspace>
+  <newelem attr="yo">contents</newelem>
+  <module name="foo">
+    <project name="bar">
+      <blah/>
+    </project>
+  </module>
+  <newelem>ignore</newelem>
+</workspace>
+"""
+        self.sampleworkspace = minidom.parseString(self.sampleworkspacestring)
+   
+    def test_loader_init(self):
+        log = MockLog()
+        vfs = MockVFS()
+        
+        loader = Loader(log,vfs)
+        loader = Loader(log,None)
+        
+        self.assertRaises(AssertionError, Loader, self, vfs)
+        self.assertRaises(AssertionError, Loader, log, self)
+        self.assertRaises(AssertionError, Loader, None, vfs)
     
-    def test_something(self):
-        # TODO replace with something useful
-        pass
+    def test_loader_get_workspace_tree_simple(self):
+        log = MockLog()
+        vfs = MockVFS()
+        loader = Loader(log,vfs)
+        
+        (wsdom, dropped_nodes) = loader.get_workspace_tree(StringIO.StringIO(self.sampleworkspacestring))
+        # TODO check wsdom content validity
+        self.assertEqual(0, len(dropped_nodes))
+        self.assertEqual(type(self.sampleworkspace), type(wsdom))
+        self.assertEqual(None, log.msg)
+        self.assertEqual(None, vfs.href)
+    
+    # TODO test loader href resolution
+    # TODO test loader looping href resolution
+    # TODO test loader href resolution failure
+    # TODO test loader vfs exception
+        
+class MockLog:
+    msg = None
+    def warning(self,msg):
+        self.msg = msg
+
+class MockVFS:
+    href = None
+    def get_as_stream(href):
+        self.href = href
+        return StringIO.StringIO()

Modified: gump/branches/Gump3/pygump/python/gump/test/testEngineModeller.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testEngineModeller.py?rev=209850&r1=209849&r2=209850&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testEngineModeller.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testEngineModeller.py Fri Jul  8 10:52:32
2005
@@ -105,7 +105,7 @@
         text = _find_element_text(root, "elem")
         self.assertEqual("contents", text)
         text = _find_element_text(root, "blah")
-        self.assertEqual("", text)
+        self.assertEqual(None, text)
         try:
             _find_element_text(root, "notthere")
         except:
@@ -179,42 +179,4 @@
     def test_engine_error(self):
         error = EngineError()
         self.assert_(isinstance(error, Exception))
-    
-    def test_loader_init(self):
-        log = MockLog()
-        vfs = MockVFS()
-        
-        loader = Loader(log,vfs)
-        loader = Loader(log,None)
-        
-        self.assertRaises(AssertionError, Loader, self, vfs)
-        self.assertRaises(AssertionError, Loader, log, self)
-        self.assertRaises(AssertionError, Loader, None, vfs)
-    
-    def test_loader_get_workspace_tree_simple(self):
-        log = MockLog()
-        vfs = MockVFS()
-        loader = Loader(log,vfs)
-        
-        (wsdom, dropped_nodes) = loader.get_workspace_tree(StringIO.StringIO(self.sampleworkspacestring))
-        # TODO check wsdom content validity
-        self.assertEqual(0, len(dropped_nodes))
-        self.assertEqual(type(self.sampleworkspace), type(wsdom))
-        self.assertEqual(None, log.msg)
-        self.assertEqual(None, vfs.href)
-    
-    # TODO test loader href resolution
-    # TODO test loader looping href resolution
-    # TODO test loader href resolution failure
-    # TODO test loader vfs exception
-        
-class MockLog:
-    msg = None
-    def warning(self,msg):
-        self.msg = msg
 
-class MockVFS:
-    href = None
-    def get_as_stream(href):
-        self.href = href
-        return StringIO.StringIO()

Modified: gump/branches/Gump3/pygump/python/gump/test/testEngineObjectifier.py
URL: http://svn.apache.org/viewcvs/gump/branches/Gump3/pygump/python/gump/test/testEngineObjectifier.py?rev=209850&r1=209849&r2=209850&view=diff
==============================================================================
--- gump/branches/Gump3/pygump/python/gump/test/testEngineObjectifier.py (original)
+++ gump/branches/Gump3/pygump/python/gump/test/testEngineObjectifier.py Fri Jul  8 10:52:32
2005
@@ -23,8 +23,17 @@
 from pmock import *
 
 import os
+from xml.dom import minidom
 
-from gump.engine.objectifier import *
+from gump.engine.objectifier import _add_dependency
+from gump.engine.objectifier import MissingDependencyError
+from gump.engine.objectifier import Objectifier
+from gump.model import Dependency
+from gump.model import DependencyInfo
+from gump.model import Module
+from gump.model import Project
+from gump.model import Repository
+from gump.model import Workspace
 
 class EngineObjectifierTestCase(MockTestCase):
     def setUp(self):
@@ -46,25 +55,224 @@
         self.o = Objectifier(self.log,self.workdir)
     
         self.samplexml = """<?xml version="1.0"?>
-<workspace>
-  blah
-  <elem>contents</elem>
-  <stuff>ignore</stuff>
-  <elem>ignore</elem>
-  <blah></blah>
-      <repositories>
-      </repositories>
-      <modules>
-      </modules>
-      <projects>
-          <project>
-            <nested>
-              <uniquetaghere>
-                <foo/>
-              </uniquetaghere>
-            </nested>
-          </project>
-       </projects>
+<workspace 
+        version="0.5" 
+        name="gump3-unittestworkspace">
+
+<repositories>
+    <repository name="ant" type="cvs">
+        <title>Ant</title>
+        <home-page>http://ant.apache.org/</home-page>
+        <cvsweb>http://cvs.apache.org/viewcvs/</cvsweb>
+        <redistributable/>
+        
+        <hostname>cvs.apache.org</hostname>
+        <method>pserver</method>
+        <path>/home/cvspublic</path>
+        <user>anoncvs</user>
+        <password>anoncvs</password>
+    </repository>
+
+    <repository name="gump" type="svn">
+        <title>Gump</title>
+        <home-page>http://gump.apache.org/</home-page>
+        <web>http://cvs.apache.org/viewcvs.cgi/gump/?root=Apache-SVN</web>
+        <url>http://svn.apache.org/repos/asf/gump/branches/Gump3</url>
+        <redistributable/>
+    </repository>
+
+    <repository name="xml" type="cvs">
+        <title>XML</title>
+        <home-page>http://xml.apache.org/</home-page>
+        <cvsweb>http://cvs.apache.org/viewcvs/</cvsweb>
+        <redistributable/>
+        
+        <hostname>cvs.apache.org</hostname>
+        <method>pserver</method>
+        <path>/home/cvspublic</path>
+        <user>anoncvs</user>
+        <password>anoncvs</password>
+    </repository>
+</repositories>
+    
+<modules>
+    <module name="ant">
+        <repository name="ant"/>
+        
+        <url>http://ant.apache.org/index.html</url>
+        <description>Java based build tool</description>
+    </module>
+    
+    <module name="gump-test" path="test">
+        <repository name="gump"/>
+        
+        <url>http://gump.apache.org/index.html</url>
+        <description>Gump Testing</description>
+    </module>
+
+    <module name="gump">
+        <repository name="gump"/>
+        
+        <url>http://gump.apache.org/index.html</url>
+        <description>Python based integration tool</description>
+    </module>
+
+    <module name="xml-commons">
+        <repository name="xml"/>
+    
+        <url>htp://xml.apache.org/commons/</url>
+        <description>XML commons -- externally defined standards - DOM,SAX,JAXP; plus
xml utilities</description>
+    </module>
+
+    <module name="xml-xerces">
+        <repository name="xml"/>
+    
+        <url href="http://xml.apache.org/xerces2-j/index.html"/>
+        <description>Java XML Parser - the sequel with no equal</description>
+    </module>
+</modules>
+
+<projects>
+    <project name="gump-unit-tests">
+        <module name="gump"/>
+        <script name="gump">
+            <arg name="" value="test"/>
+        </script> 
+    </project>
+    
+    <project name="bootstrap-ant">
+        <module name="ant"/>
+        
+        <!-- commands -->
+        <script name="bootstrap"/>
+        
+        <!-- outputs -->
+        <home nested="bootstrap"/>
+        <jar name="lib/ant.jar"/>
+        <jar name="lib/ant-launcher.jar" id="ant-launcher"/>
+    </project>
+    
+    <project name="ant">
+        <module name="ant"/>
+        
+        <!-- commands -->
+        <ant/>
+        
+        <!-- dependencies -->
+        <depend project="bootstrap-ant"/>
+    </project>
+
+    <project name="xml-apis">
+        <module name="xml-commons"/>
+
+        <!-- commands -->
+        <ant basedir="java/external"/>
+
+        <!-- outputs -->
+        <home nested="java/external/build"/>
+        <jar name="xml-apis.jar" type="boot"/>
+        
+        <!-- dependencies -->
+        <depend project="bootstrap-ant"/>
+        <depend project="jaxp"/>
+    </project>
+
+    <project name="xml-commons-which">
+        <module name="xml-commons"/>
+        
+        <!-- commands -->
+        <ant basedir="java" buildfile="which.xml" target="jar" />
+
+        <!-- outputs -->
+        <home nested="java/build"/>
+        <jar name="which.jar" id="which"/>
+        
+        <!-- dependencies -->
+        <depend project="xml-xerces" />
+        <depend project="bootstrap-ant"/>
+    </project>
+
+    <project name="xml-commons-resolver">
+        <module name="xml-commons"/>
+        <depend project="xml-resolver" inherit="jars" />
+    </project>
+
+    <project name="xml-resolver">
+        <module name="xml-commons"/>
+
+        <!-- commands -->
+        <ant basedir="java" buildfile="resolver.xml" target="gump"/>
+        
+        <!-- outputs -->
+        <home nested="java/build"/>
+        <jar name="resolver.jar"/>
+
+        <!-- dependencies -->
+        <depend project="jaxp"/>
+        <depend project="xml-apis"/>
+        <depend project="bootstrap-ant" inherit="runtime"/>
+    </project>
+    
+    <project name="jaxp">
+        <module name="xml-commons"/>
+        <!-- assumed to be provided by JDK -->
+    </project>
+
+    <project name="xml-xerces">
+        <module name="xml-xerces"/>
+        
+        <!-- commands -->
+        <ant basedir="java" target="jar"/>
+        
+        <!-- outputs -->
+        <home nested="java/build"/>
+        <jar name="xercesImpl.jar" id="xml-parser" type="boot"/>
+        
+        <!-- dependencies -->
+        <depend project="bootstrap-ant"/>
+        <depend project="xjavac"/>
+        <depend project="xml-commons-resolver"/>
+        <option project="jaxp" ids="jaxp-api dom sax"/>
+    </project>
+    
+    <project name="xml-xercesImpl">
+        <module name="xml-xerces"/>
+
+        <!-- outputs -->
+        <home nested="java/build"/>
+        <jar name="xercesImpl.jar" id="xercesImpl"/>
+        <license name="java/LICENSE"/>
+
+        <!-- dependencies -->
+        <depend project="xml-xerces"/>
+    </project>
+    
+    <project name="dist-xerces">
+        <module name="xml-xerces"/>
+
+        <!-- commands -->
+        <ant basedir="java" target="pack-bin">
+            <sysproperty name="build.clonevm" value="true"/>
+        </ant>
+        
+        <!-- dependencies -->
+        <depend project="ant" inherit="runtime"/>
+        <depend project="xjavac"/>
+        <depend project="xalan"/>
+        <depend project="xml-xerces"/>
+        <depend project="xml-stylebook2"/>
+        <depend project="xml-site"/>
+    </project>
+        
+    <project name="xjavac">
+        <module name="xml-xerces"/>
+        
+        <!-- outputs -->
+        <home nested="java/tools"/>
+        <jar name="bin/xjavac.jar"/>
+    </project>
+
+</projects>
 </workspace>
 """
         self.sampledom = minidom.parseString(self.samplexml)
@@ -91,4 +299,40 @@
         self.assertRaises(AssertionError, Objectifier, "", self.workdir)
         
     def test_Objectifier_get_workspace(self):
-        w = self.o.get_workspace(self.sampledom)
\ No newline at end of file
+        w = self.o.get_workspace(self.sampledom)
+        self.failUnless(isinstance(w, Workspace))
+
+    def test__add_dependency(self):
+        class XMLDependency:
+            def __init__(self, project, runtime, inherit, optional, ids=None):
+                self.project = project
+                self.runtime = runtime
+                self.inherit = inherit
+                self.optional = optional
+                self.ids = ids
+
+            def getAttribute(self, name):
+                return getattr(self, name, None)
+        
+        w = Workspace("bla")
+        r = Repository(w, "blabla")
+        m = Module(r, "blablabla")
+        bla_project = Project(m, "blablablabla")
+        other_project = Project(m, "other")
+        project_list = {bla_project.name: bla_project, other_project.name: other_project}
+        
+        d = XMLDependency("other", "true", "all", "true")
+        
+        _add_dependency(bla_project, d, project_list)
+        
+        relationships = bla_project.dependencies
+        self.assertEqual(1,len(relationships))
+        relationship = relationships[0]
+        self.assertEqual(relationship.dependency, other_project)
+        self.assertEqual(relationship.dependee, bla_project)
+        self.assertEqual(1,len(relationship.dependencyInfo))
+        info = relationship.dependencyInfo[0]
+        self.failUnless(info.runtime)
+        self.failUnless(info.optional)
+        self.assertEqual("all", info.inherit)
+        self.assertEqual(0,len(info.specific_output_ids))



Mime
View raw message