gump-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aj...@apache.org
Subject cvs commit: jakarta-gump/python/gump/document forrest.py
Date Tue, 18 Nov 2003 17:29:18 GMT
ajack       2003/11/18 09:29:18

  Modified:    python/gump/model module.py workspace.py rawmodel.py ant.py
                        project.py property.py object.py repository.py
               python/gump/test __init__.py model_tests.py
               python/gump/utils __init__.py
               python/gump/test/resources/simple3 project4.xml
               template/forrest/src/documentation/content/xdocs tabs.xml
               python/gump config.py
               python/gump/document forrest.py
  Added:       python/gump/test pyunit.py
  Removed:     python/gump/test test.py
  Log:
  1) Some dependency fixes (for ant properties)
  2) More work on pyunit (Simple JUnit in Python for Gump)
  
  Revision  Changes    Path
  1.3       +4 -0      jakarta-gump/python/gump/model/module.py
  
  Index: module.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/module.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- module.py	18 Nov 2003 01:15:26 -0000	1.2
  +++ module.py	18 Nov 2003 17:29:17 -0000	1.3
  @@ -151,6 +151,8 @@
       # provide default elements when not defined in xml
       def complete(self,workspace):
         
  +        if self.isComplete(): return
  +        
           # We have a CVS entry, expand it...
           if self.xml.cvs:
               repoName=self.xml.cvs.repository
  @@ -177,6 +179,8 @@
               else:
                   log.error(':TODO: No such project in w/s ['+ `xmlproject.name` +'] on ['
\
                           + self.getName() + ']')
  +                    
  +        self.setComplete(1)
               
   
   
  
  
  
  1.3       +12 -13    jakarta-gump/python/gump/model/workspace.py
  
  Index: workspace.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/workspace.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- workspace.py	18 Nov 2003 01:15:26 -0000	1.2
  +++ workspace.py	18 Nov 2003 17:29:17 -0000	1.3
  @@ -107,9 +107,7 @@
           #    
           self.startdatetime=time.strftime(setting.datetimeformat, \
                                   time.localtime())
  -        self.timezone=str(time.tzname)
  -    
  -        
  +        self.timezone=str(time.tzname)    
       
       def hasRepository(self,rname):
           return self.repositories.has_key(rname)
  @@ -132,7 +130,9 @@
       def getProject(self,pname):
           return self.projects[pname]
           
  -    def complete(self, xmlprofiles, xmlrepositories, xmlmodules, xmlprojects):
  +    def complete(self, xmlprofiles, xmlrepositories, xmlmodules, xmlprojects):        
  +        if self.isComplete(): return
  +        
           #
           # provide default elements when not defined in xml
           # expand those in XML
  @@ -260,13 +260,6 @@
                   self.error("Duplicate Module name [" + moduleName + "]")
               else:        
                   self.modules[moduleName] = module
  -
  -        #
  -        # Check repositories now modules have been imported
  -        #
  -        for repository in self.getRepositories(): 
  -            repository.check(self)
  -       
           #
           # Import all projects
           #  
  @@ -282,8 +275,12 @@
           # Complete the modules
           for module in self.getModules():
               module.complete(self)
  -    
  -        
  +            
  +        #
  +        # Check repositories now modules have been imported
  +        #
  +        for repository in self.getRepositories(): 
  +            repository.check(self)            
           
           # Complete the projects   
           haveUnnamedModule=0
  @@ -304,6 +301,8 @@
                                                                
           # Complee the properies
           self.completeProperties()
  +                                        
  +        self.setComplete(1)
               
       def addModule(self,module):
           self.modules[module.getName()]=module                         
  
  
  
  1.2       +5 -0      jakarta-gump/python/gump/model/rawmodel.py
  
  Index: rawmodel.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/rawmodel.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- rawmodel.py	17 Nov 2003 22:10:50 -0000	1.1
  +++ rawmodel.py	18 Nov 2003 17:29:17 -0000	1.2
  @@ -268,6 +268,8 @@
           
     # provide default elements when not defined in xml
     def complete(self,project):
  +    if self.isComplete(): return    
  +        
       if self.reference=='home':
         try:
           self.value=Project.list[self.project].home
  @@ -324,6 +326,9 @@
       elif not hasattr(self,'value'):
           log.error('Unhandled Property: ' + self.name + ' on project: ' + \
                       project.name)
  +                      
  +
  +    self.setComplete(1)
           
           
   # TODO: set up the below elements with defaults using complete()
  
  
  
  1.3       +39 -37    jakarta-gump/python/gump/model/ant.py
  
  Index: ant.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/ant.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ant.py	18 Nov 2003 00:29:50 -0000	1.2
  +++ ant.py	18 Nov 2003 17:29:17 -0000	1.3
  @@ -107,45 +107,48 @@
           # into dependencies
           #
           for property in self.xml.property:
  -        
  -            # Check if the property comes from another project
  -            if not property.project: continue      
  -            # If that project is the one we have in hand
  -            if property.project==project.getName(): continue
  -            # If the property is not as simple as srcdir
  -            if property.reference=="srcdir": continue
  -            # If it isn't already a classpath dependency
  -            if project.hasFullDependencyOn(property.project): continue
  +            self.expandProperty(property,project,workspace)        
  +    
  +    def expandProperty(self,property,project,workspace):
  +            
  +        # Check if the property comes from another project
  +        if not property.project: return      
  +        # If that project is the one we have in hand
  +        if property.project==project.getName(): return
  +        # If the property is not as simple as srcdir
  +        if property.reference=="srcdir": return
  +        # If it isn't already a classpath dependency
  +        if project.hasFullDependencyOn(property.project): return
               
  -            # If there are IDs specified
  -            ids=''
  -            if property.id: ids= property.id
  +        # If there are IDs specified
  +        ids=''
  +        if property.id: ids= property.id
   
  -            # Runtime?
  -            runtime=0
  -            if property.runtime: property.runtime=1
  +        # Runtime?
  +        runtime=0
  +        if property.runtime: property.runtime=1
      
  -            projectName=property.project
  -            if workspace.hasProject(projectName): 
  -                # Add a dependency (to bring property)
  -                dependency=ProjectDependency(project, 	\
  -                                workspace.getProject(property.project),	\
  -                                INHERIT_ALL,	\
  -                                runtime,
  -                                0,	\
  -                                ids)
  +        projectName=property.project
  +        if workspace.hasProject(projectName): 
  +            # Add a dependency (to bring property)
  +            dependency=ProjectDependency(project, 	\
  +                            workspace.getProject(property.project),	\
  +                            INHERIT_ALL,	\
  +                            runtime,
  +                            0,	\
  +                            ids)
                               
  -                dependency.addInfo("Property Based Dependency " + `property`)
  +            dependency.addInfo("Property Based Dependency " + `property`)
               
  -                # :TODOs:
  -                # if not property.classpath: depend['noclasspath']=Single({})
  +            # :TODOs:
  +            # if not property.classpath: depend['noclasspath']=Single({})
               
               
  -                # Add depend to project...
  -                # :TODO: Convert to ModelObject
  -                project.addDependency(dependency)
  -            else:
  -                log.error('No such project [' + projectName + '] for property')
  +            # Add depend to project...
  +            # :TODO: Convert to ModelObject
  +            project.addDependency(dependency)
  +        else:
  +            log.error('No such project [' + projectName + '] for property')
   
       def expandDependencies(self,project,workspace):
           #
  @@ -168,11 +171,7 @@
               # :TODO: AJ added this, no idea if it is right/needed.
               if depend.id: property['ids']= depend.id
               # Store it
  -            self.xml.property.append(property)      
  -            # Move onto project
  -            project.xml.depend.append(depend)
  -      
  -        self.xml.depend=None
  +            self.expandProperty(property,project,workspace)      
   
       def getTarget(self):
           return self.target
  @@ -185,12 +184,15 @@
       # at this point
       #
       def complete(self,project,workspace):
  +        if self.isComplete(): return
           
           # Import the properties..
       	PropertyContainer.importProperties(self,self.xml)
       	
       	# Compelte them all
           self.completeProperties(workspace)
  +                
  +        self.setComplete(1)
                       
       def dump(self, indent=0, output=sys.stdout):
           """ Display the contents of this object """
  
  
  
  1.3       +7 -11     jakarta-gump/python/gump/model/project.py
  
  Index: project.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/project.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- project.py	18 Nov 2003 00:29:50 -0000	1.2
  +++ project.py	18 Nov 2003 17:29:17 -0000	1.3
  @@ -203,11 +203,7 @@
       	# Outputs
       	#
           self.jars={}
  -    	
  -    	# Transient settings...
  -    	
  -    	self.isComplete=0
  -    
  +        
       def getAnt(self):
           return self.ant
           
  @@ -345,7 +341,7 @@
       
       # provide elements when not defined in xml
       def complete(self,workspace):
  -        if self.isComplete: return
  +        if self.isComplete(): return
   
           if not self.inModule():
               self.addWarning("Not in a module")
  @@ -354,7 +350,6 @@
           # Import any <ant part
           if self.xml.ant:
               self.ant = Ant(self.xml.ant,self)
  -            self.ant.complete(self, workspace)
           
           # :TODO: Scripts
           
  @@ -397,13 +392,13 @@
                   #:TODO: Warn .. no name
                   pass
   
  -        # expand properties
  +        # Expand <ant <depends/<properties...
           if self.ant: self.ant.expand(self,workspace)
   
  -        # Build Dependencies Map
  +        # Build Dependencies Map [including depends from <ant/<property/<depend
           (badDepends, badOptions) = self.buildDependenciesMap(workspace)
           
  -        # Hmm, why complete these first? Does it matter?
  +        # Complete dependencies so properties can reference the,
           for dependency in self.getDependencies():
               dependency.getProject().complete(workspace)
           
  @@ -423,7 +418,7 @@
                   self.addWarning("Bad *Optional* Dependency. Project: " + xmloption.project
+ " unknown to *this* workspace")
                   log.warn("Unknown *Optional* Dependency [" + xmloption.project + "] on
[" + self.getName() + "]")    
           
  -        self.isComplete=1
  +        self.setComplete(1)
   
       def buildDependenciesMap(self,workspace):        
           badDepends=[]
  @@ -433,6 +428,7 @@
               if workspace.hasProject(dependProjectName):
                   dependProject=workspace.getProject(dependProjectName)
                   
  +                # Import the dependency
                   dependency=importXMLDependency(self, dependProject, xmldepend, 0)
                                   
                   # Add a dependency
  
  
  
  1.2       +13 -6     jakarta-gump/python/gump/model/property.py
  
  Index: property.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/property.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- property.py	17 Nov 2003 22:10:50 -0000	1.1
  +++ property.py	18 Nov 2003 17:29:17 -0000	1.2
  @@ -79,16 +79,21 @@
           
       # provide default elements when not defined in xml
       def complete(self,parent,workspace):
  +        if self.isComplete(): return
  +                 
           if self.xml.reference=='home':
               try:
  -                self.setValue(workspace.getProject(self.xml.project).getHomeDirectory())
  +                targetProject=workspace.getProject(self.xml.project)
  +                self.setValue(targetProject.getHomeDirectory())
               except Exception, details:
  -                log.warn( "Cannot resolve homedir of " + self.xml.project + " for " + `parent`
+ ' : ' + `details`)
  +                log.warn( "Cannot resolve homedir of " + self.xml.project + " for " + `parent`
+ ' : ' + `details`,exc_info=1)                
           elif self.xml.reference=='srcdir':
               try:
  -                self.setValue(workspace.getProject(self.xml.project).getModule().getSoruceDirectory())
  +                targetProject=workspace.getProject(self.xml.project)
  +                
  +                self.setValue(targetProject.getModule().getSourceDirectory())
               except Exception, details:
  -                log.warn( "Cannot resolve srcdir of " + self.xml.project + " for " + `parent`
+ ' : ' + `details`)
  +                log.warn( "Cannot resolve srcdir of " + self.xml.project + " for " + `parent`
+ ' : ' + `details`,exc_info=1)
           elif self.xml.reference=='jarpath' or self.xml.reference=='jar':
               try:
                   targetProject=workspace.getProject(self.xml.project)
  @@ -118,7 +123,7 @@
                       log.error(self.value)
               except Exception, details:
                   log.warn( "Cannot resolve jar/jarpath of " + self.xml.project + \
  -                  " for " + `parent` + ". Details: " + str(details))
  +                  " for " + `parent` + ". Details: " + str(details),exc_info=1)
           elif self.xml.path:
               #
               # Path relative to module's srcdir 
  @@ -129,7 +134,9 @@
           
           if not hasattr(self,'value'):
               log.error('Unhandled Property: ' + self.getName() + ' on: ' + \
  -                    `parent`)
  +                    str(parent))
  +                
  +        self.setComplete(1)
           
       def dump(self, indent=0, output=sys.stdout):
           """ Display the property """
  
  
  
  1.3       +8 -0      jakarta-gump/python/gump/model/object.py
  
  Index: object.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/object.py,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- object.py	18 Nov 2003 00:29:50 -0000	1.2
  +++ object.py	18 Nov 2003 17:29:17 -0000	1.3
  @@ -148,6 +148,14 @@
   
           # The XML model
       	self.xml=xml
  +    	
  +    	self.completionPerformed=0
  +    	
  +    def isComplete(self):
  +        return self.completionPerformed
  +        
  +    def setComplete(self,complete):
  +       self.completionPerformed=complete
          
       def isDebug(self):
           return self.xml.debug
  
  
  
  1.2       +9 -1      jakarta-gump/python/gump/model/repository.py
  
  Index: repository.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/repository.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- repository.py	17 Nov 2003 22:10:50 -0000	1.1
  +++ repository.py	18 Nov 2003 17:29:17 -0000	1.2
  @@ -90,11 +90,19 @@
           pass
                        
       def check(self,workspace):
  -        if not self.modules:
  +        if not self.hasModules():
               self.addWarning('Unused Repository (not referenced by modules)')
  +    
  +    def hasModules(self):
  +        if self.modules: return 1
  +        return 0
               
  +    def getModules(self):
  +        return self.modules
  +    
       def dump(self, indent=0, output=sys.stdout):
           output.write(getIndent(indent)+'Repository : ' + self.name + '\n')   
  +        NamedModelObject.dump(self)
           
       def hasTitle(self): 
           return hasattr(self.xml,'title') and self.xml.title
  
  
  
  1.2       +5 -3      jakarta-gump/python/gump/test/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/test/__init__.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- __init__.py	17 Nov 2003 22:10:53 -0000	1.1
  +++ __init__.py	18 Nov 2003 17:29:18 -0000	1.2
  @@ -76,8 +76,7 @@
       print "Workspace File: " + str(xml)
       #
       workspace = WorkspaceLoader().load(xml)
  -   
  -    
  +
       return workspace
       
   def getWorkedTestWorkspace(xml=None):
  @@ -93,9 +92,12 @@
           listDirectoryAsWork(module,module.getSourceDirectory())
           for project in module.getProjects():
               listDirectoryAsWork(project,project.getHomeDirectory())        
  -            
  +
  +    return workspace
  +    
   def createTestWorkspace():
       xmlworkspace=XMLWorkspace({})
       workspace=Workspace(xmlworkspace)
       return workspace
  +  
       
  
  
  
  1.2       +52 -39    jakarta-gump/python/gump/test/model_tests.py
  
  Index: model_tests.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/test/model_tests.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- model_tests.py	17 Nov 2003 22:10:53 -0000	1.1
  +++ model_tests.py	18 Nov 2003 17:29:18 -0000	1.2
  @@ -69,51 +69,64 @@
   import gump.config
   from gump.model.loader import WorkspaceLoader
   from gump.utils import *
  +from gump.test import getWorkedTestWorkspace
  +from gump.test.pyunit import UnitTestSuite
   
  -if __name__=='__main__':
  +class ModelTestSuite(UnitTestSuite):
  +    def __init__(self):
  +        UnitTestSuite.__init__(self)
  +        
  +    def setUp(self):
  +        #
  +        # Load a decent Workspace
  +        #
  +        self.workspace=getWorkedTestWorkspace() 
  +         
  +        self.assertNotNone('Needed a workspace', self.workspace)
  +        
  +        self.repo1=self.workspace.getRepository('repository1')              
  +        self.project1=self.workspace.getProject('project1')
  +        self.project2=self.workspace.getProject('project2')
  +        self.module1=self.workspace.getModule('module1')
       
  -    # init logging
  -    logging.basicConfig()
  +        
  +    def testWorkspace(self):
  +        self.assertNonZero('Has Log Directory',	\
  +                    self.workspace.getLogDirectory() )
  +        
  +    def testRepository(self):
  +        repo1 = self.repo1
  +        
  +        self.assertNonZero('Repository CVSWEB',repo1.getCvsWeb())
  +        self.assertNonZeroString('Repository CVSWEB',repo1.getCvsWeb())        
  +        self.assertTrue('Repository has Modules', repo1.hasModules())
   
  -    #set verbosity to show all messages of severity >= default.logLevel
  -    log.setLevel(gump.default.logLevel)
  -    
  -    ws=WorkspaceLoader().load('gump/test/resources/simple2/workspace.xml')
  -    
  -    printSeparator()
  -    print ws.getLogDirectory()
  -    
  -    repo1=ws.getRepository('repository1')
  -    print "Repository CVSWEB:" + str(repo1.getCvsWeb())
  -    
  -    project1=ws.getProject('project1')
  -    project2=ws.getProject('project2')
  -    
  -    if project1 == project2:
  -        log.error("Different projects match!!!")
  +    def testComparisons(self):
  +        project1 = self.project1
  +        project2 = self.project2
           
  -    if not project1 == project1:
  -        log.error("Same project not matching!!!")
  +        if project1 == project2:
  +            log.error("Different projects match!!!")
           
  -    projects=[]
  -    projects.append(project1)
  -    
  -    if not project1 in projects:
  -        log.error("project not in list!!!")
  +        if not project1 == project1:
  +            log.error("Same project not matching!!!")
           
  -    if project2 in projects:
  -        log.error("project not in list!!!")
  +        projects=[]
  +        projects.append(project1)
  +   
           
  -    printSeparator()
  -    
  -    print getTerseClassName(ws)
  -    print getTerseClassName(project1)
  -    
  -    printSeparator()
  -    for p in createOrderedList([ project2, project1, project2, project1]):
  -        print p
  +        self.assertIn('Project in list',project1,projects)
  +        self.assertNotIn('Project NOT in list',project2,projects)
  +        
  +        ordered=createOrderedList([ project2, project1, project2, project1])
           
  +        self.assertAt('Project First', project1, ordered, 0)
  +        self.assertAt('Project Second', project1, ordered, 1)
  +        self.assertAt('Project Third', project2, ordered, 2)
  +        self.assertAt('Project Fourth', project2, ordered, 3)        
       
  -    module1=ws.getModule('module1')
  -    if module1.isCVS():
  -        print "CVSROOT = " + module1.cvs.getCVSRoot()
  \ No newline at end of file
  +    def testCVS(self):
  +        module1=self.module1
  +        
  +        self.assertTrue('Module is CVS', module1.isCVS())
  +        self.assertNonZeroString('CVSROOT',module1.cvs.getCVSRoot())
  \ No newline at end of file
  
  
  
  1.1                  jakarta-gump/python/gump/test/pyunit.py
  
  Index: pyunit.py
  ===================================================================
  #!/usr/bin/env python
  
  # $Header: /home/cvspublic/jakarta-gump/python/gump/conf.py,v 1.7 2003/05/10 18:20:36 nicolaken
