ajack 2003/11/22 22:16:39 Modified: python/gump/model module.py rawmodel.py python/gump engine.py gumprun.py python/gump/test pyunit.py model.py updater.py stats.py python/gump/document forrest.py Added: python/gump/test/resources/full1 jars_repository1.xml download1.xml python/gump/tool stats.py Log: Trying to fix a refactoring break of CVS. Revision Changes Path 1.11 +83 -17 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.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- module.py 21 Nov 2003 19:04:10 -0000 1.10 +++ module.py 23 Nov 2003 06:16:38 -0000 1.11 @@ -70,7 +70,7 @@ from gump.model.object import NamedModelObject from gump.utils import getIndent -class ModuleCVS(ModelObject): +class ModuleCvs(ModelObject): def __init__(self,xml,repository): ModelObject.__init__(self,xml) @@ -83,7 +83,7 @@ self.dir = xml.dir - def getCVSRoot(self): + def getCvsRoot(self): # Form the CVS root root=':' + str(self.repository.getMethod()) + ':' if self.repository.hasUser(): root+=str(self.repository.getUser()) @@ -127,7 +127,26 @@ def getModule(self): return self.module -class ModuleSVN(ModelObject): +class ModuleSvn(ModelObject): + def __init__(self,xml,repository): + ModelObject.__init__(self,xml) + + # Reference to the shared repository + self.repository=repository + + # Extract settings + if xml.url: + self.url = str(xml.url) + elif self.repository.hasUrl(): + self.url = self.repository.getUrl() + + def hasUrl(self): + return (hasattr(self,'url') and self.url) + + def getUrl(self): + return self.url + +class ModuleJars(ModelObject): def __init__(self,xml,repository): ModelObject.__init__(self,xml) @@ -263,7 +282,7 @@ repo=workspace.getRepository(repoName) self.repository=repo repo.addModule(self) - self.cvs=ModuleCVS(self.xml.cvs,repo) + self.cvs=ModuleCvs(self.xml.cvs,repo) else: self.changeState(STATE_FAILED,REASON_CONFIG_FAILED) log.error(':TODO: No such repository in w/s ['+ repoName +'] on [' \ @@ -276,7 +295,20 @@ repo=workspace.getRepository(repoName) self.repository=repo repo.addModule(self) - self.svn=ModuleSVN(self.xml.svn,repo) + self.svn=ModuleSvn(self.xml.svn,repo) + else: + self.changeState(STATE_FAILED,REASON_CONFIG_FAILED) + log.error(':TODO: No such repository in w/s ['+ repoName +'] on [' \ + + self.getName() + ']') + + elif self.xml.jars: + repoName=self.xml.jars.repository + if workspace.hasRepository(repoName): + # It references this repository... + repo=workspace.getRepository(repoName) + self.repository=repo + repo.addModule(self) + self.svn=ModuleJars(self.xml.jars,repo) else: self.changeState(STATE_FAILED,REASON_CONFIG_FAILED) log.error(':TODO: No such repository in w/s ['+ repoName +'] on [' \ @@ -435,12 +467,15 @@ def getWorkspace(self): return self.workspace - def isCvs(self): + def hasCvs(self): return hasattr(self,'cvs') and self.cvs - def isSvn(self): + def hasSvn(self): return hasattr(self,'svn') and self.svn + def hasJars(self): + return hasattr(self,'jars') and self.jars + # Where the contents (at the repository) updated? def isUpdated(self): return self.updated @@ -455,20 +490,19 @@ return self.repository def getUpdateCommand(self,exists=0): - if self.isCvs(): + if self.hasCvs(): return self.getCvsUpdateCommand(exists) - elif self.isSvn(): + elif self.hasSvn(): return self.getSvnUpdateCommand(exists) - - #:TODO: SubVersion - pass + elif self.hasJars(): + return self.getJarsUpdateCommand(exists) def getCvsUpdateCommand(self,exists=0): log.debug("CVS Update Module " + self.getName() + \ ", Repository Name: " + str(self.repository.getName())) - root=self.cvs.getCVSRoot() + root=self.cvs.getCvsRoot() log.debug("CVS Root " + root + " on Repository: " + self.repository.getName()) @@ -512,7 +546,7 @@ cmd.addParameter('-r',self.cvs.getTag(),' ') else: cmd.addParameter('-A') - cmd.addParameter(self.getName()) + cmd.addParameter(self.getName()) else: @@ -522,9 +556,11 @@ if self.cvs.hasTag(): cmd.addParameter('-r',self.cvs.getTag(),' ') - if self.cvs.hasModule(): - if not self.cvs.getModule() == self.getName(): + if not self.cvs.hasModule() or \ + not self.cvs.getModule() == self.getName(): cmd.addParameter('-d',self.getName(),' ') + + if self.cvs.hasModule(): cmd.addParameter(self.cvs.getModule()) return (self.repository, root, cmd) @@ -540,7 +576,7 @@ log.debug("SVN URL: [" + url + "] on Repository: " + self.repository.getName()) # - # Prepare CVS checkout/update command... + # Prepare SVN checkout/update command... # cmd=Cmd('svn','update_'+self.getName(),self.getWorkspace().cvsdir) @@ -569,6 +605,36 @@ # Request non-interactive # cmd.addParameter('--non-interactive') + + return (self.repository, url, cmd) + + + def getJarsUpdateCommand(self,exists=0): + + log.debug("Jars Update Module " + self.getName() + \ + ", Repository Name: " + str(self.repository.getName())) + + url=self.jars.getUrl() + + log.debug("Jars URL: [" + url + "] on Repository: " + self.repository.getName()) + + # + # Prepare SVN checkout/update command... + # + cmd=Cmd('java org.krysalis.ruper2.tool.ResourceTool','update_'+self.getName(),self.getWorkspace().cvsdir) + + + if self.svn.hasUrl(): + cmd.addParameter(self.jars.getUrl()) + + # + # Be 'quiet' (but not silent) unless requested otherwise. + # + if not self.isDebug() \ + and not self.isVerbose() \ + and not self.jars.isDebug() \ + and not self.jars.isVerbose(): + cmd.addParameter('-q') return (self.repository, url, cmd) 1.5 +1 -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.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- rawmodel.py 21 Nov 2003 19:04:10 -0000 1.4 +++ rawmodel.py 23 Nov 2003 06:16:39 -0000 1.5 @@ -134,6 +134,7 @@ def init(self): self.cvs=Single(GumpXMLModelObject) self.svn=Single(GumpXMLModelObject) + self.jars=Single(GumpXMLModelObject) self.url=Single(GumpXMLModelObject) self.description=Single(GumpXMLModelObject) self.redistributable=Single(GumpXMLModelObject) 1.15 +10 -7 jakarta-gump/python/gump/engine.py Index: engine.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/engine.py,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- engine.py 21 Nov 2003 21:57:55 -0000 1.14 +++ engine.py 23 Nov 2003 06:16:39 -0000 1.15 @@ -162,8 +162,8 @@ workspace = run.getWorkspace() # :TODO: A tad bogus to move here - os.chdir(workspace.getCVSDirectory()) - log.debug("Workspace CVS Directory: " + workspace.getCVSDirectory()) + os.chdir(workspace.getCvsDirectory()) + log.debug("Workspace CVS Directory: " + workspace.getCvsDirectory()) # # A stash of known logins. @@ -175,9 +175,11 @@ # Update all the modules that have CVS repositories for module in run.getGumpSet().getModules(): - if not module.isCvs() and not module.isSvn(): continue + if not module.hasCvs() \ + and not module.hasSvn() \ + and not module.hasJars(): continue - log.debug('Perform CVS/SVN Update on: ' + module.getName()) + log.debug('Perform CVS/SVN/Jars Update on: ' + module.getName()) if module.okToPerformWork(): @@ -189,7 +191,7 @@ # (repository, root, cmd ) = module.getUpdateCommand(exists) - if module.isCvs(): + if module.hasCvs(): # # Provide CVS logins, if not already there # @@ -227,11 +229,12 @@ for module in run.getGumpSet().getModules(): # If no CVS, nothing to sync - if not module.isCvs() and not module.isSvn(): continue + if not module.hasCvs() \ + and not module.hasSvn(): continue if module.okToPerformWork(): - sourcedir = os.path.abspath(os.path.join(workspace.getCVSDirectory(),module.name)) # todo allow override + sourcedir = os.path.abspath(os.path.join(workspace.getCvsDirectory(),module.name)) # todo allow override destdir = os.path.abspath(workspace.getBaseDirectory()) work=syncDirectories(workspace.noRSync,WORK_TYPE_SYNC,\ 1.3 +1 -1 jakarta-gump/python/gump/gumprun.py Index: gumprun.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/gumprun.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- gumprun.py 20 Nov 2003 20:51:49 -0000 1.2 +++ gumprun.py 23 Nov 2003 06:16:39 -0000 1.3 @@ -203,7 +203,7 @@ if fnmatch(project.getName(),pattern): break except Exception, detail: log.error('Failed to regexp: ' + pattern + '. Details: ' + str(detail)) - break + continue else: # no match, advance to the next name continue 1.8 +61 -27 jakarta-gump/python/gump/test/pyunit.py Index: pyunit.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/test/pyunit.py,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- pyunit.py 21 Nov 2003 19:04:10 -0000 1.7 +++ pyunit.py 23 Nov 2003 06:16:39 -0000 1.8 @@ -69,7 +69,8 @@ from gump import log import gump.config from gump.utils import createOrderedList,printSeparator,formatException - + +from fnmatch import fnmatch class Testable: def __init__(self): @@ -183,13 +184,11 @@ def getName(self): return self.name - def performTests(self): + def performTests(self,patterns=None): + tests=[] results=[] - if hasattr(self,'suiteSetUp'): - self.suiteSetUp() - # iterate over this suites properties for name in self.__class__.__dict__: if name.startswith('__') and name.endswith('__'): continue @@ -201,31 +200,56 @@ if not callable(test): continue if not name.startswith('test'): continue - # Call the test... - try: - log.info('Perform [' + self.getName() + '::' + \ - name + ']') + # If arguments, they are patterns to match + if patterns: + for pattern in patterns: + try: + if pattern=="all": pattern='*' + if fnmatch(name,pattern): break + except Exception, detail: + log.error('Failed to regexp: ' + pattern + '. Details: ' + str(detail)) + continue + else: + # no match, advance to the next name + continue + + # Store to perform + tests.append(test) + + if tests: + if hasattr(self,'suiteSetUp'): + self.suiteSetUp() + + for test in tests: + # Call the test... + try: + log.info('Perform [' + self.getName() + '::' + \ + str(test) + ']') - if hasattr(self,'setUp'): - self.setUp() + if hasattr(self,'setUp'): + self.setUp() - test() + test() - if hasattr(self,'tearDown'): - self.tearDown() + if hasattr(self,'tearDown'): + self.tearDown() - except Exception, details: - log.error('Failed') - import traceback - ei = sys.exc_info() - message=formatException(ei) - del ei - results.append(Problem(self,name,message)) + except Exception, details: + log.error('Failed') + + # Log the traceback + import traceback + ei = sys.exc_info() + message=formatException(ei) + del ei + + # Record the problem + results.append(Problem(self,name,message)) - if hasattr(self,'suiteTearDown'): - self.suiteTearDown() + if hasattr(self,'suiteTearDown'): + self.suiteTearDown() - return results + return (len(tests), results) class TestRunner: @@ -235,16 +259,19 @@ def addSuite(self,suite): self.suites.append(suite) - def run(self): + def run(self,args): # Sort to resolve dependency order runOrder=createOrderedList(self.suites) + testsRun=0 problems=[] # Perform the tests for suite in runOrder: try: - problems += suite.performTests() + (runs, results) = suite.performTests(args) + testsRun += runs + problems += results except Exception, details: log.error('Failed') import traceback @@ -254,6 +281,9 @@ problems.append(Problem(suite,'performTests',message)) printSeparator() + + log.info('Performed [' + `testsRun` + '] with [' + `len(problems)` + '] issues.') + for problem in problems: log.error('PROBLEM: ' + str(problem)) @@ -290,7 +320,11 @@ from gump.test.updater import UpdaterTestSuite runner.addSuite(UpdaterTestSuite()) + # Any args are pattern matches + patterns=list(sys.argv) + del patterns[0:1] + # Perform the tests... - runner.run() + runner.run(patterns) 1.5 +7 -7 jakarta-gump/python/gump/test/model.py Index: model.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/test/model.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- model.py 21 Nov 2003 19:04:10 -0000 1.4 +++ model.py 23 Nov 2003 06:16:39 -0000 1.5 @@ -143,18 +143,18 @@ self.assertAt('Project Third', project2, ordered, 2) self.assertAt('Project Fourth', project2, ordered, 3) - def testCVS(self): + def testCvs(self): module1=self.module1 - self.assertTrue('Module is CVS', module1.isCvs()) - self.assertFalse('Module is NOT SVN', module1.isSvn()) - self.assertNonZeroString('CVSROOT',module1.cvs.getCVSRoot()) + self.assertTrue('Module has CVS', module1.hasCvs()) + self.assertFalse('Module has NOT SVN', module1.hasSvn()) + self.assertNonZeroString('CVSROOT',module1.cvs.getCvsRoot()) - def testSVN(self): + def testSvn(self): svnmodule1= self.workspace.getModule('svn_module1') - self.assertTrue('Module is SVN', svnmodule1.isSvn()) - self.assertFalse('Module is NOT CVS', svnmodule1.isCvs()) + self.assertTrue('Module has SVN', svnmodule1.hasSvn()) + self.assertFalse('Module has NOT CVS', svnmodule1.hasCvs()) self.assertNonZeroString('SVN URL',svnmodule1.svn.getUrl()) def testDependencyMapping(self): 1.2 +1 -0 jakarta-gump/python/gump/test/updater.py Index: updater.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/test/updater.py,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- updater.py 21 Nov 2003 19:04:10 -0000 1.1 +++ updater.py 23 Nov 2003 06:16:39 -0000 1.2 @@ -87,6 +87,7 @@ self.module1=self.workspace.getModule('module1') self.svnModule1=self.workspace.getModule('svn_module1') + self.downloadModule1=self.workspace.getModule('download1') def testCommandLines(self): 1.3 +12 -2 jakarta-gump/python/gump/test/stats.py Index: stats.py =================================================================== RCS file: /home/cvs/jakarta-gump/python/gump/test/stats.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- stats.py 21 Nov 2003 02:32:41 -0000 1.2 +++ stats.py 23 Nov 2003 06:16:39 -0000 1.3 @@ -105,9 +105,19 @@ def testLoadAndUpdateStats(self): self.statsDB.loadStatistics(self.workspace) + + # Mark Updated (so we get an updated reading) + self.module1.setUpdated(1) + self.statsDB.updateStatistics(self.workspace) - rough=getGeneralDifferenceDescription(default.time, self.module1.getLastUpdated()) - self.assertNotIn('Date Diff String', 'year', rough) + lastUpdated=self.module1.getLastUpdated() + + # Give some padding. + lastUpdated -= (60*60*7) + + rough=getGeneralDifferenceDescription(default.time, lastUpdated) + self.assertNonZeroString('Date Diff String', rough) + self.assertNotIn('Date Diff String', 'year', rough) 1.1 jakarta-gump/python/gump/test/resources/full1/jars_repository1.xml Index: jars_repository1.xml =================================================================== <?xml version="1.0" encoding="ISO-8859-1"?> <repository name="jars_repository1" type="jars"> <title>Jars Repository 1</title> <home-page>http://svn.apache.org/</home-page> <web>http://jars.apache.org/</web> <redistributable/> <url>http://gump.dotnot.org/repository</url> </repository> 1.1 jakarta-gump/python/gump/test/resources/full1/download1.xml Index: download1.xml =================================================================== <module name="download1"> <url href="http://ant.apache.org/index.html"/> <description> Java based build tool </description> <jars repository="jars_repository1"/> <project name="download1"> <package>org.apache.tools.ant</package> <ant target="gump"/> <depend project="random"/> <option project="random"/> <home nested="dist"/> <jar name="lib/output.jar" id="output"/> <license name="LICENSE"/> <nag from="Gump Integration Build <[EMAIL PROTECTED]>" to="[EMAIL PROTECTED]"/> </project> <project name="honorary1"> <package>org.apache.tools.ant</package> <depend project="random"/> <option project="random"/> <home nested="dist"/> </project> </module> 1.1 jakarta-gump/python/gump/tool/stats.py Index: stats.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 [EMAIL PROTECTED] # # 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/>. """ Statistics manipulation [e.g. reseting, etc.] """ import time import os import sys import logging import anydbm from gump import log from gump.config import * from gump.output.stats import Project, ProjectStatistics from gump.model.module import Module, ModuleStatistics from gump.model.repository import Repository, RepositoryStatistics from gump.output.stats import StatisticsDB from gump.model.state import * class StatisticsTools: """Statistics Interface""" def __init__(self,db=None): if not db: db=StatisticsDB() # :TODO: Complete... if __name__=='__main__': # init logging logging.basicConfig() #set verbosity to show all messages of severity >= default.logLevel log.setLevel(gump.default.logLevel) tool=StatisticsTool() tool.dump() 1.13 +9 -6 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.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- forrest.py 21 Nov 2003 19:04:10 -0000 1.12 +++ forrest.py 23 Nov 2003 06:16:39 -0000 1.13 @@ -766,7 +766,7 @@ module, \ repoList.createEntry( "Repository: ") ) - if module.isCvs(): + if module.hasCvs(): if module.cvs.hasModule(): repoList.createEntry( "CVS Module: ", module.cvs.getModule()) @@ -779,12 +779,16 @@ if module.cvs.hasHostPrefix(): repoList.createEntry( "CVS Host Prefix: ", module.cvs.getHostPrefix()) - repoList.createEntry( "CVSROOT: ", module.cvs.getCVSRoot()) + repoList.createEntry( "CVSROOT: ", module.cvs.getCvsRoot()) - if module.isSvn(): + if module.hasSvn(): if module.svn.hasUrl(): repoList.createEntry( "SVN URL: ", module.svn.getUrl()) + if module.hasJars(): + if module.jars.hasUrl(): + repoList.createEntry( "Jars URL: ", module.jars.getUrl()) + # x.write('<p><strong>Module Config :</strong> <link href=\'xml.html\'>XML</link></p>') @@ -1002,8 +1006,7 @@ workRow=workTable.createRow() workRow.createComment(workTypeName(work.type)) - self.insertLink(work,workable, workRow.createData()) - + self.insertLink(work,workable,workRow.createData()) workRow.createData(workTypeName(work.type)) workRow.createData(stateName(work.state)) workRow.createData(secsToDate(work.result.start_time)) @@ -1021,7 +1024,7 @@ # Write out the 'tail' # workSection \ - .createSection(workTypeName(work.type)) \ + .createSection(workTypeName(work.type) + ' : ' + work.command.name) \ .createSource(tail)
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]