def testPrintCurrentRevision( self ):
		cmd = [ sys.executable, SimpleProjectTests.BuildScriptName, 'print', 'current-revision' ]
		runner = RunCommand( cmd )
		runner.run()
		self.assertEquals( runner.getReturnCode(), 0 )
		line = runner.getStdOutAsString().strip()
		# we cannot know what the current revision is, but if the return code is not zero, it should not be empty:
		self.assertTrue( line )
예제 #2
0
	def queryCurrentRevision( self ):
		cmd = [ sys.executable, self.getBuildScript(), 'print', 'current-revision' ] + self.getParameters()
		runner = RunCommand( cmd, 1800 )
		runner.run()
		if runner.getReturnCode() != 0:
			raise MomError( 'Cannot get initial revision for build script "{0}".'.format( self.getBuildScript() ) )

		revision = runner.getStdOutAsString().strip()
		return revision
예제 #3
0
	def runCommand( self, cmd, description, timeout = None, zeroReturnCode = True ):
		'''Helper method to run shell commands in tests. It creates a RunCommand object, runs it,
		and returns it. If the return code is not zero, it dumps the output of the command.'''

		runner = RunCommand( cmd, timeout )
		runner.run()
		if zeroReturnCode and runner.getReturnCode() != 0:
			print( '\n' )
			print( 'command failed: {0}'.format( description ) )
			print( 'output:' )
			print( runner.getStdOutAsString() )
			print( 'error output:' )
			print( runner.getStdErrAsString() )
		self.assertEqual( runner.getReturnCode() == 0, zeroReturnCode )
		return runner
예제 #4
0
	def querySetting( self, setting ):
		cmd = [ sys.executable, self.getBuildScript(), 'query', setting ] + self.getParameters()
		runner = RunCommand( cmd, 1800 )
		runner.run()
		if runner.getReturnCode() != 0:
			raise MomError( 'Cannot query setting "{0}" for build script "{1}":\n {2}!'\
				.format( setting, self.getBuildScript(), runner.getStdErrAsString() ) )

		output = runner.getStdOutAsString()
		if not output:
			raise MomError( 'The build script "{0}" did not return a value! It said:\n {1}'
				.format( self.getBuildScript(), runner.getStdErrAsString() ) )

		line = output.strip()
		groups = re.search( '^(.+?): (.+)$', line )
		if not groups:
			raise MomError( 'Did not understand this output: "{0}"!'.format( line ) )

		variable = groups.groups()[1]
		return variable