Exemple #1
0
	def __makeBuildInfoFromRow( self, row ):
		buildInfo = BuildInfo()
		buildInfo.setBuildId( row[0] )
		buildInfo.setProjectName( row[1] )
		buildInfo.setBuildStatus( row[2] )
		buildInfo.setPriority( row[3] )
		buildInfo.setBuildType( row[4] )
		buildInfo.setRevision( row[5] )
		buildInfo.setUrl( row[6] )
		buildInfo.setBranch( row[7] )
		buildInfo.setTag( row[8] )
		buildInfo.setBuildScript( row[9] )
		return buildInfo
	def testParsingPrintableRepresentation( self ):
		info = BuildInfo()
		info.setBuildType( self._randomString() )
		info.setPriority( 3 )
		info.setProjectName( self._randomString() )
		info.setRevision( self._randomString() )
		info.setUrl( self._randomString() )
		info.setBranch( self._randomString() )
		info.setTag( self._randomString() )
		stringRepresentation = info.printableRepresentation()
		result = BuildInfo()
		result.initializeFromPrintableRepresentation( stringRepresentation )
		self.assertEqual( info.__dict__, result.__dict__ )
Exemple #3
0
	def __getXmlSvnLogEntries( self, xmlLog, startRevision, cap ):
		revisions = []
		logentries = xmlLog.getElementsByTagName( 'logentry' )
		for entry in logentries:
			result = parse_log_entry( entry )
			if int( result[2] ) != startRevision: # svn log always spits out the last revision
				info = BuildInfo()
				info.setProjectName( mApp().getSettings().get( Settings.ScriptBuildName ) )
				info.setBuildType( 'C' )
				info.setRevision( int( result[2] ) )
				info.setUrl( self.__getRootUrl() )
				# FIXME only trunk is supported this way
				info.setBranch( None )
				info.setTag( None )
				revisions.append( info )
		if cap:
			return revisions[-cap:]
		else:
			return revisions
Exemple #4
0
 def __branchnameBuildtypeMappingTestHelper(self, branchType, branchName):
     mapping = [
         # branch type, name regular expression, build type
         [Defaults.BranchType_Branch, ".+-release$", "S"],
         [Defaults.BranchType_Branch, ".+-work$", "C"],
     ]
     mApp().getSettings().set(Settings.SCMSvnBranchNameBuildTypeMap, mapping)
     url = "file:///repo/project"
     self._initialize(self.SVN_EXAMPLE)
     scm = self.project.getScm()
     scm.setUrl(url)
     buildInfo = BuildInfo()
     buildInfo.setProjectName("scm_modules_test")
     buildInfo.setBuildType("E")
     buildInfo.setRevision(4711)
     buildInfo.setBranch(branchName)
     buildInfo.setUrl(url)
     scm._applyBranchnameBuildtypeMapping(branchType, buildInfo)
     return buildInfo
	def testPersistBuildInfo( self ):
		randomBranch = self._randomString()
		randomTag = self._randomString()
		status = BuildStatus()
		filename = NamedTemporaryFile( suffix = '.sqlite' ).name
		status.setDatabaseFilename( filename )
		info = BuildInfo()
		info.setProjectName( status.getName() )
		info.setPriority( 0 )
		info.setBuildStatus( BuildInfo.Status.NewRevision )
		info.setBuildType( 'm' )
		info.setRevision( 'abcdef' )
		info.setUrl( '0123456789' )
		info.setBranch( randomBranch )
		info.setTag( randomTag )
		info.setBuildScript( 'dummy.py' )
		status.saveBuildInfo( [ info ] )
		revs = status.loadBuildInfo( BuildInfo.Status.NewRevision )
		self.assertTrue( len( revs ) == 1 )
		self.assertEqual( revs[0].__dict__, info.__dict__ )
		os.remove( filename )
