def testPrintCurrentRevisionSyntaxError( self ):
		iface = BuildScriptInterface( BuildScriptInterfaceTests.SyntaxErrorBuildScriptName )
		try:
			iface.queryCurrentRevision()
			self.fail( 'The syntax error build script should throw an exception when querying the current revision.' )
		except MomError:
			pass
Esempio n. 2
0
	def getBuildInfoForInitialRevision( self, buildScript, projectName ):
		iface = BuildScriptInterface( buildScript )
		revision = iface.queryCurrentRevision()
		buildInfo = BuildInfo()
		buildInfo.setProjectName( projectName )
		buildInfo.setBuildStatus( BuildInfo.Status.InitialRevision )
		buildInfo.setRevision( revision )
		buildInfo.setBuildScript( buildScript )
		return buildInfo
class BuildScriptInterfaceTests( MomTestCase ):

	ThisFilePath = os.path.realpath( os.path.dirname( __file__ ) )
	BuildScriptName = os.path.join( ThisFilePath, '..', 'buildscripts', 'example_mom_buildscript.py' )
	SyntaxErrorBuildScriptName = os.path.join( ThisFilePath, '..', 'buildscripts', 'syntax_error.py' )

	def setUp( self ):
		MomTestCase.setUp( self )
		self.iface = BuildScriptInterface( BuildScriptInterfaceTests.BuildScriptName )

	def tearDown( self ):
		MomTestCase.tearDown( self )
		rmtree( "make-o-matic" )

	def testQuerySetting( self ):
		variable = self.iface.querySetting( Settings.MomVersionNumber )
		self.assertEquals( variable, mApp().getSettings().get( Settings.MomVersionNumber ) )

	def testPrintCurrentRevision( self ):
		variable = self.iface.queryCurrentRevision()
		self.assertTrue( variable )

	def testPrintRevisionsSince( self ):
		revisions = self.iface.queryRevisionsSince( '8c758c1f1de2bcc19bda516f1acadf869ba28ee4' )
		self.assertTrue( len( revisions ) >= 5 )

	def testExecuteBuildScript( self ):
		runner = self.iface.execute( buildType = 'c', revision = 'HEAD', captureOutput = True )
		self.assertEqual( 0, runner.getReturnCode() )

	def testQueryBuildNameSyntaxError( self ):
		iface = BuildScriptInterface( BuildScriptInterfaceTests.SyntaxErrorBuildScriptName )
		try:
			iface.querySetting( Settings.ScriptBuildName )
			self.fail( 'The syntax error build script should throw an exception when printing the build name.' )
		except MomError:
			pass

	def testPrintRevisionsSinceSyntaxError( self ):
		iface = BuildScriptInterface( BuildScriptInterfaceTests.SyntaxErrorBuildScriptName )
		try:
			iface.queryRevisionsSince( '8c758c1f1de2bcc19bda516f1acadf869ba28ee4' )
			self.fail( 'The syntax error build script should throw an exception when querying recent revisions.' )
		except MomError:
			pass

	def testPrintCurrentRevisionSyntaxError( self ):
		iface = BuildScriptInterface( BuildScriptInterfaceTests.SyntaxErrorBuildScriptName )
		try:
			iface.queryCurrentRevision()
			self.fail( 'The syntax error build script should throw an exception when querying the current revision.' )
		except MomError:
			pass