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
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
def getBuildInfoForRevisionsSince( self, buildScript, projectName, revision ): '''Return all revisions that modified the project since the specified revision. @return a list of BuildInfo object, with the latest commit last @throws MomEception, if any of the operations fail ''' iface = BuildScriptInterface( buildScript ) buildInfos = [] lines = iface.queryRevisionsSince( revision ) for line in lines: line = line.strip() if not line: continue buildInfo = BuildInfo() buildInfo.initializeFromPrintableRepresentation( line ) buildInfo.setBuildStatus( buildInfo.Status.NewRevision ) buildInfo.setBuildScript( buildScript ) buildInfos.append( buildInfo ) buildInfos.reverse() return buildInfos