Exemple #6
0
 def __scmSvnBranchCommitParserTestHelper(self, summarizedDiff):
     # locsl location to build type mapping for the test:
     LocationBuildTypeMap = [
         ["/trunk", Defaults.BranchType_Master, "C"],
         ["/branches/work", Defaults.BranchType_Branch, "C"],
         ["/branches/release", Defaults.BranchType_Branch, "S"],
         ["/branches", Defaults.BranchType_Branch, "C"],
         ["/tags/old", Defaults.BranchType_Tag, "C"],
         ["/tags", Defaults.BranchType_Tag, "S"],
     ]
     url = "file:///repo/project"
     self._initialize(self.SVN_EXAMPLE)
     scm = self.project.getScm()
     scm.setUrl(url)
     # set up input BuildInfo object:
     buildInfo = BuildInfo()
     buildInfo.setProjectName("scm_modules_test")
     buildInfo.setBuildType("C")
     buildInfo.setRevision(4711)
     buildInfo.setUrl(url)
     return buildInfo, scm._splitIntoBuildInfos(buildInfo, summarizedDiff, LocationBuildTypeMap)
Exemple #7
0
	def _splitIntoBuildInfos( self, buildInfo, diff, locationBuildTypeMapping ):
		changes = {}
		url = buildInfo.getUrl()
		branchPrefix = mApp().getSettings().get( Settings.SCMSvnBranchPrefix )
		tagPrefix = mApp().getSettings().get( Settings.SCMSvnTagPrefix )
		for line in diff or []:
			line = line.strip()
			if not re.match( '^[A-Z]+\s+', line ):
				continue
			strippedLocation = re.sub( '^[A-Z]+\s+', '', line ).strip()
			location = strippedLocation[len( url ):] # remove URL
			for match, locationType, buildType in locationBuildTypeMapping:
				if not location.startswith( match ):
					continue
				info = BuildInfo()
				info.setProjectName( mApp().getSettings().get( Settings.ScriptBuildName ) )
				info.setBuildType( buildType )
				info.setRevision( buildInfo.getRevision() )
				info.setUrl( self.__getRootUrl() )

				def getBranchName( paths, prefix, match ):
					pathParts = paths.split( '/' )
					prefixParts = prefix.split( '/' )
					matchParts = match.split( '/' )
					itemsToInclude = len( matchParts ) - len( prefixParts ) + 1 # plus branch name
					if len( pathParts ) <= len( matchParts ):
						return None # ignore lines like 'A	 branches' in old diffs 
					firstIndex = len( prefixParts )
					branchNameParts = pathParts[ firstIndex : firstIndex + itemsToInclude ]
					branchName = '/'.join( branchNameParts )
					return branchName

				if locationType == Defaults.BranchType_Master:
					key = self.__getRootUrl() + '/MASTER' # the actual key does not matter, as long as it is in the map
				elif locationType == Defaults.BranchType_Branch:
					if not match.startswith( branchPrefix ):
						details = 'A location mapping of the branch type needs to be located in the branches folder ' \
							+ 'in the Subversion.repository'
						raise ConfigurationError( 
							'The Subversion location mapping "{0}" does not begin with the configured branch prefix "{1}".'
							.format( match, branchPrefix ), details )
					branchName = getBranchName( location, branchPrefix, match )
					if not branchName:
						continue # this line changed the branches folders, nothing else
					info.setBranch( branchName )
					key = '/'.join( [ self.__getRootUrl(), branchPrefix, branchName ] )
				elif locationType == Defaults.BranchType_Tag:
					if not match.startswith( tagPrefix ):
						details = 'A location mapping of the tag type needs to be located in the tags folder ' \
							+ 'in the Subversion.repository'
						raise ConfigurationError( 
							'The Subversion location mapping "{0}" does not begin with the configured tag prefix "{1}".'
							.format( match, branchPrefix ), details )
					branchName = getBranchName( location, tagPrefix, match )
					if not branchName:
						continue # this line changed the tags folders, nothing else
					info.setTag( branchName )
					key = '/'.join( [ self.__getRootUrl(), tagPrefix, branchName ] )
				if not changes.has_key( key ):
					mApp().debugN( self, 2, 'New build information for revision {0}, {1}'.format( buildInfo.getRevision(), key ) )
					self._applyBranchnameBuildtypeMapping( locationType, info )
					changes[key] = info
				break
		return changes.values()