distclean implementation draft
authordaniel
Thu, 15 Nov 2012 10:59:15 +0100
changeset 116 8b8b1129560c
parent 115 cdc42f30aa2a
child 117 0a5182f04b00
distclean implementation
bake/Bake.py
bake/Dependencies.py
bake/Module.py
bake/ModuleEnvironment.py
bake/ModuleSource.py
test/TestBake.py
test/TestModuleEnvironment.py
--- a/bake/Bake.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/bake/Bake.py	Thu Nov 15 10:59:15 2012 +0100
@@ -745,11 +745,10 @@
         
         parser = self._option_parser('distclean')
         (options, args_left) = parser.parse_args(args)
-        self._check_build_version(config, options)
-        
+
         def _do_distclean(configuration, module, env):
-            module.distclean(env)
-            return True
+            returnValue = module.distclean(env)
+            return returnValue
         self._do_operation(config, options, _do_distclean)
 
     def _uninstall(self, config, args):
--- a/bake/Dependencies.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/bake/Dependencies.py	Thu Nov 15 10:59:15 2012 +0100
@@ -281,6 +281,8 @@
                     success = False
                     import sys
                     er = sys.exc_info()[0]
+#                    import bake.Utils
+#                    bake.Utils.print_backtrace()           
                     print ("  > Unexpected error: " + str(er))
                     
             elif callback is not None:
--- a/bake/Module.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/bake/Module.py	Thu Nov 15 10:59:15 2012 +0100
@@ -154,10 +154,22 @@
     def distclean(self, env):
         """ Main distclean function, deletes the source and installed files. """
         
-        env.start_build(self._name, srcDirTmp,
-                        self._build.supports_objdir)
-        os.remove(env.srcdir())
-        os.remove(env.installdir())
+        srcDirTmp = self._name
+        if self._source.attribute('module_directory').value :
+            srcDirTmp = self._source.attribute('module_directory').value
+            
+        env.start_source(self._name, srcDirTmp)
+        print(" >> Clean source " + self._name )
+        try: 
+            shutil.rmtree(env.srcdir)
+        except Exception as e:
+#            print (e)
+            pass
+        try: 
+            shutil.rmtree(env.installdir)
+        except:
+            pass
+        return True
          
 
     def uninstall(self, env):
--- a/bake/ModuleEnvironment.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/bake/ModuleEnvironment.py	Thu Nov 15 10:59:15 2012 +0100
@@ -315,6 +315,7 @@
         
         for element in self._variables:
             script = script + " export " + element  + "\n"
+        script = script + self.add_onPath("PYTHONPATH", [sys.path[0]]) + "\n"
         
         fout = open(fileName, "w")
         fout.write(script)
--- a/bake/ModuleSource.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/bake/ModuleSource.py	Thu Nov 15 10:59:15 2012 +0100
@@ -268,9 +268,9 @@
             ['tar.Z', 'tar'],
             ['tar.bz2', 'tar'],
             ['zip', 'unzip'],
-            ['rar', 'unrar']
-            ['7z', '7z']
-            ['xz', 'unxz']
+            ['rar', 'unrar'],
+            ['7z', '7z'],
+            ['xz', 'unxz'],
             ['Z', 'uncompress']
             ]
         try:
@@ -540,7 +540,6 @@
                             " platforms, %s not supported for %s,  %s" % 
                             (osName, env._module_name, 
                              self.attribute('error_message').value))
-        print(" TEST!!!! ! > %s - %s - %s " % (platform.linux_distribution()))
         
         if osName.startswith('darwin'):
                  return env.check_program('ports')
--- a/test/TestBake.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/test/TestBake.py	Thu Nov 15 10:59:15 2012 +0100
@@ -18,7 +18,6 @@
 
 def compensate_third_runner():
     """ Compensates the name of the file, if a third party program is
-        calling bake, as it is the case for running the tests from 
         inside eclipse."""
     fileName = sys.argv[0]
     if len(sys.argv) > 1:
@@ -52,7 +51,7 @@
         testStatus = commands.getoutput('mv bf.xml bakefile.xml ')
         testStatus = commands.getoutput('mv ~/.bakerc_saved ~/.bakerc')
 
-    def Dtest_simple_proceedings(self):
+    def test_simple_proceedings(self):
         """Tests the _check_source_code method of Class Bake. """
 
         mercurial = ModuleSource.create("mercurial")
@@ -76,7 +75,7 @@
                         "Should have worked the build of the code")
   
  
-    def Dtest_read_resource_file(self):
+    def test_read_resource_file(self):
         """Tests the _read_resource_file method of Class Bake."""
         
         configuration = Configuration("bakefile.xml")
@@ -97,7 +96,7 @@
         
         testStatus,testMessage = commands.getstatusoutput('mv ~/.bakerc_saved ~/.bakerc')
       
-    def Dtest_save_resource_configuration(self):
+    def test_save_resource_configuration(self):
         """Tests the _save_resource_configuration method of Class Bake."""
         
         pathname = os.path.dirname(compensate_third_runner())  
@@ -148,7 +147,7 @@
         testStatus,testMessage = commands.getstatusoutput('mv ~/.bakerc_saved ~/.bakerc')
   
    
-    def Dtest_check_source_code(self):
+    def test_check_source_code(self):
         """Tests the _check_source_code method of Class Bake. """
 
         # Environment settings        
@@ -205,7 +204,7 @@
         self.assertFalse(testResult, None)    
              
 
-    def Dtest_check_build_version(self):
+    def test_check_build_version(self):
         """Tests the _check_source_code method of Class Bake. """
 
         # Environment settings        
--- a/test/TestModuleEnvironment.py	Wed Nov 14 09:50:16 2012 +0100
+++ b/test/TestModuleEnvironment.py	Thu Nov 15 10:59:15 2012 +0100
@@ -81,6 +81,14 @@
         testStatus = commands.getoutput('rm -rf /tmp/source')
         self.assertTrue(not testStatus)
 
+    def test_create_environement_file(self):
+        """Tests the create_environement_file method of Class ModuleEnvironment. """
+        
+        testResult = self._env.create_environement_file('test.sh');
+        self.assertTrue(os.path.exists('test.sh'))
+        import commands
+        testStatus = commands.getoutput('rm -rf test.sh')
+ 
 
     # def check_program(self, program, version_arg = None,
     #                   version_regexp = None, version_required = None,