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/test model_tests.py
Date Wed, 19 Nov 2003 19:43:53 GMT
ajack       2003/11/19 11:43:53

  Modified:    python/gump engine.py
               python/gump/model object.py state.py ant.py work.py
                        project.py
               python/gump/output nag.py
               python/gump/document documenter.py
               python/gump/net cvs.py
               python/gump/test model_tests.py
  Log:
  More state fixes/unit tests
  
  Revision  Changes    Path
  1.4       +2 -1      jakarta-gump/python/gump/engine.py
  
  Index: engine.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- engine.py	18 Nov 2003 21:49:12 -0000	1.3
  +++ engine.py	19 Nov 2003 19:43:52 -0000	1.4
  @@ -386,7 +386,8 @@
                   self.performPostBuild( run, project, repository )
       
               if not project.okToPerformWork():
  -                log.warn('Failed to build project [' + project.getName() + ']')
  +                log.warn('Failed to build project [' + project.getName() + '], state:'
\
  +                        + project.getStateDescription())
               
       def performPreBuild( self, run, project ):
           """ Perform pre-build Actions """
  
  
  
  1.5       +7 -4      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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- object.py	19 Nov 2003 15:42:16 -0000	1.4
  +++ object.py	19 Nov 2003 19:43:53 -0000	1.5
  @@ -84,15 +84,18 @@
           self.causes=[]
               
       def changeState(self,state,reason=REASON_UNSET,cause=None,message=None):  
  +          
           #
           # Do NOT over-write a pre-determined condition
           #            
  -        if self.stateUnsetOrOk():
  +        if self.isUnsetOrOk():
   
  -            # Store it...
  -            Stateful.setStatePair(self,StatePair(state,reason))        
  +            # Store it...        
  +            newState=StatePair(state,reason)
  +            Stateful.setStatePair(self,newState)        
                   
  -            if not stateOk(state): 
  +            # If we are having something bad going on...
  +            if not newState.isOk(): 
                   #
                   # If no-one else to point the finger at ...
                   # ... step up.
  
  
  
  1.5       +50 -18    jakarta-gump/python/gump/model/state.py
  
  Index: state.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/state.py,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- state.py	19 Nov 2003 15:42:16 -0000	1.4
  +++ state.py	19 Nov 2003 19:43:53 -0000	1.5
  @@ -102,15 +102,7 @@
   def commandStateToWorkState(state):
       return stateMap[state]
              
  -def stateUnset(state):
  -    return state==STATE_NONE or state==STATE_UNSET 
  -        
  -def stateOk(state):
  -    return state==STATE_SUCCESS
  -        
  -def stateUnsetOrOk(state):
  -    return stateUnset(state) or stateOk(state)           
  -    
  +
   REASON_UNSET=0
   REASON_PACKAGE=1
   REASON_PACKAGE_BAD=2
  @@ -162,7 +154,7 @@
           return c
            
       def __hash__(self):
  -        return hash(self.state)+has(self.reason)
  +        return hash(self.state)+hash(self.reason)
                
       def getState(self):
           return self.state
  @@ -175,7 +167,35 @@
           
       def getReasonDescription(self):
           return reasonString(self.getState())
  -           
  +        
  +    #
  +    #
  +    #
  +    def isSuccess(self):
  +        return STATE_SUCCESS == self.state
  +                
  +    def isComplete(self):
  +        return STATE_COMPLETE == self.state
  +                
  +    def isFailed(self):
  +        return STATE_FAILED == self.state
  +        
  +    def isPrereqFailed(self):
  +        return STATE_PREREQ_FAILED == self.state
  +                
  +    def isUnset(self):
  +        return STATE_NONE==self.state \
  +                or STATE_UNSET==self.state
  +        
  +    def isUnsetOrOk(self):
  +        return self.isUnset() or self.isOk()           
  +
  +    def isOk(self):
  +        return self.isSuccess() or self.isComplete()   
  +
  +    def isNotOk(self):
  +        return self.isFailed() or self.isPrereqFailed()
  +               
   class Stateful:
       def __init__(self):        
           self.statePair=StatePair()
  @@ -198,15 +218,27 @@
       def getReasonDescription(self):
           return self.statePair.getReasonDescription()
           
  -    def stateUnsetOrOk(self):
  -        return stateUnsetOrOk(self.statePair.state)
  -        
       def isSuccess(self):
  -        return STATE_SUCCESS == self.statePair.state
  +        return self.statePair.isSuccess()
  +        
  +    def isComplete(self):
  +        return self.statePair.isComplete()
                   
       def isFailed(self):
  -        return STATE_FAILED == self.statePair.state
  +        return self.statePair.isFailed()
           
  -    def isPrereqFailure(self):
  -        return STATE_PREREQ_FAILED == self.statePair.state
  +    def isPrereqFailed(self):
  +        return self.statePair.isPrereqFailed()
  +                
  +    def isUnset(self):
  +        return self.statePair.isUnset()
           
  +    def isUnsetOrOk(self):
  +        return self.statePair.isUnsetOrOk()          
  +
  +    def isOk(self):
  +        return self.statePair.isOk()    
  +
  +    def isNotOk(self):
  +        return self.statePair.isNotOk() 
  +               
  \ No newline at end of file
  
  
  
  1.6       +1 -1      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ant.py	19 Nov 2003 15:42:16 -0000	1.5
  +++ ant.py	19 Nov 2003 19:43:53 -0000	1.6
  @@ -165,7 +165,7 @@
               elif not hasattr(property,'name') or not property['name']:
                   # :TODO: Reconsider later, but default to project name for now...
                   property['name']=depend.project
  -                project.addWarn('Unnamed property for [' + project.name + '] in depend
on: ' + depend.project )
  +                project.addWarning('Unnamed property for [' + project.name + '] in depend
on: ' + depend.project )
           
               # :TODO: AJ added this, no idea if it is right/needed.
               if depend.id: property['ids']= depend.id
  
  
  
  1.2       +1 -1      jakarta-gump/python/gump/model/work.py
  
  Index: work.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/model/work.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- work.py	17 Nov 2003 22:10:49 -0000	1.1
  +++ work.py	19 Nov 2003 19:43:53 -0000	1.2
  @@ -201,7 +201,7 @@
       	self.worklist.add(item)   
           	
       def okToPerformWork(self):
  -        return self.stateUnsetOrOk()        
  +        return self.isUnset() or self.isSuccess()        
                  
       #
       # Return a triple of hours/minutes/seconds for total
  
  
  
  1.6       +9 -10     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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- project.py	19 Nov 2003 15:42:16 -0000	1.5
  +++ project.py	19 Nov 2003 19:43:53 -0000	1.6
  @@ -313,7 +313,7 @@
           # Mark depend*ee*s as failed for this cause...
           # Warn option*ee*s
           #
  -        for dependee in self.getFullDependees():  
  +        for dependee in self.getDependees():  
       
               # This is a backwards link, so use the owner
               dependeeProject=dependee.getOwnerProject()
  @@ -990,18 +990,17 @@
           
           if not self.statepairs: self.statepairs=[]
           
  -    def addState(self,pair):            
  -        state=pair.state
  +    def addState(self,state):            
           # Stand up and be counted
  -        if stateOk(state):
  +        if state.isSuccess():
               self.successes+=1
  -        elif STATE_PREREQ_FAILED == state:
  +        elif state.isPreqFailed():
               self.prereqs+=1
  -        elif STATE_FAILED == state:
  +        elif state.isFailed():
               self.failures+=1
  -        elif STATE_NONE == state:
  +        elif state.isUnset():
               self.noworks+=1
  -        elif STATE_COMPLETE == state:
  +        elif state.isComplete():
               # :TODO: Accurate?
               self.packages+=1
           else:
  @@ -1011,8 +1010,8 @@
           self.projects += 1
                   
           # Add state, if not already there
  -        if not stateUnset(pair.state) and not pair in self.statepairs: \
  -            self.statepairs.append(pair)
  +        if not state.isUnset() and not state in self.statepairs: \
  +            self.statepairs.append(state)
           
       def addSummary(self,summary):
                    
  
  
  
  1.4       +1 -1      jakarta-gump/python/gump/output/nag.py
  
  Index: nag.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/output/nag.py,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- nag.py	19 Nov 2003 15:42:16 -0000	1.3
  +++ nag.py	19 Nov 2003 19:43:53 -0000	1.4
  @@ -95,7 +95,7 @@
               if not gumpSet.inModules(module): continue
               
               for project in module.getProjects():
  -                if STATE_FAILED == project.getState() :
  +                if project.isFailed() :
                       if not gumpSet.inSequence(project): continue    
                       
                       # :TODO: Something doesn't work w/ this.
  
  
  
  1.2       +2 -0      jakarta-gump/python/gump/document/documenter.py
  
  Index: documenter.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/document/documenter.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- documenter.py	17 Nov 2003 22:10:55 -0000	1.1
  +++ documenter.py	19 Nov 2003 19:43:53 -0000	1.2
  @@ -82,5 +82,7 @@
           if not callable(self.documentRun):
               raise RuntimeException, 'Complete [' + self.__class__ + '] with a callable
documentRun(self,run)'
           
  +        log 'Document run using [' + `self` + ']'
  +        
           self.documentRun(run)
       
  
  
  
  1.2       +15 -14    jakarta-gump/python/gump/net/cvs.py
  
  Index: cvs.py
  ===================================================================
  RCS file: /home/cvs/jakarta-gump/python/gump/net/cvs.py,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- cvs.py	17 Nov 2003 22:10:52 -0000	1.1
  +++ cvs.py	19 Nov 2003 19:43:53 -0000	1.2
  @@ -95,23 +95,24 @@
       logins={}
       cvspassfile=os.path.expanduser(os.path.join('~','.cvspass'))
       # print 'CVS Password File : ' + cvspassfile
  -    cvspass=open(cvspassfile)
  -    for line in cvspass.readlines():
  -        clean=line.strip()
  -        parts=clean.split(' ')
  +    if os.path.exists(cvspassfile):
  +        cvspass=open(cvspassfile)
  +        for line in cvspass.readlines():
  +            clean=line.strip()
  +            parts=clean.split(' ')
         
  -        # Cope with new format .cvspass 
  -        rootPart=0
  -        if '/1' == parts[0]:
  -            rootPart=1
  -        root=parts[rootPart]
  +            # Cope with new format .cvspass 
  +            rootPart=0
  +            if '/1' == parts[0]:
  +                rootPart=1
  +            root=parts[rootPart]
           
  -        # Cope w/ spaces in mangles
  -        mangle=' '.join(parts[rootPart+1:])
  +            # Cope w/ spaces in mangles
  +            mangle=' '.join(parts[rootPart+1:])
           
  -        # Stash this mangle for this root               
  -        logins[root]=mangle
  -    cvspass.close()    
  +            # Stash this mangle for this root               
  +            logins[root]=mangle
  +        cvspass.close()    
       return logins
    
   def loginToRepositoryOnDemand(repository,root,logins):
  
  
  
  1.5       +32 -9     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- model_tests.py	19 Nov 2003 15:42:16 -0000	1.4
  +++ model_tests.py	19 Nov 2003 19:43:53 -0000	1.5
  @@ -85,10 +85,17 @@
            
           self.assertNotNone('Needed a workspace', self.workspace)
           
  -        self.repo1=self.workspace.getRepository('repository1')              
  +        self.repo1=self.workspace.getRepository('repository1')  
  +                    
           self.project1=self.workspace.getProject('project1')
  -        self.project2=self.workspace.getProject('project2')
  +        self.project2=self.workspace.getProject('project2')             
  +        self.project3=self.workspace.getProject('project3')
  +        self.project4=self.workspace.getProject('project4')
  +        
           self.module1=self.workspace.getModule('module1')
  +        self.module2=self.workspace.getModule('module2')
  +        self.module3=self.workspace.getModule('module3')
  +        self.module4=self.workspace.getModule('module4')
       
           
       def testWorkspace(self):
  @@ -131,19 +138,35 @@
           
           self.assertTrue('Module is CVS', module1.isCVS())
           self.assertNonZeroString('CVSROOT',module1.cvs.getCVSRoot())
  +    
  +    def testDependencyMapping(self):
           
  -    def testStatePropogation(self):
  -        module1=self.module1
           project1=self.project1
           project2=self.project2
           
  -        module1.changeState(STATE_FAILED)
  -        
           self.assertTrue('Project2 depends upon Project1', project2.hasDirectDependencyOn(project1))
           self.assertTrue('Project1 has Project2 as a Dependee', project1.hasDirectDependee(project2))
           self.assertFalse('Project1 ought NOT have Project1 as a Dependee', project1.hasDirectDependee(project1))
           
  -        self.assertEqual('State ought propagate down', project1.getState(), STATE_FAILED)
  -        self.assertEqual('State ought propagate to here', project2.getState(), STATE_PREREQ_FAILED)
  -        self.assertNotEqual('State ought NOT propagate like this', project2.getState(),
STATE_FAILED)
  +    def testStatePropogation(self):
  +        module1=self.module1
  +        module2=self.module2
  +        module3=self.module3
  +        module4=self.module4
  +        
  +        project1=self.project1
  +        project2=self.project2
  +        project3=self.project3
  +        project4=self.project4
  +        
  +        # Make one 'packaged'
  +        module1.changeState(STATE_COMPLETE,REASON_PACKAGE)
  +        
  +        # Make one 'failed'
  +        module3.changeState(STATE_FAILED)
  +        
  +        self.assertNotEqual('Complete State ought NOT propagate down', project1.getState(),
STATE_COMPLETE)
  +        
  +        self.assertEqual('State ought propagate to here', project4.getState(), STATE_PREREQ_FAILED)
  +        self.assertNotEqual('State ought NOT propagate like this', project4.getState(),
STATE_FAILED)
           
  
  
  

Mime
View raw message