Exp $
  # $Revision: 1.7 $
  # $Date: 2003/05/10 18:20:36 $
  #
  # ====================================================================
  #
  # The Apache Software License, Version 1.1
  #
  # Copyright (c) 2003 The Apache Software Foundation.  All rights
  # reserved.
  #
  # Redistribution and use in source and binary forms, with or without
  # modification, are permitted provided that the following conditions
  # are met:
  #
  # 1. Redistributions of source code must retain the above copyright
  #    notice, this list of conditions and the following disclaimer.
  #
  # 2. Redistributions in binary form must reproduce the above copyright
  #    notice, this list of conditions and the following disclaimer in
  #    the documentation and/or other materials provided with the
  #    distribution.
  #
  # 3. The end-user documentation included with the redistribution, if
  #    any, must include the following acknowlegement:
  #       "This product includes software developed by the
  #        Apache Software Foundation (http://www.apache.org/)."
  #    Alternately, this acknowlegement may appear in the software itself,
  #    if and wherever such third-party acknowlegements normally appear.
  #
  # 4. The names "The Jakarta Project", "Alexandria", and "Apache Software
  #    Foundation" must not be used to endorse or promote products derived
  #    from this software without prior written permission. For written
  #    permission, please contact apache@apache.org.
  #
  # 5. Products derived from this software may not be called "Apache"
  #    nor may "Apache" appear in their names without prior written
  #    permission of the Apache Group.
  #
  # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  # DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  # ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  # SUCH DAMAGE.
  # ====================================================================
  #
  # This software consists of voluntary contributions made by many
  # individuals on behalf of the Apache Software Foundation.  For more
  # information on the Apache Software Foundation, please see
  # <http://www.apache.org/>.
  
  """
      This module contains information on unit testing
  """
  import sys
  from types import NoneType, StringType, TypeType, MethodType
  import types
  import logging
  
  from gump import log
  import gump.config
  from gump.utils import createOrderedList,printSeparator,formatException
      
  
  class Testable:       
      def __init__(self):
          pass
          
      def raiseIssue(self, stuff):
          message=''
          for s in stuff:
              if message: message += '. '
              message += str(s)
              
          raise RuntimeError, message
          
      def assertNotNone(self,message,object):        
          if isinstance(object,NoneType):
              self.raiseIssue(['Ought NOT be None', message, object])
              
      def assertNonZero(self,message,object):
          self.assertNotNone(message,object)
          if not object:
              self.raiseIssue(['Ought evaluate to non-zero', message, object])
              
      def assertEqual(self,message,object1,object2):
          if not object1 == object2:
              self.raiseIssue(['Ought evaluate as equal', message, object1, object2])
              
      def assertTrue(self,message,object):
          if not object:
              self.raiseIssue(['Ought evaluate as true', message, object])
              
      def assertIn(self,message,object,sequence):
          if not object in sequence:
              self.raiseIssue(['Ought evaluate as in', message, object, sequence])
              
      def assertNotIn(self,message,object,sequence):
          if object in sequence:
              self.raiseIssue(['Ought NOT evaluate as in', message, object, sequence])
  
      def assertLengthAbove(self,message,object,length):
          if not len(object) >= length:
              self.raiseIssue(['Ought be longer than', message, object, length])
      
      def assertAt(self,message,object,sequence,posn):
          self.assertLengthAbove(message,sequence,posn+1)        
          self.assertEqual(message,object,sequence[posn] )
              
      def assertString(self,message,object):
          if not type(object) == types.StringType:
              self.raiseIssue(['Ought be a String type', message, object, type(object)])
              
      def assertNonZeroString(self,message,object):
          self.assertNonZero(message,object)
          self.assertString(message,object)
          
  class Problem:
      def __init__(self,suite,test,error=None):
          self.suite=suite
          self.test=test
          self.error=error
          
      def __str__(self):
          return self.suite.getName() + ':' + self.test + ':' + self.error
              
  class UnitTestSuite(Testable):
      def __init__(self,name=None):
          Testable.__init__(self)
          if name:
              self.name=name
          else:
              self.name=self.__class__.__name__
          self.depends=[]
          self.fullDepends=[]
              
      def addDependency(self,suite):
          self.depends.append(suite)
      
      def getFullDepends(self,visited=None):        
          # Cached already
          if self.fullDepends:
              return self.fullDepends
  
          if not visited: visited=[]
          if self in visited: return []
          visited.append(self)        
          
          # Calculate
          for suite in self.depends:
              for dependSuite in self.fullDepends(visited):
                  if not dependSuite in self.fullDepends:
                      self.fullDepends.append(dependSuite)
          
          # Return complete tree
          return self.fullDepends
          
      def isDependentUpon(self,suite):
          return suite in self.getFullDepends()
          
      def __cmp__(self, other):
          if self.isDependentUpon(other): return 1
          if other.isDependentUpon(self): return -1
          return 0
          
      def getName(self):
          return self.name
          
      def performTests(self):
      
          results=[]
          
          if hasattr(self,'setUp'):
              self.setUp()
      
          # iterate over this suites properties
          for name in self.__class__.__dict__:
              if name.startswith('__') and name.endswith('__'): continue
              test=getattr(self,name)            
              # avoid nulls, metadata, and methods other than test*
              if not test: continue
              if isinstance(test,types.TypeType): continue
              if not isinstance(test,types.MethodType): continue
              if not callable(test): continue
              if not name.startswith('test'): continue
              
              # Call the test...
              try:
                  log.debug('Perform [' + self.getName() + '::' + \
                          name + ']')
                  test()
              except Exception, details:
                  import traceback
                  ei = sys.exc_info()
                  message=formatException(ei)
                  del ei                
                  results.append(Problem(self,name,message))
              
          if hasattr(self,'tearDown'):
              self.tearDown()
          
          return results
  
        
  class TestRunner:
      def __init__(self):
          self.suites=[]
          
      def addSuite(self,suite):
          self.suites.append(suite)
          
      def run(self):
          # Sort to resolve dependency order
          runOrder=createOrderedList(self.suites)
          
          problems=[]
          
          # Perform the tests
          for suite in runOrder:
              try:
                  problems += suite.performTests()
              except Exception, details:
                  import traceback
                  ei = sys.exc_info()
                  message=formatException(ei)
                  del ei                
                  problems.append(Problem(suite,'performTests',message)) 
             
          printSeparator()
          for problem in problems:
              log.error('PROBLEM: ' + str(problem))
              
          if not problems:
              log.info('No Problems Detected')
          
          if problems:   sys.exit(1)
          sys.exit()
                      
  if __name__=='__main__':
      
      # init logging
      logging.basicConfig()
  
      #set verbosity to show all messages of severity >= default.logLevel
      log.setLevel(gump.default.logLevel)
      
      runner=TestRunner()
      
      #:TODO: Figure out Python search/introspection to find these...
      
      from gump.test.model_tests import ModelTestSuite  
      runner.addSuite(ModelTestSuite())
      
      # Perform the tests...
      runner.run()
      
      
  
  
  1.2       +10 -4     jakarta-gump/python/gump/utils/__init__.py
  
  Index: __init__.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/utils/__init__.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- __init__.py	17 Nov 2003 22:10:55 -0000	1.1
  +++ __init__.py	18 Nov 2003 17:29:18 -0000	1.2
  @@ -250,10 +250,16 @@
               indent = indent + '  '
               depth = depth -1
       return indent
  -    
  -         
  -def getTerseClassName(object):
  -    return object.__class__.__name__
  +                  
  +def formatException(ei):
  +    import traceback
  +    sio = StringIO.StringIO()
  +    traceback.print_exception(ei[0], ei[1], ei[2], None, sio)
  +    s = sio.getvalue()
  +    sio.close()
  +    if s[-1] == "\n":
  +        s = s[:-1]
  +    return s
           
   if __name__=='__main__':
   
  
  
  
  1.2       +1 -0      jakarta-gump/python/gump/test/resources/simple3/project4.xml
  
  Index: project4.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/test/resources/simple3/project4.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project4.xml	17 Nov 2003 22:10:53 -0000	1.1
  +++ project4.xml	18 Nov 2003 17:29:18 -0000	1.2
  @@ -12,6 +12,7 @@
   
       <ant target="gump">
         <property name="ant.home" reference="home" project="project1"/>
  +      <property name="ant.home" reference="home" project="ant"/> 
       </ant>
   
       <depend project="project1"/>
  
  
  
  1.4       +1 -1      jakarta-gump/template/forrest/src/documentation/content/xdocs/tabs.xml
  
  Index: tabs.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/template/forrest/src/documentation/content/xdocs/tabs.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- tabs.xml	5 Nov 2003 19:09:22 -0000	1.3
  +++ tabs.xml	18 Nov 2003 17:29:18 -0000	1.4
  @@ -15,6 +15,6 @@
   
     <tab id="home" label="Home" dir=""/>
     <tab id="stats" label="Statistics" dir="gump_stats"/>
  -  <!-- tab id="xref" label="XRef" dir="gump_xref"/ -->
  +  <tab id="xref" label="XRef" dir="gump_xref"/>
   
   </tabs>
  
  
  
  1.2       +1 -1      jakarta-gump/python/gump/config.py
  
  Index: config.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/config.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- config.py	17 Nov 2003 22:10:51 -0000	1.1
  +++ config.py	18 Nov 2003 17:29:18 -0000	1.2
  @@ -99,7 +99,7 @@
       globalws   = os.path.normpath('%s/%s' % (dir.base, 'global-workspace.xml'))
       merge      = os.path.normpath('%s/%s' % (dir.work, 'merge.xml'))
       date       = time.strftime('%Y%m%d')
  -    logLevel   = logging.DEBUG # logging.INFO 
  +    logLevel   = logging.INFO # logging.DEBUG
       classpath = (os.getenv('CLASSPATH') or '').split(os.pathsep)  
       
       logurl		=	'http://cvs.apache.org/builds/gump/nightly/'
  
  
  
  1.4       +2 -2      jakarta-gump/python/gump/document/forrest.py
  
  Index: forrest.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document/forrest.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- forrest.py	18 Nov 2003 01:15:26 -0000	1.3
  +++ forrest.py	18 Nov 2003 17:29:18 -0000	1.4
  @@ -1193,7 +1193,7 @@
       def insertLink(self,toObject,fromObject,xdocNode,typed=0,state=0):
           description=''
           if typed:
  -           description=getTerseClassName(toObject)
  +           description=toObject.__class__.__name__
                   
           try: # Add a name, if present
               name=toObject.getName()             
  @@ -1201,7 +1201,7 @@
               description+=name
           except: 
               if not description:
  -                description=getTerseClassName(toObject)
  +                description=toObject.__class__.__name__
           
           # If showing 'state' then find the 
           link=self.getLink(toObject,fromObject,state)  
  
  
  

Mime
View raw message