Salome HOME
Improvement for check command. See Tuleap 2160
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 17 Jan 2017 11:23:24 +0000 (12:23 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 17 Jan 2017 11:23:24 +0000 (12:23 +0100)
commands/check.py
src/__init__.py
src/compilation.py

index 5b09e594136cc9347e27d5bb9bc6dea7372cf61f..6d9f38bac88f26e1442ddb3981f4d0a48bb24c28 100644 (file)
@@ -26,6 +26,8 @@ parser.add_option('p', 'products', 'list2', 'products',
     _('Optional: products to configure. This option can be'
     ' passed several time to configure several products.'))
 
+CHECK_PROPERTY = "has_unit_tests"
+
 def get_products_list(options, cfg, logger):
     '''method that gives the product list with their informations from 
        configuration regarding the passed options.
@@ -89,10 +91,6 @@ def check_all_products(config, products_infos, logger):
     '''
     res = 0
     for p_name_info in products_infos:
-        __, p_info = p_name_info
-        if ("build_dir" not in  "build_dir" or 
-            not src.product.product_compiles(p_info)):
-            continue
         res_prod = check_product(p_name_info, config, logger)
         if res_prod != 0:
             res += 1 
@@ -120,6 +118,47 @@ def check_product(p_name_info, config, logger):
     logger.write(header, 3)
     logger.write("\n", 4, False)
     logger.flush()
+
+    # Verify if the command has to be launched or not
+    ignored = False
+    if not src.get_property_in_product_cfg(p_info, CHECK_PROPERTY):
+        msg = _("The product %s is defined as not having tests. "
+                "product ignored." % p_name)
+        logger.write("%s\n" % msg, 4)
+        ignored = True
+    if "build_dir" not in p_info:
+        msg = _("No build_dir key defined in "
+                "the config file of %s: product ignored." % p_name)
+        logger.write("%s\n" % msg, 4)
+        ignored = True
+    if not src.product.product_compiles(p_info):
+        msg = _("The product %s is defined as not compiling. "
+                "product ignored." % p_name)
+        logger.write("%s\n" % msg, 4)
+        ignored = True
+
+    # Get the command to execute for script products
+    cmd_found = True
+    if src.product.product_has_script(p_info):
+        command = src.get_cfg_param(p_info, "test_build", "Not found")
+        if command == "Not found":
+            cmd_found = False
+            msg = _('WARNING: The product %s is defined as having tests. But it'
+                    ' is compiled using a script and the key "test_build" is '
+                    'not defined in the definition of %s' % p_name)
+            logger.write("%s\n" % msg, 4)
+                
+    if ignored or not cmd_found:
+        log_step(logger, header, "ignored")
+        logger.write("==== %(name)s %(IGNORED)s\n" %
+            { "name" : p_name ,
+             "IGNORED" : src.printcolors.printcInfo("IGNORED")},
+            4)
+        logger.write("\n", 3, False)
+        logger.flush()
+        if not cmd_found:
+            return 1
+        return 0
     
     # Instantiate the class that manages all the construction commands
     # like cmake, check, make install, make test, environment management, etc...
@@ -130,10 +169,9 @@ def check_product(p_name_info, config, logger):
     res_prepare = builder.prepare()
     log_res_step(logger, res_prepare)
     
-    # Execute buildconfigure, configure if the product is autotools
-    # Execute ccheck if the product is ccheck
     len_end_line = 20
 
+    # Launch the check    
     log_step(logger, header, "CHECK")
     res = builder.check()
     log_res_step(logger, res)
index d34d206f18e80278b976070829ef0ab6e83944aa..c70c86a113059b37cb28cff0174ea154334708ed 100644 (file)
@@ -372,4 +372,11 @@ def replace_in_file(filein, strin, strout):
     fin = open(filein, "r")
     fout = open(fileout, "w")
     for line in fin:
-        fout.write(line.replace(strin, strout))
\ No newline at end of file
+        fout.write(line.replace(strin, strout))
+
+def get_property_in_product_cfg(product_cfg, pprty):
+    if not "properties" in product_cfg:
+        return None
+    if not pprty in product_cfg.properties:
+        return None
+    return product_cfg.properties[pprty]
\ No newline at end of file
index 1de64d2acd16e60d62912168f901982f3b2cd182..11be8dbd945ad926c90cd0ac6e73277a97f54e34 100644 (file)
@@ -298,18 +298,21 @@ CC=\\"hack_libtool\\"%g" libtool'''
 
     ##
     # Runs 'make_check'.
-    def check(self):
+    def check(self, command=""):
         if src.architecture.is_windows():
-            command = 'msbuild RUN_TESTS.vcxproj'
+            cmd = 'msbuild RUN_TESTS.vcxproj'
         else :
             if self.product_info.build_source=="autotools" :
-                command = 'make check'
+                cmd = 'make check'
             else:
-                command = 'make test'
-            
-        self.log_command(command)
+                cmd = 'make test'
+        
+        if command:
+            cmd = command
+        
+        self.log_command(cmd)
 
-        res = subprocess.call(command,
+        res = subprocess.call(cmd,
                               shell=True,
                               cwd=str(self.build_dir),
                               env=self.launch_environ.environ.environ,
@@ -323,7 +326,10 @@ CC=\\"hack_libtool\\"%g" libtool'''
       
     ##
     # Performs a default build for this module.
-    def do_default_build(self, build_conf_options="", configure_options="", show_warning=True):
+    def do_default_build(self,
+                         build_conf_options="",
+                         configure_options="",
+                         show_warning=True):
         use_autotools = False
         if 'use_autotools' in self.product_info:
             uc = self.product_info.use_autotools